Re: MERGE PARTITIONS and DEPENDS ON EXTENSION.

From: "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com>
To: "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-16 18:03:11
Message-ID: DHURZGPYE4B4.2XG5GT4TQ72U4@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

For SPLIT PARTITION, the behavior remains the same since there's only
one source partition, all its extension dependencies are copied to the
new partition indexes.

While working on this patch, I noticed what might be a separate bug (or
perhaps intentional behavior that I don't understand): extension
dependencies on parent partitioned indexes don't seem to prevent DROP
EXTENSION, but dependencies on child partition indexes do. See this
example:

CREATE EXTENSION IF NOT EXISTS btree_gist;

CREATE TABLE t (i int) PARTITION BY RANGE (i);
CREATE TABLE t_1 PARTITION OF t FOR VALUES FROM (1) TO (2);
CREATE INDEX t_idx ON t USING gist (i);

-- Add dependency on the PARENT partitioned index
ALTER INDEX t_idx DEPENDS ON EXTENSION btree_gist;

-- This succeeds (I expected it to fail):
DROP EXTENSION btree_gist;

But if I add the dependency on the child partition index instead:

ALTER INDEX t_1_i_idx DEPENDS ON EXTENSION btree_gist;

DROP EXTENSION btree_gist;
ERROR: cannot drop extension btree_gist because other objects depend on it
DETAIL: index t_idx depends on operator class gist_int4_ops for access method gist

Is this expected behavior, or a separate bug? I would have expected the
dependency on the parent index to also prevent the DROP.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

Attachment Content-Type Size
v3-0001-Preserve-extension-dependencies-on-indexes-during.patch text/plain 29.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2026-04-16 20:21:35 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Previous Message Tom Lane 2026-04-16 17:47:05 Re: Reduce build times of pg_trgm GIN indexes