Re: MERGE PARTITIONS and DEPENDS ON EXTENSION.

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: MERGE PARTITIONS and DEPENDS ON EXTENSION.
Date: 2026-04-22 10:48:18
Message-ID: CALdSSPi9GE8jnLCA4aUP2F5_ax6W9Ccfh_ja0iY6wkX2uUyzDw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 22 Apr 2026 at 00:35, Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
>
> On Tue, Apr 21, 2026 at 10:23 PM Matheus Alcantara
> <matheusssilv97(at)gmail(dot)com> wrote:
> > On 21/04/26 12:57, Alexander Korotkov wrote:
> > > I've spotted the following things in this patch.
> > > 1) The equality of dependencies is not fully checked. We only check
> > > that for each new dependency, we have the same for previous partition,
> > > but not vise versa.
> > > 2) The complexity of dependency checking is O(n^2).
> > > 3) Usage of citext and other extensions in src/test/regress where they
> > > might be not available.
> > >
> >
> > Oops, I forgot to replace the citext extension on split partition tests.
> >
> > > I've revised the patch.
> > > 1) collectPartitionIndexExtDeps() is rewritten(). Now it works in
> > > three phases: collect, sort, compare. The comparison phase requires
> > > strict equivalence of dependencies and doesn't depend on the order.
> > > The complexity is now O(n * log(n)), which I think is acceptable.
> > > 2) PartitionIndexExtDepEntry struct now have indexOid. So, on
> > > conflict error contains both partition index names.
> > > 3) Tests moved to
> > > src/test/modules/test_extensions/sql/test_extdepend.sql where
> > > test_ext3/test_ext5 extensions are available.
> > > 4) More tests for different scenarios.
> > >
> > > Could you, please, review this changes?
> > >
> >
> > I think that you miss to include the patch?
>
> Yep, here it is.
>
> ------
> Regards,
> Alexander Korotkov
> Supabase

Hi!
So, we only transfer dependencies on partitioned indexes when
SPLIT/MERGE partitions, not tables themselves (this is what this
thread started from).
I think this is correct.

Some minor comments:

> +-- Sanity check: the extension can't be dropped while dependencies exist.
>+DROP EXTENSION test_ext3;

This exercises something that already works on HEAD (note this is DROP
before first MERGE partition call ). Do we really need this?

>
> +-- An index created directly on a partition has no parent in the partitioned
> +-- index tree; merge must ignore such indexes (they disappear with the old
> +-- partition).
> +CREATE INDEX part_extdep_3_extra_idx ON part_extdep_3(x);
> +ALTER TABLE part_extdep MERGE PARTITIONS (part_extdep_merged, part_extdep_3)
> + INTO part_extdep_merged2;
> +SELECT relname FROM pg_class
> +WHERE relname LIKE 'part_extdep_merged2%idx' ORDER BY relname;

Looks like this test is also redundant? This does not test new DEPENDS ON logic.

Otherwise LGTM

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matheus Alcantara 2026-04-22 10:53:04 Re: MERGE PARTITIONS and DEPENDS ON EXTENSION.
Previous Message Sami Imseih 2026-04-22 10:33:09 Re: [PATCH] Fix: Partitioned parent index remains invalid after child indexes are repaired