8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.113 2004/06/10 17:55:56 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.114 2004/06/10 18:25:02 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -199,6 +199,8 @@ static void ATPrepAddColumn(List **wqueue, Relation rel, bool recurse,
199
199
static void ATExecAddColumn (AlteredTableInfo * tab , Relation rel ,
200
200
ColumnDef * colDef );
201
201
static 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 );
202
204
static void ATExecDropNotNull (Relation rel , const char * colName );
203
205
static void ATExecSetNotNull (AlteredTableInfo * tab , Relation rel ,
204
206
const char * colName );
@@ -438,20 +440,9 @@ DefineRelation(CreateStmt *stmt, char relkind)
438
440
rawDefaults = lappend (rawDefaults , rawEnt );
439
441
}
440
442
443
+ /* Create dependency for supporting relation for this column */
441
444
if (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 );
455
446
}
456
447
457
448
/*
@@ -2926,9 +2917,11 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
2926
2917
}
2927
2918
2928
2919
/*
2929
- * Add datatype dependency for the new column.
2920
+ * Add needed dependency entries for the new column.
2930
2921
*/
2931
2922
add_column_datatype_dependency (myrelid , i , attribute -> atttypid );
2923
+ if (colDef -> support != NULL )
2924
+ add_column_support_dependency (myrelid , i , colDef -> support );
2932
2925
}
2933
2926
2934
2927
/*
@@ -2949,6 +2942,24 @@ add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid)
2949
2942
recordDependencyOn (& myself , & referenced , DEPENDENCY_NORMAL );
2950
2943
}
2951
2944
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
+
2952
2963
/*
2953
2964
* ALTER TABLE ALTER COLUMN DROP NOT NULL
2954
2965
*/
0 commit comments