aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/alter.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 5af0f2ffdf3..7e39422ecd6 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -391,6 +391,43 @@ ExecRenameStmt(RenameStmt *stmt)
}
/*
+ * Executes an ALTER OBJECT / DEPENDS ON [EXTENSION] statement.
+ *
+ * Return value is the address of the altered object. refAddress is an output
+ * argument which, if not null, receives the address of the object that the
+ * altered object now depends on.
+ */
+ObjectAddress
+ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddress)
+{
+ ObjectAddress address;
+ ObjectAddress refAddr;
+ Relation rel;
+
+ address =
+ get_object_address_rv(stmt->objectType, stmt->relation, stmt->objname,
+ stmt->objargs, &rel, AccessExclusiveLock, false);
+
+ /*
+ * If a relation was involved, it would have been opened and locked.
+ * We don't need the relation here, but we'll retain the lock until
+ * commit.
+ */
+ if (rel)
+ heap_close(rel, NoLock);
+
+ refAddr = get_object_address(OBJECT_EXTENSION, list_make1(stmt->extname),
+ NULL, &rel, AccessExclusiveLock, false);
+ Assert(rel == NULL);
+ if (refAddress)
+ *refAddress = refAddr;
+
+ recordDependencyOn(&address, refAddress, DEPENDENCY_AUTO_EXTENSION);
+
+ return address;
+}
+
+/*
* Executes an ALTER OBJECT / SET SCHEMA statement. Based on the object
* type, the function appropriate to that type is executed.
*