Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 3ACB69FB510 for ; Thu, 3 May 2007 04:56:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 01408-07 for ; Thu, 3 May 2007 04:56:45 -0300 (ADT) Received: from pgfoundry.org (pgfoundry.org [200.46.204.130]) by postgresql.org (Postfix) with ESMTP id A9CF99FB4F9 for ; Thu, 3 May 2007 04:56:47 -0300 (ADT) Received: from localhost (unknown [200.46.204.191]) by pgfoundry.org (Postfix) with ESMTP id 83F6F216D11; Thu, 3 May 2007 07:56:47 +0000 (UTC) Received: from pgfoundry.org ([200.46.204.130]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 91469-10; Thu, 3 May 2007 04:56:43 -0300 (ADT) Received: by pgfoundry.org (Postfix, from userid 80) id A3C83216D10; Thu, 3 May 2007 07:56:43 +0000 (UTC) To: noreply@pgfoundry.org From: Subject: [ psqlodbc-Bugs-1003103 ] copy_and_convert_field(...) destroys bind info for wide char varchar columns Content-type: text/plain; charset=UTF-8 Message-Id: <20070503075643.A3C83216D10@pgfoundry.org> Date: Thu, 3 May 2007 07:56:43 +0000 (UTC) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/11 X-Sequence-Number: 8924 Bugs item #1003103, was opened at 2007-04-15 16:39 You can respond by visiting: http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1003103&group_id=1000125 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Thomas Zehbe (thomasz) Assigned to: Nobody (None) Summary: copy_and_convert_field(...) destroys bind info for wide char varchar columns Initial Comment: I'm using psqlodbc 08.02.0200 on SuSE Linux 9.3, Postgres 8.0.1 with libiodbc 3.52.5 and wxWidgets. psqlodbcs config params are: ./configure --enable-pthreads --enable-unicode --with-iodbc CFLAGS="-ggdb -O0 The problem occured is that for varchar colums an insert is possible up to the max length, but an update only up to the count of characters of the value wich was last read. F. E. a colum containg "12345" can't be updated to "12345aaa". It's always cut to "12345". I found that ResolveOneParam(...) sets "used" to the number of last readed chars, instead of SQL_NTS (in fact "-3"). So on update only this number of chars is converted. At the end of copy_and_convert_field I Found this statement: if (pcbValue) *((SQLLEN *) pcbValueBindRow) = len; During the first read *pcbValue is "-3" for SQL_NTS columns, but the assignment sets it to the count of chars read. I changed it to if (pcbValue) if (*pcbValue >= 0) *((SQLLEN *) pcbValueBindRow) = len; so SQL_NTS is retained in *pcbValue. Now update works Regards, Thomas ---------------------------------------------------------------------- >Comment By: Thomas Zehbe (thomasz) Date: 2007-05-03 09:56 Message: > Please note pcbValue(BindRow) is an output parameter not >an i-o one. WhatI don't understand is that in ResolveOneParam at line 3336 inteprets this parameter. The variable used is set in line 3231, where the content of apara->used is equal to the number of bytes last read. And apara->used in fact is a pointer to memory affected by the last read. >ISTM the proper way is to call SetNullColNull() when the >column buffers are changed or change the column contents >via SetColumn() function. I couldn't find SetNullColNull() in psqlODBC, libiodbc and wxWidgets. I found SetColumn() in wxWidgets, but it is not documented. In line 3320 of convert.c used==SQL_NTS is checked, but only if it is in win_unicode mode. This correlates to the fact, the as long as I didn't use unicode mode, everything works as only the buffer pointer is copied in the SQL_C_CHAR case.