Re: indxpath.c's references to IndexOptInfo.ncolumns are all wrong, no?

Peter Geoghegan <pg@bowt.ie>

From: Peter Geoghegan <pg@bowt.ie>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-02-11T01:35:04Z
Lists: pgsql-hackers
On Sun, Feb 10, 2019 at 5:18 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Apparently, whoever went through indxpath.c to substitute nkeycolumns
> for ncolumns was not paying attention.  As far as I can tell, the
> *only* place in there where it's correct to reference ncolumns is in
> check_index_only, where we determine which columns can be extracted from
> an index-only scan.

Ugh. Yeah, it's rather inconsistent.

> I've got mixed feelings about whether to try to fix this before
> tomorrow's wraps.  The attached patch seems correct and passes
> check-world, but there's sure not a lot of margin for error now.
> Thoughts?

I think that it should be fixed in the next point release if at all
possible. The bug is a simple omission. I have a hard time imagining
how your patch could possibly destabilize things, since nkeycolumns is
already used in numerous other places in indxpath.c.

-- 
Peter Geoghegan


Commits

  1. Clean up planner confusion between ncolumns and nkeycolumns.

  2. Fix indexable-row-comparison logic to account for covering indexes.