Re: Selecting a constant question

From: "Dann Corbit" <DCorbit(at)connx(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Gregory Stark" <stark(at)enterprisedb(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Selecting a constant question
Date: 2007-06-11 20:38:10
Message-ID: D425483C2C5C9F49B5B7A41F894415470100070D@postal.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Monday, June 11, 2007 1:32 PM
> To: Dann Corbit
> Cc: Gregory Stark; pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] Selecting a constant question
>
> "Dann Corbit" <DCorbit(at)connx(dot)com> writes:
> > The issue is this:
> > Postgres describes the column with a typmod of -1 (unknown) and a
length
> > of 65534.
>
> Oh, you're looking at typlen not typmod. Please observe the comments
in
> pg_type.h:
>
> /*
> * For a fixed-size type, typlen is the number of bytes we use
to
> * represent a value of this type, e.g. 4 for an int4. But for
> a
> * variable-length type, typlen is negative. We use -1 to
indicate
> a
> * "varlena" type (one that has a length word), -2 to indicate a
> * null-terminated C string.
> */
> int2 typlen;
>
> You should be treating typlen as signed not unsigned, and not assuming
a
> fixed width for any negative value.
>
> Since the width refers to the server internal representation, and not
to
> what comes down the wire, I find it pretty strange for an application
to
> be using typlen for anything at all actually.

Thanks for the response.

Since libpq function PQfsize returns -2 for all constant character
strings in SQL statements ... What is the proper procedure to determine
the length of a constant character column after query execution but
before fetching the first row of data?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-06-11 20:46:38 Re: Selecting a constant question
Previous Message Tom Lane 2007-06-11 20:32:26 Re: Selecting a constant question