MCPcopy Create free account
hub / github.com/apache/cloudberry / relation_open

Function relation_open

src/backend/access/common/relation.c:47–84  ·  view source on GitHub ↗

---------------- * relation_open - open any relation by relation OID * * If lockmode is not "NoLock", the specified kind of lock is * obtained on the relation. (Generally, NoLock should only be * used if the caller knows it has some appropriate lock on the * relation already.) * * An error is raised if the relation does not exist. * * NB: a "relation" is anything with a pg_class

Source from the content-addressed store, hash-verified

45 * ----------------
46 */
47Relation
48relation_open(Oid relationId, LOCKMODE lockmode)
49{
50 Relation r;
51
52 Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
53
54 /* Get the lock before trying to open the relcache entry */
55 if (lockmode != NoLock)
56 LockRelationOid(relationId, lockmode);
57
58 /* The relcache does all the real work... */
59 r = RelationIdGetRelation(relationId);
60
61 if (!RelationIsValid(r))
62 ereport(ERROR,
63 (errcode(ERRCODE_UNDEFINED_TABLE),
64 errmsg("could not open relation with OID %u", relationId),
65 errdetail("This can be validly caused by a concurrent delete operation on this object.")));
66
67 /*
68 * If we didn't get the lock ourselves, assert that caller holds one,
69 * except in bootstrap mode where no locks are used.
70 */
71 Assert(lockmode != NoLock ||
72 IsBootstrapProcessingMode() ||
73 CheckRelationLockedByMe(r, AccessShareLock, true));
74
75#if 0 /* Upstream code not applicable to GPDB */
76 /* Make note that we've accessed a temporary relation */
77 if (RelationUsesLocalBuffers(r))
78 MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPNAMESPACE;
79#endif
80
81 pgstat_initstats(r);
82
83 return r;
84}
85
86/* ----------------
87 * try_relation_open - open any relation by relation OID

Callers 15

pg_visibility_mapFunction · 0.85
pg_visibilityFunction · 0.85
collect_visibility_dataFunction · 0.85
collect_corrupt_itemsFunction · 0.85
pg_freespaceFunction · 0.85
heap_force_commonFunction · 0.85
readindexFunction · 0.85
verify_heapamFunction · 0.85
PaxObjectAccessHookFunction · 0.85

Calls 7

LockRelationOidFunction · 0.85
RelationIdGetRelationFunction · 0.85
CheckRelationLockedByMeFunction · 0.85
pgstat_initstatsFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errdetailFunction · 0.50

Tested by

no test coverage detected