From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Postgres hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Subject: | Add pg_partition_root to get top-most parent of a partition tree |
Date: | 2018-12-07 01:40:15 |
Message-ID: | 20181207014015.GP2407@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
Álvaro has given faced a use case where it would be useful to have a
function which is able to return the top-most parent of a partition
tree:
https://postgr.es/m/20181204184159.eue3wlchqrkh4vsc@alvherre.pgsql
This has been mentioned as well on the thread where was discussed
pg_partition_tree, but it got shaved from the committed patch as many
things happened when discussing the thing.
Attached is a patch to do the work, which includes documentation and
tests. An argument could be made to include the top-most parent as part
of pg_partition_tree, but it feels more natural to me to have a separate
function. This makes sure to handle invalid relations by returning
NULL, and it generates an error for incorrect relkind.
I have included as well a fix for the recent crash on pg_partition_tree
I have reported, but let's discuss the crash on its thread here:
https://www.postgresql.org/message-id/20181207010406.GO2407@paquier.xyz
The bug fix would most likely get committed first, and I'll rebase this
patch as need be.
I am adding this patch to the CF of January. I think that Amit should
also be marked as a co-author of this patch, as that's inspired from
what has been submitted previously, still I have no reused the code.
Thanks,
--
Michael
Attachment | Content-Type | Size |
---|---|---|
partition-root-v1.patch | text/x-diff | 13.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2018-12-07 01:48:59 | Re: Add pg_partition_root to get top-most parent of a partition tree |
Previous Message | Michael Paquier | 2018-12-07 01:04:06 | pg_partition_tree crashes for a non-defined relation |