Skip to Content.
Sympa Menu

freetds - RE: [freetds] nulls cause data errors with bcp out

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'freetds AT lists.ibiblio.org'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] nulls cause data errors with bcp out
  • Date: Thu, 23 Jan 2003 09:23:35 -0000

Thanks James,

I'm having a look at bcp at the moment, so I'll take a look at your changes
and verify.
FYI, I'm implementing the -e flag (error file) functionality at the moment,
along the lines we discussed a while ago.
I'll also implement the -m (max errors) flag on freebcp
I'm trying to get blob data working on bcp in to sql server 7/2000 as well,
although I'm struggling a bit.

Does anyone have the wherewithal to do a network sniff for me. It might take
me a couple of days to do this myself...

I want to see what the MS version of bcp sends to the server in the
following scenario:

assuming table <DB>..<test_text_bcp> ( col1 int, col2 text )

and an input file containing :

1 abcdefghijklmnop

and the command:

bcp <DB>..<test_text_bcp> in <filename> -c -S... -U... -P...

thanks,

Bill


> -----Original Message-----
> From: Lowden, James K [SMTP:LowdenJK AT bernstein.com]
> Sent: 22 January 2003 20:44
> To: 'TDS Development Group'
> Subject: [freetds] nulls cause data errors with bcp out
>
> I think fixed our null handling in bcp.c. If you did this:
>
> 1> create table t (t varchar(9) null)
> 2> go
> 1> insert t values ('a')
> 2> insert t values (NULL)
> 3> select * from t
> 4> go
> (1 row affected)
> (1 row affected)
> t
> ---------
> a
> NULL
>
> freebcp gave you two 'a' rows, and no nulls:
>
> $ freebcp testdb..t out tt -c -S spquant -U $U -P $P
> Starting copy...
> firstrow = 0 row_of_query = 2 rows written 2
> 2 rows copied.
>
> $ cat tt
> a
> a
>
> Ugh.
>
> token.c::tds_get_data() correctly calls tds_set_null(). The data
> structure
> at that point is weird: the "current_row" is a char*, but it actually
> comprises 4 bytes of flags followed by N bytes of true data. In
> bcp.c::_exec_bcp_out(), the null status of the data was ignored, and the
> function copied (in my case) one byte of stale data to the output file.
>
> Now it instead calls tds_get_null() to decide whether or not to write
> anything.
>
> This might be only a partial solution. I don't know if bcp bindings
> should
> honor dbsetnull(). The documentation says dbsetnull() affects dbbind()
> and
> dbconvert(); nothing about bcp_bind().
>
> --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.
>
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page