PostgreSQL Source Code  git master
rewriteDefine.h File Reference
Include dependency graph for rewriteDefine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RULE_FIRES_ON_ORIGIN   'O'
 
#define RULE_FIRES_ALWAYS   'A'
 
#define RULE_FIRES_ON_REPLICA   'R'
 
#define RULE_DISABLED   'D'
 

Functions

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)
 
ObjectAddress RenameRewriteRule (RangeVar *relation, const char *oldName, const char *newName)
 
void setRuleCheckAsUser (Node *node, Oid userid)
 
void EnableDisableRule (Relation rel, const char *rulename, char fires_when)
 

Macro Definition Documentation

◆ RULE_DISABLED

#define RULE_DISABLED   'D'

Definition at line 24 of file rewriteDefine.h.

◆ RULE_FIRES_ALWAYS

#define RULE_FIRES_ALWAYS   'A'

Definition at line 22 of file rewriteDefine.h.

◆ RULE_FIRES_ON_ORIGIN

#define RULE_FIRES_ON_ORIGIN   'O'

Definition at line 21 of file rewriteDefine.h.

◆ RULE_FIRES_ON_REPLICA

#define RULE_FIRES_ON_REPLICA   'R'

Definition at line 23 of file rewriteDefine.h.

Function Documentation

◆ 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.

