Skip to content

Apply the WHERE clause in SHOW INDEX - #4293

Open
aliassar wants to merge 1 commit into
dolthub:mainfrom
aliassar:fix-show-index-where
Open

aliassar wants to merge 1 commit into
dolthub:mainfrom
aliassar:fix-show-index-where

Conversation

@aliassar

@aliassar aliassar commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Fixes dolthub/dolt#12794

SHOW {INDEX | INDEXES | KEYS} FROM t WHERE ... ignored the WHERE: the parser keeps it in ShowIndexFilterOpt, but buildShowIndex never read it, so every index came back. Prepared statements with a ? in that WHERE failed with "invalid arguments. expected: 0, found: 1", because the placeholder was never built.

buildShowIndex now puts the result columns in scope and wraps the node in a Filter, the same way SHOW COLUMNS and SHOW TABLE STATUS do. Virtual column scans are turned back on before the filter is built, as in buildShowAllColumns.

Tests: new InfoSchemaQueries cases on mytable (several indexes, a match on a multi-column index, no match, a compound predicate) and a db-qualified one on foo.othertable, plus a PreparedScriptTests script for PREPARE ... WHERE Key_name = ? and for protocol-level bindings, which is how Drupal's Schema::indexExists() calls it (#3707). All of them fail on main and pass with this change. Also drops the two SkipPrepared flags in create_table_queries.go that were only there because of this.

SHOW {INDEX | INDEXES | KEYS} FROM t WHERE ... ignored its WHERE clause and
returned every index, and a bind variable in that clause failed to prepare.
Build the filter the same way the other SHOW statements do.

Fixes dolthub/dolt#12794

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SHOW INDEX FROM t WHERE Key_name = ... returns every index

1 participant