Re: A new C function `get_partition_root`. - Mailing list pgsql-hackers

From shveta malik
Subject Re: A new C function `get_partition_root`.
Date
Msg-id CAJpy0uDNznTQFk1siP4FwzbaYzfnYeVOodVEvjpa0a1obqrsYQ@mail.gmail.com
Whole thread
In response to Re: A new C function `get_partition_root`.  (Álvaro Herrera <alvherre@kurilemu.de>)
List pgsql-hackers
On Mon, Aug 3, 2026 at 2:34 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
> Hi,
>
> I'd say this looks okay, but why do you need get_partition_root_guts()
> exposed in partition.h?  In fact, it's not clear to me why you need a
> second routine at all.  Why isn't enough to have just get_partition_root()?
>

I think to avoid performing the validation twice in
pg_partition_root(): first via check_rel_can_be_partition(), and then
again in get_partition_root (see [1]), get_partition_root_guts() is
introduced and exposed in partition.h.

[1]:
+ /* Validate relid is member of a partition tree */
+ Assert(get_rel_relispartition(relid) ||
+    RELKIND_HAS_PARTITIONS(get_rel_relkind(relid)));

thanks
Shveta



pgsql-hackers by date:

Previous
From: "Yilin Zhang"
Date:
Subject: Re: [PATCH] Add NESTED_STATEMENTS option to EXPLAIN
Next
From: Kirill Reshke
Date:
Subject: Re: GIN pageinspect support for entry tree and posting tree