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

Function RangeVarCallbackForLockTable

src/backend/commands/lockcmds.c:94–131  ·  view source on GitHub ↗

* Before acquiring a table lock on the named table, check whether we have * permission to do so. */

Source from the content-addressed store, hash-verified

92 * permission to do so.
93 */
94static void
95RangeVarCallbackForLockTable(const RangeVar *rv, Oid relid, Oid oldrelid,
96 void *arg)
97{
98 LOCKMODE lockmode = *(LOCKMODE *) arg;
99 char relkind;
100 AclResult aclresult;
101
102 if (!OidIsValid(relid))
103 return; /* doesn't exist, so no permissions check */
104 relkind = get_rel_relkind(relid);
105 if (!relkind)
106 return; /* woops, concurrently dropped; no permissions
107 * check */
108
109 /* Currently, we only allow plain tables or views to be locked */
110 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE &&
111 relkind != RELKIND_VIEW && relkind != RELKIND_DIRECTORY_TABLE)
112 ereport(ERROR,
113 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
114 errmsg("\"%s\" is not a table, directory table or view",
115 rv->relname)));
116
117#if 0 /* Upstream code not applicable to GPDB */
118 /*
119 * Make note if a temporary relation has been accessed in this
120 * transaction.
121 */
122 relpersistence = get_rel_persistence(relid);
123 if (relpersistence == RELPERSISTENCE_TEMP)
124 MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPNAMESPACE;
125#endif
126
127 /* Check permissions. */
128 aclresult = LockTableAclCheck(relid, lockmode, GetUserId());
129 if (aclresult != ACLCHECK_OK)
130 aclcheck_error(aclresult, get_relkind_objtype(get_rel_relkind(relid)), rv->relname);
131}
132
133/*
134 * Apply LOCK TABLE recursively over an inheritance tree

Callers

nothing calls this directly

Calls 8

get_rel_relkindFunction · 0.85
get_rel_persistenceFunction · 0.85
LockTableAclCheckFunction · 0.85
GetUserIdFunction · 0.85
aclcheck_errorFunction · 0.85
get_relkind_objtypeFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected