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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/analyze3.test
diff --git a/third_party/sqlite/src/test/analyze3.test b/third_party/sqlite/src/test/analyze3.test
index e7416d5730337d821be10f6c5480faa6599aa510..2fb558d16a285708f13185c21bc27aff19930546 100644
--- a/third_party/sqlite/src/test/analyze3.test
+++ b/third_party/sqlite/src/test/analyze3.test
@@ -16,6 +16,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+set testprefix analyze3
ifcapable !stat4&&!stat3 {
finish_test
@@ -46,6 +47,9 @@ ifcapable !stat4&&!stat3 {
#
# analyze3-6.*: Test that the problem fixed by commit [127a5b776d] is fixed.
#
+# analyze3-7.*: Test that some memory leaks discovered by fuzz testing
+# have been fixed.
+#
proc getvar {varname} { uplevel #0 set $varname }
db function var getvar
@@ -279,37 +283,45 @@ do_eqp_test analyze3-2.3 {
SELECT count(a) FROM t1 WHERE b LIKE '%a'
} {0 0 0 {SCAN TABLE t1}}
+# Return the first argument if like_match_blobs is true (the default)
+# or the second argument if not
+#
+proc ilmb {a b} {
+ ifcapable like_match_blobs {return $a}
+ return $b
+}
+
do_test analyze3-2.4 {
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' }
-} {101 0 100}
+} [list [ilmb 102 101] 0 100]
do_test analyze3-2.5 {
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE '%a' }
} {999 999 100}
-do_test analyze3-2.4 {
+do_test analyze3-2.6 {
set like "a%"
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
-} {101 0 100}
-do_test analyze3-2.5 {
+} [list [ilmb 102 101] 0 100]
+do_test analyze3-2.7 {
set like "%a"
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
} {999 999 100}
-do_test analyze3-2.6 {
+do_test analyze3-2.8 {
set like "a"
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
-} {101 0 0}
-do_test analyze3-2.7 {
+} [list [ilmb 102 101] 0 0]
+do_test analyze3-2.9 {
set like "ab"
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
-} {11 0 0}
-do_test analyze3-2.8 {
+} [list [ilmb 12 11] 0 0]
+do_test analyze3-2.10 {
set like "abc"
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
-} {2 0 1}
-do_test analyze3-2.9 {
+} [list [ilmb 3 2] 0 1]
+do_test analyze3-2.11 {
set like "a_c"
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
-} {101 0 10}
+} [list [ilmb 102 101] 0 10]
#-------------------------------------------------------------------------
@@ -662,4 +674,30 @@ do_eqp_test analyze3-6-2 {
SELECT * FROM t1 WHERE a = 5 AND b > 'w' AND c = 13;
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}}
+#-----------------------------------------------------------------------------
+# 2015-04-20.
+# Memory leak in sqlite3Stat4ProbeFree(). (Discovered while fuzzing.)
+#
+do_execsql_test analyze-7.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES(1,1,'0000');
+ CREATE INDEX t0b ON t1(b);
+ ANALYZE;
+ SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND hex(1);
+} {}
+
+# At one point duplicate stat1 entries were causing a memory leak.
+#
+reset_db
+do_execsql_test 7.2 {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1a ON t1(a);
+ ANALYZE;
+ SELECT * FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');
+ ANALYZE sqlite_master;
+}
+
finish_test
« 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