mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Combine options for RangeVarGetRelidExtended() into a flags argument.
A followup patch will add a SKIP_LOCKED option. To avoid introducing evermore arguments, breaking existing callers each time, introduce a flags argument. This'll no doubt break a few external users... Also change the MISSING_OK behaviour so a DEBUG1 debug message is emitted when a relation is not found. Author: Nathan Bossart Reviewed-By: Michael Paquier and Andres Freund Discussion: https://postgr.es/m/20180306005349.b65whmvj7z6hbe2y@alap3.anarazel.de
This commit is contained in:
@ -115,7 +115,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
|
||||
/* Find, lock, and check permissions on the table */
|
||||
tableOid = RangeVarGetRelidExtended(stmt->relation,
|
||||
AccessExclusiveLock,
|
||||
false, false,
|
||||
0,
|
||||
RangeVarCallbackOwnsTable, NULL);
|
||||
rel = heap_open(tableOid, NoLock);
|
||||
|
||||
|
@ -2091,7 +2091,7 @@ ReindexIndex(RangeVar *indexRelation, int options)
|
||||
* used here must match the index lock obtained in reindex_index().
|
||||
*/
|
||||
indOid = RangeVarGetRelidExtended(indexRelation, AccessExclusiveLock,
|
||||
false, false,
|
||||
0,
|
||||
RangeVarCallbackForReindexIndex,
|
||||
(void *) &heapOid);
|
||||
|
||||
@ -2183,7 +2183,7 @@ ReindexTable(RangeVar *relation, int options)
|
||||
Oid heapOid;
|
||||
|
||||
/* The lock level used here should match reindex_relation(). */
|
||||
heapOid = RangeVarGetRelidExtended(relation, ShareLock, false, false,
|
||||
heapOid = RangeVarGetRelidExtended(relation, ShareLock, 0,
|
||||
RangeVarCallbackOwnsTable, NULL);
|
||||
|
||||
if (!reindex_relation(heapOid,
|
||||
|
@ -61,8 +61,8 @@ LockTableCommand(LockStmt *lockstmt)
|
||||
bool recurse = rv->inh;
|
||||
Oid reloid;
|
||||
|
||||
reloid = RangeVarGetRelidExtended(rv, lockstmt->mode, false,
|
||||
lockstmt->nowait,
|
||||
reloid = RangeVarGetRelidExtended(rv, lockstmt->mode,
|
||||
lockstmt->nowait ? RVR_NOWAIT : 0,
|
||||
RangeVarCallbackForLockTable,
|
||||
(void *) &lockstmt->mode);
|
||||
|
||||
|
@ -161,7 +161,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
|
||||
* Get a lock until end of transaction.
|
||||
*/
|
||||
matviewOid = RangeVarGetRelidExtended(stmt->relation,
|
||||
lockmode, false, false,
|
||||
lockmode, 0,
|
||||
RangeVarCallbackOwnsTable, NULL);
|
||||
matviewRel = heap_open(matviewOid, NoLock);
|
||||
|
||||
|
@ -743,7 +743,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
|
||||
|
||||
/* Get id of table. Also handles permissions checks. */
|
||||
table_id = RangeVarGetRelidExtended(stmt->table, AccessExclusiveLock,
|
||||
false, false,
|
||||
0,
|
||||
RangeVarCallbackForPolicy,
|
||||
(void *) stmt);
|
||||
|
||||
@ -915,7 +915,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
|
||||
|
||||
/* Get id of table. Also handles permissions checks. */
|
||||
table_id = RangeVarGetRelidExtended(stmt->table, AccessExclusiveLock,
|
||||
false, false,
|
||||
0,
|
||||
RangeVarCallbackForPolicy,
|
||||
(void *) stmt);
|
||||
|
||||
@ -1215,7 +1215,7 @@ rename_policy(RenameStmt *stmt)
|
||||
|
||||
/* Get id of table. Also handles permissions checks. */
|
||||
table_id = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
false, false,
|
||||
0,
|
||||
RangeVarCallbackForPolicy,
|
||||
(void *) stmt);
|
||||
|
||||
|
@ -432,8 +432,7 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
|
||||
/* Open and lock sequence, and check for ownership along the way. */
|
||||
relid = RangeVarGetRelidExtended(stmt->sequence,
|
||||
ShareRowExclusiveLock,
|
||||
stmt->missing_ok,
|
||||
false,
|
||||
stmt->missing_ok ? RVR_MISSING_OK : 0,
|
||||
RangeVarCallbackOwnsRelation,
|
||||
NULL);
|
||||
if (relid == InvalidOid)
|
||||
|
@ -1159,8 +1159,7 @@ RemoveRelations(DropStmt *drop)
|
||||
state.heapOid = InvalidOid;
|
||||
state.partParentOid = InvalidOid;
|
||||
state.concurrent = drop->concurrent;
|
||||
relOid = RangeVarGetRelidExtended(rel, lockmode, true,
|
||||
false,
|
||||
relOid = RangeVarGetRelidExtended(rel, lockmode, RVR_MISSING_OK,
|
||||
RangeVarCallbackForDropRelation,
|
||||
(void *) &state);
|
||||
|
||||
@ -2793,7 +2792,7 @@ renameatt(RenameStmt *stmt)
|
||||
|
||||
/* lock level taken here should match renameatt_internal */
|
||||
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
stmt->missing_ok, false,
|
||||
stmt->missing_ok ? RVR_MISSING_OK : 0,
|
||||
RangeVarCallbackForRenameAttribute,
|
||||
NULL);
|
||||
|
||||
@ -2945,7 +2944,7 @@ RenameConstraint(RenameStmt *stmt)
|
||||
{
|
||||
/* lock level taken here should match rename_constraint_internal */
|
||||
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
stmt->missing_ok, false,
|
||||
stmt->missing_ok ? RVR_MISSING_OK : 0,
|
||||
RangeVarCallbackForRenameAttribute,
|
||||
NULL);
|
||||
if (!OidIsValid(relid))
|
||||
@ -2987,7 +2986,7 @@ RenameRelation(RenameStmt *stmt)
|
||||
* escalation.
|
||||
*/
|
||||
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
stmt->missing_ok, false,
|
||||
stmt->missing_ok ? RVR_MISSING_OK : 0,
|
||||
RangeVarCallbackForAlterRelation,
|
||||
(void *) stmt);
|
||||
|
||||
@ -3146,7 +3145,8 @@ CheckTableNotInUse(Relation rel, const char *stmt)
|
||||
Oid
|
||||
AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
|
||||
{
|
||||
return RangeVarGetRelidExtended(stmt->relation, lockmode, stmt->missing_ok, false,
|
||||
return RangeVarGetRelidExtended(stmt->relation, lockmode,
|
||||
stmt->missing_ok ? RVR_MISSING_OK : 0,
|
||||
RangeVarCallbackForAlterRelation,
|
||||
(void *) stmt);
|
||||
}
|
||||
@ -12683,7 +12683,7 @@ AlterTableNamespace(AlterObjectSchemaStmt *stmt, Oid *oldschema)
|
||||
ObjectAddress myself;
|
||||
|
||||
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
stmt->missing_ok, false,
|
||||
stmt->missing_ok ? RVR_MISSING_OK : 0,
|
||||
RangeVarCallbackForAlterRelation,
|
||||
(void *) stmt);
|
||||
|
||||
@ -14613,7 +14613,7 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
|
||||
state.parentTblOid = parentIdx->rd_index->indrelid;
|
||||
state.lockedParentTbl = false;
|
||||
partIdxId =
|
||||
RangeVarGetRelidExtended(name, AccessExclusiveLock, false, false,
|
||||
RangeVarGetRelidExtended(name, AccessExclusiveLock, 0,
|
||||
RangeVarCallbackForAttachIndex,
|
||||
(void *) &state);
|
||||
/* Not there? */
|
||||
|
@ -1667,7 +1667,7 @@ renametrig(RenameStmt *stmt)
|
||||
* release until end of transaction).
|
||||
*/
|
||||
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
false, false,
|
||||
0,
|
||||
RangeVarCallbackForRenameTrigger,
|
||||
NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user