[freetds] bcp is really busted
James K. Lowden
jklowden at schemamania.org
Mon Dec 29 17:56:15 EST 2003
On Mon, 29 Dec 2003 11:58:20 -0500, christos at zoulas.com (Christos Zoulas)
wrote:
> | By encoding the NULL specially. Microsoft's bcp works fine. I will
> | check how it encodes it and report back. (Same for native format).
>
> It encodes the NULL by outputting a length of \xff\xff. We should be
> doing the same.
Right, thanks for checking that out, Christos. That's a 2-byte -1, as you
know. Precisely what the TDS protocol uses.
For native bcp files, I bet all we need is tds_put_packet_to_file().
Don't interpret the row image; just grab the buffer and go.
Sending is a little more work, because we have to allow for the
possibility that the table definition has changed meanwhile. It's valid
to bcp out a table, alter its datatypes (say, float -> real) and reload
it. It's db-lib's job to bind and convert the data accordingly.
Assuming I'm right -- that the bcp native file image mimics the wire image
-- sending may be just a matter of reading rows from a native bcp file in
much the same way we read rows from a socket. That's not how things are
architected now, but, you know ... live and learn.
--jkl
More information about the FreeTDS
mailing list