> -----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@postgresql.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.


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Reply via email to