-
Notifications
You must be signed in to change notification settings - Fork 748
Labels
correctnessindexesnot-for-botsqlrightbugs found using SQLRight (https://github.com/PSU-Security-Universe/sqlright)Ïbugs found using SQLRight (https://github.com/PSU-Security-Universe/sqlright)Ï
Description
Description
BETWEEN expressions in expression index columns are accepted at CREATE INDEX time but cause an error on INSERT. The SELECT path works correctly but the INSERT path fails to rewrite the BETWEEN expression.
Reproducer
CREATE TABLE t(a INTEGER, b INTEGER);
CREATE INDEX idx ON t(a BETWEEN 1 AND 10);
INSERT INTO t VALUES(5, 5);
-- Turso: Parse error: BETWEEN expression should have been rewritten in optmizer
-- SQLite: succeeds, inserts rowError Message
Parse error: BETWEEN expression should have been rewritten in optmizer
core/translate/index.rs - validate_index_expression has a _ => {} catch-all that lets Expr::Between through at CREATE INDEX time. On INSERT, rewrite_index_expr_for_insertion does not call rewrite_between_expr, so translate_expr hits the BETWEEN case and bails. The SELECT path (emit_index_column_value_from_cursor) uses bind_and_rewrite_expr which does rewrite BETWEEN correctly.
This issue brought to you by Mikaël and Claude Code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
correctnessindexesnot-for-botsqlrightbugs found using SQLRight (https://github.com/PSU-Security-Universe/sqlright)Ïbugs found using SQLRight (https://github.com/PSU-Security-Universe/sqlright)Ï