pgsql: Use generateClonedIndexStmt to propagate CREATE INDEX to partiti
От | Tom Lane |
---|---|
Тема | pgsql: Use generateClonedIndexStmt to propagate CREATE INDEX to partiti |
Дата | |
Msg-id | E1sx9nr-002JlB-EK@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Use generateClonedIndexStmt to propagate CREATE INDEX to partitions. When instantiating an existing partitioned index for a new child partition, we use generateClonedIndexStmt to build a suitable IndexStmt to pass to DefineIndex. However, when DefineIndex needs to recurse to instantiate a newly created partitioned index on an existing child partition, it was doing copyObject on the given IndexStmt and then applying a bunch of ad-hoc fixups. This has a number of problems, primarily that it implies fresh lookups of referenced objects such as opclasses and collations. Since commit 2af07e2f7 caused DefineIndex to restrict search_path internally, those lookups could fail or deliver different results than the original one. We can avoid those problems and save a few dozen lines of code by using generateClonedIndexStmt in this code path too. Another thing this fixes is incorrect propagation of parent-index comments to child indexes (because the copyObject approach copies the idxcomment field while generateClonedIndexStmt doesn't). I had noticed this in connection with commit c01eb619a, but not run the problem to ground. I'm tempted to back-patch this further than v17, but the only thing it's known to fix in older branches is the comment issue, which is pretty minor and doesn't seem worth the risk of introducing new issues in stable branches. (If anyone does care about that, clearing idxcomment in the copied IndexStmt would be a safer fix.) Per bug #18637 from usamoi. Back-patch to v17 where the search_path change came in. Discussion: https://postgr.es/m/18637-f51e314546e3ba2a@postgresql.org Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fee8cb9473462e023dcf0b41212ca3890ddc28d6 Modified Files -------------- contrib/seg/Makefile | 2 +- contrib/seg/expected/partition.out | 54 +++++++++++++++++++++++++++++ contrib/seg/meson.build | 1 + contrib/seg/sql/partition.sql | 36 ++++++++++++++++++++ src/backend/commands/indexcmds.c | 56 ++++++------------------------- src/test/regress/expected/alter_table.out | 5 ++- src/test/regress/sql/alter_table.sql | 2 -- 7 files changed, 105 insertions(+), 51 deletions(-)
В списке pgsql-committers по дате отправления: