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 of writing to WITHOUT ROWID virtual tables
12 # using the tclvar eponymous virtual table.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
24 register_tclvar_module db
26 unset -nocomplain vtabJ
32 SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;
34 } {vtabJ(1) this vtabJ(3) {a test} vtabJ(two) is}
37 INSERT INTO tclvar(fullname, value)
38 VALUES('vtabJ(4)',4),('vtabJ(five)',555);
39 SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;
40 } {vtabJ(1) this vtabJ(3) {a test} vtabJ(4) 4 vtabJ(five) 555 vtabJ(two) is}
43 foreach vname [lsort [array names vtabJ]] {
44 lappend res vtabJ($vname) $vtabJ($vname)
47 } {vtabJ(1) this vtabJ(3) {a test} vtabJ(4) 4 vtabJ(five) 555 vtabJ(two) is}
51 INSERT INTO tclvar(fullname, value) VALUES('vtabJ(4)',444);
58 INSERT INTO tclvar(fullname, value) VALUES('vtabJ(4)',NULL);
65 UPDATE tclvar SET value=55 WHERE fullname='vtabJ(five)';
72 UPDATE tclvar SET fullname='vtabJ(5)' WHERE fullname='vtabJ(five)';
77 info exists vtabJ(five)
81 foreach vname [lsort [array names vtabJ]] {
82 lappend res vtabJ($vname) $vtabJ($vname)
85 } {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55 vtabJ(two) is}
88 SELECT fullname FROM tclvar WHERE arrayname='two'
91 DELETE FROM tclvar WHERE arrayname='two';
92 SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;
93 } {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55}
96 foreach vname [lsort [array names vtabJ]] {
97 lappend res vtabJ($vname) $vtabJ($vname)
100 } {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55}
102 # Try to trick the module into updating the same variable twice for a
103 # single UPDATE statement.
105 do_execsql_test 171 {
106 INSERT INTO tclvar(fullname, value) VALUES('xx', 'a');
107 SELECT name, value FROM tclvar where name = 'xx';
109 do_execsql_test 172 {
110 UPDATE tclvar SET value = value || 't'
111 WHERE name = 'xx' OR name = 'x'||'x';
112 SELECT name, value FROM tclvar where name = 'xx';
114 do_execsql_test 173 {
115 UPDATE tclvar SET value = value || 't'
116 WHERE name = 'xx' OR name BETWEEN 'xx' AND 'xx';
117 SELECT name, value FROM tclvar where name = 'xx';
120 do_execsql_test 181 {
121 DELETE FROM tclvar WHERE name BETWEEN 'xx' AND 'xx' OR name='xx';
122 SELECT name, value FROM tclvar where name = 'xx';