SQLite

View Ticket
Login
Ticket Hash: ec8abb025e78f40cd94532cf86270e62ba49df79
Title: Debug assertion sqlite3BtreeInsert: Assertion `pCur->curFlags & BTCF_ValidNKey' failed
Status: Fixed Type: Code_Defect
Severity: Minor Priority: Low
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-12-29 00:56:15
Version Found In: 3.30.0
User Comments:
mrigger added on 2019-12-26 18:50:46: (text/x-fossil-wiki)
Consider the following test case:

<pre>
CREATE TABLE t0(c0 UNIQUE AS(0), c1, c2);
INSERT INTO t0(c1) VALUES(0);
UPDATE t0 SET c1 = 0, c2 = 0 WHERE(c0) >= 0; -- sqlite3.c:72305: sqlite3BtreeInsert: Assertion `pCur->curFlags & BTCF_ValidNKey' failed.
</pre>

When compiling with -DSQLITE_DEBUG, the UPDATE triggers an assertion error.

drh added on 2019-12-29 00:56:15: (text/x-fossil-wiki)
Other ways of provoking this problem:

<blockquote><verbatim>
CREATE TABLE t1(a TEXT, b INTEGER PRIMARY KEY UNIQUE); 
INSERT INTO t1 VALUES(1,2);
UPDATE t1 SET a = quote(b) WHERE b>=2;
</verbatim></blockquote>

The redundant UNIQUE on the PRIMARY KEY is required for the problem
to occur.

Also:

<blockquote><verbatim>
CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
CREATE INDEX t1x1 ON t1(a+25);
INSERT INTO t1(a,b) VALUES(75,33);
UPDATE t1 SET b=1 WHERE a+25=100;
</verbatim></blockquote>