diff --git a/ma_desc.c b/ma_desc.c index 77258e0a..376b42eb 100644 --- a/ma_desc.c +++ b/ma_desc.c @@ -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; diff --git a/test/result2.c b/test/result2.c index 3b65ad7d..816982c0 100644 --- a/test/result2.c +++ b/test/result2.c @@ -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"}, @@ -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} };