Dear all, I've been looking at tidying up some of the repeated code which now resides in tablecmds.c - in particular the ALTER TABLE ALTER COLUMN code.
Most of these routines share common code: 1) AccessExclusive Lock on relation. 2) Relation is a table, not a system table, user is owner. 3) Recurse over child relations. And several routines then: 4) check column exists 5) check column is not a system attribute I would propose to combine these checks into two routines: CanAlterTable(relid,systemOK) [systemOK is for the set statistics case] GetTargetAttnum(relid,Attname) returns attnum [This would bring some consistency to checking, for example fixing the current segfault if you try ALTER TABLE test ALTER COLUMN xmin SET DEFAULT 3;] and two macros: RECURSE_OVER_CHILDREN(relid); AlterTableDoSomething(childrel,...); RECURSE_OVER_CHILDREN_END; (this seems more straightforward than passing the text of the function call as a macro parameter). ALTER COLUMN RENAME Currently, attributes in tables, views and sequences can be renamed. -tables and views make sense, of course. Sequences still seem to work after they've had attributes renamed, but I see little value in being able to do this. Is it OK to prohibit the renaming of sequence columns? tcop/utility.c vs. commands/ There are also permissions checks made in tcop/utility.c before AlterTableOwner and renamerel are called. It may be best to move these into commands/tablecmds.c. It seems that tcop/utility.c was supposed to handle the permissions checks for statements, but the inheritance support has pushed some of that into commands/ . Should permissions checking for other utility statements be migrated to commands/ for consistency? I don't propose to do this now -but it might be a later stage in the process. If this general outline is OK, I'll work on a patch -this shouldn't be quite as drastic as the last one :-) Regards John -- John Gray ECHOES: sponsored walks for Christian Aid to the highest Azuli IT points of English counties, 4th-6th May 2002 www.azuli.co.uk www.stannesmoseley.care4free.net/echoes.html ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly