Thread: psqlodbc30w.dll: wrong string termination after SQLFetch for SQL_C_WCHAR buffer bound via SQLBindCol
psqlodbc30w.dll: wrong string termination after SQLFetch for SQL_C_WCHAR buffer bound via SQLBindCol
From
zisi1@gmx.net
Date:
Hi, I have the problem described below in an ODBC application which occurs only with PostgreSQL and PostgreSQL-ODBC drivers: When I fetch string data via ODBC of a column with the "text" datatype (but also when the datatype is "varchar") of a unicode encoded database into a SQLWCHAR-buffer, the string termination in the out-buffer is set wrong, as only the first byte of the string-termination is set to 0 (i.e., SQLWCHAR character at relevant position is 0xcdcd before fetch, and set to 0xcd00 after fetch instead of 0x000). The problem doesn't occur with other drivers (e.g., SQL-Server or SAP-DB/MaxDB). Details: -------- - PostgreSQL Server version: 7.3.2-1 running on Windows 2000 under cygwin-environment - PostgreSQL-ODBC driver: version: 7-03.02.00 date: 22.10.2003 dll-name: psqlodbc30w.dll - MS Windows ODBC-Driver Manager - Create unicode-encoded database with "createdb -E UNICODE unicode" -> ok - Create "text"-encoded table with "CREATE TABLE unicode(name TEXT)" -> ok - Insert of string-data: "INSERT INTO unicode(name) VALUES ('Michael')" -> ok - Select in the cygwin-shell with "SELECT name FROM unicode" -> ok, returns one row with "Michael" - Logfiles attached: psqlodbc_3092.log, mylog_3092.log When I run the ODBC-Application shown below, the number of bytes returned in the indicator buffer "nIndOut" by the driver is ok (14), but the string-termination indicator at position pOutput[8] is set to 0xcd00 instead of 0x0000 (i.e., only first byte is set to 0). Is this a bug in the driver (as the error doesn't occur with other ODBC-drivers), or am I doing something wrong? I appriceate your comments on this problem, as I would like to make our application ready for use with PostgreSQL via ODBC. Thanks for your help, Michael Ziehensack ---------------------------------------------------------- BEGIN OF APPLICATION CODE ---------------------------------------------------------- #include <windows.h> #include <sqlext.h> #include <sql.h> #include <stdio.h> int main(int argc, char* argv[]) { SQLRETURN rc = SQL_SUCCESS; //! allocate environment handle SQLHENV henv = 0; rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); //! Set the ODBC version environment attribute */ rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); //! allocate connection handle SQLHDBC hdbc = 0; rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); //! ... and set autocommit off rc = SQLSetConnectAttr(hdbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0); //! Connect to data source */ rc = SQLConnectW(hdbc, (SQLWCHAR*) L"unicode", SQL_NTS, (SQLWCHAR*) L"ADONIS", SQL_NTS, (SQLWCHAR*) L"BPMS", SQL_NTS); //! Allocate statement handle SQLHSTMT hstmt; rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); SQLWCHAR * pOutput = new SQLWCHAR[100]; SQLINTEGER nIndOut; SQLINTEGER nCount; rc = SQLPrepareW (hstmt, (SQLWCHAR*)L"SELECT name FROM unicode", SQL_NTS); rc = SQLBindCol ( hstmt, 1, SQL_C_WCHAR, pOutput, 100, &nIndOut); rc = SQLExecute (hstmt); rc = SQLFetch(hstmt); /* Error with PostgreSQL-ODBC: driver sets string termination at relevant position as 0xcd00 (i.e., only the first byte of the character is set) instead of 0x0000 !!! */ nCount = wcslen(pOutput); -> wrong, due to wrong string termination rc = SQLEndTran (SQL_HANDLE_DBC, hdbc, SQL_ROLLBACK ); //! Free statment handle rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); //! disconnect rc = SQLDisconnect(hdbc); //! Free connection handle rc = SQLFreeHandle(SQL_HANDLE_DBC, hdbc); //! Free environment handle rc = SQLFreeHandle(SQL_HANDLE_ENV, henv); delete [] pOutput; return rc; } -- +++ GMX - die erste Adresse für Mail, Message, More +++ Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net
Attachment
zisi1@gmx.net wrote: > > Hi, > > I have the problem described below in an ODBC application which > occurs only with PostgreSQL and PostgreSQL-ODBC drivers: > > When I fetch string data via ODBC of a column with the "text" > datatype (but also when the datatype is "varchar") of a unicode > encoded database into a SQLWCHAR-buffer, the string termination > in the out-buffer is set wrong, as only the first byte of the > string-termination is set to 0 (i.e., SQLWCHAR character at > relevant position is 0xcdcd before fetch, and set to 0xcd00 after > fetch instead of 0x000). Could you try the dll at http://www.geocities.jp/inocchichichi/psqlodbc/ ? regards, Hiroshi Inoue
What's happening ?? >Because of an unpleasant reason, I'm not sure if I would >continue to be a maintainer of psqlodbc driver Regards
Sime� Reig wrote: > What's happening ?? > > >Because of an unpleasant reason, I'm not sure if I would > >continue to be a maintainer of psqlodbc driver I have not heard this. What are the details? Where did you see this? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
> Simeó Reig wrote: > > What's happening ?? > > > > >Because of an unpleasant reason, I'm not sure if I would > > >continue to be a maintainer of psqlodbc driver > > I have not heard this. What are the details? Where did you see this? In his web : http://www.geocities.jp/inocchichichi/psqlodbc/ I hope it's a joke ... Best Regards Simeó Reig
> > > >Because of an unpleasant reason, I'm not sure if I would > > > >continue to be a maintainer of psqlodbc driver > > > > I have not heard this. What are the details? Where did > > you see this? If this is indeed true, I'd like to be one of the many who offer Hiroshi thanks for his work on the psqlodbc driver. He has always been extremely helpful and friendly, providing fixes and improvements at an unbelievable speed of knots. Hiroshi if you are out there, good luck for the future! You will be missed. :/ Yours Unwhettedly, Robert John Shepherd. Editor DVD REVIEWER The UK's BIGGEST Online DVD Magazine http://www.dvd.reviewer.co.uk For a copy of my Public PGP key, email: pgp@robertsworld.org.uk
Count me in on the offering of thanks, leaving or not, he deserves them anyway. Hiroshi, thanks for your good support, especialy your high response/fix speed. Good luck in the future. Regards, Jean Huveneers Xillion ICT Solutions B.V. Marktplein 8 6243 BR Geulle The Netherlands tel: +31 (0)43 3659244 fax: +31 (0)43 3659249 gsm: +31 (0)6 456 44 357 www: www.xillion.nl > -----Original Message----- > From: Robert John Shepherd [mailto:robert@reviewer.co.uk] > Sent: dinsdag 23 december 2003 23:08 > To: pgsql-odbc@postgresql.org > Cc: inoue@postgresql.org > Subject: Re: [ODBC] Hiroshi leaves the psqlodc driver ? > > > > > > >Because of an unpleasant reason, I'm not sure if I would > > > > >continue to be a maintainer of psqlodbc driver > > > > > > I have not heard this. What are the details? Where did > > > you see this? > > If this is indeed true, I'd like to be one of the many who > offer Hiroshi > thanks for his work on the psqlodbc driver. He has always > been extremely > helpful and friendly, providing fixes and improvements at an > unbelievable > speed of knots. > > Hiroshi if you are out there, good luck for the future! > > You will be missed. :/ > > > > Yours Unwhettedly, > Robert John Shepherd. > > Editor > DVD REVIEWER > The UK's BIGGEST Online DVD Magazine > http://www.dvd.reviewer.co.uk > > For a copy of my Public PGP key, email: pgp@robertsworld.org.uk > > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > >
Thank you, Hiroshi. -Jason ----- Original Message ----- From: "Jean Huveneers" <j.huveneers@xillion.nl> To: <pgsql-odbc@postgresql.org> Cc: <inoue@postgresql.org> Sent: Wednesday, December 24, 2003 2:31 PM Subject: Re: [ODBC] Hiroshi leaves the psqlodc driver ? > Count me in on the offering of thanks, leaving or not, he deserves them > anyway. > > Hiroshi, thanks for your good support, especialy your high response/fix > speed. > Good luck in the future. > > Regards, > > Jean Huveneers > > Xillion ICT Solutions B.V. > Marktplein 8 > 6243 BR Geulle > The Netherlands > > tel: +31 (0)43 3659244 > fax: +31 (0)43 3659249 > gsm: +31 (0)6 456 44 357 > www: www.xillion.nl > > > -----Original Message----- > > From: Robert John Shepherd [mailto:robert@reviewer.co.uk] > > Sent: dinsdag 23 december 2003 23:08 > > To: pgsql-odbc@postgresql.org > > Cc: inoue@postgresql.org > > Subject: Re: [ODBC] Hiroshi leaves the psqlodc driver ? > > > > > > > > > >Because of an unpleasant reason, I'm not sure if I would > > > > > >continue to be a maintainer of psqlodbc driver > > > > > > > > I have not heard this. What are the details? Where did > > > > you see this? > > > > If this is indeed true, I'd like to be one of the many who > > offer Hiroshi > > thanks for his work on the psqlodbc driver. He has always > > been extremely > > helpful and friendly, providing fixes and improvements at an > > unbelievable > > speed of knots. > > > > Hiroshi if you are out there, good luck for the future! > > > > You will be missed. :/ > > > > > > > > Yours Unwhettedly, > > Robert John Shepherd. > > > > Editor > > DVD REVIEWER > > The UK's BIGGEST Online DVD Magazine > > http://www.dvd.reviewer.co.uk > > > > For a copy of my Public PGP key, email: pgp@robertsworld.org.uk > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 5: Have you checked our extensive FAQ? > > > > http://www.postgresql.org/docs/faqs/FAQ.html > > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings >