SQLite

View Ticket
Login
Ticket Hash: 51f5b6e4270230a39be0dbf221ca9646d3597dc1
Title: Short-circuit evaluation issue
Status: Closed Type: Feature_Request
Severity: Minor Priority: Immediate
Subsystem: Unknown Resolution: Wont_Fix
Last Modified: 2019-08-29 12:54:37
Version Found In: 3.29.0
User Comments:
mrigger added on 2019-08-28 21:11:44:

In the following test case, the integer overflow error is unexpected:

CREATE TABLE t0 (c0);
INSERT INTO t0(c0) VALUES (-9223372036854775808);
SELECT FALSE AND ABS(t0.c0) FROM t0; -- unexpected: integer overflow

I would expect that short-circuit evaluation is applied, which is the case when using the expression in the WHERE clause:

SELECT * FROM t0 WHERE FALSE AND ABS(t0.c0); -- expected: no error


drh added on 2019-08-29 12:54:37:

Neither SQL nor SQLite require nor disallow short-circuit evaluation. The query planner is free to choose short-circuit evaluation or not, as it sees fit.