wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 # 2011 Jan 21
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 # This file implements regression tests for SQLite library.
12 #
13 # This file implements tests for the "sqlite3_trace()" API. Specifically,
14 # it tests the special handling of nested SQL statements (those executed
15 # by virtual table or user function callbacks). These statements are treated
16 # differently in two respects:
17 #
18 # 1. Each line of the statement is prefixed with "-- " to turn it into
19 # an SQL comment.
20 #
21 # 2. Parameter expansion is not performed.
22 #
23  
24 set testdir [file dirname $argv0]
25 source $testdir/tester.tcl
26 ifcapable !trace { finish_test ; return }
27 set ::testprefix trace2
28  
29 proc sql {zSql} { db one $zSql }
30 proc trace {zSql} { lappend ::trace $zSql }
31  
32 db func sql sql
33 db trace trace
34  
35 proc do_trace_test {tn sql expected} {
36 # Test that the list of string passed to the trace callback when $sql
37 # is executed is equivalent to the list of strings in $expected.
38 #
39 set ::trace [list]
40 execsql $sql
41 uplevel do_test $tn [list {set ::trace}] [list [list {*}$expected]]
42 }
43  
44 proc do_trace_select_test {tn sql expected} {
45  
46 uplevel [list do_trace_test ${tn}.a $sql $expected]
47  
48 # Now execute each SQL statement passed to the trace callback in the
49 # block above. Check that this causes the same set of strings to be
50 # passed to the trace callback again. i.e. that executing the output
51 # of the trace callback is equivalent to the SQL script in $sql.
52 #
53 set sqllist $::trace
54 set ::trace [list]
55 foreach item $sqllist { execsql $item }
56 uplevel do_test $tn.b [list {set ::trace}] [list $sqllist]
57 }
58  
59 do_trace_select_test 1.1 {
60 SELECT 1, 2, 3;
61 } {
62 "SELECT 1, 2, 3;"
63 }
64  
65 do_trace_select_test 1.2 {
66 SELECT sql('SELECT 1, 2, 3');
67 } {
68 "SELECT sql('SELECT 1, 2, 3');"
69 "-- SELECT 1, 2, 3"
70 }
71  
72 # C# needs to process the comments better
73 if 0 {
74 do_trace_select_test 1.3 {
75 SELECT sql('SELECT 1,
76 2,
77 3'
78 );
79 } {
80 "SELECT sql('SELECT 1,
81 2,
82 3'
83 );"
84 "-- SELECT 1,
85 -- 2,
86 -- 3"
87 }
88  
89 do_trace_select_test 1.4 {
90 SELECT sql('SELECT 1,
91  
92  
93 3'
94 );
95 } {
96 "SELECT sql('SELECT 1,
97  
98  
99 3'
100 );"
101 "-- SELECT 1,
102 --
103 --
104 -- 3"
105 }
106  
107 do_trace_select_test 1.5 {
108 SELECT $var, sql('SELECT 1,
109 $var,
110 3'
111 );
112 } {
113 "SELECT NULL, sql('SELECT 1,
114 $var,
115 3'
116 );"
117 "-- SELECT 1,
118 -- $var,
119 -- 3"
120 }
121 }
122  
123 ifcapable fts3 {
124 do_execsql_test 2.1 {
125 CREATE VIRTUAL TABLE x1 USING fts4;
126 INSERT INTO x1 VALUES('Cloudy, with a high near 16');
127 INSERT INTO x1 VALUES('Wind chill values as low as -13');
128 }
129  
130 do_trace_test 2.2 {
131 INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');
132 } {
133 "INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');"
134 "-- INSERT INTO 'main'.'x1_content' VALUES(?,(?))"
135 "-- REPLACE INTO 'main'.'x1_docsize' VALUES(?,?)"
136 "-- SELECT value FROM 'main'.'x1_stat' WHERE id=0"
137 "-- REPLACE INTO 'main'.'x1_stat' VALUES(0,?)"
138 "-- SELECT (SELECT max(idx) FROM 'main'.'x1_segdir' WHERE level = ?) + 1"
139 "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)"
140 "-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
141 }
142  
143 do_trace_test 2.3 {
144 INSERT INTO x1(x1) VALUES('optimize');
145 } {
146 "INSERT INTO x1(x1) VALUES('optimize');"
147 "-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?ORDER BY level DESC, idx ASC"
148 "-- SELECT max(level) FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?"
149 "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)"
150 "-- DELETE FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?"
151 "-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
152 }
153 }
154  
155 finish_test