Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: third_party/sqlite/src/test/trace3.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/tkt4018.test ('k') | third_party/sqlite/src/test/triggerE.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2016 July 14
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. The focus of
12 # this test file is the "sqlite3_trace_v2()" and "sqlite3_expanded_sql()"
13 # APIs.
14 #
15
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 ifcapable !trace { finish_test ; return }
19 set ::testprefix trace3
20
21 proc trace_v2_error { args } {
22 lappend ::stmtlist(error) [string trim $args]
23 error "trace error"; # this will be ignored.
24 }
25 proc trace_v2_record { args } {
26 lappend ::stmtlist(record) [string trim $args]
27 }
28 proc trace_v2_nop { args } {}; # do nothing.
29
30 do_test trace3-1.0 {
31 execsql {
32 CREATE TABLE t1(a,b);
33 INSERT INTO t1 VALUES(1,NULL);
34 INSERT INTO t1 VALUES(2,-1);
35 INSERT INTO t1 VALUES(3,0);
36 INSERT INTO t1 VALUES(4,1);
37 INSERT INTO t1 VALUES(5,-2147483648);
38 INSERT INTO t1 VALUES(6,2147483647);
39 INSERT INTO t1 VALUES(7,-9223372036854775808);
40 INSERT INTO t1 VALUES(8,9223372036854775807);
41 INSERT INTO t1 VALUES(9,-1.0);
42 INSERT INTO t1 VALUES(10,0.0);
43 INSERT INTO t1 VALUES(11,1.0);
44 INSERT INTO t1 VALUES(12,'');
45 INSERT INTO t1 VALUES(13,'1');
46 INSERT INTO t1 VALUES(14,'one');
47 INSERT INTO t1 VALUES(15,x'abcd0123');
48 INSERT INTO t1 VALUES(16,x'4567cdef');
49 }
50 } {}
51
52 do_test trace3-1.1 {
53 set rc [catch {db trace_v2 1 2 3} msg]
54 lappend rc $msg
55 } {1 {wrong # args: should be "db trace_v2 ?CALLBACK? ?MASK?"}}
56 do_test trace3-1.2 {
57 set rc [catch {db trace_v2 1 bad} msg]
58 lappend rc $msg
59 } {1 {bad trace type "bad": must be statement, profile, row, or close}}
60
61 do_test trace3-2.1 {
62 db trace_v2 trace_v2_nop
63 db trace_v2
64 } {trace_v2_nop}
65
66 do_test trace3-3.1 {
67 unset -nocomplain ::stmtlist
68 db trace_v2 trace_v2_nop
69 execsql {
70 SELECT a, b FROM t1 ORDER BY a;
71 }
72 array get ::stmtlist
73 } {}
74 do_test trace3-3.2 {
75 set ::stmtlist(error) {}
76 db trace_v2 trace_v2_error
77 execsql {
78 SELECT a, b FROM t1 ORDER BY a;
79 }
80 set ::stmtlist(error)
81 } {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
82 do_test trace3-3.3 {
83 set ::stmtlist(record) {}
84 db trace_v2 trace_v2_record
85 execsql {
86 SELECT a, b FROM t1 ORDER BY a;
87 }
88 set ::stmtlist(record)
89 } {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
90 do_test trace3-3.4 {
91 set ::stmtlist(record) {}
92 db trace_v2 trace_v2_record statement
93 execsql {
94 SELECT a, b FROM t1 ORDER BY a;
95 }
96 set ::stmtlist(record)
97 } {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
98 do_test trace3-3.5 {
99 set ::stmtlist(record) {}
100 db trace_v2 trace_v2_record 1
101 execsql {
102 SELECT a, b FROM t1 ORDER BY a;
103 }
104 set ::stmtlist(record)
105 } {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
106
107 do_test trace3-4.1 {
108 set ::stmtlist(record) {}
109 db trace_v2 trace_v2_record profile
110 execsql {
111 SELECT a, b FROM t1 ORDER BY a;
112 }
113 set ::stmtlist(record)
114 } {/^\{-?\d+ -?\d+\}$/}
115 do_test trace3-4.2 {
116 set ::stmtlist(record) {}
117 db trace_v2 trace_v2_record 2
118 execsql {
119 SELECT a, b FROM t1 ORDER BY a;
120 }
121 set ::stmtlist(record)
122 } {/^\{-?\d+ -?\d+\}$/}
123
124 do_test trace3-5.1 {
125 set ::stmtlist(record) {}
126 db trace_v2 trace_v2_record row
127 execsql {
128 SELECT a, b FROM t1 ORDER BY a;
129 }
130 set ::stmtlist(record)
131 } "/^[string trim [string repeat {-?\d+ } 16]]\$/"
132 do_test trace3-5.2 {
133 set ::stmtlist(record) {}
134 db trace_v2 trace_v2_record 4
135 execsql {
136 SELECT a, b FROM t1 ORDER BY a;
137 }
138 set ::stmtlist(record)
139 } "/^[string trim [string repeat {-?\d+ } 16]]\$/"
140
141 do_test trace3-6.1 {
142 set ::stmtlist(record) {}
143 db trace_v2 trace_v2_record {profile row}
144 execsql {
145 SELECT a, b FROM t1 ORDER BY a;
146 }
147 set ::stmtlist(record)
148 } "/^[string trim [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/"
149 do_test trace3-6.2 {
150 set ::stmtlist(record) {}
151 db trace_v2 trace_v2_record {statement profile row}
152 execsql {
153 SELECT a, b FROM t1 ORDER BY a;
154 }
155 set ::stmtlist(record)
156 } "/^\\\{-?\\d+ \\\{SELECT a, b FROM t1 ORDER BY a;\\\}\\\} [string trim \
157 [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/"
158
159 do_test trace3-7.1 {
160 set DB [sqlite3_connection_pointer db]
161
162 set STMT [sqlite3_prepare_v2 $DB \
163 "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 TAIL]
164 } {/^[0-9A-Fa-f]+$/}
165
166 do_test trace3-8.1 {
167 list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT]
168 } {{} {SELECT a, b FROM t1 WHERE b = NULL ORDER BY a;}}
169 do_test trace3-8.2 {
170 list [sqlite3_bind_int $STMT 1 123] [sqlite3_expanded_sql $STMT]
171 } {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}
172 do_test trace3-8.3 {
173 list [sqlite3_bind_int64 $STMT 1 123] [sqlite3_expanded_sql $STMT]
174 } {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}
175 do_test trace3-8.4 {
176 list [sqlite3_bind_text $STMT 1 "some string" 11] \
177 [sqlite3_expanded_sql $STMT]
178 } {{} {SELECT a, b FROM t1 WHERE b = 'some string' ORDER BY a;}}
179 do_test trace3-8.5 {
180 list [sqlite3_bind_text $STMT 1 "some 'bad' string" 17] \
181 [sqlite3_expanded_sql $STMT]
182 } {{} {SELECT a, b FROM t1 WHERE b = 'some ''bad'' string' ORDER BY a;}}
183 do_test trace3-8.6 {
184 list [sqlite3_bind_double $STMT 1 123] [sqlite3_expanded_sql $STMT]
185 } {{} {SELECT a, b FROM t1 WHERE b = 123.0 ORDER BY a;}}
186 do_test trace3-8.7 {
187 list [sqlite3_bind_text16 $STMT 1 \
188 [encoding convertto unicode hi\000yall\000] 16] \
189 [sqlite3_expanded_sql $STMT]
190 } {{} {SELECT a, b FROM t1 WHERE b = 'hi' ORDER BY a;}}
191 do_test trace3-8.8 {
192 list [sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3] \
193 [sqlite3_expanded_sql $STMT]
194 } {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}}
195 do_test trace3-8.9 {
196 list [sqlite3_bind_blob $STMT 1 "\xAB\xCD\xEF" 3] \
197 [sqlite3_expanded_sql $STMT]
198 } {{} {SELECT a, b FROM t1 WHERE b = x'abcdef' ORDER BY a;}}
199
200 do_test trace3-9.1 {
201 sqlite3_finalize $STMT
202 } {SQLITE_OK}
203
204 do_test trace3-10.1 {
205 db trace_v2 ""
206 db trace_v2
207 } {}
208 do_test trace3-10.2 {
209 unset -nocomplain ::stmtlist
210 db trace_v2 "" {statement profile row}
211 execsql {
212 SELECT a, b FROM t1 ORDER BY a;
213 }
214 array get ::stmtlist
215 } {}
216
217 do_test trace3-11.1 {
218 set ::stmtlist(record) {}
219 db trace_v2 trace_v2_record close
220 db close
221 set ::stmtlist(record)
222 } {/^-?\d+$/}
223
224 reset_db
225
226 do_test trace3-11.2 {
227 set ::stmtlist(record) {}
228 db trace_v2 trace_v2_record 8
229 db close
230 set ::stmtlist(record)
231 } {/^-?\d+$/}
232
233 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/tkt4018.test ('k') | third_party/sqlite/src/test/triggerE.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698