231 {
232  Relation event_relation;
233  ListCell *l;
234  Query *query;
235  Oid ruleId = InvalidOid;
236  ObjectAddress address;
237 
238  /*
239  * If we are installing an ON SELECT rule, we had better grab
240  * AccessExclusiveLock to ensure no SELECTs are currently running on the
241  * event relation. For other types of rules, it would be sufficient to
242  * grab ShareRowExclusiveLock to lock out insert/update/delete actions and
243  * to ensure that we lock out current CREATE RULE statements; but because
244  * of race conditions in access to catalog entries, we can't do that yet.
245  *
246  * Note that this lock level should match the one used in DefineRule.
247  */
248  event_relation = table_open(event_relid, AccessExclusiveLock);
249 
250  /*
251  * Verify relation is of a type that rules can sensibly be applied to.
252  * Internal callers can target materialized views, but transformRuleStmt()
253  * blocks them for users. Don't mention them in the error message.
254  */
255  if (event_relation->rd_rel->relkind != RELKIND_RELATION &&
256  event_relation->rd_rel->relkind != RELKIND_MATVIEW &&
257  event_relation->rd_rel->relkind != RELKIND_VIEW &&
258  event_relation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
259  ereport(ERROR,
260  (errcode(ERRCODE_WRONG_OBJECT_TYPE),
261  errmsg("relation \"%s\" cannot have rules",
262  RelationGetRelationName(event_relation)),
263  errdetail_relkind_not_supported(event_relation->rd_rel->relkind)));
264 
265  if (!allowSystemTableMods && IsSystemRelation(event_relation))
266  ereport(ERROR,
267  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
268  errmsg("permission denied: \"%s\" is a system catalog",
269  RelationGetRelationName(event_relation))));
270 
271  /*
272  * Check user has permission to apply rules to this relation.
273  */
274  if (!object_ownercheck(RelationRelationId, event_relid, GetUserId()))
275  aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(event_relation->rd_rel->relkind),
276  RelationGetRelationName(event_relation));
277 
278  /*
279  * No rule actions that modify OLD or NEW
280  */
281  foreach(l, action)
282  {
283  query = lfirst_node(Query, l);
284  if (query->resultRelation == 0)
285  continue;
286  /* Don't be fooled by INSERT/SELECT */
287  if (query != getInsertSelectQuery(query, NULL))
288  continue;
289  if (query->resultRelation == PRS2_OLD_VARNO)
290  ereport(ERROR,
291  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
292  errmsg("rule actions on OLD are not implemented"),
293  errhint("Use views or triggers instead.")));
294  if (query->resultRelation == PRS2_NEW_VARNO)
295  ereport(ERROR,
296  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
297  errmsg("rule actions on NEW are not implemented"),
298  errhint("Use triggers instead.")));
299  }
300 
301  if (event_type == CMD_SELECT)
302  {
303  /*
304  * Rules ON SELECT are restricted to view definitions
305  *
306  * So this had better be a view, ...
307  */
308  if (event_relation->rd_rel->relkind != RELKIND_VIEW &&
309  event_relation->rd_rel->relkind != RELKIND_MATVIEW)
310  ereport(ERROR,
311  (errcode(ERRCODE_WRONG_OBJECT_TYPE),
312  errmsg("relation \"%s\" cannot have ON SELECT rules",
313  RelationGetRelationName(event_relation)),
314  errdetail_relkind_not_supported(event_relation->rd_rel->relkind)));
315 
316  /*
317  * ... there cannot be INSTEAD NOTHING, ...
318  */
319  if (action == NIL)
320  ereport(ERROR,
321  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
322  errmsg("INSTEAD NOTHING rules on SELECT are not implemented"),
323  errhint("Use views instead.")));
324 
325  /*
326  * ... there cannot be multiple actions, ...
327  */
328  if (list_length(action) > 1)
329  ereport(ERROR,
330  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
331  errmsg("multiple actions for rules on SELECT are not implemented")));
332 
333  /*
334  * ... the one action must be a SELECT, ...
335  */
336  query = linitial_node(Query, action);
337  if (!is_instead ||
338  query->commandType != CMD_SELECT)
339  ereport(ERROR,
340  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
341  errmsg("rules on SELECT must have action INSTEAD SELECT")));
342 
343  /*
344  * ... it cannot contain data-modifying WITH ...
345  */
346  if (query->hasModifyingCTE)
347  ereport(ERROR,
348  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
349  errmsg("rules on SELECT must not contain data-modifying statements in WITH")));
350 
351  /*
352  * ... there can be no rule qual, ...
353  */
354  if (event_qual != NULL)
355  ereport(ERROR,
356  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
357  errmsg("event qualifications are not implemented for rules on SELECT")));
358 
359  /*
360  * ... the targetlist of the SELECT action must exactly match the
361  * event relation, ...
362  */
364  RelationGetDescr(event_relation),
365  true,
366  event_relation->rd_rel->relkind !=
367  RELKIND_MATVIEW);
368 
369  /*
370  * ... there must not be another ON SELECT rule already ...
371  */
372  if (!replace && event_relation->rd_rules != NULL)
373  {
374  int i;
375 
376  for (i = 0; i < event_relation->rd_rules->numLocks; i++)
377  {
378  RewriteRule *rule;
379 
380  rule = event_relation->rd_rules->rules[i];
381  if (rule->event == CMD_SELECT)
382  ereport(ERROR,
383  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
384  errmsg("\"%s\" is already a view",
385  RelationGetRelationName(event_relation))));
386  }
387  }
388 
389  /*
390  * ... and finally the rule must be named _RETURN.
391  */
392  if (strcmp(rulename, ViewSelectRuleName) != 0)
393  {
394  /*
395  * In versions before 7.3, the expected name was _RETviewname. For
396  * backwards compatibility with old pg_dump output, accept that
397  * and silently change it to _RETURN. Since this is just a quick
398  * backwards-compatibility hack, limit the number of characters
399  * checked to a few less than NAMEDATALEN; this saves having to
400  * worry about where a multibyte character might have gotten
401  * truncated.
402  */
403  if (strncmp(rulename, "_RET", 4) != 0 ||
404  strncmp(rulename + 4, RelationGetRelationName(event_relation),
405  NAMEDATALEN - 4 - 4) != 0)
406  ereport(ERROR,
407  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
408  errmsg("view rule for \"%s\" must be named \"%s\"",
409  RelationGetRelationName(event_relation),
411  rulename = pstrdup(ViewSelectRuleName);
412  }
413  }
414  else
415  {
416  /*
417  * For non-SELECT rules, a RETURNING list can appear in at most one of
418  * the actions ... and there can't be any RETURNING list at all in a
419  * conditional or non-INSTEAD rule. (Actually, there can be at most
420  * one RETURNING list across all rules on the same event, but it seems
421  * best to enforce that at rule expansion time.) If there is a
422  * RETURNING list, it must match the event relation.
423  */
424  bool haveReturning = false;
425 
426  foreach(l, action)
427  {
428  query = lfirst_node(Query, l);
429 
430  if (!query->returningList)
431  continue;
432  if (haveReturning)
433  ereport(ERROR,
434  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
435  errmsg("cannot have multiple RETURNING lists in a rule")));
436  haveReturning = true;
437  if (event_qual != NULL)
438  ereport(ERROR,
439  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
440  errmsg("RETURNING lists are not supported in conditional rules")));
441  if (!is_instead)
442  ereport(ERROR,
443  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
444  errmsg("RETURNING lists are not supported in non-INSTEAD rules")));
446  RelationGetDescr(event_relation),
447  false, false);
448  }
449 
450  /*
451  * And finally, if it's not an ON SELECT rule then it must *not* be
452  * named _RETURN. This prevents accidentally or maliciously replacing
453  * a view's ON SELECT rule with some other kind of rule.
454  */
455  if (strcmp(rulename, ViewSelectRuleName) == 0)
456  ereport(ERROR,
457  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
458  errmsg("non-view rule for \"%s\" must not be named \"%s\"",
459  RelationGetRelationName(event_relation),
461  }
462 
463  /*
464  * This rule is allowed - prepare to install it.
465  */
466 
467  /* discard rule if it's null action and not INSTEAD; it's a no-op */
468  if (action != NIL || is_instead)
469  {
470  ruleId = InsertRule(rulename,
471  event_type,
472  event_relid,
473  is_instead,
474  event_qual,
475  action,
476  replace);
477 
478  /*
479  * Set pg_class 'relhasrules' field true for event relation.
480  *
481  * Important side effect: an SI notice is broadcast to force all
482  * backends (including me!) to update relcache entries with the new
483  * rule.
484  */
485  SetRelationRuleStatus(event_relid, true);
486  }
487 
488  ObjectAddressSet(address, RewriteRelationId, ruleId);
489 
490  /* Close rel, but keep lock till commit... */
491  table_close(event_relation, NoLock);
492 
493  return address;
494 }
@ ACLCHECK_NOT_OWNER
Definition: acl.h:185
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:2688
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
Definition: aclchk.c:4130
bool IsSystemRelation(Relation relation)
Definition: catalog.c:73
int errhint(const char *fmt,...)
Definition: elog.c:1319
int errcode(int sqlerrcode)
Definition: elog.c:859
int errmsg(const char *fmt,...)
Definition: elog.c:1072
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
bool allowSystemTableMods
Definition: globals.c:127
int i
Definition: isn.c:73
#define NoLock
Definition: lockdefs.h:34
#define AccessExclusiveLock
Definition: lockdefs.h:43
char * pstrdup(const char *in)
Definition: mcxt.c:1683
Oid GetUserId(void)
Definition: miscinit.c:514
@ CMD_SELECT
Definition: nodes.h:265
ObjectType get_relkind_objtype(char relkind)
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
int errdetail_relkind_not_supported(char relkind)
Definition: pg_class.c:24
#define NAMEDATALEN
#define lfirst_node(type, lc)
Definition: pg_list.h:176
static int list_length(const List *l)
Definition: pg_list.h:152
#define linitial_node(type, l)
Definition: pg_list.h:181
#define NIL
Definition: pg_list.h:68
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
#define PRS2_OLD_VARNO
Definition: primnodes.h:230
#define PRS2_NEW_VARNO
Definition: primnodes.h:231
#define RelationGetDescr(relation)
Definition: rel.h:533
#define RelationGetRelationName(relation)
Definition: rel.h:541
static Oid InsertRule(const char *rulname, int evtype, Oid eventrel_oid, bool evinstead, Node *event_qual, List *action, bool replace)
Definition: rewriteDefine.c:52
static void checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect, bool requireColumnNameMatch)
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
Definition: rewriteManip.c:998
void SetRelationRuleStatus(Oid relationId, bool relHasRules)
#define ViewSelectRuleName
List * returningList
Definition: parsenodes.h:197
CmdType commandType
Definition: parsenodes.h:121
List * targetList
Definition: parsenodes.h:190
RuleLock * rd_rules
Definition: rel.h:115
Form_pg_class rd_rel
Definition: rel.h:111
RewriteRule ** rules
Definition: prs2lock.h:43
int numLocks
Definition: prs2lock.h:42
Definition: localtime.c:73
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:40

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().

◆ DefineRule()

ObjectAddress DefineRule ( RuleStmt stmt,
const char *  queryString 
)

Definition at line 190 of file rewriteDefine.c.

191 {
192  List *actions;
193  Node *whereClause;
194  Oid relId;
195 
196  /* Parse analysis. */
197  transformRuleStmt(stmt, queryString, &actions, &whereClause);
198 
199  /*
200  * Find and lock the relation. Lock level should match
201  * DefineQueryRewrite.
202  */
203  relId = RangeVarGetRelid(stmt->relation, AccessExclusiveLock, false);
204 
205  /* ... and execute */
206  return DefineQueryRewrite(stmt->rulename,
207  relId,
208  whereClause,
209  stmt->event,
210  stmt->instead,
211  stmt->replace,
212  actions);
213 }
#define stmt
Definition: indent_codes.h:59
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Definition: namespace.h:80
void transformRuleStmt(RuleStmt *stmt, const char *queryString, List **actions, Node **whereClause)
ObjectAddress DefineQueryRewrite(const char *rulename, Oid event_relid, Node *event_qual, CmdType event_type, bool is_instead, bool replace, List *action)
Definition: pg_list.h:54
Definition: nodes.h:129

References AccessExclusiveLock, DefineQueryRewrite(), RangeVarGetRelid, stmt, and transformRuleStmt().

Referenced by ProcessUtilitySlow().

◆ EnableDisableRule()

void EnableDisableRule ( Relation  rel,
const char *  rulename,
char  fires_when 
)

Definition at line 691 of file rewriteDefine.c.

693 {
694  Relation pg_rewrite_desc;
695  Oid owningRel = RelationGetRelid(rel);
696  Oid eventRelationOid;
697  HeapTuple ruletup;
698  Form_pg_rewrite ruleform;
699  bool changed = false;
700 
701  /*
702  * Find the rule tuple to change.
703  */
704  pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
705  ruletup = SearchSysCacheCopy2(RULERELNAME,
706  ObjectIdGetDatum(owningRel),
707  PointerGetDatum(rulename));
708  if (!HeapTupleIsValid(ruletup))
709  ereport(ERROR,
710  (errcode(ERRCODE_UNDEFINED_OBJECT),
711  errmsg("rule \"%s\" for relation \"%s\" does not exist",
712  rulename, get_rel_name(owningRel))));
713 
714  ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
715 
716  /*
717  * Verify that the user has appropriate permissions.
718  */
719  eventRelationOid = ruleform->ev_class;
720  Assert(eventRelationOid == owningRel);
721  if (!object_ownercheck(RelationRelationId, eventRelationOid, GetUserId()))
723  get_rel_name(eventRelationOid));
724 
725  /*
726  * Change ev_enabled if it is different from the desired new state.
727  */
728  if (DatumGetChar(ruleform->ev_enabled) !=
729  fires_when)
730  {
731  ruleform->ev_enabled = CharGetDatum(fires_when);
732  CatalogTupleUpdate(pg_rewrite_desc, &ruletup->t_self, ruletup);
733 
734  changed = true;
735  }
736 
737  InvokeObjectPostAlterHook(RewriteRelationId, ruleform->oid, 0);
738 
739  heap_freetuple(ruletup);
740  table_close(pg_rewrite_desc, RowExclusiveLock);
741 
742  /*
743  * If we changed anything, broadcast a SI inval message to force each
744  * backend (including our own!) to rebuild relation's relcache entry.
745  * Otherwise they will fail to apply the change promptly.
746  */
747  if (changed)
749 }
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1434
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define GETSTRUCT(TUP)
Definition: htup_details.h:653
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
Definition: indexing.c:313
void CacheInvalidateRelcache(Relation relation)
Definition: inval.c:1360
Assert(fmt[strlen(fmt) - 1] !='\n')
#define RowExclusiveLock
Definition: lockdefs.h:38
char get_rel_relkind(Oid relid)
Definition: lsyscache.c:1981
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1906
#define InvokeObjectPostAlterHook(classId, objectId, subId)
Definition: objectaccess.h:197
FormData_pg_rewrite * Form_pg_rewrite
Definition: pg_rewrite.h:52
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:252
static char DatumGetChar(Datum X)
Definition: postgres.h:112
static Datum CharGetDatum(char X)
Definition: postgres.h:122
#define RelationGetRelid(relation)
Definition: rel.h:507
ItemPointerData t_self
Definition: htup.h:65
#define SearchSysCacheCopy2(cacheId, key1, key2)
Definition: syscache.h:88

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().

