Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzlB9-0005iW-Mp for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2019 16:38:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzlB7-0004KX-AH for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2019 16:38:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzlB6-0004KQ-V5 for pgsql-hackers@lists.postgresql.org; Fri, 01 Mar 2019 16:38:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzlB4-0005yn-FV for pgsql-hackers@postgresql.org; Fri, 01 Mar 2019 16:38:27 +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 x21GcKSY031091; Fri, 1 Mar 2019 11:38:20 -0500 From: Tom Lane To: Michael Paquier cc: Amit Langote , Alvaro Herrera , Stephen Frost , Postgres hackers Subject: Re: pg_partition_tree crashes for a non-defined relation In-reply-to: <20190301075829.GE31098@paquier.xyz> References: <20190228014549.GD1617@paquier.xyz> <20190228193203.GA26151@alvherre.pgsql> <20190301002204.GA1348@paquier.xyz> <10305.1551415816@sss.pgh.pa.us> <20190301075829.GE31098@paquier.xyz> Comments: In-reply-to Michael Paquier message dated "Fri, 01 Mar 2019 16:58:29 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31089.1551458300.1@sss.pgh.pa.us> Date: Fri, 01 Mar 2019 11:38:20 -0500 Message-ID: <31090.1551458300@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier writes: > On Thu, Feb 28, 2019 at 11:50:16PM -0500, Tom Lane wrote: >> But, having said that, we've learned that it's generally bad for >> catalog-query functions to fail outright just because they're pointed >> at the wrong kind of catalog object. So I think that what we want here >> is for pg_partition_tree to return NULL or an empty set or some such >> for a plain table, while its output for a childless partitioned table >> should be visibly different from that. I'm not wedded to details >> beyond that idea. > Yep, that's the intention since cc53123. I won't come back to return > an ERROR in any case. Here is what the patch gives for childless > partitions FWIW: > =# CREATE TABLE ptif_test (a int, b int) PARTITION BY range (a); > CREATE TABLE > =# SELECT * FROM pg_partition_tree('ptif_test'); > relid | parentrelid | isleaf | level > -----------+-------------+--------+------- > ptif_test | null | f | 0 > (1 row) Right, while you'd get zero rows out for a non-partitioned table. WFM. regards, tom lane