SQLite

View Ticket
Login
2019-08-15
14:35 Fixed ticket [e4598ecb]: Division by zero in the query planner. plus 5 other changes (artifact: b83367a9 user: drh)
14:35
Ensure that the optional "sz=N" parameter that can be manually added to the end of an sqlite_stat1 entry does not have an N value that is too small. Ticket [e4598ecbdd18bd82] (check-in: 98357d8c user: drh tags: trunk)
14:28 New ticket [e4598ecb] Division by zero in the query planner.. (artifact: d93508fc user: drh)

Ticket Hash: e4598ecbdd18bd82945f6029013296690e719a62
Title: Division by zero in the query planner.
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-08-15 14:35:55
Version Found In: 3.29.0
User Comments:
drh added on 2019-08-15 14:28:04:

The following SQL causes a division by zero in the query planner:

ANALYZE;
CREATE TABLE t1(a PRIMARY KEY);
INSERT INTO sqlite_stat1 VALUES('t1',null,'sz=0');
ANALYZE sqlite_master;
SELECT 0 FROM t1 WHERE a IN(1,2,3);

The problem is the sz=0 parameter on the sqlite_stat1 entry for the t1 table. The value of sz needs to be 2 or greater, and this is not enforced. The problem was introduced by check-in [90e36676476e8db0] on 2014-04-30 and first appeared in version 3.8.5.

This problem was reported on the SQLite mailing list by Xingwei Lin.