Skip to Content.
Sympa Menu

freetds - RE: [freetds] 0.63RC5 - dblib - varbinary & dbconvert

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] 0.63RC5 - dblib - varbinary & dbconvert
  • Date: Fri, 7 Jan 2005 11:58:27 -0000

Chris,

Looks good to me, and if it works, all well and good.

Do you mean :

if (srctype == desttype) {
ret = -2; /* to make sure we always set it */
tdsdump_log(TDS_DBG_INFO1, "dbconvert() srctype == desttype\n");
switch (desttype) {

case SYBBINARY:
+ case SYBVARBINARY:
case SYBIMAGE:
if (srclen > destlen && destlen >= 0) {
_dblib_client_msg(NULL, SYBECOFL, EXCONVERSION,
"Data-conversion resulted in overflow.");
ret = -1;
} else {
memcpy(dest, src, srclen);
if (srclen < destlen)
memset(dest + srclen, 0, destlen - srclen);
ret = srclen;
}
break;

?

Bill


-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Cole, Chris
(London)
Sent: 07 January 2005 11:47
To: freetds AT lists.ibiblio.org
Subject: [freetds] 0.63RC5 - dblib - varbinary & dbconvert


Using 0.63RC5 I am bulkloading programmatically into a SQLServer
database. I have a column defined as varbinary. My program variable is a
variable length block of binary data. In bcp_bind I have defined the
"type" to be SYBVARBINARY. During loading this is detected by
dbconvert() as a column not requiring conversion (line 1742: ...srctype
== desttype). However, in the subsequent code that follows this
condition there is no switch to handle SYBVARBINARY (i.e. copy src to
dest and pad dest). What happens is that the default case is hit and -1
returned as the converted_data_size to _bcp_get_col_data. This isn't a
failure condition in _bcp_get_col_data, so execution continues in
_bcp_build_bcp_record until an attempt is made to append the converted
data to the output buffer (bcp.c : 2624) at which point my process dies.

I can fix this very easily by adding a SYBVARBINARY case to the switch
starting in dbconvert at line 1742. Is this appropriate? Is there
anything wrong with doing this?

BTW: if I set the program variable to be SYBBINARY, tds_convert
correctly handles the conversion (i.e. just copies the src to dest), but
the conversion ultimately fails gracefully with unrecognized desttype
(SYBVARBINARY). dbconvert doesn't seem to cater for SYBVARBINARY at all.

--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy,
retain or redistribute it. Click here for important additional terms
relating to this e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------

_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy, retain or
redistribute it. Click here for important additional terms relating to this
e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------





Archive powered by MHonArc 2.6.24.

Top of Page