On 06/11/2014 11:50 PM, Walter Couto wrote:
> Have a table similar to the one below:
>
> CREATE TABLE bitstring_test
> (
> test integer NOT NULL,
> bit_col bit(47),
> bitvarying_col bit varying(47),
> PRIMARY KEY (test)
> )
>
> You can before a select * from the table above and observe what information is given back to you by the ODBC driver
forthe bit and bit varying colums:
>
>
> 1) Both bit_col and bitvarying_col return "unknown" for the type name (SQLColAttribute using
SQL_DESC_TYPE_NAME). This appears to be due to the fact that in pgtypes.c the method pgtype_attr_to_name is missing the
casefor PG_TYPE_BIT and is missing the #define and case for bit varying(1562).
>
> 2) For bit_col, calls to SQLColAttribute passing either SQL_DESC_LENGTH or SQL_DESC_DISPLAY_SIZE both return the
value255. Which is not what the size is stated above but at least it is bigger :).
>
> 3) For bitvarying_col, calls to SQLColAttribute passing either SQL_DESC_LENGTH or SQL_DESC_DISPLAY_SIZE return
thevalue 43. Which is not correct and smaller than what is stated above so this can cause problems. :(
>
> Any idea if I there is a way for me to avoid problem 3) as I can't tell from the type name what I am looking at.
The list of built-in types that the internal pgtype_attr_to_name()
function knows about haven't been updated for a long time. At a quick
glance, it's also seems to be missing all range and array types, for
example.
Given that writing custom data types is a very prominent feature in
PostgreSQL, it would be nice if we could do better than check against a
hard-coded list of built-in functions. I think
SQLColAttribute(SQL_DESC_TYPE_NAME) should query the pg_type catalog to
get the type name.
Patches are welcome..
- Heikki