Skip to Content.
Sympa Menu

freetds - RE: Losing last character of TEXT fields

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: ZIGLIO Frediano <Frediano.Ziglio AT vodafoneomnitel.it>
  • To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
  • Subject: RE: Losing last character of TEXT fields
  • Date: Wed, 10 Jul 2002 11:09:04 +0200


>
> Eric,
>
> Your remarks are on the money. Please ignore my last
> message. I now like
> your "radical" solution best, because it's both simple and funny.
>
> I should have looked at cs.c, at cs_convert(). I was fixing dblib in
> tdslib, with the consequence of breaking ctlib. The weird termination
> behavior described in the dblib docs shouldn't be embedded in a shared
> library. dbconvert() is what needs attention.
>
> Brian, I'd like to suggest a policy about conversions for the
> project; if
> you like it then it should be explicitly noted somewhere.
>
> <policy>
> tds_convert copies from src to dest and returns the output
> data length,
> period. All padding and termination is the responsibilty of
> the API library
> and is done post conversion. There may be some shared
> utility padding &
> termination functions, but they're really not "conversion".
> Trying to do
> anything nonstraightforward in tds_convert will only confuse
> and confound
> the higher levels, us among them.
> </policy>
>
> An alternative would be to pass the padding & termination
> policy argument as
> an enumerated type, which tds_convert would carry out if the basic
> conversion succeeds.
>
> You have more experience with this (obviously), and have some
> idea where
> UTF-8 is taking us, so I'm curious how you see things.
>
Perhaps we should find a common beetween all library. Is not clear what
destlen mean. I know quite well odbc, but not other library.
I execute some test with ms odbc with following results

Test with ODBC, 128 byte buffer

SELECT CAST('123' AS CHAR(6))
return "123 ", always terminated, indicator = 6

SELECT CAST('123' AS VARCHAR(6))
return "123", always terminated, indicator = 3

SELECT CAST('123' AS TEXT)
return "123", always terminated, indicator = 3

Test with ODBC, 2 byte buffer

SELECT CAST('123' AS CHAR(6))
return "1", always terminated, indicator = 6

SELECT CAST('123' AS VARCHAR(6))
return "1", always terminated, indicator = 3

SELECT CAST('123' AS TEXT)
return "1", always terminated, indicator = 3

Test with ODBC, 0 byte buffer

SELECT CAST('123' AS CHAR(6))
return nothing, always terminated, indicator = 6

SELECT CAST('123' AS VARCHAR(6))
return nothing, always terminated, indicator = 3

SELECT CAST('123' AS TEXT)
return nothing, always terminated, indicator = 3

Test with ODBC, 2 byte buffer

SELECT CAST(NULL AS CHAR(6))
return nothing, always terminated, indicator = -1

SELECT CAST(NULL AS VARCHAR(6))
return nothing, always terminated, indicator = -1

SELECT CAST(NULL AS TEXT)
return nothing, always terminated, indicator = -1

Test with ODBC, -1 byte buffer
Fail to bind

Test with ODBC, -2 byte buffer
Fail to bind

return nothing mean that function do not write nothing in destination
buffer. As we can see ODBC do not handle destlen of -1 or destlen of -2.
Also There destination can be only a terminated string (no difference
beetween DBCHAR, DBVARCHAR or DBTEXT)

I think ctlib and DB-Library have different destlen value and terminator
problems...
Watching some doc seem that converting to DBCHAR do not append terminator
(if destlen >=0) but pad with spaces and always terminated if
DBVARCHAR/DBTEXT.
Someone else have better info?

freddy77

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

=================================




Archive powered by MHonArc 2.6.24.

Top of Page