Re: hiding variable-length fields from Form_pg_* structs - Mailing list pgsql-hackers

From Robert Haas
Subject Re: hiding variable-length fields from Form_pg_* structs
Date
Msg-id CA+TgmobN8rhxMNg=VMLm4W2hpbRGHk75pw31A3EjZ=api9-N=Q@mail.gmail.com
Whole thread Raw
In response to Re: hiding variable-length fields from Form_pg_* structs  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: hiding variable-length fields from Form_pg_* structs  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On Mon, Dec 5, 2011 at 3:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> On Mon, Dec 5, 2011 at 2:47 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> Peter Eisentraut <peter_e@gmx.net> writes:
>>>> To clarify, I believe the rule is that the first variable-length field
>>>> can be accessed as a struct field.  Are there any exceptions to this?
>
>>> If it is known not null, yes, but I wonder just how many places actually
>>> depend on that.
>
>> My impression is that all the varlena fields also allow nulls.
>
> See MARKNOTNULL in bootstrap.c.  I think the exceptions were designed to
> protect direct accesses to pg_index.

Hmm, OK.

rhaas=# select r.relname, a.attname, a.atttypid::regtype from pg_class
r, pg_attribute a where relnamespace=11 and relkind='r' and attrelid =
r.oid and a.attnotnull and a.attlen<0; relname   |   attname    |  atttypid
------------+--------------+------------pg_proc    | proargtypes  | oidvectorpg_index   | indkey       |
int2vectorpg_index  | indcollation | oidvectorpg_index   | indclass     | oidvectorpg_index   | indoption    |
int2vectorpg_trigger| tgattr       | int2vector 
(6 rows)

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: JSON for PG 9.2
Next
From: Dimitri Fontaine
Date:
Subject: Re: Command Triggers