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

Function sepgsql_relation_post_create

contrib/sepgsql/relation.c:239–408  ·  view source on GitHub ↗

* sepgsql_relation_post_create * * The post creation hook of relation/attribute */

Source from the content-addressed store, hash-verified

237 * The post creation hook of relation/attribute
238 */
239void
240sepgsql_relation_post_create(Oid relOid)
241{
242 Relation rel;
243 ScanKeyData skey;
244 SysScanDesc sscan;
245 HeapTuple tuple;
246 Form_pg_class classForm;
247 ObjectAddress object;
248 uint16_t tclass;
249 char *scontext; /* subject */
250 char *tcontext; /* schema */
251 char *rcontext; /* relation */
252 char *ccontext; /* column */
253 char *nsp_name;
254 StringInfoData audit_name;
255
256 /*
257 * Fetch catalog record of the new relation. Because pg_class entry is not
258 * visible right now, we need to scan the catalog using SnapshotSelf.
259 */
260 rel = table_open(RelationRelationId, AccessShareLock);
261
262 ScanKeyInit(&skey,
263 Anum_pg_class_oid,
264 BTEqualStrategyNumber, F_OIDEQ,
265 ObjectIdGetDatum(relOid));
266
267 sscan = systable_beginscan(rel, ClassOidIndexId, true,
268 SnapshotSelf, 1, &skey);
269
270 tuple = systable_getnext(sscan);
271 if (!HeapTupleIsValid(tuple))
272 elog(ERROR, "could not find tuple for relation %u", relOid);
273
274 classForm = (Form_pg_class) GETSTRUCT(tuple);
275
276 /* ignore indexes on toast tables */
277 if (classForm->relkind == RELKIND_INDEX &&
278 classForm->relnamespace == PG_TOAST_NAMESPACE)
279 goto out;
280
281 /*
282 * check db_schema:{add_name} permission of the namespace
283 */
284 object.classId = NamespaceRelationId;
285 object.objectId = classForm->relnamespace;
286 object.objectSubId = 0;
287 sepgsql_avc_check_perms(&object,
288 SEPG_CLASS_DB_SCHEMA,
289 SEPG_DB_SCHEMA__ADD_NAME,
290 getObjectIdentity(&object, false),
291 true);
292
293 switch (classForm->relkind)
294 {
295 case RELKIND_RELATION:
296 case RELKIND_PARTITIONED_TABLE:

Callers 1

sepgsql_object_accessFunction · 0.85

Calls 15

table_openFunction · 0.85
ScanKeyInitFunction · 0.85
ObjectIdGetDatumFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85
sepgsql_avc_check_permsFunction · 0.85
getObjectIdentityFunction · 0.85
sepgsql_index_modifyFunction · 0.85
sepgsql_get_client_labelFunction · 0.85
sepgsql_get_labelFunction · 0.85
sepgsql_compute_createFunction · 0.85
get_namespace_nameFunction · 0.85

Tested by

no test coverage detected