Skip to Content.
Sympa Menu

freetds - Re: [freetds] bcp is really busted

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: christos AT zoulas.com (Christos Zoulas)
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] bcp is really busted
  • Date: Mon, 29 Dec 2003 18:26:18 -0500

On Dec 29, 5:56pm, jklowden AT schemamania.org ("James K. Lowden") wrote:
-- Subject: Re: [freetds] bcp is really busted

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

Yes.

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

Well, hmm... I had other evil ideas. Yes for the current functionality
the 'grab the buffer and go' is a good idea. What I always wanted from
bcp was inout functionality, i.e. copy a table from one database/dataserver
to another without having to go through the intermediate file because:

1. speed -- single step
2. space -- no need for the intermediate buffer space
3. conversions -- maybe as you say below, you want to do dblib conversions.

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

Yes, for now that might be the easiest fix. The problem is that currently
writing files does not do NULL's properly, i.e. it encodes them as \x00\x00.
We'll have to fix that one first. I'll look into that when I get some spare
cycles, unless someone beats me to it.

christos




Archive powered by MHonArc 2.6.24.

Top of Page