Re: partition tree inspection functions - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: partition tree inspection functions
Date
Msg-id 20181009111720.GC1582@paquier.xyz
Whole thread Raw
In response to Re: partition tree inspection functions  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Responses Re: partition tree inspection functions  (Michael Paquier <michael@paquier.xyz>)
Re: partition tree inspection functions  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
List pgsql-hackers
On Tue, Oct 09, 2018 at 07:20:40PM +0900, Amit Langote wrote:
> Sorry if I'm misunderstanding something, but why would we need a new
> clone?  If we don't change pg_partition_tree() to only accept tables
> (regular/partitioned/foreign tables) as input, then the same code can work
> for indexes as well.  As long as we store partition relationship in
> pg_inherits, same code should work for both.

Okay, I see what you are coming at.  However, please note that even if I
can see the dependencies in pg_inherits for indexes, the patch still
needs some work I am afraid if your intention is to do so:
CREATE TABLE ptif_test (a int, b int) PARTITION BY range (a);
create index ptif_test_i on ptif_test (a);
CREATE TABLE ptif_test0 PARTITION OF ptif_test
  FOR VALUES FROM (minvalue) TO (0) PARTITION BY list (b);

=# select relid::regclass, parentrelid::regclass from
     pg_partition_tree('ptif_test'::regclass);
   relid    | parentrelid
------------+-------------
 ptif_test  | null
 ptif_test0 | ptif_test
(2 rows)
=# select relid::regclass, parentrelid::regclass from
     pg_partition_tree('ptif_test_i'::regclass);
    relid    | parentrelid
-------------+-------------
 ptif_test_i | null
(1 row)

In this case I would have expected ptif_test0_a_idx to be listed, with
ptif_test_i as a parent.

isleaf is of course wrong if the input is a partitioned index, so more
regression tests to cover those cases would be nice.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: partition tree inspection functions
Next
From: Michael Paquier
Date:
Subject: Re: Refactor textToQualifiedNameList()