Debian Codegraph @

ext/fts5/test/fts5contentless5.test

raw
1 # 2023 August 7
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
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.
9 #
10 #***********************************************************************
11 #
12 # This file contains tests for the content= and content_rowid= options.
13 #
14
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5contentless5
17
18 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
19 ifcapable !fts5 {
20 finish_test
21 return
22 }
23
24 do_execsql_test 1.0 {
25 CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, content='', contentless_delete=1);
26 INSERT INTO t1 VALUES('A', 'B', 'C');
27 INSERT INTO t1 VALUES('D', 'E', 'F');
28 INSERT INTO t1 VALUES('G', 'H', 'I');
29 }
30
31 do_execsql_test 1.01 {
32 CREATE TABLE t2(x, y);
33 INSERT INTO t2 VALUES('x', 'y');
34 }
35
36 # explain_i "UPDATE t1 SET a='a' WHERE t1.rowid=1"
37 breakpoint
38 explain_i "UPDATE t1 SET a='a' FROM t2 WHERE t1.rowid=1 AND b IS NULL"
39
40 #breakpoint
41 #explain_i "UPDATE t1 SET a='a' WHERE b IS NULL AND rowid=?"
42
43 foreach {tn up err} {
44 1 "UPDATE t1 SET a='a', b='b', c='c' WHERE rowid=1" 0
45 2 "UPDATE t1 SET a='a', b='b' WHERE rowid=1" 1
46 3 "UPDATE t1 SET b='b', c='c' WHERE rowid=1" 1
47 4 "UPDATE t1 SET a='a', c='c' WHERE rowid=1" 1
48 5 "UPDATE t1 SET a='a', c='c' WHERE t1.rowid=1 AND b IS NULL" 1
49 6 "UPDATE t1 SET a='a' FROM t2 WHERE t1.rowid=1" 1
50 7 "UPDATE t1 SET a='a', b='b', c='c' FROM t2 WHERE t1.rowid=1" 0
51 } {
52
53 set res(0) {0 {}}
54 set res(1) {1 {cannot UPDATE a subset of columns on fts5 contentless-delete table: t1}}
55 do_catchsql_test 1.$tn $up $res($err)
56 }
57
58 finish_test