summaryrefslogtreecommitdiff
path: root/src/backend/commands/alter.c
diff options
context:
space:
mode:
authorAlvaro Herrera2020-04-20 17:42:12 +0000
committerAlvaro Herrera2020-04-20 17:42:12 +0000
commit5fc703946bf3b18642ce83b937671d254a8ac5b5 (patch)
treee870c58ea48bbaa990e7c1c797d5357a7c880196 /src/backend/commands/alter.c
parent4157f73b4ba7fa0c6fb117cb9b5a771875850c83 (diff)
Add ALTER .. NO DEPENDS ON
Commit f2fcad27d59c (9.6 era) added the ability to mark objects as dependent an extension, but forgot to add a way for such dependencies to be removed. This commit fixes that oversight. Strictly speaking this should be backpatched to 9.6, but due to lack of demand we're not doing so at this time. Discussion: https://postgr.es/m/[email protected] Reviewed-by: ahsan hadi <[email protected]> Reviewed-by: Ibrar Ahmed <[email protected]> Reviewed-by: Tom Lane <[email protected]>
Diffstat (limited to 'src/backend/commands/alter.c')
-rw-r--r--src/backend/commands/alter.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 11db9bfe922..951690b2b8d 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -421,7 +421,7 @@ ExecRenameStmt(RenameStmt *stmt)
}
/*
- * Executes an ALTER OBJECT / DEPENDS ON [EXTENSION] statement.
+ * Executes an ALTER OBJECT / [NO] 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
@@ -433,7 +433,6 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
ObjectAddress address;
ObjectAddress refAddr;
Relation rel;
- List *currexts;
address =
get_object_address_rv(stmt->objectType, stmt->relation, (List *) stmt->object,
@@ -463,11 +462,22 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
if (refAddress)
*refAddress = refAddr;
- /* Avoid duplicates */
- currexts = getAutoExtensionsOfObject(address.classId,
- address.objectId);
- if (!list_member_oid(currexts, refAddr.objectId))
- recordDependencyOn(&address, &refAddr, DEPENDENCY_AUTO_EXTENSION);
+ if (stmt->remove)
+ {
+ deleteDependencyRecordsForSpecific(address.classId, address.objectId,
+ DEPENDENCY_AUTO_EXTENSION,
+ refAddr.classId, refAddr.objectId);
+ }
+ else
+ {
+ List *currexts;
+
+ /* Avoid duplicates */
+ currexts = getAutoExtensionsOfObject(address.classId,
+ address.objectId);
+ if (!list_member_oid(currexts, refAddr.objectId))
+ recordDependencyOn(&address, &refAddr, DEPENDENCY_AUTO_EXTENSION);
+ }
return address;
}