Skip to Content.
Sympa Menu

freetds - [freetds] dbconvert and null data (was: short read during bcp?)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: [freetds] dbconvert and null data (was: short read during bcp?)
  • Date: Tue, 16 Dec 2003 15:36:58 -0500

Well, a half day of simplification, and we're down to something truly
trivial. It looks like dbconvert() doesn't understand all possible null
inputs.

It relies on this macro:

#define is_nullable_type(x) (x==SYBINTN || \
x==SYBFLTN || \
x==SYBDATETIMN || \
x==SYBVARCHAR || \
x==SYBVARBINARY || \
x==SYBMONEYN || \
x==SYBTEXT || \
x==SYBNTEXT || \
x==SYBBITN || \
x==SYBIMAGE)

thus:

if (src == NULL || (srclen == 0 && is_nullable_type(srctype))) {

/* FIX set appropriate NULL value for destination type */
if (destlen > 0)
memset(dest, '\0', destlen);
if (destlen == -1 || destlen == -2)
*dest = '\0';
return 0;
}

I think the intent is to avoid calling tds_convert for null inputs.

My newfangled log shows:

pid: 12583:15:21:42.193508 parsing host column 9
pid: 12583:15:21:42.193508 prefix_len = 0 collen = 0
pid: 12583:_bcp_measure_terminated_field returned 0
pid: 12583:15:21:42.194485 dbconvert(47 [SYBCHAR] len 0 => 52 [SYBINT2] len
2)
pid: 12583:15:21:42.194485 dbconvert() calling tds_convert
pid: 12583:15:21:42.194485 dbconvert() called tds_convert returned -3
pid: 12583:15:21:42.195461 tds_client_msg: #20050: "Attempt to convert data
stopped by syntax error in source field.". Connection state is now -1.

.
. . It appears there's a call of dbconvert(dbproc, SYBCHAR, 0, ...). I
think that should return a null dest; that is, I think is_nullable_type()
should yield TRUE for SYBCHAR.

Is this an oversight, or is the problem more involved?

--jkl
-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.





  • [freetds] dbconvert and null data (was: short read during bcp?), Lowden, James K, 12/16/2003

Archive powered by MHonArc 2.6.24.

Top of Page