Re: Bug: When user-defined AM is used, the index path cannot be selected correctly

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Quan Zongliang <quanzongliang@yeah.net>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-09-01T21:22:29Z
Lists: pgsql-hackers

Attachments

I wrote:
> I think we need something more like the attached.

Meh -- serves me right for not doing check-world before sending.
The patch causes some plans to change in the btree_gin and btree_gist
modules; which is good, because that shows that the patch is actually
doing what it's supposed to.  The fact that your patch didn't make
the cfbot unhappy implies that it wasn't triggering for those modules.
I think the reason is that you did

+        ((amid) >= FirstNormalObjectId && \
+                OidIsValid(GetDefaultOpClass(BOOLOID, (amid)))) \

so that the FirstNormalObjectId cutoff was applied to the AM's OID,
not to the opfamily OID, causing it to do the wrong thing for
extension opclasses over built-in AMs.

The good news is this means we don't need to worry about making
a test case ...

			regards, tom lane

Commits

  1. Fix planner to consider matches to boolean columns in extension indexes.