From d2c86a1ccd17145eeed2377ff7930e2ccbf5869e Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Thu, 14 Jun 2012 09:47:30 -0400
Subject: [PATCH] Remove RELKIND_UNCATALOGED.

This may have been important at some point in the past, but it no
longer does anything useful.

Review by Tom Lane.
---
 contrib/pgstattuple/pgstattuple.c      | 1 -
 src/backend/access/common/reloptions.c | 1 -
 src/backend/catalog/dependency.c       | 4 ----
 src/backend/catalog/heap.c             | 4 ++--
 src/backend/catalog/index.c            | 1 -
 src/backend/catalog/toasting.c         | 4 +---
 src/backend/commands/indexcmds.c       | 4 +---
 src/backend/utils/cache/relcache.c     | 5 +++--
 src/include/catalog/pg_class.h         | 1 -
 src/include/utils/relcache.h           | 3 ++-
 10 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c
index 2b62b785063..8d4fd8b0c9e 100644
--- a/contrib/pgstattuple/pgstattuple.c
+++ b/contrib/pgstattuple/pgstattuple.c
@@ -217,7 +217,6 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
 	{
 		case RELKIND_RELATION:
 		case RELKIND_TOASTVALUE:
-		case RELKIND_UNCATALOGED:
 		case RELKIND_SEQUENCE:
 			return pgstat_heap(rel, fcinfo);
 		case RELKIND_INDEX:
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 607a80d7d4a..1eeaadecffe 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -790,7 +790,6 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, Oid amoptions)
 		case RELKIND_RELATION:
 		case RELKIND_TOASTVALUE:
 		case RELKIND_VIEW:
-		case RELKIND_UNCATALOGED:
 			options = heap_reloptions(classForm->relkind, datum, false);
 			break;
 		case RELKIND_INDEX:
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index d4e1f76f315..98ce5981c11 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -2968,10 +2968,6 @@ getRelationDescription(StringInfo buffer, Oid relid)
 			appendStringInfo(buffer, _("sequence %s"),
 							 relname);
 			break;
-		case RELKIND_UNCATALOGED:
-			appendStringInfo(buffer, _("uncataloged table %s"),
-							 relname);
-			break;
 		case RELKIND_TOASTVALUE:
 			appendStringInfo(buffer, _("toast table %s"),
 							 relname);
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 49e76446993..c959a469fd6 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -327,7 +327,8 @@ heap_create(const char *relname,
 									 reltablespace,
 									 shared_relation,
 									 mapped_relation,
-									 relpersistence);
+									 relpersistence,
+									 relkind);
 
 	/*
 	 * Have the storage manager create the relation's disk file, if needed.
@@ -889,7 +890,6 @@ AddNewRelationTuple(Relation pg_class_desc,
 	new_rel_reltup->relowner = relowner;
 	new_rel_reltup->reltype = new_type_oid;
 	new_rel_reltup->reloftype = reloftype;
-	new_rel_reltup->relkind = relkind;
 
 	new_rel_desc->rd_att->tdtypeid = new_type_oid;
 
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 9e8b1cc49bc..89d346886d4 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -836,7 +836,6 @@ index_create(Relation heapRelation,
 	 */
 	indexRelation->rd_rel->relowner = heapRelation->rd_rel->relowner;
 	indexRelation->rd_rel->relam = accessMethodObjectId;
-	indexRelation->rd_rel->relkind = RELKIND_INDEX;
 	indexRelation->rd_rel->relhasoids = false;
 
 	/*
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 707ba7e2837..1feffd25efa 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -84,9 +84,7 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
 
 	rel = heap_openrv(makeRangeVar(NULL, relName, -1), AccessExclusiveLock);
 
-	/* Note: during bootstrap may see uncataloged relation */
-	if (rel->rd_rel->relkind != RELKIND_RELATION &&
-		rel->rd_rel->relkind != RELKIND_UNCATALOGED)
+	if (rel->rd_rel->relkind != RELKIND_RELATION)
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a table",
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index a68d500e5b4..1f9bf618904 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -378,9 +378,7 @@ DefineIndex(RangeVar *heapRelation,
 	relationId = RelationGetRelid(rel);
 	namespaceId = RelationGetNamespace(rel);
 
-	/* Note: during bootstrap may see uncataloged relation */
-	if (rel->rd_rel->relkind != RELKIND_RELATION &&
-		rel->rd_rel->relkind != RELKIND_UNCATALOGED)
+	if (rel->rd_rel->relkind != RELKIND_RELATION)
 	{
 		if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
 
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 4cbf812ed59..2e6776e78f7 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2409,7 +2409,8 @@ RelationBuildLocalRelation(const char *relname,
 						   Oid reltablespace,
 						   bool shared_relation,
 						   bool mapped_relation,
-						   char relpersistence)
+						   char relpersistence,
+						   char relkind)
 {
 	Relation	rel;
 	MemoryContext oldcxt;
@@ -2515,7 +2516,7 @@ RelationBuildLocalRelation(const char *relname,
 	namestrcpy(&rel->rd_rel->relname, relname);
 	rel->rd_rel->relnamespace = relnamespace;
 
-	rel->rd_rel->relkind = RELKIND_UNCATALOGED;
+	rel->rd_rel->relkind = relkind;
 	rel->rd_rel->relhasoids = rel->rd_att->tdhasoid;
 	rel->rd_rel->relnatts = natts;
 	rel->rd_rel->reltype = InvalidOid;
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index 1567206a7e0..a3307b44337 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -147,7 +147,6 @@ DESCR("");
 #define		  RELKIND_VIEW			  'v'		/* view */
 #define		  RELKIND_COMPOSITE_TYPE  'c'		/* composite type */
 #define		  RELKIND_FOREIGN_TABLE   'f'		/* foreign table */
-#define		  RELKIND_UNCATALOGED	  'u'		/* not yet cataloged */
 
 #define		  RELPERSISTENCE_PERMANENT	'p'		/* regular table */
 #define		  RELPERSISTENCE_UNLOGGED	'u'		/* unlogged permanent table */
diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h
index 2f39486c974..abbc9ca16ab 100644
--- a/src/include/utils/relcache.h
+++ b/src/include/utils/relcache.h
@@ -70,7 +70,8 @@ extern Relation RelationBuildLocalRelation(const char *relname,
 						   Oid reltablespace,
 						   bool shared_relation,
 						   bool mapped_relation,
-						   char relpersistence);
+						   char relpersistence,
+						   char relkind);
 
 /*
  * Routine to manage assignment of new relfilenode to a relation
-- 
GitLab