pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float
4+ messages / 2 participants
[nested] [flat]

* Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float
@ 2010-11-03 03:22 Adrien de Croy <adrien@qbik.com>
  2010-11-03 08:36 ` Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 4+ messages in thread

From: Adrien de Croy @ 2010-11-03 03:22 UTC (permalink / raw)
  To: pgsql-odbc


Hi all,

apologies if this is already in the bug tracker (I had a look but didn't 
find it).

We recently did some work to get our product working with PostgreSQL 9.0 
and the latest ODBC driver.  Our code is written to (try to) be 
DBMS-agnostic.  So it enumerates reported types, searches for matching 
types etc, and builds CREATE TABLE statements etc from what it finds.

There were a couple of inconsistencies in data returned from the ODBC 
driver.

1. Data returned from SQLGetTypeInfo uses ODBC2 field names.

The columns reported include

"PRECISION" instead of "COLUMN_SIZE"
"MONEY" instead of "FIXED_PREC_SCALE"
"AUTO_INCREMENT" instead of "AUTO_UNIQUE_VALUE"

2. Data returned from SQLTables uses ODBC2 field names

"TABLE_QUALIFIER" instead of "TABLE_CAT"
"TABLE_OWNER" instead of "TABLE_SCHEM"

These 2 issues aren't huge problems, since the ordinal column number 
stays the same.

3. Not all supported types returned by SQLGetTypeInfo

Specifically the types SERIAL and BIGSERIAL are not reported.  This 
means we needed to hard-code a hack so if the driver was PostgreSQL and 
we needed an AUTO_UNIQUE_VALUE counter, we used "SERIAL".  It works, but 
if SQLGetTypeInfo returned these types, it wouldn't need the hack.

4.  Oddness with bigint fields.

bigint reported as precision of 19, instead of 20.  This isn't big 
enough to store an unsigned __int64

5. Oddness with double precision fields.

We had to use double precision fields to store file size information, 
because bigint couldn't do an __int64 (not sure what actual C type this 
really maps to in reality).  However when we get the field data back in 
a query, it is reported as type SQL_FLOAT, even though the DB structure 
in the PostgreSQL manager shows it as double precision.  Obviously you 
don't want to truncate double to float, so is this just in the driver 
(some type switch case not supported?)

Once we worked around all these issues, it seems to be working great.  
I'm a bit concerned about losing precision with double vs float though.

Regards

Adrien



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float
  2010-11-03 03:22 Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Adrien de Croy <adrien@qbik.com>
@ 2010-11-03 08:36 ` Hiroshi Inoue <inoue@tpf.co.jp>
  2010-11-03 10:13   ` Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Adrien de Croy <adrien@qbik.com>
  2010-11-04 05:39   ` Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Adrien de Croy <adrien@qbik.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Hiroshi Inoue @ 2010-11-03 08:36 UTC (permalink / raw)
  To: Adrien de Croy <adrien@qbik.com>; +Cc: pgsql-odbc

Hi,

(2010/11/03 12:22), Adrien de Croy wrote:
>
> Hi all,
>
> apologies if this is already in the bug tracker (I had a look but didn't
> find it).
>
> We recently did some work to get our product working with PostgreSQL 9.0
> and the latest ODBC driver. Our code is written to (try to) be
> DBMS-agnostic. So it enumerates reported types, searches for matching
> types etc, and builds CREATE TABLE statements etc from what it finds.
>
> There were a couple of inconsistencies in data returned from the ODBC
> driver.
>
> 1. Data returned from SQLGetTypeInfo uses ODBC2 field names.
>
> The columns reported include
>
> "PRECISION" instead of "COLUMN_SIZE"
> "MONEY" instead of "FIXED_PREC_SCALE"
> "AUTO_INCREMENT" instead of "AUTO_UNIQUE_VALUE"
>
> 2. Data returned from SQLTables uses ODBC2 field names
>
> "TABLE_QUALIFIER" instead of "TABLE_CAT"
> "TABLE_OWNER" instead of "TABLE_SCHEM"
>
> These 2 issues aren't huge problems, since the ordinal column number
> stays the same.
>
> 3. Not all supported types returned by SQLGetTypeInfo
>
> Specifically the types SERIAL and BIGSERIAL are not reported. This means
> we needed to hard-code a hack so if the driver was PostgreSQL and we
> needed an AUTO_UNIQUE_VALUE counter, we used "SERIAL". It works, but if
> SQLGetTypeInfo returned these types, it wouldn't need the hack.
>
> 4. Oddness with bigint fields.
>
> bigint reported as precision of 19, instead of 20. This isn't big enough
> to store an unsigned __int64

Because int8 type in PostgreSQL is signed, the precision is 19.

> 5. Oddness with double precision fields.
>
> We had to use double precision fields to store file size information,
> because bigint couldn't do an __int64 (not sure what actual C type this
> really maps to in reality). However when we get the field data back in a
> query, it is reported as type SQL_FLOAT, even though the DB structure in
> the PostgreSQL manager shows it as double precision. Obviously you don't
> want to truncate double to float, so is this just in the driver (some
> type switch case not supported?)

SQL_FLOAT means double precision type. What means signle precision type
is SQL_REAL.

> Once we worked around all these issues, it seems to be working great.
> I'm a bit concerned about losing precision with double vs float though.
>
> Regards
>
> Adrien




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float
  2010-11-03 03:22 Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Adrien de Croy <adrien@qbik.com>
  2010-11-03 08:36 ` Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Hiroshi Inoue <inoue@tpf.co.jp>
@ 2010-11-03 10:13   ` Adrien de Croy <adrien@qbik.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Adrien de Croy @ 2010-11-03 10:13 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: pgsql-odbc

  Hi

