[freetds] bcp appears broken

Lowden, James K LowdenJK at bernstein.com
Thu Dec 5 12:59:56 EST 2002


> From: Lowden, James K [mailto:LowdenJK at bernstein.com]
> Sent: December 2, 2002 5:08 PM
> 
> Bad news:  bcp doesn't work for other reasons.
> 
> In testing freebcp with the Northwind database, I found we 
> fail to process the last token or so, and don't write the file.  

Fixed and committed, despite wrong diagnosis. 

The table I used had an nchar column, for which the server sends metadata
(charset information, perhaps) that we weren't parsing.  The packet looked
like

0000
	81 		TDS7_RESULT_TOKEN

	02 00 		two columns
	00 00 		usertype [none]
	08 00 		flags [writeable]
	38  		datatype [int]
	08 		colnamelen
	
	52 00 65 00 67 00 69   	|R.e.g.i|
0010  
	00 6f 00 6e 00 49 00 44 00	|.o.n.I.D.| 
	
	00 00		usertype [none]	
	0a 00		flags [writeable and 0x02 (undefined!)]
	ef		datatype [nchar, 239] 
	64 00		columnsize [100] (varint is 2)
0020  
	09 04 00 01 00 	column_collation
	^^ ^^ ^^ ^^ ^^
	These were the unexpected bytes.

	11 		colnamelen [17]
	52 00 65 00 67 00 69 00 6f 00	|R.e.g.i.o.|
0030  
	6e 00 44 00 65 00 73 00  63 00 72 00 69 00 70 00   |n.D.e.s.
c.r.i.p.|
0040  
	74 00 69 00 6f 00 6e 00  	|t.i.o.n.|
	
	d1 		TDS_ROW_TOKEN

The parser hit the unanticipated 0x09, decided that was the column's name
length, grabbed 18 bytes of unicode data (some of which was the name), and
sought its next token at offset 0033, a null.  Things didn't get better
after that....

--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.





More information about the FreeTDS mailing list