Skip to Content.
Sympa Menu

freetds - RE: [freetds] Removal of trailing spaces by FreeTDS

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Simon Talbot" <simont AT nse.co.uk>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Removal of trailing spaces by FreeTDS
  • Date: Fri, 14 Nov 2003 15:28:17 -0000

Yes, Results as follows:

Linux:
creating table
insert into #varchartest values (1, 'AAAAAAAAAA')
insert into #varchartest values (2, '')
insert into #varchartest values (3, 'BBBBBBB ')
select
dbresults returns (1) succeed
1 >AAAAAAAAAA<
2 ><
3 >BBBBBBB<
dbresults returns (2)

Win32
creating table
insert into #varchartest values (1, 'AAAAAAAAAA')
insert into #varchartest values (2, '')
insert into #varchartest values (3, 'BBBBBBB ')
select
dbresults returns (1) succeed
1 >AAAAAAAAAA<
2 ><
3 >BBBBBBB<
dbresults returns (2)


OK -- So I could have lied -- the Win32 implementation also strips
trailing spaces -- Upon further investigation, my Like for Like
comparison of code uses the ODBC API to get the data in question to
overcome the 255 character limit on VarChar's which Microsoft's DB
Library seemingly imposes.

I still think this is fundimentally wrong though, the library is not
returning a faithfull representation of what is contained in the
Database, it is arbitrarily deciding that trailing spaces are not
required by the client app and stripping them without being asked ! In
the case our our data mining application, the trailing spaces are all
important -- still think this is a prime candidate for a switch in the
config file,

Simon

Simon Talbot MEng, ACGI
(Chief Engineer)
Net Solutions Europe Limited


-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Thompson, Bill D
(London)
Sent: 14 November 2003 13:44
To: 'FreeTDS Development Group'
Subject: RE: [freetds] Removal of trailing spaces by FreeTDS

By DBlibrary under windows you mean MS's dblib and by Linux you mean
freetds dblib ?

Here's my little test program. perhaps you'd be so good as to compile it
in both your envs, and send me the results ?

<<varchar.c>>
(you will need to amend the connect information, which was hard coded in
my
program)

Bill

> -----Original Message-----
> From: Simon Talbot [SMTP:simont AT nse.co.uk]
> Sent: 14 November 2003 13:37
> To: FreeTDS Development Group
> Subject: RE: [freetds] Removal of trailing spaces by FreeTDS
>
> We are doing parallel testing with DBLibrary under Windows and Linux
> and the Windows version returns the space and the Unix version doesn't

> -- typical
>
> I assume it would be relatively trivial to include a flag to
> enable/disable this behaviour for Sybase/Microsoft compatibility --
> maybe the flag is already there?
>
> Simon
>
>
> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Thompson, Bill

> D
> (London)
> Sent: 14 November 2003 13:29
> To: 'FreeTDS Development Group'
> Subject: RE: [freetds] Removal of trailing spaces by FreeTDS
>
> HI Simon,
>
> I'm afraid that this is how it's *supposed* to behave.
> The manuals aren't really explicit on some behaviours, but we did a
> LOT of work in this area a year or so back.
> I personally did detailed parallel testing of programs compiled with
> Sybase open client db-library and our own.
> In this case, w e have just reproduced the behaviours of Sybase
> db-library with respect to varchar data and the NTBSTRINGBIND argument

> to dbbind.
>
> Bill
>
> > -----Original Message-----
> > From: Simon Talbot [SMTP:simont AT nse.co.uk]
> > Sent: 14 November 2003 13:17
> > To: FreeTDS Development Group
> > Subject: [freetds] Removal of trailing spaces by FreeTDS
> >
> > Hi All,
> >
> > I have observed the following with both the stable and the dev
> > version
>
> > of FreeTDS.
> >
> > Communicating with a Win2000 SQL Server 2000 from FreeTDS on Linux
> > 2.4.22, using code like:
> >
> > DBCHAR P_TEXT[6000];
> >
> > ...
> >
> > Connect and issue query etc.
> >
> > ...
> >
> > dbresults(dbconn);
> >
> > dbbind(dbconn, 4, NTBSTRINGBIND, 0, (BYTE *)&P_TEXT);
> >
> > /* Loop thru the result set */
> > while (dbnextrow(dbconn) != NO_MORE_ROWS)
> > {
> > printf("Text:%s:\n",P_TEXT)
> > }
> >
> > ...
> >
> > Close database connection etc.
> >
> >
> > The column that the dbbind is binding to is of type varchar(6000).
> >
> > Data is returned correctly apart from the following:
> >
> > If the last character of the VARCHAR data is a space (0x20) this
> > last character is not returned into P_TEXT. If the last character is

> > anything else there is not a problem.
> >
> > For example if the field conatined (note ' marks are for
> > illustration only, they are not in the actual field data):
> >
> > '!20 michigan mini cooper , volvo ' -- P_TEXT would incorrectly
> > contain '!20 michigan mini cooper , volvo'
> >
> > Whereas if the field conatined:
> >
> > '!20 michigan mini cooper , volvo :' -- P_TEXT would correctly
> > contain
>
> > '!20 michigan mini cooper , volvo :'
> >
> >
> > Thoughts ?
> >
> > Simon
> >
> > Simon Talbot MEng, ACGI
> > (Chief Engineer)
> > Net Solutions Europe Limited
> >
> > _______________________________________________
> > FreeTDS mailing list
> > FreeTDS AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/freetds
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
>
> _______________________________________________
> 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