* Before acquiring a table lock on the named table, check whether we have * permission to do so. */
| 92 | * permission to do so. |
| 93 | */ |
| 94 | static void |
| 95 | RangeVarCallbackForLockTable(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 |
nothing calls this directly
no test coverage detected