From: keyurgovande@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #11767: ODBC driver bug when fetching constant string columns
Date: Wed, 22 Oct 2014 21:22:10 +0000
Message-ID: <20141022212210.2665.47909@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 11767
Logged by: Keyur Govande
Email address: keyurgovande@gmail.com
PostgreSQL version: 9.0.3
Operating system: Centos 6.5
Description:
Hello,
This was reported to the PHP project (https://bugs.php.net/bug.php?id=68087)
but it seems like a Postgres ODBC driver bug.
If we run a SELECT statement like: SELECT id, varchar_col, date_col, 'random
string' as random;
via ODBC, then the last column comes back as junk into PHP.
In PHP we use the SQL_DESC_OCTET_LENGTH to figure out how many bytes to
allocate. But for that column, SQL_DESC_OCTET_LENGTH returns 0 and we don't
allocate enough space.
The driver issue seems to be that when SQLColAttributes() is called with
SQL_COLUMN_TYPE for column 'random', it returns SQL_VARCHAR even though the
PG type is PG_TYPE_UNKNOWN. The promotion is happening here:
http://git.postgresql.org/gitweb/?p=psqlodbc.git;a=blob;f=pgtypes.c;h=4ce7636b69d371d9f511d492c68013...
I think the same promotion needs to happen when fetching octet-length here:
http://git.postgresql.org/gitweb/?p=psqlodbc.git;a=blob;f=pgtypes.c;h=4ce7636b69d371d9f511d492c68013...
Thoughts? This is not a problem when using the Vertica ODBC driver for
example.
A temporary workaround is to use a cast thusly: SELECT id, varchar_col,
date_col, varchar 'random string' as random;
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: keyurgovande@gmail.com, pgsql-bugs@postgresql.org
Subject: Re: BUG #11767: ODBC driver bug when fetching constant string columns
In-Reply-To: <20141022212210.2665.47909@wrigleys.postgresql.org>
References: <20141022212210.2665.47909@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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