88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.113 2004/06/1017:55:56 tgl Exp $
11+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.114 2004/06/1018:25:02 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -199,6 +199,8 @@ static void ATPrepAddColumn(List **wqueue, Relation rel, bool recurse,
199199static void ATExecAddColumn (AlteredTableInfo * tab ,Relation rel ,
200200ColumnDef * colDef );
201201static void add_column_datatype_dependency (Oid relid ,int32 attnum ,Oid typid );
202+ static void add_column_support_dependency (Oid relid ,int32 attnum ,
203+ RangeVar * support );
202204static void ATExecDropNotNull (Relation rel ,const char * colName );
203205static void ATExecSetNotNull (AlteredTableInfo * tab ,Relation rel ,
204206const char * colName );
@@ -438,20 +440,9 @@ DefineRelation(CreateStmt *stmt, char relkind)
438440rawDefaults = lappend (rawDefaults ,rawEnt );
439441}
440442
443+ /* Create dependency for supporting relation for this column */
441444if (colDef -> support != NULL )
442- {
443- /* Create dependency for supporting relation for this column */
444- ObjectAddress colobject ,
445- suppobject ;
446-
447- colobject .classId = RelOid_pg_class ;
448- colobject .objectId = relationId ;
449- colobject .objectSubId = attnum ;
450- suppobject .classId = RelOid_pg_class ;
451- suppobject .objectId = RangeVarGetRelid (colDef -> support , false);
452- suppobject .objectSubId = 0 ;
453- recordDependencyOn (& suppobject ,& colobject ,DEPENDENCY_INTERNAL );
454- }
445+ add_column_support_dependency (relationId ,attnum ,colDef -> support );
455446}
456447
457448/*
@@ -2926,9 +2917,11 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
29262917}
29272918
29282919/*
2929- * Adddatatype dependency for the new column.
2920+ * Addneeded dependency entries for the new column.
29302921 */
29312922add_column_datatype_dependency (myrelid ,i ,attribute -> atttypid );
2923+ if (colDef -> support != NULL )
2924+ add_column_support_dependency (myrelid ,i ,colDef -> support );
29322925}
29332926
29342927/*
@@ -2949,6 +2942,24 @@ add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid)
29492942recordDependencyOn (& myself ,& referenced ,DEPENDENCY_NORMAL );
29502943}
29512944
2945+ /*
2946+ * Install a dependency for a column's supporting relation (serial sequence).
2947+ */
2948+ static void
2949+ add_column_support_dependency (Oid relid ,int32 attnum ,RangeVar * support )
2950+ {
2951+ ObjectAddress colobject ,
2952+ suppobject ;
2953+
2954+ colobject .classId = RelOid_pg_class ;
2955+ colobject .objectId = relid ;
2956+ colobject .objectSubId = attnum ;
2957+ suppobject .classId = RelOid_pg_class ;
2958+ suppobject .objectId = RangeVarGetRelid (support , false);
2959+ suppobject .objectSubId = 0 ;
2960+ recordDependencyOn (& suppobject ,& colobject ,DEPENDENCY_INTERNAL );
2961+ }
2962+
29522963/*
29532964 * ALTER TABLE ALTER COLUMN DROP NOT NULL
29542965 */