Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug] INCLUDE (non-key) index column referenced by a predicate is treated as valid

Aperta
#2,126 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, postgresql
Ambito
databases

Direzione di ricerca

The bug is in GPORCA's construction of index conditions, and the issue suspects CXformUtils::PdrgpcrIndexColumns, which merges key and INCLUDE columns into one array. Reproduce the two SELECT statements with optimizer on and compare against optimizer off, then check which Index Cond the plan builds and where nodeIndexscan.c rejects it. Done means both queries return rows under optimizer=on without either sanity-check error. The issue reports an unmerged local fix but does not name a target design, so confirm the expected behaviour with maintainers first.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

type: Bug
Apache Cloudberry version

No response

What happened

A GPORCA bug: an INCLUDE (non-key) index column referenced by a predicate is treated as a valid
index key column when building an Index Cond (likely via CXformUtils::PdrgpcrIndexColumns, which
concatenates key and included columns into one array with no marker distinguishing the two). The
resulting plan carries a scan key against an attribute beyond indnkeyatts, which the executor
rejects. Which sanity check fires depends on the predicate, so one bug produces two error
messages -- both are suppressed below:

CREATE TABLE t(a int, b ); CREATE INDEX i ON t USING btree (a) INCLUDE (b);
SET optimizer = on;
SELECT a FROM t WHERE b; -- b boolean: "bogus index qualification (nodeIndexscan.c)"
SELECT a FROM t WHERE b IS NULL; -- b int: "btree index keys must be ordered by attribute"

Verified scope: optimizer=on only (the Postgres planner never builds such an Index Cond, and
every case above returns the correct rows under optimizer=off); not specific to a distribution
policy (DISTRIBUTED BY and DISTRIBUTED REPLICATED both reproduce); needs no data, an empty table
is enough; and the INCLUDE list does not have to overlap the key columns -- a plain
"INCLUDE (b)" is sufficient. A fix exists locally but has not been merged into the Cloudberry
main branch this environment is built from.

What you think should happen instead

No response

How to reproduce
CREATE TABLE t(a int, b int); CREATE INDEX i ON t USING btree (a) INCLUDE (b);
SET optimizer = on;
SELECT a FROM t WHERE b IS NULL; -- b int: "btree index keys must be ordered by attribute"
Operating System

any

Anything else

No response

Are you willing to submit PR?
  • Yes, I am willing to submit a PR!
Code of Conduct
Lingua principale
C
Stelle
1.4k
Fork
260
Merge medio
4g 13h
PR unite (30g)
56

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/cloudberry

Tutte le issue di apache/cloudberry

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.