mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Use table/index_close() more consistently
All the code paths updated here have been using relation_close() to close a relation that has already been opened with table_open() or index_open(), where a relkind check is enforced. table_close() and index_open() do the same thing as relation_close(), so there was no harm, but being inconsistent could lead to issues if the internals of these close() functions begin to introduce some logic specific to each relkind in the future. Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/aUKamYGiDKO6byp5@ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
@@ -1478,8 +1478,8 @@ brin_summarize_range(PG_FUNCTION_ARGS)
|
|||||||
/* Restore userid and security context */
|
/* Restore userid and security context */
|
||||||
SetUserIdAndSecContext(save_userid, save_sec_context);
|
SetUserIdAndSecContext(save_userid, save_sec_context);
|
||||||
|
|
||||||
relation_close(indexRel, ShareUpdateExclusiveLock);
|
index_close(indexRel, ShareUpdateExclusiveLock);
|
||||||
relation_close(heapRel, ShareUpdateExclusiveLock);
|
table_close(heapRel, ShareUpdateExclusiveLock);
|
||||||
|
|
||||||
PG_RETURN_INT32((int32) numSummarized);
|
PG_RETURN_INT32((int32) numSummarized);
|
||||||
}
|
}
|
||||||
@@ -1568,8 +1568,8 @@ brin_desummarize_range(PG_FUNCTION_ARGS)
|
|||||||
errmsg("index \"%s\" is not valid",
|
errmsg("index \"%s\" is not valid",
|
||||||
RelationGetRelationName(indexRel))));
|
RelationGetRelationName(indexRel))));
|
||||||
|
|
||||||
relation_close(indexRel, ShareUpdateExclusiveLock);
|
index_close(indexRel, ShareUpdateExclusiveLock);
|
||||||
relation_close(heapRel, ShareUpdateExclusiveLock);
|
table_close(heapRel, ShareUpdateExclusiveLock);
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2572,7 +2572,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Close the index relation but keep the lock */
|
/* Close the index relation but keep the lock */
|
||||||
relation_close(index_rel, NoLock);
|
index_close(index_rel, NoLock);
|
||||||
|
|
||||||
index->indexOid = index_oid;
|
index->indexOid = index_oid;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user