After some investigation I figured that I need to add two more checks into the ALTER TABLE code to prevent certain types of direct changes to typed tables (see attached patch).
But it's not clear to me whether such checks should go into the "Prep" or the "Exec" phases. Prep seems more plausible to me, but some commands such as DropColumn don't have a Prep handler. A clarification would be helpful.
Index: src/backend/commands/tablecmds.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v retrieving revision 1.332 diff -u -3 -p -r1.332 tablecmds.c --- src/backend/commands/tablecmds.c 6 Jul 2010 19:18:56 -0000 1.332 +++ src/backend/commands/tablecmds.c 21 Jul 2010 14:34:41 -0000 @@ -5788,6 +5788,11 @@ ATPrepAlterColumnType(List **wqueue, NewColumnValue *newval; ParseState *pstate = make_parsestate(NULL); + if (rel->rd_rel->reloftype) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot alter column type of typed table"))); + /* lookup the attribute so we can check inheritance status */ tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName); if (!HeapTupleIsValid(tuple)) @@ -7126,6 +7131,11 @@ ATExecAddInherit(Relation child_rel, Ran int32 inhseqno; List *children; + if (child_rel->rd_rel->reloftype) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot change inheritance of typed table"))); + /* * AccessShareLock on the parent is what's obtained during normal CREATE * TABLE ... INHERITS ..., so should be enough here.
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers