On Mon, Aug 3, 2026 at 8:15 PM shveta malik <[email protected]> wrote:
>
> On Mon, Aug 3, 2026 at 2:34 PM Álvaro Herrera <[email protected]> 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)));
>

PSA patch v7, which has the following changes:

1. The wrapped function get_partition_root_guts() is removed. It
previously existed in v6 only to avoid a double validation when called
from the SQL pg_partition_root() function. Now, we chose not to care
about double validation because the inner validation is Assert code,
so it only happens in DEBUG build anyhow.

3. The status validation function check_rel_can_be_partition() is now
common code so that it can be called from all places.

3. Similar validation (checking if relid can be part of a partition
tree) is now also done for the get_partition_ancestors() C function.
(Note: Existing code calls this function with RELKIND_INDEX/
RELKIND_PARTITIONED_INDEX, so the assertion is slightly different)

======
Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment: v7-0001-Add-C-function-get_partition_root.patch
Description: Binary data

Reply via email to