1/*-------------------------------------------------------------------------
4 * routines for removing rewrite rules
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/rewrite/rewriteRemove.c
13 *-------------------------------------------------------------------------
25#include "utils/fmgroids.h"
30 * Guts of rule deletion.
43 * Open the pg_rewrite relation.
48 * Find the tuple for the target rule.
61 elog(
ERROR,
"could not find tuple for rule %u", ruleOid);
64 * We had better grab AccessExclusiveLock to ensure that no queries are
65 * going on that might depend on this rule. (Note: a weaker lock would
66 * suffice if it's not an ON SELECT rule.)
73 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
74 errmsg(
"permission denied: \"%s\" is a system catalog",
78 * Now delete the pg_rewrite tuple for the rule
87 * Issue shared-inval notice to force all backends (including me!) to
88 * update relcache entries with the new rule set.
92 /* Close rel, but keep lock till commit... */
bool IsSystemRelation(Relation relation)
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)
bool allowSystemTableMods
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
void CacheInvalidateRelcache(Relation relation)
#define AccessExclusiveLock
FormData_pg_rewrite * Form_pg_rewrite
static Datum ObjectIdGetDatum(Oid X)
#define RelationGetRelationName(relation)
void RemoveRewriteRuleById(Oid ruleOid)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define BTEqualStrategyNumber
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)