Re: [HACKERS] pg_attribute.attisinherited ? - Mailing list pgsql-patches

From Tom Lane
Subject Re: [HACKERS] pg_attribute.attisinherited ?
Date
Msg-id 18628.1030735785@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] pg_attribute.attisinherited ?  (Alvaro Herrera <alvherre@atentus.com>)
Responses Re: [HACKERS] pg_attribute.attisinherited ?
List pgsql-patches
Alvaro Herrera <alvherre@atentus.com> writes:
> - Adds a new attribute in pg_attribute named attisinherited.
> - Creation of tables marks it true for attributes that are inherited
> - Addition of new attribute to existing inherited table marks the
>   attribute as inherited for child tables.
> - Checked when trying to rename inherited attributes: if table has
>   inheritors, only allow renaming if asked to recurse.  Disallow
>   renaming for child tables only.
> - Checked when trying to drop inherited attributes: if table has
>   inheritors, mark attribute as non-inherited for direct inheritors.
>   Disallow dropping for child tables only.

I've applied this patch after a little editorializing.  FYI ---

* copyfuncs.c,equalfuncs.c,outfuncs.c,readfuncs.c needed to be updated
  for the field added to ColumnDef.  In general, any time you alter the
  definition of a Node structure, you gotta update these files.

* I didn't like having to touch all the callers of TupleDescInitEntry,
  so I just made it initialize attisinherited to false.  In the one
  place where attisinherited might be set true, just update after return
  from TupleDescInitEntry.

* Moved the checks for rename/drop ONLY with child tables into
  tablecmds.c instead of utility.c, so that they'd be applied after
  grabbing an exclusive lock on the table, not before.  Otherwise a
  child could be added after you look.


            regards, tom lane

pgsql-patches by date:

Previous
From: Joe Conway
Date:
Subject: update to contrib/dblink
Next
From: Joe Conway
Date:
Subject: [Fwd: Re: [HACKERS] Accessing original TupleDesc from SRF]