ODBC breaks COUNTS, SEQUENCES as of Postgresql 7.3 - Mailing list pgsql-odbc

From Alain Picard
Subject ODBC breaks COUNTS, SEQUENCES as of Postgresql 7.3
Date
Msg-id 15933.45721.965448.55685@outback.memetrics.local
Whole thread Raw
Responses Re: ODBC breaks COUNTS, SEQUENCES as of Postgresql 7.3
List pgsql-odbc
Dear ODBC users,

I have an application, written in lisp, which uses the unixODBC
driver manager (though I've tested what follows with iODBC, with
the same results).  I have no real control over how the ODBC library
is being used in this application; it comes from a 3rd party vendor.
I'm trying to reverse engineer what they do via customer support and
inspecting the ODBC trace log files.


On the the problem.
With versions of Postgresql <= 7.2, I would obtain the following
results,

    (select [count [*]] :from [foo])
     =>
    ((73))
    ("count")


As of 7.3, I am now obtaining

    (select [count [*]] :from [foo])
     =>
    (("73"))
    ("count")

Note the 73 is now "73".  My understanding is that this is because as
of 7.3, postgresql now reports counts, sequences, etc as INTEGER8,
whereas they were previously INTEGER4.

I tried to switch to using the "official" postgresql ODBC driver,
psqlodbc, and compiled it from the sources in CVS.  My thinking is
that they would track the changes in Postgresql more closely than the
unixODBC group.

Setting up a DSN to use this driver, I can no longer connect to the
back end:

    XOS 23 > (connect "test_new_postgres/kooks")
    Error: Sql-Database-Data-Error id HY092[28] : [unixODBC]ColAttribute for this type not implemented yet
      1 (abort) Return to level 0.
      2 Return to top loop level 0.

    Type :b for backtrace, :c <option number> to proceed,  or :? for other options

The SQL log file of unixODBC shows:

    [ODBC][7481][SQLColAttributes.c][226]
            Entry:
                Statement = 0x806cda0
                Column Number = 1
                Field Identifier = 0
                Character Attr = 0x807c168
                Buffer Length = 4
                String Length = 0x805cd96
                Numeric Attribute = 0x805cd90

    [ODBC][7481][SQLColAttributes.c][553]
            Exit:[SQL_ERROR]
            DIAG [HY092] [unixODBC]ColAttribute for this type not implemented yet

    [ODBC][7481][SQLError.c][310]
            Entry:
                Statement = 0x806cda0
                SQLState = 0x807c178
                Native = 0x805cd94
                Message Text = 0x807c698
                Buffer Length = 512
                Text Len Ptr = 0x805cd92

Which seems to be being raised at line 740 of results.c
(as of revision 1.57) in function PGAPI_ColAttributes.
At this point, the code is trying to map the fDescType.

Note that the Field Identifier = 0 seems to correspond
to an input for fDescType of SQL_COLUMN_COUNT.

There is a commented out case at line 558 which says
that SQL_COLUMN_COUNT is "handled above", however, it seems
that in fact, it is not handled, as the code eventually falls
through to the default case and prints the error message
detailed above.


Does anybody know:
 a) how to fix this?
 b) how to get 7.3 to return numbers via ODBC
 c) if I'm just totally confused?  :-)


Thanks for any input.


--
            Alain Picard
            Memetrics

pgsql-odbc by date:

Previous
From: Giuliano Gavazzi
Date:
Subject: Re: Postgresql & ODBC
Next
From: Tom Lane
Date:
Subject: Re: ODBC breaks COUNTS, SEQUENCES as of Postgresql 7.3