41#include "utils/fmgroids.h"
86 errmsg(
"permission denied: \"%s\" is a system catalog",
113 elog(
ERROR,
"unrecognized policy command");
115 if (
strcmp(cmd_name,
"all") == 0)
117 else if (
strcmp(cmd_name,
"select") == 0)
119 else if (
strcmp(cmd_name,
"insert") == 0)
121 else if (
strcmp(cmd_name,
"update") == 0)
123 else if (
strcmp(cmd_name,
"delete") == 0)
126 elog(
ERROR,
"unrecognized policy command");
169 errmsg(
"ignoring specified roles other than PUBLIC"),
170 errhint(
"All roles are members of the PUBLIC role.")));
210 "row security descriptor",
265 elog(
ERROR,
"unexpected null value in pg_policy.polroles");
373 errmsg(
"\"%s\" is not a table",
379 errmsg(
"permission denied: \"%s\" is a system catalog",
477 if (roles[
i] != roleid)
497 memset(isnull, 0,
sizeof(isnull));
583 Node *with_check_qual;
603 errmsg(
"WITH CHECK cannot be applied to SELECT or DELETE")));
612 errmsg(
"only WITH CHECK expression allowed for INSERT")));
624 memset(isnull, 0,
sizeof(isnull));
686 errmsg(
"policy \"%s\" for table \"%s\" already exists",
834 if (
stmt->with_check)
860 memset(isnull, 0,
sizeof(isnull));
887 errmsg(
"policy \"%s\" for table \"%s\" does not exist",
905 errmsg(
"only USING expression allowed for SELECT, DELETE")));
915 errmsg(
"only WITH CHECK expression allowed for INSERT")));
996 if (with_check_qual !=
NULL)
1032 NULL,
false,
false);
1138 errmsg(
"policy \"%s\" for table \"%s\" already exists",
1166 errmsg(
"policy \"%s\" for table \"%s\" does not exist",
1237 errmsg(
"policy \"%s\" for table \"%s\" does not exist",
Oid get_rolespec_oid(const RoleSpec *role, bool missing_ok)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
#define DatumGetArrayTypePCopy(X)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define Assert(condition)
bool IsSystemRelation(Relation relation)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
bool IsSystemClass(Oid relid, Form_pg_class reltuple)
void recordDependencyOnExpr(const ObjectAddress *depender, Node *expr, List *rtable, DependencyType behavior)
@ SHARED_DEPENDENCY_POLICY
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define palloc_array(type, count)
#define DirectFunctionCall1(func, arg1)
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)
bool allowSystemTableMods
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_copytuple(HeapTuple tuple)
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)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
void CacheInvalidateRelcache(Relation relation)
void CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
List * lcons(void *datum, List *list)
#define AccessExclusiveLock
char * get_rel_name(Oid relid)
char get_rel_relkind(Oid relid)
char * MemoryContextStrdup(MemoryContext context, const char *string)
void * MemoryContextAllocZero(MemoryContext context, Size size)
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
MemoryContext CacheMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
#define MemoryContextCopyAndSetIdentifier(cxt, id)
void namestrcpy(Name name, const char *str)
Datum namein(PG_FUNCTION_ARGS)
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
ObjectType get_relkind_objtype(char relkind)
#define ObjectAddressSet(addr, class_id, object_id)
char * nodeToString(const void *obj)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Node * transformWhereClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName)
void assign_expr_collations(ParseState *pstate, Node *expr)
void free_parsestate(ParseState *pstate)
ParseState * make_parsestate(ParseState *parentParseState)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
FormData_pg_class * Form_pg_class
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDeps)
static int list_length(const List *l)
FormData_pg_policy * Form_pg_policy
void deleteSharedDependencyRecordsFor(Oid classId, Oid objectId, int32 objectSubId)
void recordSharedDependencyOn(ObjectAddress *depender, ObjectAddress *referenced, SharedDependencyType deptype)
bool RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id)
static void RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid, void *arg)
ObjectAddress CreatePolicy(CreatePolicyStmt *stmt)
static Datum * policy_role_list_to_array(List *roles, int *num_roles)
ObjectAddress AlterPolicy(AlterPolicyStmt *stmt)
void RelationBuildRowSecurity(Relation relation)
static char parse_policy_command(const char *cmd_name)
bool relation_has_policies(Relation rel)
Oid get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
ObjectAddress rename_policy(RenameStmt *stmt)
void RemovePolicyById(Oid policy_id)
static Datum PointerGetDatum(const void *X)
static Oid DatumGetObjectId(Datum X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static char DatumGetChar(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum CharGetDatum(char X)
void * stringToNode(const char *str)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
bool checkExprHasSubLink(Node *node)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
struct RowSecurityDesc * rd_rsdesc
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
void CommandCounterIncrement(void)