postgresql/src/backend/commands
Tom Lane e6dbb48487 Fix subtly-incorrect matching of parent and child partitioned indexes.
When creating a partitioned index, DefineIndex tries to identify
any existing indexes on the partitions that match the partitioned
index, so that it can absorb those as child indexes instead of
building new ones.  Part of the matching is to compare IndexInfo
structs --- but that wasn't done quite right.  We're comparing
the IndexInfo built within DefineIndex itself to one made from
existing catalog contents by BuildIndexInfo.  Notably, while
BuildIndexInfo will run index expressions and predicates through
expression preprocessing, that has not happened to DefineIndex's
struct.  The result is failure to match and subsequent creation
of duplicate indexes.

The easiest and most bulletproof fix is to build a new IndexInfo
using BuildIndexInfo, thereby guaranteeing that the processing done
is identical.

While here, let's also extract the opfamily and collation data
from the new partitioned index, removing ad-hoc logic that
duplicated knowledge about how those are constructed.

Per report from Christophe Pettus.  Back-patch to v11 where
we invented partitioned indexes.

Richard Guo and Tom Lane

Discussion: https://postgr.es/m/8864BFAA-81FD-4BF9-8E06-7DEB8D4164ED@thebuild.com
2022-08-18 12:12:03 -04:00
..
Makefile Move parallel vacuum code to vacuumparallel.c. 2021-12-23 11:42:52 +05:30
aggregatecmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
alter.c Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
amcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
analyze.c Invent qsort_interruptible(). 2022-07-12 16:30:36 -04:00
async.c Revert the addition of GetMaxBackends() and related stuff. 2022-04-12 14:45:23 -04:00
cluster.c Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
collationcmds.c Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
comment.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
constraint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
conversioncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copy.c Reject MERGE in CTEs and COPY 2022-08-12 12:05:50 +02:00
copyfrom.c Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
copyfromparse.c Simplify and clarify an error message 2022-08-18 11:36:55 +02:00
copyto.c Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
createas.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
dbcommands.c Avoid using a fake relcache entry to own an SmgrRelation. 2022-08-12 08:25:41 -04:00
define.c Improve two comments related to a boolean DefElem's value 2022-07-11 11:07:33 +09:00
discard.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dropcmds.c Use list_copy_head() instead of list_truncate(list_copy(...), ...) 2022-07-13 15:03:47 +12:00
event_trigger.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
explain.c Fix formatting and comment typos 2022-08-04 16:41:29 +07:00
extension.c Fix missed corner cases for grantable permissions on GUCs. 2022-07-19 17:21:55 -04:00
foreigncmds.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
functioncmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
indexcmds.c Fix subtly-incorrect matching of parent and child partitioned indexes. 2022-08-18 12:12:03 -04:00
lockcmds.c Add support for security invoker views. 2022-03-22 10:28:10 +00:00
matview.c Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
opclasscmds.c Fix DDL deparse of CREATE OPERATOR CLASS 2022-05-20 18:52:55 +02:00
operatorcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
policy.c Add construct_array_builtin, deconstruct_array_builtin 2022-07-01 11:23:15 +02:00
portalcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
prepare.c Replace many MemSet calls with struct initialization 2022-07-16 08:50:49 +02:00
proclang.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
publicationcmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
schemacmds.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
seclabel.c Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
sequence.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
statscmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
subscriptioncmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
tablecmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
tablespace.c Replace pgwin32_is_junction() with lstat(). 2022-08-06 12:50:59 +12:00
trigger.c Fix ENABLE/DISABLE TRIGGER to handle recursion correctly 2022-08-05 09:47:26 +02:00
tsearchcmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
typecmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
user.c Fix brain fade in e530be2c5c. 2022-07-26 15:12:09 -04:00
vacuum.c Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
vacuumparallel.c Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
variable.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
view.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00