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 231 of file rewriteDefine.c.

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

198 {
199  List *actions;
200  Node *whereClause;
201  Oid relId;
202 
203  /* Parse analysis. */
204  transformRuleStmt(stmt, queryString, &actions, &whereClause);
205 
206  /*
207  * Find and lock the relation. Lock level should match
208  * DefineQueryRewrite.
209  */
210  relId = RangeVarGetRelid(stmt->relation, AccessExclusiveLock, false);
211 
212  /* ... and execute */
213  return DefineQueryRewrite(stmt->rulename,
214  relId,
215  whereClause,
216  stmt->event,
217  stmt->instead,
218  stmt->replace,
219  actions);
220 }
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Definition: namespace.h:79
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
char * rulename
Definition: parsenodes.h:3325
bool instead
Definition: parsenodes.h:3328
RangeVar * relation
Definition: parsenodes.h:3324
bool replace
Definition: parsenodes.h:3330
CmdType event
Definition: parsenodes.h:3327

References AccessExclusiveLock, DefineQueryRewrite(), RuleStmt::event, RuleStmt::instead, RangeVarGetRelid, RuleStmt::relation, RuleStmt::replace, RuleStmt::rulename, and transformRuleStmt().

Referenced by ProcessUtilitySlow().

◆ EnableDisableRule()

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

Definition at line 698 of file rewriteDefine.c.

700 {
701  Relation pg_rewrite_desc;
702  Oid owningRel = RelationGetRelid(rel);
703  Oid eventRelationOid;
704  HeapTuple ruletup;
705  Form_pg_rewrite ruleform;
706  bool changed = false;
707 
708  /*
709  * Find the rule tuple to change.
710  */
711  pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
713  ObjectIdGetDatum(owningRel),
714  PointerGetDatum(rulename));
715  if (!HeapTupleIsValid(ruletup))
716  ereport(ERROR,
717  (errcode(ERRCODE_UNDEFINED_OBJECT),
718  errmsg("rule \"%s\" for relation \"%s\" does not exist",
719  rulename, get_rel_name(owningRel))));
720 
721  ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
722 
723  /*
724  * Verify that the user has appropriate permissions.
725  */
726  eventRelationOid = ruleform->ev_class;
727  Assert(eventRelationOid == owningRel);
728  if (!object_ownercheck(RelationRelationId, eventRelationOid, GetUserId()))
730  get_rel_name(eventRelationOid));
731 
732  /*
733  * Change ev_enabled if it is different from the desired new state.
734  */
735  if (DatumGetChar(ruleform->ev_enabled) !=
736  fires_when)
737  {
738  ruleform->ev_enabled = CharGetDatum(fires_when);
739  CatalogTupleUpdate(pg_rewrite_desc, &ruletup->t_self, ruletup);
740 
741  changed = true;
742  }
743 
744  InvokeObjectPostAlterHook(RewriteRelationId, ruleform->oid, 0);
745 
746  heap_freetuple(ruletup);
747  table_close(pg_rewrite_desc, RowExclusiveLock);
748 
749  /*
750  * If we changed anything, broadcast a SI inval message to force each
751  * backend (including our own!) to rebuild relation's relcache entry.
752  * Otherwise they will fail to apply the change promptly.
753  */
754  if (changed)
756 }
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
#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:301
void CacheInvalidateRelcache(Relation relation)
Definition: inval.c:1363
Assert(fmt[strlen(fmt) - 1] !='\n')
#define RowExclusiveLock
Definition: lockdefs.h:38
char get_rel_relkind(Oid relid)
Definition: lsyscache.c:1985
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1910
#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:501
ItemPointerData t_self
Definition: htup.h:65
#define SearchSysCacheCopy2(cacheId, key1, key2)
Definition: syscache.h:181
@ RULERELNAME
Definition: syscache.h:92

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, RULERELNAME, 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 800 of file rewriteDefine.c.

802 {
803  Oid relid;
804  Relation targetrel;
805  Relation pg_rewrite_desc;
806  HeapTuple ruletup;
807  Form_pg_rewrite ruleform;
808  Oid ruleOid;
809  ObjectAddress address;
810 
811  /*
812  * Look up name, check permissions, and acquire lock (which we will NOT
813  * release until end of transaction).
814  */
816  0,
818  NULL);
819 
820  /* Have lock already, so just need to build relcache entry. */
821  targetrel = relation_open(relid, NoLock);
822 
823  /* Prepare to modify pg_rewrite */
824  pg_rewrite_desc = table_open(RewriteRelationId, RowExclusiveLock);
825 
826  /* Fetch the rule's entry (it had better exist) */
828  ObjectIdGetDatum(relid),
829  PointerGetDatum(oldName));
830  if (!HeapTupleIsValid(ruletup))
831  ereport(ERROR,
832  (errcode(ERRCODE_UNDEFINED_OBJECT),
833  errmsg("rule \"%s\" for relation \"%s\" does not exist",
834  oldName, RelationGetRelationName(targetrel))));
835  ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
836  ruleOid = ruleform->oid;
837 
838  /* rule with the new name should not already exist */
839  if (IsDefinedRewriteRule(relid, newName))
840  ereport(ERROR,
842  errmsg("rule \"%s\" for relation \"%s\" already exists",
843  newName, RelationGetRelationName(targetrel))));
844 
845  /*
846  * We disallow renaming ON SELECT rules, because they should always be
847  * named "_RETURN".
848  */
849  if (ruleform->ev_type == CMD_SELECT + '0')
850  ereport(ERROR,
851  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
852  errmsg("renaming an ON SELECT rule is not allowed")));
853 
854  /* OK, do the update */
855  namestrcpy(&(ruleform->rulename), newName);
856 
857  CatalogTupleUpdate(pg_rewrite_desc, &ruletup->t_self, ruletup);
858 
859  InvokeObjectPostAlterHook(RewriteRelationId, ruleOid, 0);
860 
861  heap_freetuple(ruletup);
862  table_close(pg_rewrite_desc, RowExclusiveLock);
863 
864  /*
865  * Invalidate relation's relcache entry so that other backends (and this
866  * one too!) are sent SI message to make them rebuild relcache entries.
867  * (Ideally this should happen automatically...)
868  */
869  CacheInvalidateRelcache(targetrel);
870 
871  ObjectAddressSet(address, RewriteRelationId, ruleOid);
872 
873  /*
874  * Close rel, but keep exclusive lock!
875  */
876  relation_close(targetrel, NoLock);
877 
878  return address;
879 }
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:239
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:206
Relation relation_open(Oid relationId, LOCKMODE lockmode)
Definition: relation.c:48
#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, RULERELNAME, SearchSysCacheCopy2, HeapTupleData::t_self, table_close(), and table_open().

Referenced by ExecRenameStmt().

◆ setRuleCheckAsUser()

void setRuleCheckAsUser ( Node node,
Oid  userid 
)

Definition at line 638 of file rewriteDefine.c.

639 {
640  (void) setRuleCheckAsUser_walker(node, &userid);
641 }
static bool setRuleCheckAsUser_walker(Node *node, Oid *context)

References setRuleCheckAsUser_walker().

Referenced by get_row_security_policies(), and RelationBuildRuleLock().