Re: = TRUE vs IS TRUE confuses partition index creation
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Christophe Pettus <xof@thebuild.com>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2022-08-17T07:16:00Z
Lists: pgsql-bugs
On Wed, Aug 17, 2022 at 12:27 PM Richard Guo <guofenglinux@gmail.com> wrote: > > On Wed, Aug 17, 2022 at 5:57 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > >> IIRC, "b = true" will be simplified to just "b" somewhere in expression >> preprocessing. I'm betting that something in the partitioned index >> matching code is applying that preprocessing to one index predicate and >> not the other, whereupon they look different. If that's the explanation, >> there are likely other cases that should match and fail to. > > > Yeah, you're right. The matching work happens in indexcmds.c, using > CompareIndexInfo to compare 'cldIdxInfo' and 'indexInfo'. The > 'cldIdxInfo' is constructed with BuildIndexInfo, which would run index > expressions and index predicates through const-simplification before > creating the IndexInfo node. While 'indexInfo' is created without any > const-simplification. > > This can be verified with the attached changes, which would make it work > for this case. > BTW, I searched other callers of CompareIndexInfo and they all have both IndexInfo nodes to be compared constructed from BuildIndexInfo, which means both nodes have applied const-simplification to their index expressions and index predicates. So those callers are fine. Thanks Richard
Commits
-
Fix subtly-incorrect matching of parent and child partitioned indexes.
- e6dbb48487fa 16.0 landed
- 2a42c1c51d15 15.0 landed
- 9f0073ef7dac 13.9 landed
- 3bfea5cbba98 14.6 landed
- 2cf16cd7497d 12.13 landed
- 116f20f92656 11.18 landed