I couldn't figure out how to make use of the predigested constraints in the
relcache, so I continued on the tack I was on. I just stuf the entire
HeapTuple in a list and decompiled the constraint source only if I find a
constraint with a matching name.
Points I'm uncertain about:
. I throw an elog() error if there's a null conbin for a CHECK constraint. Is
it possible for a valid CHECK constraint structure to have a null conbin?
. Memory management. Do I need the heap_copytuple or is that unnecessary?
Would it be ok to simply store the actual HeapTuples as the scan proceeds?
. Locking -- all of it :)
I added some basic (very basic) regression tests and documentation. Did I find
the right places? Is that enough or should I add more?
Index: doc/src/sgml/ref/alter_table.sgml
===
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v
retrieving revision 1.84
diff -u -p -c -r1.84 alter_table.sgml
cvs diff: conflicting specifications of output style
*** doc/src/sgml/ref/alter_table.sgml 12 Feb 2006 19:11:00 - 1.84
--- doc/src/sgml/ref/alter_table.sgml 12 Jun 2006 21:30:54 -
*** where act
*** 46,51
--- 46,53
CLUSTER ON index_name
SET WITHOUT CLUSTER
SET WITHOUT OIDS
+ INHERIT parent_table
+ NO INHERIT parent_table
OWNER TO new_owner
SET TABLESPACE new_tablespace
*** where act
*** 250,255
--- 252,303
+ INHERIT parent_table
+
+
+
+ This form adds a new parent table to the table. This won't add new
+ columns to the child table, instead all columns of the parent table must
+ already exist in the child table. They must have matching data types,
+ and if they have NOT NULL constraints in the parent
+ then they must also have NOT NULL constraints in the
+ child.
+
+
+
+
+ There must also be matching table constraints for all
+ CHECK table constraints of the parent. Currently
+ UNIQUE, PRIMARY KEY, and
+ FOREIGN KEY constraints are ignored however this may
+ change in the future.
+
+
+
+
+ The easiest way to create a suitable table is to create a table using
+ INHERITS and then remove it via NO
+ INHERIT. Alternatively create a table using
+ LIKE however note that LIKE does
+ not create the necessary constraints.
+
+
+
+
+
+
+
+ NO INHERIT parent_table
+
+
+This form removes a parent table from the list of parents of the table.
+Queries against the parent table will no longer include records drawn
+from the target table.
+
+
+
+
+
OWNER
Index: src/backend/commands/tablecmds.c
===
RCS file: /projects/cvsroot/pgsql/src/backend/commands/tablecmds.c,v
retrieving revision 1.184
diff -u -p -c -r1.184 tablecmds.c
cvs diff: conflicting specifications of output style
*** src/backend/commands/tablecmds.c10 May 2006 23:18:39 - 1.184
--- src/backend/commands/tablecmds.c12 Jun 2006 21:30:54 -
*** typedef struct NewColumnValue
*** 159,166
--- 159,168
static void truncate_check_rel(Relation rel);
static List *MergeAttributes(List *schema, List *supers, bool istemp,
List **supOids, List **supconstr, int
*supOidCount);
+ static void MergeAttributesIntoExisting(Relation rel, Relation relation);
static bool change_varattnos_of_a_node(Node *node, const AttrNumber
*newattno);
static void StoreCatalogInheritance(Oid relationId, List *supers);
+ static void StoreCatalogInheritance1(Oid relationId, Oid parentOid, int16
seqNumber, Relation catalogRelation);
static intfindAttrByName(const char *attributeName, List *schema);
static void setRelhassubclassInRelation(Oid relationId, bool relhassubclass);
static bool needs_toast_table(Relation rel);
*** static void ATPrepSetTableSpace(AlteredT
*** 246,251
--- 248,255
static void ATExecSetTableSpace(Oid tableOid, Oid newTableSpace);
static void ATExecEnableDisableTrigger(Relation rel, char *trigname,
bool enable, bool
skip_system);
+ static void ATExecAddInherits(Relation rel, RangeVar *parent);
+ static void ATExecDropInherits(Relation rel, RangeVar *parent);
static void copy_relation_data(Relation rel, SMgrRelation dst);
static void update_ri_trigger_args(Oid relid,
const char *oldname,
*** static void
*** 1156,1165
StoreCatalogInheritance(Oid relationId, List *supers)
{
Relationrelation;
- TupleDesc desc;
int16 seqNumber;
ListCell *entry;
- HeapTuple tuple;
/*