Skip to Content.
Sympa Menu

freetds - Re: [freetds] Status: bcp

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Status: bcp
  • Date: Thu, 18 Dec 2003 19:18:01 -0500

On Thu, 18 Dec 2003, "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
wrote:
> if (_bcp_get_prog_data(dbproc) == SUCCEED) {
>
> if (IS_TDS7_PLUS(tds)) {
> tds_put_byte(tds, row_token); /* 0xd1 */
>
> for (i = 0; i < dbproc->bcp.db_colcount; i++) {
>
> /* send the data for each column */
> ret = tds7_put_bcpcol(tds, dbproc->bcp.db_columns[i]);
>
> if (ret == TDS_FAIL) {
> _bcp_err_handler(dbproc, SYBEBCNN);
+++ return FAIL;
> }
>
> }
> return SUCCEED;
>
> If the error condition is hit in tds7_put_bcpcol a BAD ROW will be
> constructed (the bad column having neen nissed out....)

I looked at fixing this, Bill, but it a problem is. It's easy to insert
the line, above, but how to reset the TDS buffer? We've already plugged
it with 0xd1 and N columns (well, i, really). For a really wide row, that
could mean packets were already shipped to the server.


The straightforward answer would be that tds7_put_bcpcol() mustn't check
if its target is nullable. Just construct the row according to the data,
and let the server reject them. Are the vendors' libraries any smarter
than that?

The alternative, which I like better, is to write bcp_exec atop bcp_bind,
bcp_sendrow, and bcp_batch. These of course need tds names and should be
in src/tds/bcp.c (which doesn't exist yet). But they define the core
functionality of bcp. Everything else is setup and window dressing.

Of course, writing bcp_exec in terms of bcp_bind means we build a row
image in memory before writing it to the server all at once (with
tds_put_n). That has ramification for blobs. Here's my suggestion:
mmap(2). Use a memory mapped file to hold the row image. What do you
think?

--jkl






Archive powered by MHonArc 2.6.24.

Top of Page