Re: PQfmod and varchars - Mailing list pgsql-hackers

From Tom Lane
Subject Re: PQfmod and varchars
Date
Msg-id 541.1114180265@sss.pgh.pa.us
Whole thread Raw
In response to Re: PQfmod and varchars  (Andrew - Supernews <andrew+nonews@supernews.com>)
List pgsql-hackers
Andrew - Supernews <andrew+nonews@supernews.com> writes:
> Interpreting PQfmod requires a rather intimate knowledge of the internal
> type implementations.

> For several types, including varchar, the typmod is rather arbitrarily
> the type's length limit plus the size of a varlena header (which appears
> to be 4 bytes on all platforms, even 64-bit ones).

Right --- it's +4 regardless of sizeof(Pointer).  If we had it to do
over we'd surely have eliminated that and defined the typmod as exactly
the externally supplied length number ... but changing it now would
break way too much stuff.

It is conceivable there will someday be a compile-time option to make
the varlena overhead 8 bytes, to support field widths wider than 32 bits
(but don't hold your breath waiting for this).  I think though that we'd
probably find it wise to continue to define typmod as length limit plus
4, to avoid breaking client code that would usually not know what the
server's internal representation is.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Dave Held"
Date:
Subject: Re: Woo hoo ... a whole new set of compiler headaches!! :)
Next
From: "Marc G. Fournier"
Date:
Subject: Re: Woo hoo ... a whole new set of compiler headaches!!