> -----Original Message-----
> From: Dave Page
> Sent: 27 July 2004 21:34
> To: 'Antonio Pennino'
> Subject: RE: [ODBC] problem with CVS version
>
>
> The behaviour you see is correct when calling
> SQLDescribeColW, however, I did just test this using ANSI
> ODBC Test and it is also returning -9 which is not correct.
> I'm not convinced this will resolve your problem, but it
> certainly isn't right. I'll look into it some more...
OK, I've traced this through the code, and as far as I can see it is
just fine. If the connection is made using SQLConnectW,
SQLDriverConnectW or SQLBrowseConnectW, then a unicode flag in the
connection object is set. When a PostgreSQL type is later converted to
an ODBC type (as happens for SQLDescribeCol), that flag is checked. The
following rules apply:
If the column length exceeds max_varchar_size, if the unicode flag is
set, SQL_WLONGVARCHAR is returned, otherwise SQL_LONGVARCHAR is
returned. If the column length does not exceed max_varchar_size, if the
unicode flag is set, SQL_WVARCHAR is returned, otherwise SQL_VARCHAR is
returned.
I believe the ANSI ODBC Test program is giving a bit of a red herring.
The SQL trace log shows it calling SQLConnectW:
odbcte32 d10-d14 ENTER SQLDriverConnectW
HDBC 003A1510
HWND 00140560
WCHAR * 0x1F7A9D2C [ -3] "******\ 0"
SWORD -3
WCHAR * 0x1F7A9D2C
SWORD 2
SWORD * 0x00000000
UWORD 1 <SQL_DRIVER_COMPLETE>
Therefore it's no surprise that the driver thinks it's OK to return
unicode datatypes.
Regards, Dave.