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

From Peter Eisentraut
Subject Re: hiding variable-length fields from Form_pg_* structs
Date
Msg-id 1323113223.10992.21.camel@vanquo.pezone.net
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
List pgsql-hackers
On sön, 2011-11-27 at 18:20 -0500, Tom Lane wrote:
> The low-tech way would be
> 
> CATALOG(pg_attribute,1249) BKI_BOOTSTRAP ...
> {
>     ...
>     int4        attinhcount;
>     Oid         attcollation;
>     aclitem     attacl[1];
> #ifdef CATALOG_VARLEN_FIELDS
>     text        attoptions[1];
>     text        attfdwoptions[1];
> #endif
> } FormData_pg_attribute;

Good enough.

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?
This kind of comment is pretty confusing:

CATALOG(pg_rewrite,2618)
{   NameData    rulename;   Oid         ev_class;   int2        ev_attr;   char        ev_type;   char
ev_enabled;  bool        is_instead;
 
   /* NB: remaining fields must be accessed via heap_getattr */   pg_node_tree ev_qual;   pg_node_tree ev_action;
} FormData_pg_rewrite;

Also, this code in relcache.c accesses indclass, which is after an
int2vector and an oidvector field:
   /* Check to see if it is a unique, non-partial btree index on OID */   if (index->indnatts == 1 &&
index->indisunique&& index->indimmediate &&       index->indkey.values[0] == ObjectIdAttributeNumber &&
index->indclass.values[0]== OID_BTREE_OPS_OID &&       heap_attisnull(htup, Anum_pg_index_indpred))       oidIndex =
index->indexrelid;



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: [PATCH] Caching for stable expressions with constant arguments v3
Next
From: Tom Lane
Date:
Subject: Re: planner fails on HEAD