Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5dGE-0005TS-Ci for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Sep 2018 20:51:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5dGC-0004VD-9z for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Sep 2018 20:51:44 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5dGB-0004V4-Vg for pgsql-hackers@lists.postgresql.org; Thu, 27 Sep 2018 20:51:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5dG9-0001Kn-3O for pgsql-hackers@postgresql.org; Thu, 27 Sep 2018 20:51:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w8RKpdC9023038; Thu, 27 Sep 2018 16:51:39 -0400 From: Tom Lane To: Justin Pryzby cc: pgsql-hackers@postgresql.org, Alvaro Herrera Subject: Re: \d+ fails on index on partition In-reply-to: <20180927200020.GJ776@telsasoft.com> References: <20180927200020.GJ776@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Thu, 27 Sep 2018 15:00:20 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23036.1538081499.1@sss.pgh.pa.us> Date: Thu, 27 Sep 2018 16:51:39 -0400 Message-ID: <23037.1538081499@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby writes: > pg_get_partition_constraintdef() doesn't like being passed a relkind='I', It'll also fall over if the passed OID isn't a relation at all, which is also very much not-nice for SQL-exposed inquiry functions. I'm inclined to fix this by (1) inventing an lsyscache function to fetch relispartition, which will have the behavior of returning false for a lookup failure (which is generally consistent with the behavior of most of the other lsyscache functions). (2) replace the if (rel->rd_rel->relispartition) check in get_partition_qual_relid with a test like if (get_rel_relispartition(relid)), and don't open the Relation at all unless that succeeds. regards, tom lane