pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #11767: ODBC driver bug when fetching constant string columns
3+ messages / 3 participants
[nested] [flat]

* BUG #11767: ODBC driver bug when fetching constant string columns
@ 2014-10-22 21:22  keyurgovande@gmail.com
  0 siblings, 1 reply; 3+ messages in thread

From: keyurgovande@gmail.com @ 2014-10-22 21:22 UTC (permalink / raw)
  To: pgsql-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



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

* Re: [BUGS] BUG #11767: ODBC driver bug when fetching constant string columns
@ 2014-10-24 13:36  Michael Paquier <michael.paquier@gmail.com>
  parent: keyurgovande@gmail.com
  0 siblings, 1 reply; 3+ messages in thread

From: Michael Paquier @ 2014-10-24 13:36 UTC (permalink / raw)
  To: keyurgovande@gmail.com; +Cc: PostgreSQL mailing lists <pgsql-odbc@postgresql.org>

On Wed, Oct 22, 2014 at 11:22 PM,  <keyurgovande@gmail.com> wrote:
> 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
You should update to 9.0.18, you are 3.5 years of bug fixes.

> 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;
> This was reported to the PHP project (https://bugs.php.net/bug.php?id=68087)
> but it seems like a Postgres ODBC driver bug.
pgsql-odbc is more adapted for a bug report on the ODBC driver. I am
moving the thread there.
-- 
Michael


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



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

* Re: [BUGS] BUG #11767: ODBC driver bug when fetching constant string columns
@ 2014-10-24 16:10  Keyur Govande <keyurgovande@gmail.com>
  parent: Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Keyur Govande @ 2014-10-24 16:10 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: PostgreSQL mailing lists <pgsql-odbc@postgresql.org>

On Fri, Oct 24, 2014 at 9:36 AM, Michael Paquier <michael.paquier@gmail.com>
wrote:

> On Wed, Oct 22, 2014 at 11:22 PM,  <keyurgovande@gmail.com> wrote:
> > 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
> You should update to 9.0.18, you are 3.5 years of bug fixes.
>

Ah I apologize, I chose the wrong version in the bug report dropdown. This
bug was observed with the latest driver: psqlodbc-09.03.0300 connecting to
a Postgres server 9.1.14.


>
> > 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;
> > This was reported to the PHP project (
> https://bugs.php.net/bug.php?id=68087)
> > but it seems like a Postgres ODBC driver bug.
> pgsql-odbc is more adapted for a bug report on the ODBC driver. I am
> moving the thread there.
> --
> Michael
>

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


end of thread, other threads:[~2014-10-24 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-10-22 21:22 BUG #11767: ODBC driver bug when fetching constant string columns keyurgovande@gmail.com
2014-10-24 13:36 ` Michael Paquier <michael.paquier@gmail.com>
2014-10-24 16:10   ` Keyur Govande <keyurgovande@gmail.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