Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/expridx2.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / expridx2.test` 86 lines ยท 2027 bytes Raw Blame History 1 # 2026-04-23 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 # Tests for omitting the update of an index when the new value is the 13 # same as the old. 14 # 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 set testprefix expridx2 18 19 # This test requires wal mode, but the journaltest permutation installs 20 # a custom VFS that does not support wal mode. 21 if {[permutation]=="journaltest"} { 22 finish_test 23 return 24 } 25 26 do_execsql_test 1.0 { 27 PRAGMA journal_mode = wal; 28 CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); 29 INSERT INTO t1 VALUES(1, '{a: 10, b: 20, c: 30}'); 30 INSERT INTO t1 VALUES(2, '{a: 11, b: 21, c: 31}'); 31 INSERT INTO t1 VALUES(3, '{a: 12, b: 22, c: 32}'); 32 INSERT INTO t1 VALUES(4, '{a: 13, b: 23, c: 33}'); 33 34 CREATE INDEX t1a ON t1( (b->>'a') ); 35 CREATE INDEX t1b ON t1( (b->>'b') ); 36 CREATE INDEX t1c ON t1( (b->>'c') ); 37 38 CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c); 39 CREATE INDEX t2b ON t2( b ); 40 INSERT INTO t2 VALUES(1, 1, 1); 41 INSERT INTO t2 VALUES(2, 2, 2); 42 INSERT INTO t2 VALUES(3, 3, 3); 43 INSERT INTO t2 VALUES(4, 4, 4); 44 } {wal} 45 46 proc nWrite {sql} { 47 sqlite3_db_status db CACHE_WRITE 1 48 execsql $sql 49 lindex [sqlite3_db_status db CACHE_WRITE 0] 1 50 } 51 52 do_test 1.1 { 53 nWrite { UPDATE t1 SET b = json_set(b, '$.a', b->>'a' + 1) } 54 } {2} 55 56 do_test 1.2 { 57 nWrite { 58 UPDATE t1 SET b = json_set( 59 json_set(b, '$.a', b->>'a' + 1), 60 '$.b', b->>'b' + 1 61 ); 62 } 63 } {3} 64 65 do_test 1.3 { 66 nWrite { 67 UPDATE t1 SET b = '{a:1, b:2, c:3}' WHERE rowid=1; 68 } 69 } {4} 70 71 integrity_check 1.4 72 73 do_test 1.5 { 74 nWrite { UPDATE t2 SET b = b+1, c=c+1 } 75 } {2} 76 77 do_test 1.6 { 78 nWrite { UPDATE t2 SET b = b, c=c+1 } 79 } {2} 80 81 do_test 1.7 { 82 nWrite { UPDATE t2 SET c=c+1 } 83 } {1} 84 85 finish_test 86