freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Andrew Victor" <avictor.za AT gmail.com>
- To: freetds AT lists.ibiblio.org
- Subject: [freetds] ctlib and BLOB data-types
- Date: Tue, 29 Jul 2008 10:47:11 +0200
hi,
When executing a database stored-procedure and binding an BLOB
data-type (eg, IMAGE) as an input parameter, you end up with just 0x00
bytes in that database column.
It looks like ct-lib's paramrowalloc() is not initializing the TDSBLOB
data-structure (in curcol->column_data) correctly.
The attached patch fixes this issue. It basically handles it the same
way as the code in dblib.
This is against freetds-0.82.
Regards,
Andrew Victor
diff -urN freetds-0.82/src/ctlib/ct.c freetds-0.82.new/src/ctlib/ct.c --- freetds-0.82/src/ctlib/ct.c 2008-05-06 05:23:45.000000000 +0200 +++ freetds-0.82.new/src/ctlib/ct.c 2008-07-22 10:38:27.000000000 +0200 @@ -4084,11 +4084,22 @@ if (size > 0 && value) { /* TODO check for BLOB and numeric */ - if (size > curcol->column_size) + if (size > curcol->column_size) { + tdsdump_log(TDS_DBG_FUNC, "paramrowalloc(): RESIZE %d to %d\n", size, curcol->column_size); size = curcol->column_size; + } /* TODO blobs */ if (!is_blob_type(curcol->column_type)) memcpy(curcol->column_data, value, size); + else { + TDSBLOB *blob = (TDSBLOB *) curcol->column_data; + blob->textvalue = malloc(size); + tdsdump_log(TDS_DBG_FUNC, "blob parameter supported, size %d textvalue pointer is %p\n", + size, blob->textvalue); + if (!blob->textvalue) + return NULL; + memcpy(blob->textvalue, value, size); + } curcol->column_cur_size = size; } else { tdsdump_log(TDS_DBG_FUNC, "paramrowalloc(): setting parameter #%d to NULL\n", param_num);
-
[freetds] ctlib and BLOB data-types,
Andrew Victor, 07/29/2008
- Re: [freetds] ctlib and BLOB data-types, James K. Lowden, 07/29/2008
Archive powered by MHonArc 2.6.24.