From 668db147d5d20291a67749ee0102d70b81a108e7 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sat, 16 Jun 2001 18:59:31 +0000
Subject: [PATCH] It turns out that the relcache thinks it can distinguish
 different rules and triggers by OID.  So, even though we have no
 cross-references in the system catalogs to pg_rewrite.oid or pg_trigger.oid,
 we'd better have unique indexes on them.  Put back pg_rewrite_oid_index,
 which I mistakenly removed a few days ago, and add pg_trigger_oid_index.

---
 src/backend/catalog/indexing.c   |  6 +++---
 src/include/catalog/catversion.h |  4 ++--
 src/include/catalog/indexing.h   | 10 +++++++---
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index a9e63225800..96d3085f7a6 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.78 2001/06/12 05:55:49 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.79 2001/06/16 18:59:31 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,13 +66,13 @@ char	   *Name_pg_proc_indices[Num_pg_proc_indices] =
 char	   *Name_pg_relcheck_indices[Num_pg_relcheck_indices] =
 {RelCheckIndex};
 char	   *Name_pg_rewrite_indices[Num_pg_rewrite_indices] =
-{RewriteRulenameIndex};
+{RewriteOidIndex, RewriteRulenameIndex};
 char	   *Name_pg_shadow_indices[Num_pg_shadow_indices] =
 {ShadowNameIndex, ShadowSysidIndex};
 char	   *Name_pg_statistic_indices[Num_pg_statistic_indices] =
 {StatisticRelidAttnumIndex};
 char	   *Name_pg_trigger_indices[Num_pg_trigger_indices] =
-{TriggerRelidIndex, TriggerConstrNameIndex, TriggerConstrRelidIndex};
+{TriggerRelidIndex, TriggerConstrNameIndex, TriggerConstrRelidIndex, TriggerOidIndex};
 char	   *Name_pg_type_indices[Num_pg_type_indices] =
 {TypeNameIndex, TypeOidIndex};
 char	   *Name_pg_description_indices[Num_pg_description_indices] =
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 6fcd0f1c1cc..91feaec19e2 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.82 2001/06/12 05:55:50 tgl Exp $
+ * $Id: catversion.h,v 1.83 2001/06/16 18:59:31 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*							yyyymmddN */
-#define CATALOG_VERSION_NO	200106111
+#define CATALOG_VERSION_NO	200106161
 
 #endif
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 496ba4eaa3c..50e4d14a8f9 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.50 2001/06/12 05:55:50 tgl Exp $
+ * $Id: indexing.h,v 1.51 2001/06/16 18:59:31 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -38,10 +38,10 @@
 #define Num_pg_operator_indices		2
 #define Num_pg_proc_indices			2
 #define Num_pg_relcheck_indices		1
-#define Num_pg_rewrite_indices		1
+#define Num_pg_rewrite_indices		2
 #define Num_pg_shadow_indices		2
 #define Num_pg_statistic_indices	1
-#define Num_pg_trigger_indices		3
+#define Num_pg_trigger_indices		4
 #define Num_pg_type_indices			2
 
 /*
@@ -77,6 +77,7 @@
 #define ProcedureNameIndex			"pg_proc_proname_narg_type_index"
 #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 ShadowNameIndex				"pg_shadow_usename_index"
 #define ShadowSysidIndex			"pg_shadow_usesysid_index"
@@ -84,6 +85,7 @@
 #define TriggerConstrNameIndex		"pg_trigger_tgconstrname_index"
 #define TriggerConstrRelidIndex		"pg_trigger_tgconstrrelid_index"
 #define TriggerRelidIndex			"pg_trigger_tgrelid_index"
+#define TriggerOidIndex				"pg_trigger_oid_index"
 #define TypeNameIndex				"pg_type_typname_index"
 #define TypeOidIndex				"pg_type_oid_index"
 
@@ -181,6 +183,7 @@ DECLARE_UNIQUE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_proc_proname_narg_type_index on pg_proc using btree(proname name_ops, pronargs int2_ops, proargtypes oidvector_ops));
 /* 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_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));
@@ -188,6 +191,7 @@ DECLARE_UNIQUE_INDEX(pg_statistic_relid_att_index on pg_statistic using btree(st
 DECLARE_INDEX(pg_trigger_tgconstrname_index on pg_trigger using btree(tgconstrname name_ops));
 DECLARE_INDEX(pg_trigger_tgconstrrelid_index on pg_trigger using btree(tgconstrrelid oid_ops));
 DECLARE_INDEX(pg_trigger_tgrelid_index on pg_trigger using btree(tgrelid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_trigger_oid_index on pg_trigger using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_type_oid_index on pg_type using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_type_typname_index on pg_type using btree(typname name_ops));
 
-- 
GitLab