diff options
author | Peter Eisentraut | 2024-11-15 07:42:59 +0000 |
---|---|---|
committer | Peter Eisentraut | 2024-11-15 07:52:43 +0000 |
commit | e468ec0fddcd93e282da6685b75d5687c2a87f2a (patch) | |
tree | 1c4a33420fd0587ca42cd37cb275637f49610fa1 /src/backend/commands/alter.c | |
parent | 818119afccd342823e5b638be51f64ba36221318 (diff) |
Add an assertion in get_object_address()
Some places declared a Relation before calling get_object_address()
only to assert that the relation is NULL after the call.
The new assertion allows passing NULL as the relation argument at
those places making the code cleaner and easier to understand.
Author: Bertrand Drouvot <[email protected]>
Discussion: https://www.postgresql.org/message-id/ZzG34eNrT83W/[email protected]
Diffstat (limited to 'src/backend/commands/alter.c')
-rw-r--r-- | src/backend/commands/alter.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 4f99ebb4470..a45f3bb6b83 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -421,13 +421,11 @@ ExecRenameStmt(RenameStmt *stmt) { ObjectAddress address; Relation catalog; - Relation relation; address = get_object_address(stmt->renameType, stmt->object, - &relation, + NULL, AccessExclusiveLock, false); - Assert(relation == NULL); catalog = table_open(address.classId, RowExclusiveLock); AlterObjectRename_internal(catalog, @@ -482,8 +480,7 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre table_close(rel, NoLock); refAddr = get_object_address(OBJECT_EXTENSION, (Node *) stmt->extname, - &rel, AccessExclusiveLock, false); - Assert(rel == NULL); + NULL, AccessExclusiveLock, false); if (refAddress) *refAddress = refAddr; @@ -563,16 +560,14 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt, case OBJECT_TSTEMPLATE: { Relation catalog; - Relation relation; Oid classId; Oid nspOid; address = get_object_address(stmt->objectType, stmt->object, - &relation, + NULL, AccessExclusiveLock, false); - Assert(relation == NULL); classId = address.classId; catalog = table_open(classId, RowExclusiveLock); nspOid = LookupCreationNamespace(stmt->newschema); @@ -876,15 +871,13 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt) case OBJECT_TSDICTIONARY: case OBJECT_TSCONFIGURATION: { - Relation relation; ObjectAddress address; address = get_object_address(stmt->objectType, stmt->object, - &relation, + NULL, AccessExclusiveLock, false); - Assert(relation == NULL); AlterObjectOwner_internal(address.classId, address.objectId, newowner); |