>> What I don't understand is *why* it's complaining about the constant column >> and not, for example, any other variable length column. There are a very small >> number of cases where a useful length is returned, 99% of the time it doesn't, >> yet you're obviously not get any performance problems there.
The statement above is contrary to my actual results. The proper length is returned in all non-const cases. Here is a specific example: test=# create table test1 ( a varchar(20), b char(10), c integer ); CREATE TABLE test=# Note .. The table is empty, and contains no data at this point: Select a, b, c, '123' , '123'::char(3), '123'::varchar(3) from test1 For column a libpq returns the following: Pqfsize returns -1 Pqfmod (-4) returns 20 For column b libpq returns the following: Pqfsize returns -1 Pqfmod (-4) returns 10 For column c libpq returns the following: Pqfsize returns 4 For constant '123' libpq returns the following: Pqfsize returns -2 Pqfmod returns -1 For constant '123'::char(3) libpq returns the following: Pqfsize returns -1 Pqfmod (-4) returns 3 For constant '123'::varchar(3) libpq returns the following: Pqfsize returns -1 Pqfmod returns -1 Thanks lm -----Original Message----- From: Brian Hurt [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 12, 2007 11:09 AM To: Larry McGhaw Cc: pgsql-hackers@postgresql.org Subject: Re: [HACKERS] Selecting a constant question Larry McGhaw wrote: >I'm really frustrated by this process I'm not trying to attack anyone >here. I'm just surprised that no one will even entertain the idea that >this is an issue that needs to be addressed. > >Instead nearly all of the responses have been attacking the >applications that rely on the metadata. > > Having been following this debate, I think what people have really been attacking is the idea that the metadata for: SELECT '1' AS varchar_column; should be different from the metadata for: SELECT varchar_column FROM really_big_table; or for: SELECT varchar_column FROM really_small_table; Or at least that's what I've taken away from the dicussion- it's not so much that the metadata shouldn't be relied on, it's that the metadata may be more generic than theoretically necessary. And that the metadata may not contain the length of a variable length field even when that length is known. Brian ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster