diff options
Diffstat (limited to 'src/backend/catalog/namespace.c')
-rw-r--r-- | src/backend/catalog/namespace.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 52dd400b968..687d31e083b 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -206,23 +206,25 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames, * Given a RangeVar describing an existing relation, * select the proper namespace and look up the relation OID. * - * If the schema or relation is not found, return InvalidOid if missing_ok - * = true, otherwise raise an error. + * If the schema or relation is not found, return InvalidOid if flags contains + * RVR_MISSING_OK, otherwise raise an error. * - * If nowait = true, throw an error if we'd have to wait for a lock. + * If flags contains RVR_NOWAIT, throw an error if we'd have to wait for a + * lock. * * Callback allows caller to check permissions or acquire additional locks * prior to grabbing the relation lock. */ Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, - bool missing_ok, bool nowait, + uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg) { uint64 inval_count; Oid relId; Oid oldRelId = InvalidOid; bool retry = false; + bool missing_ok = (flags & RVR_MISSING_OK) != 0; /* * We check the catalog name and then ignore it. @@ -361,7 +363,7 @@ RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, */ if (!OidIsValid(relId)) AcceptInvalidationMessages(); - else if (!nowait) + else if (!(flags & RVR_NOWAIT)) LockRelationOid(relId, lockmode); else if (!ConditionalLockRelationOid(relId, lockmode)) { @@ -392,15 +394,17 @@ RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, oldRelId = relId; } - if (!OidIsValid(relId) && !missing_ok) + if (!OidIsValid(relId)) { + int elevel = missing_ok ? DEBUG1 : ERROR; + if (relation->schemaname) - ereport(ERROR, + ereport(elevel, (errcode(ERRCODE_UNDEFINED_TABLE), errmsg("relation \"%s.%s\" does not exist", relation->schemaname, relation->relname))); else - ereport(ERROR, + ereport(elevel, (errcode(ERRCODE_UNDEFINED_TABLE), errmsg("relation \"%s\" does not exist", relation->relname))); |