summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorRobert Haas2012-01-26 14:24:54 +0000
committerRobert Haas2012-01-26 14:30:27 +0000
commit0e549697d1c6b8eeb623c497dc38a5aed4deea1e (patch)
treed1b6063331a7ff56f061e35d45523776c04680d8 /src/backend/commands
parentbc3347484a7bf9eddb98e4352d84599cae9a31c6 (diff)
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')
-rw-r--r--src/backend/commands/cluster.c2
-rw-r--r--src/backend/commands/dropcmds.c2
-rw-r--r--src/backend/commands/foreigncmds.c2
-rw-r--r--src/backend/commands/opclasscmds.c4
-rw-r--r--src/backend/commands/tablecmds.c29
-rw-r--r--src/backend/commands/typecmds.c2
6 files changed, 27 insertions, 14 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 9408f259a61..349d13034e3 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -1443,7 +1443,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
* The new relation is local to our transaction and we know nothing
* depends on it, so DROP_RESTRICT should be OK.
*/
- performDeletion(&object, DROP_RESTRICT);
+ performDeletion(&object, DROP_RESTRICT, PERFORM_DELETION_INTERNAL);
/* performDeletion does CommandCounterIncrement at end */
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 9eeba041cff..298940c7c42 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -119,7 +119,7 @@ RemoveObjects(DropStmt *stmt)
}
/* Here we really delete them. */
- performMultipleDeletions(objects, stmt->behavior);
+ performMultipleDeletions(objects, stmt->behavior, 0);
free_object_addresses(objects);
}
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
index a9ec904c357..4135e268575 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -1286,7 +1286,7 @@ RemoveUserMapping(DropUserMappingStmt *stmt)
object.objectId = umId;
object.objectSubId = 0;
- performDeletion(&object, DROP_CASCADE);
+ performDeletion(&object, DROP_CASCADE, 0);
}
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 5dca0222fdf..5dc131a50e2 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -1519,7 +1519,7 @@ dropOperators(List *opfamilyname, Oid amoid, Oid opfamilyoid,
object.objectId = amopid;
object.objectSubId = 0;
- performDeletion(&object, DROP_RESTRICT);
+ performDeletion(&object, DROP_RESTRICT, 0);
}
}
@@ -1559,7 +1559,7 @@ dropProcedures(List *opfamilyname, Oid amoid, Oid opfamilyoid,
object.objectId = amprocid;
object.objectSubId = 0;
- performDeletion(&object, DROP_RESTRICT);
+ performDeletion(&object, DROP_RESTRICT, 0);
}
}
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
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 0043bf1fee2..03918486a15 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -2318,7 +2318,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
conobj.objectId = HeapTupleGetOid(contup);
conobj.objectSubId = 0;
- performDeletion(&conobj, behavior);
+ performDeletion(&conobj, behavior, 0);
found = true;
}
}