Skip to content

Expression index with correlated EXISTS subquery causes panic #5551

@LeMikaelF

Description

@LeMikaelF

Description

An expression index combined with a correlated EXISTS subquery causes the planner to fail resolving column references through the expression index.

Reproducer

CREATE TABLE t(b, c);
CREATE UNIQUE INDEX idx ON t(c, c + b);
SELECT c + b FROM t WHERE EXISTS (SELECT 1 FROM t AS t2 WHERE t.b = t2.b);
-- Turso:  PANIC
-- SQLite: (works correctly)

Panic Message

thread 'main' panicked at core/translate/expr.rs:2642:41:
index idx does not contain column number 0 of table t1

core/translate/expr.rs:2642 - The planner tries to resolve column references through the expression index but fails when a correlated subquery references columns not directly in the index.


This issue brought to you by Mikaël and Claude Code.

Metadata

Metadata

Labels

indexespanicsqlrightbugs found using SQLRight (https://github.com/PSU-Security-Universe/sqlright)Ï

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions