From d12280d05fdebd2f35478badc4ce2ea804be8ffe Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Wed, 8 Jul 2015 18:27:30 -0300
Subject: [PATCH 05/24] relcache: don't consider nonzero pg_class.relam as an
 index

Right now, only indexes have the "relam" field set to a value different
from zero.  Once we introduce other kinds of access methods, that's no
longer the case.  In the one test that currently only checks for relam,
add a test for relkind also.  (Without this, creating a different kind
of relation with nonzero relam causes weird failures that the pg_index
row cannot be found).
---
 src/backend/utils/cache/relcache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 44e9509..5ca4e2f6 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -1051,7 +1051,8 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
 	/*
 	 * if it's an index, initialize index-related information
 	 */
-	if (OidIsValid(relation->rd_rel->relam))
+	if (relation->rd_rel->relkind == RELKIND_INDEX &&
+		OidIsValid(relation->rd_rel->relam))
 		RelationInitIndexAccessInfo(relation);
 
 	/* extract reloptions if any */
-- 
2.1.4

