ctlib and BLOB data-types
"Andrew Victor" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
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 _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds
ctlib.blob.patch
(text/x-patch, 1 KB)
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);