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

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

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/analyze.test ('k') | third_party/sqlite/src/test/analyze8.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2009 August 06 1 # 2009 August 06
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # 11 #
12 # This file implements regression tests for SQLite library. This file 12 # This file implements regression tests for SQLite library. This file
13 # implements tests for range and LIKE constraints that use bound variables 13 # implements tests for range and LIKE constraints that use bound variables
14 # instead of literal constant arguments. 14 # instead of literal constant arguments.
15 # 15 #
16 16
17 set testdir [file dirname $argv0] 17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl 18 source $testdir/tester.tcl
19 set testprefix analyze3
19 20
20 ifcapable !stat4&&!stat3 { 21 ifcapable !stat4&&!stat3 {
21 finish_test 22 finish_test
22 return 23 return
23 } 24 }
24 25
25 #---------------------------------------------------------------------- 26 #----------------------------------------------------------------------
26 # Test Organization: 27 # Test Organization:
27 # 28 #
28 # analyze3-1.*: Test that the values of bound parameters are considered 29 # analyze3-1.*: Test that the values of bound parameters are considered
(...skipping 10 matching lines...) Expand all
39 # 40 #
40 # analyze3-4.*: Test that SQL or authorization callback errors occuring 41 # analyze3-4.*: Test that SQL or authorization callback errors occuring
41 # within sqlite3Reprepare() are handled correctly. 42 # within sqlite3Reprepare() are handled correctly.
42 # 43 #
43 # analyze3-5.*: Check that the query plans of applicable statements are 44 # analyze3-5.*: Check that the query plans of applicable statements are
44 # invalidated if the values of SQL parameter are modified 45 # invalidated if the values of SQL parameter are modified
45 # using the clear_bindings() or transfer_bindings() APIs. 46 # using the clear_bindings() or transfer_bindings() APIs.
46 # 47 #
47 # analyze3-6.*: Test that the problem fixed by commit [127a5b776d] is fixed. 48 # analyze3-6.*: Test that the problem fixed by commit [127a5b776d] is fixed.
48 # 49 #
50 # analyze3-7.*: Test that some memory leaks discovered by fuzz testing
51 # have been fixed.
52 #
49 53
50 proc getvar {varname} { uplevel #0 set $varname } 54 proc getvar {varname} { uplevel #0 set $varname }
51 db function var getvar 55 db function var getvar
52 56
53 proc eqp {sql {db db}} { 57 proc eqp {sql {db db}} {
54 uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db 58 uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
55 } 59 }
56 60
57 proc sf_execsql {sql {db db}} { 61 proc sf_execsql {sql {db db}} {
58 set ::sqlite_search_count 0 62 set ::sqlite_search_count 0
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 276 }
273 execsql COMMIT 277 execsql COMMIT
274 } {} 278 } {}
275 do_eqp_test analyze3-2.2 { 279 do_eqp_test analyze3-2.2 {
276 SELECT count(a) FROM t1 WHERE b LIKE 'a%' 280 SELECT count(a) FROM t1 WHERE b LIKE 'a%'
277 } {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (b>? AND b<?)}} 281 } {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (b>? AND b<?)}}
278 do_eqp_test analyze3-2.3 { 282 do_eqp_test analyze3-2.3 {
279 SELECT count(a) FROM t1 WHERE b LIKE '%a' 283 SELECT count(a) FROM t1 WHERE b LIKE '%a'
280 } {0 0 0 {SCAN TABLE t1}} 284 } {0 0 0 {SCAN TABLE t1}}
281 285
286 # Return the first argument if like_match_blobs is true (the default)
287 # or the second argument if not
288 #
289 proc ilmb {a b} {
290 ifcapable like_match_blobs {return $a}
291 return $b
292 }
293
282 do_test analyze3-2.4 { 294 do_test analyze3-2.4 {
283 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' } 295 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' }
284 } {101 0 100} 296 } [list [ilmb 102 101] 0 100]
285 do_test analyze3-2.5 { 297 do_test analyze3-2.5 {
286 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE '%a' } 298 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE '%a' }
287 } {999 999 100} 299 } {999 999 100}
288 300
289 do_test analyze3-2.4 { 301 do_test analyze3-2.6 {
290 set like "a%" 302 set like "a%"
291 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } 303 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
292 } {101 0 100} 304 } [list [ilmb 102 101] 0 100]
293 do_test analyze3-2.5 { 305 do_test analyze3-2.7 {
294 set like "%a" 306 set like "%a"
295 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } 307 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
296 } {999 999 100} 308 } {999 999 100}
297 do_test analyze3-2.6 { 309 do_test analyze3-2.8 {
298 set like "a" 310 set like "a"
299 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } 311 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
300 } {101 0 0} 312 } [list [ilmb 102 101] 0 0]
301 do_test analyze3-2.7 { 313 do_test analyze3-2.9 {
302 set like "ab" 314 set like "ab"
303 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } 315 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
304 } {11 0 0} 316 } [list [ilmb 12 11] 0 0]
305 do_test analyze3-2.8 { 317 do_test analyze3-2.10 {
306 set like "abc" 318 set like "abc"
307 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } 319 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
308 } {2 0 1} 320 } [list [ilmb 3 2] 0 1]
309 do_test analyze3-2.9 { 321 do_test analyze3-2.11 {
310 set like "a_c" 322 set like "a_c"
311 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } 323 sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
312 } {101 0 10} 324 } [list [ilmb 102 101] 0 10]
313 325
314 326
315 #------------------------------------------------------------------------- 327 #-------------------------------------------------------------------------
316 # This block of tests checks that statements are correctly marked as 328 # This block of tests checks that statements are correctly marked as
317 # expired when the values bound to any parameters that may affect the 329 # expired when the values bound to any parameters that may affect the
318 # query plan are modified. 330 # query plan are modified.
319 # 331 #
320 drop_all_tables 332 drop_all_tables
321 db auth auth 333 db auth auth
322 proc auth {args} { 334 proc auth {args} {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } {} 667 } {}
656 668
657 do_eqp_test analyze3-6-3 { 669 do_eqp_test analyze3-6-3 {
658 SELECT * FROM t1 WHERE a = 5 AND c = 13; 670 SELECT * FROM t1 WHERE a = 5 AND c = 13;
659 } {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}} 671 } {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}}
660 672
661 do_eqp_test analyze3-6-2 { 673 do_eqp_test analyze3-6-2 {
662 SELECT * FROM t1 WHERE a = 5 AND b > 'w' AND c = 13; 674 SELECT * FROM t1 WHERE a = 5 AND b > 'w' AND c = 13;
663 } {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}} 675 } {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}}
664 676
677 #-----------------------------------------------------------------------------
678 # 2015-04-20.
679 # Memory leak in sqlite3Stat4ProbeFree(). (Discovered while fuzzing.)
680 #
681 do_execsql_test analyze-7.1 {
682 DROP TABLE IF EXISTS t1;
683 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
684 INSERT INTO t1 VALUES(1,1,'0000');
685 CREATE INDEX t0b ON t1(b);
686 ANALYZE;
687 SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND hex(1);
688 } {}
689
690 # At one point duplicate stat1 entries were causing a memory leak.
691 #
692 reset_db
693 do_execsql_test 7.2 {
694 CREATE TABLE t1(a,b,c);
695 CREATE INDEX t1a ON t1(a);
696 ANALYZE;
697 SELECT * FROM sqlite_stat1;
698 INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');
699 INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');
700 ANALYZE sqlite_master;
701 }
702
665 finish_test 703 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/analyze.test ('k') | third_party/sqlite/src/test/analyze8.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698