Re: Selecting a constant question

From: "Dann Corbit" <DCorbit(at)connx(dot)com>
To: "Larry McGhaw" <lmcghaw(at)connx(dot)com>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, "Hannu Krosing" <hannu(at)skype(dot)net>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Selecting a constant question
Date: 2007-06-12 20:42:32
Message-ID: D425483C2C5C9F49B5B7A41F894415470100072E@postal.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> -----Original Message-----
> From: Larry McGhaw
> Sent: Tuesday, June 12, 2007 1:40 PM
> To: Martijn van Oosterhout
> Cc: Andrew Dunstan; Hannu Krosing; Tom Lane; Alvaro Herrera; Dann
Corbit;
> Gregory Stark; pgsql-hackers(at)postgresql(dot)org
> Subject: RE: [HACKERS] Selecting a constant question
>
> For what its worth .. Your statement about why we are the first people
to
> mention this problem really got me thinking. Anyone who would attempt
to
> write an ODBC driver for Postgres would run into the exact same issue.
> So I installed the official Postgres ODBC driver, and ran the
identical
> query and here are my results:
>
> I probably should have looked at this first .... There is a whole
Postgres
> ODBC dialog dedicated to the very subject of this thread:
> Handling of "unknown" data sizes. The pgodbc driver is configured to
> treat unknowns as varchar(255) by default,
> As shown by my example below. This can be configured up or down as
> desired.
>
> SQLExecDirect:
> In: hstmt = 0x003C18E0, szSqlStr = "Select a,b,c, '123' ,
'123'::char(3),
> '123'::varchar(3) from...", cbSqlStr = -3
> Return: SQL_SUCCESS=0
>
> Describe Column All:
> icol, szColName, *pcbColName, *pfSqlType, *pcbColDef, *pibScale,
> *pfNullable
> 1, a, 1, SQL_VARCHAR=12, 20, 0, SQL_NULLABLE=1
> 2, b, 1, SQL_CHAR=1, 10, 0, SQL_NULLABLE=1
> 3, c, 1, SQL_INTEGER=4, 10, 0, SQL_NULLABLE=1
> 4, ?column?, 8, SQL_VARCHAR=12, 255, 0, SQL_NULLABLE=1
> 5, bpchar, 6, SQL_CHAR=1, 3, 0, SQL_NULLABLE=1
> 6, varchar, 7, SQL_VARCHAR=12, 255, 0, SQL_NULLABLE=1
>
> From psqlodbc.h
>
> #define MAX_VARCHAR_SIZE 255 /* default maximum size
of
> * varchar fields (not
including null
> term) */
>
> So I guess the bottom line is that we are not the first to encounter
this
> problem .. Its just been covered up by assigning
> An arbitrary maximum size .. So I guess we will do the same and make
it
> configurable like the official postgres driver.

Of course, the downside here is that choosing a default will truncate
the data when the actual data is larger than the default chosen.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2007-06-12 21:21:21 Re: Selecting a constant question: A summary
Previous Message Dann Corbit 2007-06-12 20:41:00 Selecting a constant question: A summary