Re: MERGE PARTITIONS and DEPENDS ON EXTENSION. - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: MERGE PARTITIONS and DEPENDS ON EXTENSION.
Date
Msg-id CAPpHfds2NsGvpi4fK-xBDk9S=ZY8FEsG-a3z7m_cRSJhn5GKvQ@mail.gmail.com
Whole thread
In response to Re: MERGE PARTITIONS and DEPENDS ON EXTENSION.  ("Matheus Alcantara" <matheusssilv97@gmail.com>)
Responses Re: MERGE PARTITIONS and DEPENDS ON EXTENSION.
List pgsql-hackers
Hi!

On Tue, Apr 21, 2026 at 4:20 PM Matheus Alcantara
<matheusssilv97@gmail.com> wrote:
> On Mon Apr 20, 2026 at 4:08 PM -03, Alexander Korotkov wrote:
> > On Thu, Apr 16, 2026 at 9:03 PM Matheus Alcantara
> > <matheusssilv97@gmail.com> wrote:
> >>
> >> On Tue Apr 14, 2026 at 6:05 AM -03, Dmitry Koval wrote:
> >> > Hi Matheus!
> >> >
> >> > Thank you for patch.
> >> > I agree that dependency should be automatically added for SPLIT
> >> > PARTITION. But I'm not sure about MERGE PARTITION ...
> >> > Might be it would be more correct to automatically add a dependency only
> >> > if all merged partitions have it?
> >>
> >> Hi,
> >>
> >> Thank you for taking a look on this!
> >>
> >> I agree with your suggestion. The attached patch implements the
> >> intersection behavior for MERGE PARTITIONS: extension dependencies are
> >> only preserved on the merged partition's index if all source partition
> >> indexes have that dependency.
> >>
> >> For example:
> >> MERGE(idx1(ext_a, ext_b), idx2(ext_a)) -> idx3(ext_a)  -- only ext_a is common
> >> MERGE(idx1(ext_a), idx2())             -> idx3()       -- no common deps
> >
> > This is not obvious for me.  I would rather trigger an error if there
> > are different dependencies on merging partitions.
> >
>
> Yeah, I agree that this sounds a bit confusing, although this behavior
> is documented on the last patch version I think that raising an error is
> more simple and maybe is more obvious. The attached patch implement
> this.

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.

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?

------
Regards,
Alexander Korotkov
Supabase



pgsql-hackers by date:

Previous
From: SATYANARAYANA NARLAPURAM
Date:
Subject: [Patch]Add Graph* node support to expression_tree_mutator
Next
From: Ashutosh Bapat
Date:
Subject: Re: Better shared data structure management and resizable shared data structures