Re: problem with CVS version - Mailing list pgsql-odbc

From Dave Page
Subject Re: problem with CVS version
Date
Msg-id E7F85A1B5FF8D44C8A1AF6885BC9A0E41A7499@ratbert.vale-housing.co.uk
Whole thread Raw
In response to problem with CVS version  ("Antonio Pennino" <a.pennino@nocerainformatica.net>)
Responses Re: problem with CVS version
List pgsql-odbc

> -----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.

pgsql-odbc by date:

Previous
From: "Dave Page"
Date:
Subject: Re: problem with CVS version
Next
From: "Mark Dexter"
Date:
Subject: Updatable Cursors, CTID, and Views