[freetds] dblib bcp & freebcp

Lowden, James K LowdenJK at bernstein.com
Thu Jun 3 10:04:19 EDT 2004

> From: freetds-bounces at lists.ibiblio.org
> [mailto:freetds-bounces at lists.ibiblio.org]On Behalf Of 
> Thompson, Bill D
> Sent: June 3, 2004 7:01 AM
> > Yay!  How did you work around the fseek() in "measuring" delimited
> character files?  
> I'm afraid you caught me out. I was planning to the 
> stdin/stdout work today,
> I thought it would be easy.
> Just do this, right ?
>     FILE *fptr;
>     if (strcmp(filename,"stdin") == 0 ) {
>         fptr = stdin;
>     } else {
>         fptr = fopen(filename, "r");
>     }

No, yaar, that won't work, because _bcp_measure_terminated_field() uses fseek(3).  Try that on stdin, an you'll get EBADF.  

BTW, I fixed (I think) the seek-the-terminator logic this weekend.  You might want to update your bcp.c.  

I used fseek() to avoid double buffering, but it's probably not the best approach.  We can probably work with a fixed 8000 byte buffer (big enough for all "normal" datatypes), and read text/ntext in chunks.  Tedious, but about as efficient: we'd be trading off fseek() for memcpy().  

> I'll take a look at bcp_moretext(). It should be possible.

I don't remember exactly why, but I came to the conclusion some time back -- and you agreed, IIRC -- that supporting bcp_moretext() will actually force some improvements in how bcp is implemented.  Had to do with building a row image and with cancelling a partial row.  

I'll be interested to see what you come up with, Bill.  



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.
If you, as the intended recipient of this message, the purpose of which is to inform and update our clients, prospects and consultants of developments relating to our services and products, would not like to receive further e-mail correspondence from the sender, please "reply" to the sender indicating your wishes.  In the U.S.: 1345 Avenue of the Americas, New York, NY 10105.

More information about the FreeTDS mailing list