Re: PQfmod and varchars

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: andrew(at)supernews(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org, Shachar Shemesh <psql(at)shemesh(dot)biz>
Subject: Re: PQfmod and varchars
Date: 2005-04-22 14:31:05
Message-ID: 541.1114180265@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew - Supernews <andrew+nonews(at)supernews(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2005-04-22 14:46:04 Re: Woo hoo ... a whole new set of compiler headaches!!
Previous Message Dave Held 2005-04-22 14:09:59 Re: Woo hoo ... a whole new set of compiler headaches!! :)