Re: Selecting a constant question

From: "Larry McGhaw" <lmcghaw(at)connx(dot)com>
To: "Brian Hurt" <bhurt(at)janestcapital(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Selecting a constant question
Date: 2007-06-12 18:46:33
Message-ID: D425483C2C5C9F49B5B7A41F89441547013DB283@postal.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> 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:bhurt(at)janestcapital(dot)com]
Sent: Tuesday, June 12, 2007 11:09 AM
To: Larry McGhaw
Cc: pgsql-hackers(at)postgresql(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Hammond 2007-06-12 18:50:49 Re: one click install?
Previous Message Brian Hurt 2007-06-12 18:09:02 Re: Selecting a constant question