Re: pg_partition_tree crashes for a non-defined relation
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>,
Alvaro Herrera <alvherre@2ndquadrant.com>,
Stephen Frost <sfrost@snowman.net>,
Postgres hackers <pgsql-hackers@postgresql.org>
Date: 2019-03-01T16:38:20Z
Lists: pgsql-hackers
Michael Paquier <michael@paquier.xyz> 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
Commits
-
Test partition functions with legacy inheritance children, too
- d12fbe2f8e5d 12.0 landed
-
Consider only relations part of partition trees in partition functions
- 3422955735d9 12.0 landed
-
Make pg_partition_tree return no rows on unsupported and undefined objects
- 0f3cdf873e7d 12.0 landed
-
Tweak pg_partition_tree for undefined relations and unsupported relkinds
- cc53123bcc9d 12.0 landed