I think this is the right fix for this problem.  I wonder about
exploring other callers of RelationGetIndexList to see who else could be
confused ...

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 53506fd3a9f0cb81334024bf5a0e8856fd8e5e82 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvhe...@alvh.no-ip.org>
Date: Wed, 24 Jan 2018 14:40:26 -0300
Subject: [PATCH] Ignore partitioned indexes in get_relation_info

---
 src/backend/optimizer/util/plancat.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/backend/optimizer/util/plancat.c 
b/src/backend/optimizer/util/plancat.c
index 8c60b35068..60f21711f4 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -208,6 +208,16 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, 
bool inhparent,
                        }
 
                        /*
+                        * Ignore partitioned indexes, since they are not 
usable for
+                        * queries.
+                        */
+                       if (indexRelation->rd_rel->relkind == 
RELKIND_PARTITIONED_INDEX)
+                       {
+                               index_close(indexRelation, NoLock);
+                               continue;
+                       }
+
+                       /*
                         * If the index is valid, but cannot yet be used, 
ignore it; but
                         * mark the plan we are generating as transient. See
                         * src/backend/access/heap/README.HOT for discussion.
-- 
2.11.0

Reply via email to