Skip to content

Commit

Permalink
[ODBC-134] Fix and testcase. Fetch would fail, if unbound column
Browse files Browse the repository at this point in the history
contained NULL, and for that column some arbitrary descriptor field was
set by application(but not value/len/ind buffer ptrs). The bug affected
ADO, as that is something it can do in some cases with CursorLocation adUseClient
  • Loading branch information
lawrinn committed Feb 4, 2018
1 parent d506530 commit d93b0b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ma_desc.c
Expand Up @@ -973,7 +973,9 @@ SQLRETURN MADB_DescSetField(SQLHDESC DescriptorHandle,
break;
}

if (DescRecord)
/* inUse is only used to check if column/parameter was bound or not. Thus we do not set it for each field, but only for those,
that make column/parameter "bound" */
if (DescRecord && (DescRecord->DataPtr != NULL || DescRecord->OctetLengthPtr != NULL || DescRecord->IndicatorPtr != NULL))
DescRecord->inUse= 1;
}
return ret;
Expand Down
17 changes: 17 additions & 0 deletions test/result2.c
Expand Up @@ -1140,6 +1140,22 @@ ODBC_TEST(t_odbc73)
return OK;
}


ODBC_TEST(t_odbc134)
{
SQLHANDLE Ard;

OK_SIMPLE_STMT(Stmt, "SELECT NULL");

CHECK_STMT_RC(Stmt, SQLGetStmtAttr(Stmt, SQL_ATTR_APP_ROW_DESC, &Ard, 0, NULL));
CHECK_DESC_RC(Ard, SQLSetDescField(Ard, 1, SQL_DESC_TYPE, (SQLPOINTER)SQL_NUMERIC, 0));
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

return OK;
}


MA_ODBC_TESTS my_tests[]=
{
{t_bug32420, "t_bug32420"},
Expand All @@ -1164,6 +1180,7 @@ MA_ODBC_TESTS my_tests[]=
{t_odbc77, "t_odbc-77-analyze_table"},
{t_odbc78, "t_odbc-78-sql_no_data"},
{t_odbc73, "t_odbc-73-bin_collation"},
{t_odbc134, "t_odbc-134-fetch_unbound_null"},
{NULL, NULL}
};

Expand Down

0 comments on commit d93b0b8

Please sign in to comment.