Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFuk4-0001QB-RJ for pgsql-odbc@arkaria.postgresql.org; Wed, 19 Feb 2014 00:10:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WFuk4-0007BH-1Z for pgsql-odbc@arkaria.postgresql.org; Wed, 19 Feb 2014 00:10:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFuk2-0007B8-6r for pgsql-odbc@postgresql.org; Wed, 19 Feb 2014 00:10:22 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by magus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WFujw-0006pc-B8 for pgsql-odbc@postgresql.org; Wed, 19 Feb 2014 00:10:21 +0000 Received: (qmail 32053 invoked by uid 512); 19 Feb 2014 00:10:10 -0000 Received: from unknown (HELO ?100.0.33.224?) (100.0.33.224) by sd2.tpf-fw-c.co.jp with SMTP; 19 Feb 2014 00:10:10 -0000 Message-ID: <5303F655.8000200@tpf.co.jp> Date: Wed, 19 Feb 2014 09:09:57 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Heikki Linnakangas , =?UTF-8?B?TmlscyBHw7ZzYw==?= =?UTF-8?B?aGU=?= CC: pgsql-odbc@postgresql.org Subject: Re: Null Characters in Strings, Version 9.3.1 References: <006a01cf28e4$7c425450$74c6fcf0$@de> <003201cf2ccb$c5d6ddd0$51849970$@de> <5303960F.3050706@vmware.com> <003b01cf2ce1$2e33bc80$8a9b3580$@de> <5303C2EA.7060109@vmware.com> In-Reply-To: <5303C2EA.7060109@vmware.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org (2014/02/19 5:30), Heikki Linnakangas wrote: > On 02/18/2014 09:39 PM, Nils Gösche wrote: >> Heikki wrote: >> >>> On 02/18/2014 07:06 PM, Nils Gösche wrote: >>>> I wrote: >>>> >>>>> If I retrieve the value in a C# program using the ODBC driver, I get >>>>> a string that has a null character at position 459, but a total >>>>> length of 487! The string up to position 458 is correct, but has >>> now >>>>> been extended with a null character and a few junk characters. >>>> >>>> Am I the only one thinking this is a serious bug? >>> >>> Maybe.. I don't have a C# environment to test this with; if you can >>> write a small stand-alone C program to reproduce this and post it, I'll >>> take a look. >> >> Thanks! I have never written an ODBC program in C before. Wow, what a >> PITA... ;-). > > Yep, it's quite verbose :-). > >> I took a little example program from Microsoft's site and adapted >> it. The code is attached. > > 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/select-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. > >> The essential point is at line 353: >> >> if (wcslen(pThisBinding->wszBuffer) * sizeof(wchar_t) != >> pThisBinding->indPtr) >> { >> wprintf(L"2 * wcslen = %d, indPtr = %d\n", >> wcslen(pThisBinding->wszBuffer) * sizeof(wchar_t), >> pThisBinding->indPtr); >> } >> else >> { >> wprintf(pThisBinding->fChar ? DISPLAY_FORMAT_C:DISPLAY_FORMAT, >> PIPE, >> pThisBinding->cDisplaySize, >> pThisBinding->cDisplaySize, >> pThisBinding->wszBuffer); >> } >> >> If I run this with version 9.2.1 of the driver (I am using 32 Bit >> here), it will go to the else clause and print the value of the text >> column. However, if I run this with the latest version, I get the >> following output: > > Hmm. If you could pinpoint it to the exact commit that changed the > behavior, that would help too. Maybe it's caused by the commit 3666c87c1440862bde2e6b8f43ee585deed70d31 Author: Hiroshi Inoue Date: Thu Aug 22 20:40:01 2013 +0900 When LF->CR+LF conversion causes an buffer truncation, supress the conversion (in case of unicode). Nils, please try to turn off *LF <-> CR/LF conversion* option. Anyway I can't think of the way to cure the problem other than putting back the commit. regards, Hiroshi Inoue -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc