/ View Ticket
Login
Ticket UUID: e6f1f2e34dceeb1ed61531c7e98cbac52c84b9b6
Title: REPLACE can insert a default NULL into a NOT NULL column
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2018-12-22 01:13:33
Version Found In: 3.26.0
User Comments:
drh added on 2018-12-22 00:10:51:

The REPLACE statement is able to put a NULL value into a NOT NULL column. If the DEFAULT value for a NOT NULL column is NULL, and if you try to insert a NULL, then the inserted NULL is detected and the "REPLACE" algorithm kicks in and substitutes the default value. But if the default is also NULL, the second NULL is never detected. For example:

CREATE TABLE t1(x NOT NULL DEFAULT NULL);
REPLACE INTO t1 DEFAULT VALUES;
SELECT quote(x) FROM t1;

This bug has existed in the code since before SQLite version 3.1.0 (2005-01-21). The problem was detected by the Chromium developers using a fuzzer.