summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-04-18 20:01:11 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-04-18 20:01:11 +0000
commitb3120804ad1692322a6d905b352df7fa0d7cdd80 (patch)
tree93aaf632df82db20e63c952be8a6fd1e4ec15629 /src/include
parent4e08a625b006ba3992be881b516773adba5863e4 (diff)
downloadpostgresql-b3120804ad1692322a6d905b352df7fa0d7cdd80.tar.gz
Rule names are now unique per-relation, rather than unique globally.
DROP RULE and COMMENT ON RULE syntax adds an 'ON tablename' clause, similar to TRIGGER syntaxes. To allow loading of existing pg_dump files containing COMMENT ON RULE, the COMMENT code will still accept the old syntax --- but only if the target rulename is unique across the whole database.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/indexing.h6
-rw-r--r--src/include/catalog/pg_proc.h8
-rw-r--r--src/include/catalog/pg_rewrite.h13
-rw-r--r--src/include/nodes/nodes.h4
-rw-r--r--src/include/nodes/parsenodes.h35
-rw-r--r--src/include/rewrite/rewriteDefine.h5
-rw-r--r--src/include/rewrite/rewriteRemove.h4
-rw-r--r--src/include/rewrite/rewriteSupport.h4
-rw-r--r--src/include/utils/builtins.h3
-rw-r--r--src/include/utils/syscache.h4
11 files changed, 54 insertions, 36 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 492c3e9b3f..4d6742fdbd 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.117 2002/04/17 20:57:56 tgl Exp $
+ * $Id: catversion.h,v 1.118 2002/04/18 20:01:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200204171
+#define CATALOG_VERSION_NO 200204181
#endif
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index b2b3f1f39c..e08e3aa8e9 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: indexing.h,v 1.64 2002/04/17 20:57:56 tgl Exp $
+ * $Id: indexing.h,v 1.65 2002/04/18 20:01:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -80,7 +80,7 @@
#define ProcedureOidIndex "pg_proc_oid_index"
#define RelCheckIndex "pg_relcheck_rcrelid_index"
#define RewriteOidIndex "pg_rewrite_oid_index"
-#define RewriteRulenameIndex "pg_rewrite_rulename_index"
+#define RewriteRelRulenameIndex "pg_rewrite_rel_rulename_index"
#define ShadowNameIndex "pg_shadow_usename_index"
#define ShadowSysidIndex "pg_shadow_usesysid_index"
#define StatisticRelidAttnumIndex "pg_statistic_relid_att_index"
@@ -178,7 +178,7 @@ DECLARE_UNIQUE_INDEX(pg_proc_proname_args_nsp_index on pg_proc using btree(prona
/* This following index is not used for a cache and is not unique */
DECLARE_INDEX(pg_relcheck_rcrelid_index on pg_relcheck using btree(rcrelid oid_ops));
DECLARE_UNIQUE_INDEX(pg_rewrite_oid_index on pg_rewrite using btree(oid oid_ops));
-DECLARE_UNIQUE_INDEX(pg_rewrite_rulename_index on pg_rewrite using btree(rulename name_ops));
+DECLARE_UNIQUE_INDEX(pg_rewrite_rel_rulename_index on pg_rewrite using btree(ev_class oid_ops, rulename name_ops));
DECLARE_UNIQUE_INDEX(pg_shadow_usename_index on pg_shadow using btree(usename name_ops));
DECLARE_UNIQUE_INDEX(pg_shadow_usesysid_index on pg_shadow using btree(usesysid int4_ops));
DECLARE_UNIQUE_INDEX(pg_statistic_relid_att_index on pg_statistic using btree(starelid oid_ops, staattnum int2_ops));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index a7f77f1f7d..f8863d9340 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.227 2002/04/11 20:00:12 tgl Exp $
+ * $Id: pg_proc.h,v 1.228 2002/04/18 20:01:10 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2150,9 +2150,11 @@ DATA(insert OID = 1639 ( oidge PGNSP PGUID 12 f t f t f i 2 16 "26 26" 10
DESCR("greater-than-or-equal");
/* System-view support functions */
-DATA(insert OID = 1640 ( pg_get_ruledef PGNSP PGUID 12 f t f t f s 1 25 "19" 100 0 0 100 pg_get_ruledef - _null_ ));
+DATA(insert OID = 1573 ( pg_get_ruledef PGNSP PGUID 12 f t f t f s 1 25 "26" 100 0 0 100 pg_get_ruledef - _null_ ));
DESCR("source text of a rule");
-DATA(insert OID = 1641 ( pg_get_viewdef PGNSP PGUID 12 f t f t f s 1 25 "19" 100 0 0 100 pg_get_viewdef - _null_ ));
+DATA(insert OID = 1640 ( pg_get_viewdef PGNSP PGUID 12 f t f t f s 1 25 "25" 100 0 0 100 pg_get_viewdef_name - _null_ ));
+DESCR("select statement of a view");
+DATA(insert OID = 1641 ( pg_get_viewdef PGNSP PGUID 12 f t f t f s 1 25 "26" 100 0 0 100 pg_get_viewdef - _null_ ));
DESCR("select statement of a view");
DATA(insert OID = 1642 ( pg_get_userbyid PGNSP PGUID 12 f t f t f s 1 19 "23" 100 0 0 100 pg_get_userbyid - _null_ ));
DESCR("user name by UID (with fallback)");
diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h
index 46b73bc083..00b0eb2974 100644
--- a/src/include/catalog/pg_rewrite.h
+++ b/src/include/catalog/pg_rewrite.h
@@ -4,11 +4,14 @@
* definition of the system "rewrite-rule" relation (pg_rewrite)
* along with the relation's initial contents.
*
+ * As of Postgres 7.3, the primary key for this table is <ev_class, rulename>
+ * --- ie, rule names are only unique among the rules of a given table.
+ *
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_rewrite.h,v 1.17 2001/11/05 17:46:32 momjian Exp $
+ * $Id: pg_rewrite.h,v 1.18 2002/04/18 20:01:11 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -34,9 +37,9 @@
CATALOG(pg_rewrite)
{
NameData rulename;
- char ev_type;
Oid ev_class;
int2 ev_attr;
+ char ev_type;
bool is_instead;
/* NB: remaining fields must be accessed via heap_getattr */
@@ -57,9 +60,9 @@ typedef FormData_pg_rewrite *Form_pg_rewrite;
*/
#define Natts_pg_rewrite 7
#define Anum_pg_rewrite_rulename 1
-#define Anum_pg_rewrite_ev_type 2
-#define Anum_pg_rewrite_ev_class 3
-#define Anum_pg_rewrite_ev_attr 4
+#define Anum_pg_rewrite_ev_class 2
+#define Anum_pg_rewrite_ev_attr 3
+#define Anum_pg_rewrite_ev_type 4
#define Anum_pg_rewrite_is_instead 5
#define Anum_pg_rewrite_ev_qual 6
#define Anum_pg_rewrite_ev_action 7
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index ff03eb1228..1664e76900 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodes.h,v 1.104 2002/04/05 11:56:54 momjian Exp $
+ * $Id: nodes.h,v 1.105 2002/04/18 20:01:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -181,7 +181,7 @@ typedef enum NodeTag
T_VariableShowStmt,
T_VariableResetStmt,
T_CreateTrigStmt,
- T_DropTrigStmt,
+ T_DropPropertyStmt,
T_CreatePLangStmt,
T_DropPLangStmt,
T_CreateUserStmt,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index ba9ed9aa8d..dc2eabb5b2 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.171 2002/04/17 20:57:57 tgl Exp $
+ * $Id: parsenodes.h,v 1.172 2002/04/18 20:01:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -940,13 +940,6 @@ typedef struct CreateTrigStmt
RangeVar *constrrel; /* opposite relation */
} CreateTrigStmt;
-typedef struct DropTrigStmt
-{
- NodeTag type;
- char *trigname; /* TRIGGER' name */
- RangeVar *relation; /* triggered relation */
-} DropTrigStmt;
-
/* ----------------------
* Create/Drop PROCEDURAL LANGUAGE Statement
* ----------------------
@@ -1060,7 +1053,7 @@ typedef struct CreateDomainStmt
} CreateDomainStmt;
/* ----------------------
- * Drop Table|Sequence|View|Index|Rule|Type Statement
+ * Drop Table|Sequence|View|Index|Type|Domain Statement
* ----------------------
*/
@@ -1068,9 +1061,8 @@ typedef struct CreateDomainStmt
#define DROP_SEQUENCE 2
#define DROP_VIEW 3
#define DROP_INDEX 4
-#define DROP_RULE 5
-#define DROP_TYPE 6
-#define DROP_DOMAIN 7
+#define DROP_TYPE 5
+#define DROP_DOMAIN 6
typedef struct DropStmt
{
@@ -1081,6 +1073,25 @@ typedef struct DropStmt
} DropStmt;
/* ----------------------
+ * Drop Rule|Trigger Statement
+ *
+ * In general this may be used for dropping any property of a relation;
+ * for example, someday soon we may have DROP ATTRIBUTE.
+ * ----------------------
+ */
+
+#define DROP_RULE 100
+#define DROP_TRIGGER 101
+
+typedef struct DropPropertyStmt
+{
+ NodeTag type;
+ RangeVar *relation; /* owning relation */
+ char *property; /* name of rule, trigger, etc */
+ int removeType;
+} DropPropertyStmt;
+
+/* ----------------------
* Truncate Table Statement
* ----------------------
*/
diff --git a/src/include/rewrite/rewriteDefine.h b/src/include/rewrite/rewriteDefine.h
index a9f7792a61..4bf20a2ca7 100644
--- a/src/include/rewrite/rewriteDefine.h
+++ b/src/include/rewrite/rewriteDefine.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteDefine.h,v 1.13 2001/11/05 17:46:35 momjian Exp $
+ * $Id: rewriteDefine.h,v 1.14 2002/04/18 20:01:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,6 +18,7 @@
extern void DefineQueryRewrite(RuleStmt *args);
-extern void RenameRewriteRule(char *oldname, char *newname);
+extern void RenameRewriteRule(Oid owningRel, const char *oldName,
+ const char *newName);
#endif /* REWRITEDEFINE_H */
diff --git a/src/include/rewrite/rewriteRemove.h b/src/include/rewrite/rewriteRemove.h
index ac79e6c919..3aa4cbdf53 100644
--- a/src/include/rewrite/rewriteRemove.h
+++ b/src/include/rewrite/rewriteRemove.h
@@ -7,14 +7,14 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteRemove.h,v 1.12 2002/03/29 19:06:26 tgl Exp $
+ * $Id: rewriteRemove.h,v 1.13 2002/04/18 20:01:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef REWRITEREMOVE_H
#define REWRITEREMOVE_H
-extern void RemoveRewriteRule(List *names);
+extern void RemoveRewriteRule(Oid owningRel, const char *ruleName);
extern void RelationRemoveRules(Oid relid);
#endif /* REWRITEREMOVE_H */
diff --git a/src/include/rewrite/rewriteSupport.h b/src/include/rewrite/rewriteSupport.h
index 6f955d6eea..7453dd9958 100644
--- a/src/include/rewrite/rewriteSupport.h
+++ b/src/include/rewrite/rewriteSupport.h
@@ -7,14 +7,14 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rewriteSupport.h,v 1.20 2001/11/05 17:46:35 momjian Exp $
+ * $Id: rewriteSupport.h,v 1.21 2002/04/18 20:01:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef REWRITESUPPORT_H
#define REWRITESUPPORT_H
-extern bool IsDefinedRewriteRule(const char *ruleName);
+extern bool IsDefinedRewriteRule(Oid owningRel, const char *ruleName);
extern char *MakeRetrieveViewRuleName(const char *view_name);
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index b38f4429cb..caa2c57102 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: builtins.h,v 1.176 2002/04/11 20:00:17 tgl Exp $
+ * $Id: builtins.h,v 1.177 2002/04/18 20:01:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -337,6 +337,7 @@ extern Datum regproctooid(PG_FUNCTION_ARGS);
/* ruleutils.c */
extern Datum pg_get_ruledef(PG_FUNCTION_ARGS);
extern Datum pg_get_viewdef(PG_FUNCTION_ARGS);
+extern Datum pg_get_viewdef_name(PG_FUNCTION_ARGS);
extern Datum pg_get_indexdef(PG_FUNCTION_ARGS);
extern Datum pg_get_userbyid(PG_FUNCTION_ARGS);
extern Datum pg_get_expr(PG_FUNCTION_ARGS);
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index dbe50b37be..a5282a9753 100644
--- a/src/include/utils/syscache.h
+++ b/src/include/utils/syscache.h
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: syscache.h,v 1.46 2002/04/17 20:57:57 tgl Exp $
+ * $Id: syscache.h,v 1.47 2002/04/18 20:01:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -52,7 +52,7 @@
#define PROCOID 21
#define RELNAMENSP 22
#define RELOID 23
-#define RULENAME 24
+#define RULERELNAME 24
#define SHADOWNAME 25
#define SHADOWSYSID 26
#define STATRELATT 27