summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2020-03-11 11:04:59 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2020-03-11 11:04:59 -0300
commit3dfd2d6cd28a125edc4761eaefaa1193f111459d (patch)
treefe862692d64574fb2ae7ed1466e55c68b1ebf4ad /src/backend/commands
parent475b061c867557499559227d743b332c257033a3 (diff)
Avoid duplicates in ALTER ... DEPENDS ON EXTENSION
If the command is attempted for an extension that the object already depends on, silently do nothing. In particular, this means that if a database containing multiple such entries is dumped, the restore will silently do the right thing and record just the first one. (At least, in a world where pg_dump does dump such entries -- which it doesn't currently, but it will.) Backpatch to 9.6, where this kind of dependency was introduced. Reviewed-by: Ibrar Ahmed, Tom Lane (offlist) Discussion: https://postgr.es/m/20200217225333.GA30974@alvherre.pgsql
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/alter.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index acb580df880..6c197171dc3 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -425,6 +425,7 @@ 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,
@@ -454,7 +455,11 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
if (refAddress)
*refAddress = refAddr;
- recordDependencyOn(&address, &refAddr, DEPENDENCY_AUTO_EXTENSION);
+ /* Avoid duplicates */
+ currexts = getAutoExtensionsOfObject(address.classId,
+ address.objectId);
+ if (!list_member_oid(currexts, refAddr.objectId))
+ recordDependencyOn(&address, &refAddr, DEPENDENCY_AUTO_EXTENSION);
return address;
}