pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix subtly-incorrect matching of parent and child partitioned in
Date: Thu, 18 Aug 2022 16:12:20 +0000
Message-ID: <E1oOi83-0008Lh-Ot@gemulon.postgresql.org> (raw)

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

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9f0073ef7dac2837c45e7960d1157d4a69046b3c

Modified Files
--------------
src/backend/commands/indexcmds.c       | 23 ++++++++----
src/test/regress/expected/indexing.out | 66 +++++++++++++++++++++++++++++++++-
src/test/regress/sql/indexing.sql      | 15 +++++++-
3 files changed, 96 insertions(+), 8 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1oOi83-0008Lh-Ot@gemulon.postgresql.org>
Permalink:  ../E1oOi83-0008Lh-Ot@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oOi83-0008Lh-Ot@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix subtly-incorrect matching of parent and child partitioned in
  In-Reply-To: <E1oOi83-0008Lh-Ot@gemulon.postgresql.org>
  References: <E1oOi83-0008Lh-Ot@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox