mirror of
https://github.com/postgres/postgres.git
synced 2025-09-05 02:22:28 +03:00
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 <bertranddrouvot.pg@gmail.com> Discussion: https://www.postgresql.org/message-id/ZzG34eNrT83W/Orz@ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user