#30 Postgres UTF-8 parameter handling

open
nobody
None
5
2008-10-22
2008-10-22
Mozart Hasse
No

When I use a parameterized query (e.g. "INSERT INTO X (FIELD1) VALUES (?)") to put a value into a varchar field, I get the message "value too long for type character varying" when my text has exactly the size of the varchar field *and* I use special characters like ç ã ô , etc. The same command works fine in any other case.
I´m using a Postgres 8.3.4 server with a UTF8 database with ODBC driver psqlodbc_08_03_0200. I'm connecting to it using Delphi 2007. My ODBC DataSource is configured to PostgreSQL Unicode as shown in the attachment.
Other connection options:

DriverName=PostgresODBC
GetDriverFunc=getSQLDriverODBCW
LibraryName=dbxoodbc.dll
VendorLib=psqlodbc35w.dll
DriverUnit=DBXDynalink
DriverPackageLoader=TDBXDynalinkDriverLoader
DriverPackage=DBXCommonDriver110.bpl
DbxWOterroRBase TransIsolation=ReadCommited
RowsetSize=1
BlobSize=-1
Trim Char=True
Custom String=coLockMode=-1;coCatalog=0;coMapInt64ToBcd=1;coMapCharAsBDE=1

Discussion

  • Mozart Hasse
    Mozart Hasse
    2008-10-22

    ODBC configuration

     
    Attachments
  • see DbxOpenOdbc.inc
    ---
    {$DEFINE _FIX_PostgreSQL_ODBC_}// fixed: PostgreSQL ODBC driver charset conversion bug.
    // Driver supported only utf8 charsets for odbc api
    // function "SQLBindParameter".
    ---
    Possible this bug is already corrected. Then it is necessary to switch off _FIX_PostgreSQL_ODBC_.

     
  • Mozart Hasse
    Mozart Hasse
    2008-11-17

    I tried that. Without _FIX_PostgreSQL_ODBC_, many things stop working, all parameters seem to be truncated. When I turn _FIX_PostgreSQL_ODBC_ on, UTF8 strings smaller than the maximum size work perfectly. It seems to me that this indicates the Postgres ODBC driver is still using UTF8.

     
  • Subject is united with "Postgres string parameter with odd size"