So it happens _before_ the update or replace? That is weird indeed.

Using "indexed by" still returns 2 rows from the index, but integrity check 
reports 1 missing, so I'm curious as to what part of the integrity got broken.



SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.

sqlite> create table t1 (c0, c1 real primary key);
QUERY PLAN
`--SEARCH TABLE sqlite_master USING INTEGER PRIMARY KEY (rowid=?)

sqlite> insert into t1 (c0, c1) values (0, 9223372036854775807), (0, 0);
QUERY PLAN
`--SCAN 2 CONSTANT ROWS

sqlite> select * from t1;
QUERY PLAN
`--SCAN TABLE t1
c0|c1
0|9.22337203685478e+18
0|0.0

sqlite> select c1 from t1 indexed by sqlite_autoindex_t1_1;
QUERY PLAN
`--SCAN TABLE t1 USING COVERING INDEX sqlite_autoindex_t1_1
c1
0.0
9.22337203685478e+18

sqlite> pragma integrity_check;
integrity_check
ok

sqlite> update t1 set c0 = null;
QUERY PLAN
`--SCAN TABLE t1

sqlite> select * from t1;
QUERY PLAN
`--SCAN TABLE t1
c0|c1
|9.22337203685478e+18
|0.0

sqlite> select c1 from t1 indexed by sqlite_autoindex_t1_1;
QUERY PLAN
`--SCAN TABLE t1 USING COVERING INDEX sqlite_autoindex_t1_1
c1
0.0
9.22337203685478e+18

sqlite> pragma integrity_check;
integrity_check
row 1 missing from index sqlite_autoindex_t1_1

sqlite>



-----Original Message-----
From: sqlite-users [mailto:[email protected]] On 
Behalf Of Richard Hipp
Sent: Thursday, May 09, 2019 11:08 AM
To: SQLite mailing list
Subject: Re: [sqlite] Series of statements results in a malformed database disk 
image

On 5/9/19, Manuel Rigger <[email protected]> wrote:
>
> I discovered a sequence of statements that results in a malformed database
> disk image:
>
> CREATE TABLE t1 (c0, c1 REAL PRIMARY KEY);
> INSERT INTO t1(c0, c1) VALUES (TRUE, 9223372036854775807), (TRUE, 0);
> UPDATE t1 SET c0 = NULL;
> UPDATE OR REPLACE t1 SET c1 = 1;
> SELECT DISTINCT * FROM t1 WHERE (t1.c0 IS NULL);
>
> The last statement returns the following:
> |1.0
> Error: near line 5: database disk image is malformed

Ticket here: https://www.sqlite.org/src/tktview/6c1d3febc00b22d457c7

-- 
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to