mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Add ALTER .. NO DEPENDS ON
Commit f2fcad27d5
(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/20200217225333.GA30974@alvherre.pgsql
Reviewed-by: ahsan hadi <ahsan.hadi@gmail.com>
Reviewed-by: Ibrar Ahmed <ibrar.ahmad@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user