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

Function try_table_open

src/backend/access/table/table.c:73–97  ·  view source on GitHub ↗

---------------- * try_table_open - open a table relation by relation OID * * Same as table_open, except return NULL instead of failing * if the relation does not exist. * ---------------- */

Source from the content-addressed store, hash-verified

71 * ----------------
72 */
73Relation
74try_table_open(Oid relationId, LOCKMODE lockmode, bool noWait)
75{
76 Relation r;
77
78 r = try_relation_open(relationId, lockmode, noWait);
79
80 /* leave if table does not exist */
81 if (!r)
82 return NULL;
83
84 if (r->rd_rel->relkind == RELKIND_INDEX ||
85 r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
86 ereport(ERROR,
87 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
88 errmsg("\"%s\" is an index",
89 RelationGetRelationName(r))));
90 else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
91 ereport(ERROR,
92 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
93 errmsg("\"%s\" is a composite type",
94 RelationGetRelationName(r))));
95
96 return r;
97}
98
99/* ----------------
100 * table_openrv - open a table relation specified

Callers 6

addRangeTableEntryFunction · 0.85
logicalrep_rel_openFunction · 0.85
CdbTryOpenTableFunction · 0.85
reindex_indexFunction · 0.85
reindex_relationFunction · 0.85

Calls 3

try_relation_openFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected