Preserve extension dependencies on indexes during partition merge/split When using ALTER TABLE ... MERGE PARTITIONS or ALTER TABLE ... SPLIT PARTITION, extension dependencies on partition indexes were being lost. This happened because the new partition indexes are created fresh from the parent partitioned table's indexes, while the old partition indexes (with their extension dependencies) are dropped.
Fix this by collecting extension dependencies from source partition indexes before detaching them, then applying those dependencies to the corresponding new partition indexes after they're created. The mapping between old and new indexes is done via their common parent partitioned index. For MERGE operations, all source partition indexes sharing a parent partitioned index must have the same extension dependencies; if they differ, an error naming both conflicting partition indexes is raised. The check is implemented by collecting one entry per partition index, sorting by parent index OID, and comparing adjacent entries in a single pass. This is order-independent: the same set of partitions produces the same decision regardless of the order they are listed in the MERGE command, and subset mismatches are caught in both directions. For SPLIT operations, the new partition indexes simply inherit all extension dependencies from the source partition's index. The regression tests exercising this feature live under src/test/modules/test_extensions, where the test_ext3 and test_ext5 extensions are available; core regression tests cannot assume any particular extension is installed. Author: Matheus Alcantara <[email protected]> Co-authored-by: Alexander Korotkov <[email protected]> Reported-by: Kirill Reshke <[email protected]> Reviewed-by: Dmitry Koval <[email protected]> Discussion: https://www.postgresql.org/message-id/CALdSSPjXtzGM7Uk4fWRwRMXcCczge5uNirPQcYCHKPAWPkp9iQ%40mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/713e553e3213d53f4ba25dcb7a8c41994b7cab9d Modified Files -------------- doc/src/sgml/ref/alter_table.sgml | 17 ++ src/backend/commands/tablecmds.c | 283 +++++++++++++++++++++ .../test_extensions/expected/test_extdepend.out | 120 +++++++++ .../modules/test_extensions/sql/test_extdepend.sql | 104 ++++++++ src/tools/pgindent/typedefs.list | 1 + 5 files changed, 525 insertions(+)
