24 #include "utils/fmgroids.h"
126 if (
stmt->provider == NULL)
130 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
131 errmsg(
"no security label providers have been loaded")));
134 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
135 errmsg(
"must specify provider when multiple security label providers have been loaded")));
152 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
153 errmsg(
"security label provider \"%s\" is not loaded",
159 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
160 errmsg(
"security labels are not supported for this type of object")));
173 stmt->object, relation);
176 switch (
stmt->objtype)
185 if (relation->
rd_rel->relkind != RELKIND_RELATION &&
186 relation->
rd_rel->relkind != RELKIND_VIEW &&
187 relation->
rd_rel->relkind != RELKIND_MATVIEW &&
188 relation->
rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
189 relation->
rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
190 relation->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
192 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
193 errmsg(
"cannot set security label on relation \"%s\"",
213 if (relation != NULL)
232 char *seclabel = NULL;
235 Anum_pg_shseclabel_objoid,
239 Anum_pg_shseclabel_classoid,
243 Anum_pg_shseclabel_provider,
280 char *seclabel = NULL;
288 Anum_pg_seclabel_objoid,
292 Anum_pg_seclabel_classoid,
296 Anum_pg_seclabel_objsubid,
300 Anum_pg_seclabel_provider,
338 bool nulls[Natts_pg_shseclabel];
339 bool replaces[Natts_pg_shseclabel];
342 memset(nulls,
false,
sizeof(nulls));
343 memset(replaces,
false,
sizeof(replaces));
352 Anum_pg_shseclabel_objoid,
356 Anum_pg_shseclabel_classoid,
360 Anum_pg_shseclabel_provider,
376 replaces[Anum_pg_shseclabel_label - 1] =
true;
385 if (newtup == NULL &&
label != NULL)
413 bool nulls[Natts_pg_seclabel];
414 bool replaces[Natts_pg_seclabel];
424 memset(nulls,
false,
sizeof(nulls));
425 memset(replaces,
false,
sizeof(replaces));
435 Anum_pg_seclabel_objoid,
439 Anum_pg_seclabel_classoid,
443 Anum_pg_seclabel_objsubid,
447 Anum_pg_seclabel_provider,
463 replaces[Anum_pg_seclabel_label - 1] =
true;
472 if (newtup == NULL &&
label != NULL)
499 Anum_pg_shseclabel_objoid,
503 Anum_pg_shseclabel_classoid,
540 Anum_pg_seclabel_objoid,
544 Anum_pg_seclabel_classoid,
550 Anum_pg_seclabel_objsubid,
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define Assert(condition)
bool IsSharedRelation(Oid relationId)
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)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
static JitProviderCallbacks provider
List * lappend(List *list, void *datum)
#define ShareUpdateExclusiveLock
char * pstrdup(const char *in)
MemoryContext TopMemoryContext
void check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, Node *object, Relation relation)
ObjectAddress get_object_address(ObjectType objtype, Node *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
@ OBJECT_PUBLICATION_NAMESPACE
int errdetail_relkind_not_supported(char relkind)
static int list_length(const List *l)
static Datum ObjectIdGetDatum(Oid X)
static Datum Int32GetDatum(int32 X)
MemoryContextSwitchTo(old_ctx)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
bool criticalSharedRelcachesBuilt
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
char * GetSecurityLabel(const ObjectAddress *object, const char *provider)
void SetSecurityLabel(const ObjectAddress *object, const char *provider, const char *label)
ObjectAddress ExecSecLabelStmt(SecLabelStmt *stmt)
void register_label_provider(const char *provider_name, check_object_relabel_type hook)
static List * label_provider_list
static bool SecLabelSupportsObjectType(ObjectType objtype)
static void SetSharedSecurityLabel(const ObjectAddress *object, const char *provider, const char *label)
static char * GetSharedSecurityLabel(const ObjectAddress *object, const char *provider)
void DeleteSecurityLabel(const ObjectAddress *object)
void DeleteSharedSecurityLabel(Oid objectId, Oid classId)
void(* check_object_relabel_type)(const ObjectAddress *object, const char *seclabel)
void relation_close(Relation relation, LOCKMODE lockmode)
#define BTEqualStrategyNumber
const char * provider_name
check_object_relabel_type hook
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)