SQLPutData() with a size of zero

Sebastien FLAESCH <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Organization Four Js Development Tools
Message-ID <[email protected]>
Hello,

I believe I found a defect (0.92.377): with SQL_DATA_AT_EXEC binding, when a
blob is empty but not null, it should be possible to call SQLPutData() with
a size of zero:

    r = SQLPutData(st->stmtHandle, (SQLPOINTER) "", 0L);

This is working with SQL Native Client and Easysoft ODBC for SQL Server...

But FreeTDS returns:

HY001 / [FreeTDS][SQL Server]Memory allocation failure

...

It appears that the code in prepare_query.c:continue_parse_prepared_query()
is not prepared to get a StrLen_or_Ind of zero...

In fact we end up in this part, with len=0:

                 if (blob->textvalue)
                         p = (TDS_CHAR *) realloc(blob->textvalue, len + curcol->column_cur_size);
                 else {
                         assert(curcol->column_cur_size == 0);
                         p = (TDS_CHAR *) malloc(len);
                 }
                 if (!p) {
                         odbc_errs_add(&stmt->errs, "HY001", NULL); /* Memory allocation error */
                         return SQL_ERROR;
                 }


and here malloc(0) returns zero (AIX 6.1)...

Seb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.