On 3/11/2010 9:36 p.m., Hiroshi Inoue wrote:
> Hi,
>
> (2010/11/03 12:22), Adrien de Croy wrote: 5. Oddness with double 
> precision fields.
>>
>> We had to use double precision fields to store file size information,
>> because bigint couldn't do an __int64 (not sure what actual C type this
>> really maps to in reality). However when we get the field data back in a
>> query, it is reported as type SQL_FLOAT, even though the DB structure in
>> the PostgreSQL manager shows it as double precision. Obviously you don't
>> want to truncate double to float, so is this just in the driver (some
>> type switch case not supported?)
>
> SQL_FLOAT means double precision type. What means signle precision type
> is SQL_REAL.

When I tried to store a C double type (8byte floating point) into this 
field which reported itself as SQL_FLOAT even though it's "double 
precision", it reported that the thing I was poking in was too big, so I 
had to fall back to storing it as a C float type.  This is using 
SQLBindParameter.

my understanding is SQL_DOUBLE is required.   Is that used?  It's 
certainly used by other DBs, such as MySQL, MS SQL server and Access even.

Thanks for your reply

Regards

Adrien

>
>> Once we worked around all these issues, it seems to be working great.
>> I'm a bit concerned about losing precision with double vs float though.
>>
>> Regards
>>
>> Adrien
>

-- 
Adrien de Croy - WinGate Proxy Server - http://www.wingate.com




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float
  2010-11-03 03:22 Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Adrien de Croy <adrien@qbik.com>
  2010-11-03 08:36 ` Re: Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Hiroshi Inoue <inoue@tpf.co.jp>
@ 2010-11-04 05:39   ` Adrien de Croy <adrien@qbik.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Adrien de Croy @ 2010-11-04 05:39 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: pgsql-odbc


Hi again

apologies, I did some more research.  Looks like SQL_FLOAT and 
SQL_DOUBLE are used for c double types, and SQL_REAL for c float type.

very confusing, but that's not unusual for ODBC.

So I've also managed to solve my bigint issue, by falling back to a 
signed __int64 instead of unsigned.  I guess there's no plan to 
implement unsigned numeric types?

Adrien


On 3/11/2010 9:36 p.m., Hiroshi Inoue wrote:
> Hi,
>
> (2010/11/03 12:22), Adrien de Croy wrote:
>>
>> Hi all,
>>
>> apologies if this is already in the bug tracker (I had a look but didn't
>> find it).
>>
>> We recently did some work to get our product working with PostgreSQL 9.0
>> and the latest ODBC driver. Our code is written to (try to) be
>> DBMS-agnostic. So it enumerates reported types, searches for matching
>> types etc, and builds CREATE TABLE statements etc from what it finds.
>>
>> There were a couple of inconsistencies in data returned from the ODBC
>> driver.
>>
>> 1. Data returned from SQLGetTypeInfo uses ODBC2 field names.
>>
>> The columns reported include
>>
>> "PRECISION" instead of "COLUMN_SIZE"
>> "MONEY" instead of "FIXED_PREC_SCALE"
>> "AUTO_INCREMENT" instead of "AUTO_UNIQUE_VALUE"
>>
>> 2. Data returned from SQLTables uses ODBC2 field names
>>
>> "TABLE_QUALIFIER" instead of "TABLE_CAT"
>> "TABLE_OWNER" instead of "TABLE_SCHEM"
>>
>> These 2 issues aren't huge problems, since the ordinal column number
>> stays the same.
>>
>> 3. Not all supported types returned by SQLGetTypeInfo
>>
>> Specifically the types SERIAL and BIGSERIAL are not reported. This means
>> we needed to hard-code a hack so if the driver was PostgreSQL and we
>> needed an AUTO_UNIQUE_VALUE counter, we used "SERIAL". It works, but if
>> SQLGetTypeInfo returned these types, it wouldn't need the hack.
>>
>> 4. Oddness with bigint fields.
>>
>> bigint reported as precision of 19, instead of 20. This isn't big enough
>> to store an unsigned __int64
>
> Because int8 type in PostgreSQL is signed, the precision is 19.
>
>> 5. Oddness with double precision fields.
>>
>> We had to use double precision fields to store file size information,
>> because bigint couldn't do an __int64 (not sure what actual C type this
>> really maps to in reality). However when we get the field data back in a
>> query, it is reported as type SQL_FLOAT, even though the DB structure in
>> the PostgreSQL manager shows it as double precision. Obviously you don't
>> want to truncate double to float, so is this just in the driver (some
>> type switch case not supported?)
>
> SQL_FLOAT means double precision type. What means signle precision type
> is SQL_REAL.
>
>> Once we worked around all these issues, it seems to be working great.
>> I'm a bit concerned about losing precision with double vs float though.
>>
>> Regards
>>
>> Adrien
>
>



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2010-11-04 05:39 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-11-03 03:22 Various errors in psqlodbc: SQLGetTypeInfo, SQLTables, bigint, and double vs float Adrien de Croy <adrien@qbik.com>
2010-11-03 08:36 ` Hiroshi Inoue <inoue@tpf.co.jp>
2010-11-03 10:13   ` Adrien de Croy <adrien@qbik.com>
2010-11-04 05:39   ` Adrien de Croy <adrien@qbik.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox