agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index 6+ messages / 1 participants [nested] [flat]
* pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index @ 2026-04-22 01:35 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2026-04-22 01:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index This commit tweaks ALTER INDEX .. ATTACH PARTITION to attempt a validation of a parent index in the case where an index is already attached but the parent is not yet valid. This occurs in cases where a parent index was created invalid such as with CREATE INDEX ONLY, but was left invalid after an invalid child index was attached (partitioned indexes set indisvalid to false if at least one partition is !indisvalid, indisvalid is true in a partitioned table iff all partitions are indisvalid). This could leave a partition tree in a situation where a user could not bring the parent index back to valid after fixing the child index, as there is no built-in mechanism to do so. This commit relies on the fact that repeated ATTACH PARTITION commands on the same index silently succeed. An invalid parent index is more than just a passive issue. It causes for example ON CONFLICT on a partitioned table if the invalid parent index is used to enforce a unique constraint. Some test cases are added to track some of problematic patterns, using a set of partition trees with combinations of invalid indexes and ATTACH PARTITION. Reported-by: Mohamed Ali <moali.pg@gmail.com> Author: Sami Imseih <sanmimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Haibo Yan <tristan.yim@gmail.com> Discussion: http://postgr.es/m/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com Backpatch-through: 14 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9d3e094f12cce57a477c3df92f411b2fae816b60 Modified Files -------------- src/backend/commands/tablecmds.c | 13 +++- src/test/regress/expected/indexing.out | 105 +++++++++++++++++++++++++++++++++ src/test/regress/sql/indexing.sql | 59 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index @ 2026-04-22 01:35 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2026-04-22 01:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index This commit tweaks ALTER INDEX .. ATTACH PARTITION to attempt a validation of a parent index in the case where an index is already attached but the parent is not yet valid. This occurs in cases where a parent index was created invalid such as with CREATE INDEX ONLY, but was left invalid after an invalid child index was attached (partitioned indexes set indisvalid to false if at least one partition is !indisvalid, indisvalid is true in a partitioned table iff all partitions are indisvalid). This could leave a partition tree in a situation where a user could not bring the parent index back to valid after fixing the child index, as there is no built-in mechanism to do so. This commit relies on the fact that repeated ATTACH PARTITION commands on the same index silently succeed. An invalid parent index is more than just a passive issue. It causes for example ON CONFLICT on a partitioned table if the invalid parent index is used to enforce a unique constraint. Some test cases are added to track some of problematic patterns, using a set of partition trees with combinations of invalid indexes and ATTACH PARTITION. Reported-by: Mohamed Ali <moali.pg@gmail.com> Author: Sami Imseih <sanmimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Haibo Yan <tristan.yim@gmail.com> Discussion: http://postgr.es/m/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5713ac248f266c689d93999aacd318d9f7f9daec Modified Files -------------- src/backend/commands/tablecmds.c | 13 +++- src/test/regress/expected/indexing.out | 105 +++++++++++++++++++++++++++++++++ src/test/regress/sql/indexing.sql | 59 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index @ 2026-04-22 01:35 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2026-04-22 01:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index This commit tweaks ALTER INDEX .. ATTACH PARTITION to attempt a validation of a parent index in the case where an index is already attached but the parent is not yet valid. This occurs in cases where a parent index was created invalid such as with CREATE INDEX ONLY, but was left invalid after an invalid child index was attached (partitioned indexes set indisvalid to false if at least one partition is !indisvalid, indisvalid is true in a partitioned table iff all partitions are indisvalid). This could leave a partition tree in a situation where a user could not bring the parent index back to valid after fixing the child index, as there is no built-in mechanism to do so. This commit relies on the fact that repeated ATTACH PARTITION commands on the same index silently succeed. An invalid parent index is more than just a passive issue. It causes for example ON CONFLICT on a partitioned table if the invalid parent index is used to enforce a unique constraint. Some test cases are added to track some of problematic patterns, using a set of partition trees with combinations of invalid indexes and ATTACH PARTITION. Reported-by: Mohamed Ali <moali.pg@gmail.com> Author: Sami Imseih <sanmimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Haibo Yan <tristan.yim@gmail.com> Discussion: http://postgr.es/m/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d809b16d1bd21ff708126ef111ddfee0fc477dbf Modified Files -------------- src/backend/commands/tablecmds.c | 13 +++- src/test/regress/expected/indexing.out | 105 +++++++++++++++++++++++++++++++++ src/test/regress/sql/indexing.sql | 59 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index @ 2026-04-22 01:35 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2026-04-22 01:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index This commit tweaks ALTER INDEX .. ATTACH PARTITION to attempt a validation of a parent index in the case where an index is already attached but the parent is not yet valid. This occurs in cases where a parent index was created invalid such as with CREATE INDEX ONLY, but was left invalid after an invalid child index was attached (partitioned indexes set indisvalid to false if at least one partition is !indisvalid, indisvalid is true in a partitioned table iff all partitions are indisvalid). This could leave a partition tree in a situation where a user could not bring the parent index back to valid after fixing the child index, as there is no built-in mechanism to do so. This commit relies on the fact that repeated ATTACH PARTITION commands on the same index silently succeed. An invalid parent index is more than just a passive issue. It causes for example ON CONFLICT on a partitioned table if the invalid parent index is used to enforce a unique constraint. Some test cases are added to track some of problematic patterns, using a set of partition trees with combinations of invalid indexes and ATTACH PARTITION. Reported-by: Mohamed Ali <moali.pg@gmail.com> Author: Sami Imseih <sanmimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Haibo Yan <tristan.yim@gmail.com> Discussion: http://postgr.es/m/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/becf6d26961aabe26facebee2604ef5def9733e5 Modified Files -------------- src/backend/commands/tablecmds.c | 13 +++- src/test/regress/expected/indexing.out | 105 +++++++++++++++++++++++++++++++++ src/test/regress/sql/indexing.sql | 59 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index @ 2026-04-22 01:35 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2026-04-22 01:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index This commit tweaks ALTER INDEX .. ATTACH PARTITION to attempt a validation of a parent index in the case where an index is already attached but the parent is not yet valid. This occurs in cases where a parent index was created invalid such as with CREATE INDEX ONLY, but was left invalid after an invalid child index was attached (partitioned indexes set indisvalid to false if at least one partition is !indisvalid, indisvalid is true in a partitioned table iff all partitions are indisvalid). This could leave a partition tree in a situation where a user could not bring the parent index back to valid after fixing the child index, as there is no built-in mechanism to do so. This commit relies on the fact that repeated ATTACH PARTITION commands on the same index silently succeed. An invalid parent index is more than just a passive issue. It causes for example ON CONFLICT on a partitioned table if the invalid parent index is used to enforce a unique constraint. Some test cases are added to track some of problematic patterns, using a set of partition trees with combinations of invalid indexes and ATTACH PARTITION. Reported-by: Mohamed Ali <moali.pg@gmail.com> Author: Sami Imseih <sanmimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Haibo Yan <tristan.yim@gmail.com> Discussion: http://postgr.es/m/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0859000d0d7195738b1c52e430b25fc72642cd73 Modified Files -------------- src/backend/commands/tablecmds.c | 13 +++- src/test/regress/expected/indexing.out | 105 +++++++++++++++++++++++++++++++++ src/test/regress/sql/indexing.sql | 59 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index @ 2026-04-22 01:35 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2026-04-22 01:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index This commit tweaks ALTER INDEX .. ATTACH PARTITION to attempt a validation of a parent index in the case where an index is already attached but the parent is not yet valid. This occurs in cases where a parent index was created invalid such as with CREATE INDEX ONLY, but was left invalid after an invalid child index was attached (partitioned indexes set indisvalid to false if at least one partition is !indisvalid, indisvalid is true in a partitioned table iff all partitions are indisvalid). This could leave a partition tree in a situation where a user could not bring the parent index back to valid after fixing the child index, as there is no built-in mechanism to do so. This commit relies on the fact that repeated ATTACH PARTITION commands on the same index silently succeed. An invalid parent index is more than just a passive issue. It causes for example ON CONFLICT on a partitioned table if the invalid parent index is used to enforce a unique constraint. Some test cases are added to track some of problematic patterns, using a set of partition trees with combinations of invalid indexes and ATTACH PARTITION. Reported-by: Mohamed Ali <moali.pg@gmail.com> Author: Sami Imseih <sanmimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Haibo Yan <tristan.yim@gmail.com> Discussion: http://postgr.es/m/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/313355d68016a4c83bcbcb16a743dc7a8e54f8a1 Modified Files -------------- src/backend/commands/tablecmds.c | 13 +++- src/test/regress/expected/indexing.out | 105 +++++++++++++++++++++++++++++++++ src/test/regress/sql/indexing.sql | 59 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2026-04-22 01:35 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-04-22 01:35 pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index Michael Paquier <michael@paquier.xyz> 2026-04-22 01:35 pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index Michael Paquier <michael@paquier.xyz> 2026-04-22 01:35 pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index Michael Paquier <michael@paquier.xyz> 2026-04-22 01:35 pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index Michael Paquier <michael@paquier.xyz> 2026-04-22 01:35 pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index Michael Paquier <michael@paquier.xyz> 2026-04-22 01:35 pgsql: Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index Michael Paquier <michael@paquier.xyz>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox