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

Side by Side Diff: third_party/sqlite/test/trace.test

Issue 3108030: Move bundled copy of sqlite one level deeper to better separate it... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/test/tokenize.test ('k') | third_party/sqlite/test/trans.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 # 2004 Jun 29
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.
14 #
15 # $Id: trace.test,v 1.8 2009/04/07 14:14:23 danielk1977 Exp $
16
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
19
20 ifcapable !trace {
21 finish_test
22 return
23 }
24
25 set ::stmtlist {}
26 do_test trace-1.1 {
27 set rc [catch {db trace 1 2 3} msg]
28 lappend rc $msg
29 } {1 {wrong # args: should be "db trace ?CALLBACK?"}}
30 proc trace_proc cmd {
31 lappend ::stmtlist [string trim $cmd]
32 }
33 do_test trace-1.2 {
34 db trace trace_proc
35 db trace
36 } {trace_proc}
37 do_test trace-1.3 {
38 execsql {
39 CREATE TABLE t1(a,b);
40 INSERT INTO t1 VALUES(1,2);
41 SELECT * FROM t1;
42 }
43 } {1 2}
44 do_test trace-1.4 {
45 set ::stmtlist
46 } {{CREATE TABLE t1(a,b);} {INSERT INTO t1 VALUES(1,2);} {SELECT * FROM t1;}}
47 do_test trace-1.5 {
48 db trace {}
49 db trace
50 } {}
51
52 # If we prepare a statement and execute it multiple times, the trace
53 # happens on each execution.
54 #
55 db close
56 sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
57 do_test trace-2.1 {
58 set STMT [sqlite3_prepare $DB {INSERT INTO t1 VALUES(2,3)} -1 TAIL]
59 db trace trace_proc
60 proc trace_proc sql {
61 global TRACE_OUT
62 set TRACE_OUT $sql
63 }
64 set TRACE_OUT {}
65 sqlite3_step $STMT
66 set TRACE_OUT
67 } {INSERT INTO t1 VALUES(2,3)}
68 do_test trace-2.2 {
69 set TRACE_OUT {}
70 sqlite3_reset $STMT
71 set TRACE_OUT
72 } {}
73 do_test trace-2.3 {
74 sqlite3_step $STMT
75 set TRACE_OUT
76 } {INSERT INTO t1 VALUES(2,3)}
77 do_test trace-2.4 {
78 execsql {SELECT * FROM t1}
79 } {1 2 2 3 2 3}
80 do_test trace-2.5 {
81 set TRACE_OUT
82 } {SELECT * FROM t1}
83 catch {sqlite3_finalize $STMT}
84
85 # Similar tests, but this time for profiling.
86 #
87 do_test trace-3.1 {
88 set rc [catch {db profile 1 2 3} msg]
89 lappend rc $msg
90 } {1 {wrong # args: should be "db profile ?CALLBACK?"}}
91 set ::stmtlist {}
92 proc profile_proc {cmd tm} {
93 lappend ::stmtlist [string trim $cmd]
94 }
95 do_test trace-3.2 {
96 db trace {}
97 db profile profile_proc
98 db profile
99 } {profile_proc}
100 do_test trace-3.3 {
101 execsql {
102 CREATE TABLE t2(a,b);
103 INSERT INTO t2 VALUES(1,2);
104 SELECT * FROM t2;
105 }
106 } {1 2}
107 do_test trace-3.4 {
108 set ::stmtlist
109 } {{CREATE TABLE t2(a,b);} {INSERT INTO t2 VALUES(1,2);} {SELECT * FROM t2;}}
110 do_test trace-3.5 {
111 db profile {}
112 db profile
113 } {}
114
115 # If we prepare a statement and execute it multiple times, the profile
116 # happens on each execution.
117 #
118 db close
119 sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
120 do_test trace-4.1 {
121 set STMT [sqlite3_prepare $DB {INSERT INTO t2 VALUES(2,3)} -1 TAIL]
122 db trace trace_proc
123 proc profile_proc {sql tm} {
124 global TRACE_OUT
125 set TRACE_OUT $sql
126 }
127 set TRACE_OUT {}
128 sqlite3_step $STMT
129 set TRACE_OUT
130 } {INSERT INTO t2 VALUES(2,3)}
131 do_test trace-4.2 {
132 set TRACE_OUT {}
133 sqlite3_reset $STMT
134 set TRACE_OUT
135 } {}
136 do_test trace-4.3 {
137 sqlite3_step $STMT
138 set TRACE_OUT
139 } {INSERT INTO t2 VALUES(2,3)}
140 do_test trace-4.4 {
141 execsql {SELECT * FROM t1}
142 } {1 2 2 3 2 3}
143 do_test trace-4.5 {
144 set TRACE_OUT
145 } {SELECT * FROM t1}
146 catch {sqlite3_finalize $STMT}
147
148 # Trigger tracing.
149 #
150 ifcapable trigger {
151 do_test trace-5.1 {
152 db eval {
153 CREATE TRIGGER r1t1 AFTER UPDATE ON t1 BEGIN
154 UPDATE t2 SET a=new.a WHERE rowid=new.rowid;
155 END;
156 CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN
157 SELECT 'hello';
158 END;
159 }
160 set TRACE_OUT {}
161 proc trace_proc cmd {
162 lappend ::TRACE_OUT [string trim $cmd]
163 }
164 db eval {
165 UPDATE t1 SET a=a+1;
166 }
167 set TRACE_OUT
168 } {{UPDATE t1 SET a=a+1;} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1 } {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2}}
169 }
170
171 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/tokenize.test ('k') | third_party/sqlite/test/trans.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698