PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "access/relation.h"
#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_rewrite.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_utilcmd.h"
#include "rewrite/rewriteDefine.h"
#include "rewrite/rewriteManip.h"
#include "rewrite/rewriteSupport.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
Go to the source code of this file.
Functions | |
static void | checkRuleResultList (List *targetList, TupleDesc resultDesc, bool isSelect, bool requireColumnNameMatch) |
static bool | setRuleCheckAsUser_walker (Node *node, Oid *context) |
static void | setRuleCheckAsUser_Query (Query *qry, Oid userid) |
static Oid | InsertRule (const char *rulname, int evtype, Oid eventrel_oid, bool evinstead, Node *event_qual, List *action, bool replace) |
ObjectAddress | DefineRule (RuleStmt *stmt, const char *queryString) |
ObjectAddress | DefineQueryRewrite (const char *rulename, Oid event_relid, Node *event_qual, CmdType event_type, bool is_instead, bool replace, List *action) |
void | setRuleCheckAsUser (Node *node, Oid userid) |
void | EnableDisableRule (Relation rel, const char *rulename, char fires_when) |
static void | RangeVarCallbackForRenameRule (const RangeVar *rv, Oid relid, Oid oldrelid, void *arg) |
ObjectAddress | RenameRewriteRule (RangeVar *relation, const char *oldName, const char *newName) |
|
static |
Definition at line 506 of file rewriteDefine.c.
References Assert, attname, ereport, errcode(), errdetail(), errmsg(), ERROR, TargetEntry::expr, exprType(), exprTypmod(), format_type_be(), format_type_with_typemod(), i, lfirst, NameStr, TupleDescData::natts, and TupleDescAttr.
Referenced by DefineQueryRewrite().
ObjectAddress DefineQueryRewrite | ( | const char * | rulename, |
Oid | event_relid, | ||
Node * | event_qual, | ||
CmdType | event_type, | ||
bool | is_instead, | ||
bool | replace, | ||
List * | action | ||
) |
Definition at line 224 of file rewriteDefine.c.
References AccessExclusiveLock, aclcheck_error(), ACLCHECK_NOT_OWNER, generate_unaccent_rules::action, allowSystemTableMods, checkRuleResultList(), CMD_SELECT, Query::commandType, ereport, errcode(), errdetail_relkind_not_supported(), errhint(), errmsg(), ERROR, get_relkind_objtype(), getInsertSelectQuery(), GetUserId(), i, InsertRule(), InvalidOid, IsSystemRelation(), lfirst_node, linitial_node, list_length(), NAMEDATALEN, NIL, NoLock, RuleLock::numLocks, object_ownercheck(), ObjectAddressSet, PRS2_NEW_VARNO, PRS2_OLD_VARNO, pstrdup(), RelationData::rd_rel, RelationData::rd_rules, RelationGetDescr, RelationGetRelationName, Query::returningList, RuleLock::rules, SetRelationRuleStatus(), table_close(), table_open(), Query::targetList, and ViewSelectRuleName.
Referenced by DefineRule(), and DefineViewRules().
ObjectAddress DefineRule | ( | RuleStmt * | stmt, |
const char * | queryString | ||
) |
Definition at line 190 of file rewriteDefine.c.
References AccessExclusiveLock, DefineQueryRewrite(), RangeVarGetRelid, stmt, and transformRuleStmt().
Referenced by ProcessUtilitySlow().
void EnableDisableRule | ( | Relation | rel, |
const char * | rulename, | ||
char | fires_when | ||
) |
Definition at line 691 of file rewriteDefine.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, Assert, CacheInvalidateRelcache(), CatalogTupleUpdate(), CharGetDatum(), DatumGetChar(), ereport, errcode(), errmsg(), ERROR, get_rel_name(), get_rel_relkind(), get_relkind_objtype(), GETSTRUCT, GetUserId(), heap_freetuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, object_ownercheck(), ObjectIdGetDatum(), PointerGetDatum(), RelationGetRelid, RowExclusiveLock, SearchSysCacheCopy2, HeapTupleData::t_self, table_close(), and table_open().
Referenced by ATExecEnableDisableRule().
|
static |
Definition at line 52 of file rewriteDefine.c.
References generate_unaccent_rules::action, BoolGetDatum(), CatalogTupleInsert(), CatalogTupleUpdate(), CharGetDatum(), ObjectAddress::classId, CMD_SELECT, CStringGetTextDatum, deleteDependencyRecordsFor(), DEPENDENCY_AUTO, DEPENDENCY_INTERNAL, DEPENDENCY_NORMAL, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, get_rel_name(), getInsertSelectQuery(), GetNewOidWithIndex(), GETSTRUCT, heap_form_tuple(), heap_freetuple(), heap_modify_tuple(), HeapTupleIsValid, InvokeObjectPostCreateHook, linitial_node, NameGetDatum(), namestrcpy(), NIL, nodeToString(), ObjectAddress::objectId, ObjectIdGetDatum(), ObjectAddress::objectSubId, PointerGetDatum(), RelationData::rd_att, recordDependencyOn(), recordDependencyOnExpr(), RelationGetDescr, ReleaseSysCache(), RowExclusiveLock, Query::rtable, RULE_FIRES_ON_ORIGIN, SearchSysCache2(), HeapTupleData::t_self, table_close(), table_open(), and values.
Referenced by DefineQueryRewrite().
|
static |
Definition at line 756 of file rewriteDefine.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, allowSystemTableMods, ereport, errcode(), errdetail_relkind_not_supported(), errmsg(), ERROR, get_rel_relkind(), get_relkind_objtype(), GETSTRUCT, GetUserId(), HeapTupleIsValid, IsSystemClass(), object_ownercheck(), ObjectIdGetDatum(), ReleaseSysCache(), RangeVar::relname, and SearchSysCache1().
Referenced by RenameRewriteRule().
ObjectAddress RenameRewriteRule | ( | RangeVar * | relation, |
const char * | oldName, | ||
const char * | newName | ||
) |
Definition at line 793 of file rewriteDefine.c.
References AccessExclusiveLock, CacheInvalidateRelcache(), CatalogTupleUpdate(), CMD_SELECT, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, GETSTRUCT, heap_freetuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, IsDefinedRewriteRule(), namestrcpy(), NoLock, ObjectAddressSet, ObjectIdGetDatum(), PointerGetDatum(), RangeVarCallbackForRenameRule(), RangeVarGetRelidExtended(), relation_close(), relation_open(), RelationGetRelationName, RowExclusiveLock, SearchSysCacheCopy2, HeapTupleData::t_self, table_close(), and table_open().
Referenced by ExecRenameStmt().
Definition at line 631 of file rewriteDefine.c.
References setRuleCheckAsUser_walker().
Referenced by get_row_security_policies(), and RelationBuildRuleLock().
Definition at line 651 of file rewriteDefine.c.
References castNode, RTEPermissionInfo::checkAsUser, Query::cteList, CommonTableExpr::ctequery, lfirst, lfirst_node, QTW_IGNORE_RC_SUBQUERIES, query_tree_walker, Query::rtable, RTE_SUBQUERY, RangeTblEntry::rtekind, setRuleCheckAsUser_walker(), and RangeTblEntry::subquery.
Referenced by setRuleCheckAsUser_walker().
Definition at line 637 of file rewriteDefine.c.
References context, expression_tree_walker, IsA, and setRuleCheckAsUser_Query().
Referenced by setRuleCheckAsUser(), and setRuleCheckAsUser_Query().