Skip to content

Commit

Permalink
Merge pull request wankdanker#9 from markdirish/bound_row_data
Browse files Browse the repository at this point in the history
Fixing both an SQL_FLOAT issue and boundRow garbage Data

Fixes wankdanker#67
Fixes wankdanker#8
  • Loading branch information
markdirish authored Jun 13, 2019
2 parents 64672dd + e17247b commit 677d22b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,14 @@ SQLRETURN ODBC::BindColumns(QueryData *data) {
switch(column->DataType) {

case SQL_REAL:
case SQL_DECIMAL :
case SQL_NUMERIC :
case SQL_DECIMAL:
case SQL_NUMERIC:
maxColumnLength = (column->ColumnSize + 1) * sizeof(SQLCHAR);
targetType = SQL_C_CHAR;
break;

case SQL_DOUBLE :
case SQL_FLOAT:
case SQL_DOUBLE:
maxColumnLength = column->ColumnSize;
targetType = SQL_C_DOUBLE;
break;
Expand Down Expand Up @@ -433,7 +434,7 @@ SQLRETURN ODBC::FetchAll(QueryData *data) {

while(SQL_SUCCEEDED(returnCode = SQLFetch(data->hSTMT))) {

ColumnData *row = new ColumnData[data->columnCount];
ColumnData *row = new ColumnData[data->columnCount]();

// Iterate over each column, putting the data in the row object
for (int i = 0; i < data->columnCount; i++) {
Expand All @@ -442,7 +443,7 @@ SQLRETURN ODBC::FetchAll(QueryData *data) {
if (row[i].size == SQL_NULL_DATA) {
row[i].data = NULL;
} else {
row[i].data = new SQLCHAR[row[i].size];
row[i].data = new SQLCHAR[row[i].size + 1]();
memcpy(row[i].data, data->boundRow[i], row[i].size);
}
}
Expand Down

0 comments on commit 677d22b

Please sign in to comment.