3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements tests for a strange scenario discovered by
12 # dbsqlfuzz (0ad6d441f9bf3dfc32626a9900bc1700495b16f9) in which a
13 # virtual table is named "sqlite_stat1".
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
20 ifcapable !vtab||!rtree||!fts5 {
27 INSERT INTO t1 VALUES(123);
28 PRAGMA writable_schema=ON;
29 CREATE VIRTUAL TABLE sqlite_stat1 USING fts5(a);
30 PRAGMA writable_schema=OFF;
31 CREATE VIRTUAL TABLE t3 USING fts5(b);
32 INSERT INTO t3 VALUES('this is a test');
34 do_catchsql_test 110 {
35 CREATE VIRTUAL TABLE t2 USING rtree(id,x,y);
36 } {1 {no such column: stat}}
41 INSERT INTO t3(b) VALUES('Four score and seven years ago');
42 SELECT * FROM t3 WHERE t3 MATCH 'this';
45 SELECT * FROM t3 WHERE t3 MATCH 'four seven';
46 } {{Four score and seven years ago}}
48 INSERT INTO sqlite_stat1(a)
49 VALUES('We hold these truths to be self-evident...');
50 SELECT * FROM sqlite_stat1;
51 } {{We hold these truths to be self-evident...}}
52 do_catchsql_test 160 {
54 } {1 {database disk image is malformed}}
56 PRAGMA integrity_check;
59 # Follow-on dbsqlfuzz bc02a0cde82dee801a8d6f653d2831680f87dca1
63 INSERT INTO t1 VALUES('Ebed-malech');
65 PRAGMA writable_schema=ON;
66 CREATE VIRTUAL TABLE sqlite_stat1 USING fts5(a);
68 do_catchsql_test 210 {
69 CREATE VIRTUAL TABLE t2 USING rtree(id,x,y);
70 } {1 {no such column: stat}}
75 # Follow-on dbsqlfuzz a097eaad43c3c845b236126df92fb49b25449b0c
77 do_catchsql_test 300 {
78 CREATE VIRTUAL TABLE t1 USING rtree(a,b,c);
80 ALTER TABLE t2 ADD d GENERATED ALWAYS AS (c IN (SELECT 1 FROM t1)) VIRTUAL;
81 } {1 {error in table t2 after add column: subqueries prohibited in generated columns}}