freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC]
- From: "Lowden, James K" <james.k.lowden AT alliancebernstein.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] freebcp out from MS SQL Server drops spaces [NC]
- Date: Fri, 10 Jul 2009 14:06:33 -0400
> From: Frediano Ziglio
>
> Personally I looked at bcp.c code. I think it would be better to
change
> len passed to dbconvert in order to avoid trimming. We use a len -1 or
> -2 so dbconvert trim but passing a specific len cause dbconvert not to
> trim!
Hi Freddy,
True. Actually, there's no reason to treat nullable and non-nullable
CHAR columns differently. That's the real source of Cedric's complaint.
I'm glad you looked into this. I made this change:
Index: src/dblib/bcp.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/dblib/bcp.c,v
retrieving revision 1.186
diff -u -r1.186 bcp.c
--- src/dblib/bcp.c 28 May 2009 16:23:32 -0000 1.186
+++ src/dblib/bcp.c 10 Jul 2009 17:34:11 -0000
@@ -857,12 +857,6 @@
destlen = -1;
break;
case SYBCHAR:
- buflen = curcol->column_size + 1;
- if (curcol->column_nullable)
- destlen = -1;
- else
- destlen = -2;
- break;
case SYBTEXT:
/* FIXME column_size ?? if 2gb ?? */
buflen = curcol->column_size + 1;
The effect is to pass -2 to dbconvert() for SYBCHAR, which is what we do
for SYBTEXT anyway. It seems to work.
http://manuals.sybase.com/onlinebooks/group-cnarc/cng1110e/dblib/@Generi
c__BookTextView/11509;pt=39614
"The string will not be trimmed of trailing blanks, but will be given a
terminating null."
$ bsqldb -S$S -U$U -P$P <<< 'select *, datalength(c) as length,
datalength(rtrim(c)) as nchars from ##char'
c length nchars
---------------- ----------- -----------
a 16 1
pad 16 3
NULL NULL NULL
16 0
$ ./src/apps/freebcp '##char' out c -c -S$S -U$U -P$P && hexdump -C c
&& perl -pe "s/ /./g" c
Starting copy...
4 rows copied.
00000000 61 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |a
|
00000010 0a 70 61 64 20 20 20 20 20 20 20 20 20 20 20 20 |.pad
|
00000020 20 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 | ..
|
00000030 20 20 20 0a | .|
00000034
a...............
pad.............
................
(The last row was created with "insert ##char values ('')".)
Regards,
--jkl
-----------------------------------------------------------------------------------
The information contained in the linked e-mail transmission and any
attachments may be privileged and confidential and is intended only for
the use of the person(s) named in the linked e-mail transmission. If you
are not the intended recipient, or an employee or agent responsible for
delivering this message to the intended recipient, you should not
review, disseminate, distribute or duplicate this e-mail transmission or
any attachments. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the
original message. We do not accept account orders and/or instructions
related to AllianceBernstein products or services by e-mail, and
therefore will not be responsible for carrying out such orders and/or
instructions. The linked e-mail transmission and any attachments are
provided for informational purposes only and should not be construed in
any manner as any solicitation or offer to buy or sell any investment
opportunities or any related financial instruments and should not be
construed in any manner as a public offer of any investment
opportunities or any related financial instruments. If you, as the
intended recipient of the linked e-mail transmission, 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. Although we attempt to sweep
e-mail and attachments for viruses, we will not be liable for any
damages arising from the alteration of the contents of this linked e-mail
transmission and any attachments by a third party or as a result of any
virus being passed on. Please note: Trading instructions sent
electronically to Bernstein shall not be deemed accepted until a
representative of Bernstein acknowledges receipt electronically or by
telephone. Comments in the linked e-mail transmission and any
attachments are part of a larger body of investment analysis. For our
research reports, which contain information that may be used to
support investment decisions, and disclosures, see our website at
www.bernsteinresearch.com.
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC]
, (continued)
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Cedric ROUVRAIS, 07/09/2009
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Frediano Ziglio, 07/09/2009
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Cedric ROUVRAIS, 07/09/2009
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Frediano Ziglio, 07/09/2009
- [freetds] fsql does not support -b option [NC], Cedric ROUVRAIS, 07/09/2009
- Re: [freetds] freebcp out from MS SQL Server drops spaces [NC], Cedric ROUVRAIS, 07/09/2009
- Re: [freetds] freebcp out from MS SQL Server drops spaces [NC], Konrad J Hambrick, 07/09/2009
- Re: [freetds] freebcp out from MS SQL Server drops spaces [NC], Cedric ROUVRAIS, 07/09/2009
- Re: [freetds] freebcp out from MS SQL Server drops spaces [NC], James K. Lowden, 07/09/2009
- Re: [freetds] freebcp out from MS SQL Server drops spaces [NC], Frediano Ziglio, 07/10/2009
- Re: [freetds] freebcp out from MS SQL Server drops spaces [NC], Lowden, James K, 07/10/2009
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Frediano Ziglio, 07/09/2009
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Cedric ROUVRAIS, 07/09/2009
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Frediano Ziglio, 07/09/2009
-
Re: [freetds] freebcp out from MS SQL Server drops spaces [NC],
Cedric ROUVRAIS, 07/09/2009
Archive powered by MHonArc 2.6.24.