26 #include "utils/fmgroids.h"
61 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
71 Anum_pg_attribute_attrelid,
75 Anum_pg_attribute_attnum,
84 elog(
ERROR,
"could not find tuple for column %d of relation %u",
98 object.classId = RelationRelationId;
99 object.objectId = relOid;
100 object.objectSubId = 0;
115 object.classId = RelationRelationId;
116 object.objectId = relOid;
117 object.objectSubId =
attnum;
139 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
145 object.classId = RelationRelationId;
146 object.objectId = relOid;
147 object.objectSubId =
attnum;
166 const char *seclabel)
172 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
174 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
175 errmsg(
"cannot set security label on non-regular columns")));
177 object.classId = RelationRelationId;
178 object.objectId = relOid;
179 object.objectSubId =
attnum;
215 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
221 object.classId = RelationRelationId;
222 object.objectId = relOid;
223 object.objectSubId =
attnum;
272 elog(
ERROR,
"could not find tuple for relation %u", relOid);
277 if (classForm->relkind == RELKIND_INDEX &&
278 classForm->relnamespace == PG_TOAST_NAMESPACE)
284 object.classId = NamespaceRelationId;
285 object.objectId = classForm->relnamespace;
286 object.objectSubId = 0;
293 switch (classForm->relkind)
295 case RELKIND_RELATION:
296 case RELKIND_PARTITIONED_TABLE:
299 case RELKIND_SEQUENCE:
320 classForm->relnamespace, 0);
342 object.classId = RelationRelationId;
343 object.objectId = relOid;
344 object.objectSubId = 0;
350 if (classForm->relkind == RELKIND_RELATION ||
351 classForm->relkind == RELKIND_PARTITIONED_TABLE)
362 Anum_pg_attribute_attrelid,
393 object.classId = RelationRelationId;
394 object.objectId = relOid;
395 object.objectSubId = attForm->attnum;
425 case RELKIND_RELATION:
426 case RELKIND_PARTITIONED_TABLE:
429 case RELKIND_SEQUENCE:
449 object.classId = NamespaceRelationId;
451 object.objectSubId = 0;
462 if (relkind == RELKIND_INDEX)
471 object.classId = RelationRelationId;
472 object.objectId = relOid;
473 object.objectSubId = 0;
486 if (relkind == RELKIND_RELATION || relkind == RELKIND_PARTITIONED_TABLE)
499 if (attForm->attisdropped)
502 object.classId = RelationRelationId;
503 object.objectId = relOid;
504 object.objectSubId = attForm->attnum;
533 case RELKIND_RELATION:
534 case RELKIND_PARTITIONED_TABLE:
545 object.classId = RelationRelationId;
546 object.objectId = relOid;
547 object.objectSubId = 0;
571 if (relkind == RELKIND_RELATION || relkind == RELKIND_PARTITIONED_TABLE)
573 else if (relkind == RELKIND_SEQUENCE)
575 else if (relkind == RELKIND_VIEW)
579 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
580 errmsg(
"cannot set security labels on relations except "
581 "for tables, sequences or views")));
583 object.classId = RelationRelationId;
584 object.objectId = relOid;
585 object.objectSubId = 0;
630 case RELKIND_RELATION:
631 case RELKIND_PARTITIONED_TABLE:
634 case RELKIND_SEQUENCE:
664 elog(
ERROR,
"could not find tuple for relation %u", relOid);
672 elog(
ERROR,
"cache lookup failed for relation %u", relOid);
678 if (newform->relnamespace != oldform->relnamespace)
683 if (strcmp(
NameStr(newform->relname),
NameStr(oldform->relname)) != 0)
694 object.classId = RelationRelationId;
695 object.objectId = relOid;
696 object.objectSubId = 0;
741 elog(
ERROR,
"could not find tuple for object %u in catalog \"%s\"",
770 Anum_pg_index_indrelid,
771 Anum_pg_index_indexrelid);
#define Assert(condition)
void ReleaseCatCacheList(CatCList *list)
void sepgsql_attribute_setattr(Oid relOid, AttrNumber attnum)
void sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
void sepgsql_relation_post_create(Oid relOid)
void sepgsql_attribute_relabel(Oid relOid, AttrNumber attnum, const char *seclabel)
static void sepgsql_index_modify(Oid indexOid)
static void sepgsql_relation_setattr_extra(Relation catalog, Oid catindex_id, Oid extra_oid, AttrNumber anum_relation_id, AttrNumber anum_extra_id)
void sepgsql_relation_truncate(Oid relOid)
void sepgsql_relation_relabel(Oid relOid, const char *seclabel)
void sepgsql_relation_setattr(Oid relOid)
void sepgsql_relation_drop(Oid relOid)
void sepgsql_attribute_drop(Oid relOid, AttrNumber attnum)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
char * sepgsql_get_label(Oid classId, Oid objectId, int32 subId)
char * sepgsql_get_client_label(void)
char * get_namespace_name(Oid nspid)
char get_rel_relkind(Oid relid)
Oid get_rel_namespace(Oid relid)
void pfree(void *pointer)
char * getObjectIdentity(const ObjectAddress *object, bool missing_ok)
FormData_pg_attribute * Form_pg_attribute
FormData_pg_class * Form_pg_class
static Oid DatumGetObjectId(Datum X)
static Datum Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
const char * quote_identifier(const char *ident)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void sepgsql_schema_rename(Oid namespaceId)
void sepgsql_schema_remove_name(Oid namespaceId)
void sepgsql_schema_add_name(Oid namespaceId)
void SetSecurityLabel(const ObjectAddress *object, const char *provider, const char *label)
char * sepgsql_compute_create(const char *scontext, const char *tcontext, uint16 tclass, const char *objname)
#define SEPG_DB_COLUMN__CREATE
#define SEPG_DB_COLUMN__SETATTR
#define SEPG_CLASS_DB_SCHEMA
#define SEPG_CLASS_DB_TABLE
#define SEPG_DB_DATABASE__CREATE
#define SEPG_DB_SCHEMA__REMOVE_NAME
bool sepgsql_avc_check_perms_label(const char *tcontext, uint16 tclass, uint32 required, const char *audit_name, bool abort_on_violation)
#define SEPG_DB_TABLE__SETATTR
#define SEPG_DB_TABLE__TRUNCATE
#define SEPG_DB_COLUMN__DROP
#define SEPG_DB_TABLE__RELABELFROM
#define SEPG_DB_SCHEMA__ADD_NAME
#define SEPG_DB_TABLE__RELABELTO
#define SEPG_DB_COLUMN__RELABELFROM
#define SEPG_DB_PROCEDURE__RELABELTO
#define SEPG_CLASS_DB_COLUMN
#define SEPG_DB_TABLE__DROP
#define SEPGSQL_LABEL_TAG
#define SEPG_CLASS_DB_VIEW
#define SEPG_CLASS_DB_SEQUENCE
bool sepgsql_avc_check_perms(const ObjectAddress *tobject, uint16 tclass, uint32 required, const char *audit_name, bool abort_on_violation)
#define BTEqualStrategyNumber
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define SearchSysCacheList1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)