diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-01-26 09:24:54 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-01-26 09:30:27 -0500 |
commit | 0e549697d1c6b8eeb623c497dc38a5aed4deea1e (patch) | |
tree | d1b6063331a7ff56f061e35d45523776c04680d8 /src/backend/commands/tablecmds.c | |
parent | bc3347484a7bf9eddb98e4352d84599cae9a31c6 (diff) | |
download | postgresql-0e549697d1c6b8eeb623c497dc38a5aed4deea1e.tar.gz postgresql-0e549697d1c6b8eeb623c497dc38a5aed4deea1e.zip |
Classify DROP operations by whether or not they are user-initiated.
This doesn't do anything useful just yet, but is intended as supporting
infrastructure for allowing sepgsql to sensibly check DROP permissions.
KaiGai Kohei and Robert Haas
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index cb8ac67812a..9172d999310 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -816,7 +816,7 @@ RemoveRelations(DropStmt *drop) add_exact_object_address(&obj, objects); } - performMultipleDeletions(objects, drop->behavior); + performMultipleDeletions(objects, drop->behavior, 0); free_object_addresses(objects); } @@ -4803,8 +4803,13 @@ ATExecColumnDefault(Relation rel, const char *colName, * Remove any old default for the column. We use RESTRICT here for * safety, but at present we do not expect anything to depend on the * default. + * + * We treat removing the existing default as an internal operation when + * it is preparatory to adding a new default, but as a user-initiated + * operation when the user asked for a drop. */ - RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false); + RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false, + newDefault == NULL ? false : true); if (newDefault) { @@ -5217,7 +5222,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName, object.objectId = RelationGetRelid(rel); object.objectSubId = attnum; - performDeletion(&object, behavior); + performDeletion(&object, behavior, 0); /* * If we dropped the OID column, must adjust pg_class.relhasoids and tell @@ -6731,7 +6736,7 @@ ATExecDropConstraint(Relation rel, const char *constrName, conobj.objectId = HeapTupleGetOid(tuple); conobj.objectSubId = 0; - performDeletion(&conobj, behavior); + performDeletion(&conobj, behavior, 0); found = true; @@ -7453,7 +7458,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, * We use RESTRICT here for safety, but at present we do not expect * anything to depend on the default. */ - RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, true); + RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, true, + true); StoreAttrDefault(rel, attnum, defaultexpr); } @@ -7598,7 +7604,7 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode) obj.classId = ConstraintRelationId; obj.objectId = lfirst_oid(oid_item); obj.objectSubId = 0; - performDeletion(&obj, DROP_RESTRICT); + performDeletion(&obj, DROP_RESTRICT, PERFORM_DELETION_INTERNAL); } foreach(oid_item, tab->changedIndexOids) @@ -7606,7 +7612,7 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode) obj.classId = RelationRelationId; obj.objectId = lfirst_oid(oid_item); obj.objectSubId = 0; - performDeletion(&obj, DROP_RESTRICT); + performDeletion(&obj, DROP_RESTRICT, PERFORM_DELETION_INTERNAL); } /* @@ -9764,7 +9770,14 @@ PreCommit_on_commit_actions(void) object.classId = RelationRelationId; object.objectId = oc->relid; object.objectSubId = 0; - performDeletion(&object, DROP_CASCADE); + + /* + * Since this is an automatic drop, rather than one + * directly initiated by the user, we pass the + * PERFORM_DELETION_INTERNAL flag. + */ + performDeletion(&object, + DROP_CASCADE, PERFORM_DELETION_INTERNAL); /* * Note that table deletion will call |