SQLite

View Ticket
Login
Ticket Hash: a0e88d8d7a462552d5a521df669d5a5ac12083ad
Title: Inconsistent handling of subqueries in index expressions
Status: Closed Type: Feature_Request
Severity: Minor Priority: Low
Subsystem: Unknown Resolution: Wont_Fix
Last Modified: 2019-12-31 13:55:54
Version Found In: 3.30
User Comments:
mrigger added on 2019-12-30 21:32:36:

Consider the following test case:

CREATE TABLE t0(c0);
CREATE INDEX i0 ON t0((0 AND (SELECT 1))); -- unexpected: no error
ALTER TABLE t0 RENAME COLUMN c0 TO c1; -- error in index i0: subqueries prohibited in index expressions

The test case demonstrates that the error reporting for subqueries in index expression is inconsistent. The CREATE INDEX succeeds, while an error for the subquery is raised by the ALTER TABLE. I would expect that either both raise an error, or allow the subquery.


drh added on 2019-12-30 23:40:15:

This happens because "0 AND anything" gets converted into just "0" by the parser, long before the code ever reaches semantic analysis.

I don't think this is something we want to fix, because it would be a performance reduction and a complexity increase, all of the sake of "consistent error messages". However, I will take the suggestion under advisement...


mrigger added on 2019-12-31 10:12:19:

In this case, it's probably not worth to further pursue this. In practice, the chances that someone relies on an error message in this case is probably minuscule.