Changes to documentation comments in fts5.h.
[sqlite.git] / ext / session / sessionwor.test
blob7d9e5c6a897a673018f54d889862ffc73c7c7a83
1 # 2017 Jan 31
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 #***********************************************************************
12 # The focus of this file is testing the session module. Specifically,
13 # testing support for WITHOUT ROWID tables.
16 if {![info exists testdir]} {
17   set testdir [file join [file dirname [info script]] .. .. test]
18
19 source [file join [file dirname [info script]] session_common.tcl]
20 source $testdir/tester.tcl
21 ifcapable !session {finish_test; return}
23 set testprefix sessionwor
25 proc test_reset {} {
26   catch { db close }
27   catch { db2 close }
28   forcedelete test.db test.db2
29   sqlite3 db test.db
30   sqlite3 db2 test.db2
33 foreach {tn wo} {
34   1 ""
35   2 "WITHOUT ROWID"
36 } {
37   reset_db
39   do_execsql_test 1.$tn.0 "CREATE TABLE t1(a PRIMARY KEY, b) $wo ;"
40   
41   do_iterator_test 1.$tn.1 t1 {
42     INSERT INTO t1 VALUES('one', 'two');
43   } {
44     {INSERT t1 0 X. {} {t one t two}}
45   }
46   
47   do_iterator_test 1.$tn.2 t1 {
48     UPDATE t1 SET b='three'
49   } {
50     {UPDATE t1 0 X. {t one t two} {{} {} t three}}
51   }
52   
53   do_iterator_test 1.$tn.3 t1 {
54     REPLACE INTO t1 VALUES('one', 'four');
55   } {
56     {UPDATE t1 0 X. {t one t three} {{} {} t four}}
57   }
58   
59   do_iterator_test 1.$tn.4 t1 {
60     DELETE FROM t1;
61   } {
62     {DELETE t1 0 X. {t one t four} {}}
63   }
66 foreach {tn wo} {
67   1 ""
68   2 "WITHOUT ROWID"
69 } {
70   reset_db
72   do_execsql_test 2.$tn.0.1 "CREATE TABLE t1(a INTEGER PRIMARY KEY, b) $wo ;"
73   do_execsql_test 2.$tn.0.2 "CREATE TABLE t2(a INTEGER PRIMARY KEY, b) $wo ;"
74   do_execsql_test 2.$tn.0.3 "CREATE TABLE t3(a INTEGER PRIMARY KEY, b) $wo ;"
75   
76   do_iterator_test 1.1 t1 {
77     INSERT INTO t1 VALUES(1, 'two');
78   } {
79     {INSERT t1 0 X. {} {i 1 t two}}
80   }
81   
82   do_iterator_test 2.$tn.2 t1 {
83     UPDATE t1 SET b='three'
84   } {
85     {UPDATE t1 0 X. {i 1 t two} {{} {} t three}}
86   }
87   
88   do_iterator_test 2.$tn.3 t1 {
89     REPLACE INTO t1 VALUES(1, 'four');
90   } {
91     {UPDATE t1 0 X. {i 1 t three} {{} {} t four}}
92   }
93   
94   do_iterator_test 2.$tn.4 t1 {
95     DELETE FROM t1;
96   } {
97     {DELETE t1 0 X. {i 1 t four} {}}
98   }
100   do_execsql_test 2.$tn.5 {
101     INSERT INTO t1 VALUES(1, 'one');
102     INSERT INTO t1 VALUES(2, 'two');
103     INSERT INTO t1 VALUES(3, 'three');
104   }
106   do_iterator_test 2.$tn.6 t2 {
107     INSERT INTO t2 SELECT a, b FROM t1
108   } {
109     {INSERT t2 0 X. {} {i 1 t one}} 
110     {INSERT t2 0 X. {} {i 2 t two}}
111     {INSERT t2 0 X. {} {i 3 t three}}
112   }
113   do_iterator_test 2.$tn.7 t3 {
114     INSERT INTO t3 SELECT * FROM t1
115   } {
116     {INSERT t3 0 X. {} {i 1 t one}} 
117     {INSERT t3 0 X. {} {i 2 t two}}
118     {INSERT t3 0 X. {} {i 3 t three}}
119   }
122 finish_test