Skip to content

[Bug] ORCA: "bogus index qualification" when a filter on an INCLUDE-only index column is pushed into the index qual #1948

Description

@my-ship-it

Apache Cloudberry version

main branch (recent build)

What happened

With ORCA enabled, a query filtering on a column that is only an INCLUDE column of an index fails at execution time with an internal error:

ERROR:  bogus index qualification (nodeIndexscan.c:1249)

ORCA generates an index scan on bogus_i and pushes c1 into the index qualification (EXPLAIN shows Index Cond: (c1 = true)), but c1 is a non-key INCLUDE column and ExecIndexBuildScanKeys rejects it. Line number is from current main. With optimizer = off the query returns the correct 2 rows.

Found by SQLancer.

What you think should happen instead

The query should return the two rows where c1 is true, with either optimizer.

How to reproduce

CREATE TABLE bogus_t (c0 boolean, c1 boolean);
CREATE INDEX bogus_i ON bogus_t (c0) INCLUDE (c1);
INSERT INTO bogus_t VALUES (true, true), (false, true), (true, false);

SET optimizer = on;
SELECT * FROM bogus_t WHERE c1;
-- ERROR:  bogus index qualification (nodeIndexscan.c:1249)

SET optimizer = off;
SELECT * FROM bogus_t WHERE c1;
-- 2 rows

Operating System

Linux

Anything else

Found while running SQLancer against Cloudberry main (3-segment demo cluster, --enable-cassert). See the proposal to run SQLancer continuously: #1952

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: BugSomething isn't workingtype: Orcaonly orca has the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions