Re: Null Characters in Strings, Version 9.3.1

From: Nils Gösche <cartan(at)cartan(dot)de>
To: "'Heikki Linnakangas'" <hlinnakangas(at)vmware(dot)com>
Cc: <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: Null Characters in Strings, Version 9.3.1
Date: 2014-02-18 23:28:12
Message-ID: 004401cf2d01$17dcb070$47961150$@cartan.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Heikki wrote:

> I'm afraid I can't easily compile and execute that either, with all the
Windows-ism's in it. Could you pick one of the regression test cases (e.g
http://git.postgresql.org/gitweb/?p=psqlodbc.git;a=blob_plain;f=test/src/sel
ect-test.c;hb=HEAD),
> and modify it to reproduce the problem? And please also include the SQL
statements to create the test table and data.

Ok, I included a little create script, and modified one of the regression
test files to fetch a single text value as WCHAR from a single row of data.
The resulting program is reasonably simple.

The end of the output with version 9.2.1 of the driver looks like this:

$computedZiffer = 10 - ($sum % 10)

if ($computedZiffer -eq $pruefZiffer) { $ret = $true }
}
$ret
strlen = 487
sqlLen = 974
disconnecting
Press ENTER to exit...

And here it is with 9.3.1:

$computedZiffer = 10 - ($sum % 10)

if ($computedZiffer -eq $pruefZiffer) { $ret = $true }
}
$ret
strlen = 459
sqlLen = 974
disconnecting
Press ENTER to exit...

strlen is different in both cases, but sqlLen is the same. I modified the
program to output the received SQL_C_WCHAR value in binary (preceded by a
UTF16 BOM). The two result files are attached (value921.txt and
value931.txt). If you look at them in a hex editor, you will notice that the
9.2.1 version contains some Ctrl-M characters! Apparently, these have been
stripped in the 9.3.1 version, but the sqlLen value is still the same. I
suppose that .NET uses the latter value to determine how many characters to
include in its query result string (null characters are perfectly normal
characters in C# strings).

Regards,
--
Nils Gösche
Don’t ask for whom the <Ctrl-G> tolls.

Attachment Content-Type Size
Create.sql application/octet-stream 595 bytes
CODBCSimple.c text/plain 1.5 KB
value921.txt text/plain 976 bytes
value931.txt text/plain 976 bytes

Browse pgsql-odbc by date

  From Date Subject
Next Message Hiroshi Inoue 2014-02-19 00:09:57 Re: Null Characters in Strings, Version 9.3.1
Previous Message Heikki Linnakangas 2014-02-18 20:30:34 Re: Null Characters in Strings, Version 9.3.1