◆ RenameRewriteRule()

ObjectAddress RenameRewriteRule ( RangeVar relation,
const char *  oldName,
const char *  newName 
)

Definition at line 793 of file rewriteDefine.c.

795 {
796  Oid relid;
797  Relation targetrel;
798  Relation pg_rewrite_desc;
799  HeapTuple ruletup;
800  Form_pg_rewrite ruleform;
801  Oid ruleOid;
802  ObjectAddress address;
803 
804  /*
805  * Look up name, check permissions, and acquire lock (which we will NOT
806  * release until end of transaction).
807  */
809  0,
811  NULL);
812 
813  /* Have lock already, so just need to build relcache entry. */
814  targetrel = relation_open(relid, NoLock);
815 
816  /* Prepare to modify pg_rewrite */
817  pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
818 
819  /* Fetch the rule's entry (it had better exist) */
820  ruletup = SearchSysCacheCopy2(RULERELNAME,
821  ObjectIdGetDatum(relid),
822  PointerGetDatum(oldName));
823  if (!HeapTupleIsValid(ruletup))
824  ereport(ERROR,
825  (errcode(ERRCODE_UNDEFINED_OBJECT),
826  errmsg("rule \"%s\" for relation \"%s\" does not exist",
827  oldName, RelationGetRelationName(targetrel))));
828  ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
829  ruleOid = ruleform->oid;
830 
831  /* rule with the new name should not already exist */
832  if (IsDefinedRewriteRule(relid, newName))
833  ereport(ERROR,
835  errmsg("rule \"%s\" for relation \"%s\" already exists",
836  newName, RelationGetRelationName(targetrel))));
837 
838  /*
839  * We disallow renaming ON SELECT rules, because they should always be
840  * named "_RETURN".
841  */
842  if (ruleform->ev_type == CMD_SELECT + '0')
843  ereport(ERROR,
844  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
845  errmsg("renaming an ON SELECT rule is not allowed")));
846 
847  /* OK, do the update */
848  namestrcpy(&(ruleform->rulename), newName);
849 
850  CatalogTupleUpdate(pg_rewrite_desc, &ruletup->t_self, ruletup);
851 
852  InvokeObjectPostAlterHook(RewriteRelationId, ruleOid, 0);
853 
854  heap_freetuple(ruletup);
855  table_close(pg_rewrite_desc, RowExclusiveLock);
856 
857  /*
858  * Invalidate relation's relcache entry so that other backends (and this
859  * one too!) are sent SI message to make them rebuild relcache entries.
860  * (Ideally this should happen automatically...)
861  */
862  CacheInvalidateRelcache(targetrel);
863 
864  ObjectAddressSet(address, RewriteRelationId, ruleOid);
865 
866  /*
867  * Close rel, but keep exclusive lock!
868  */
869  relation_close(targetrel, NoLock);
870 
871  return address;
872 }
void namestrcpy(Name name, const char *str)
Definition: name.c:233
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:426
static void RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid, void *arg)
bool IsDefinedRewriteRule(Oid owningRel, const char *ruleName)
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:205
Relation relation_open(Oid relationId, LOCKMODE lockmode)
Definition: relation.c:47
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:32

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().

◆ setRuleCheckAsUser()

void setRuleCheckAsUser ( Node node,
Oid  userid 
)

Definition at line 631 of file rewriteDefine.c.

632 {
633  (void) setRuleCheckAsUser_walker(node, &userid);
634 }
static bool setRuleCheckAsUser_walker(Node *node, Oid *context)

References setRuleCheckAsUser_walker().

Referenced by get_row_security_policies(), and RelationBuildRuleLock().