-C Avoid\smultiple\sstorage\sclass\sspecifiers\s("static\sextern")\sin\sthe\samalagmation.\s(CVS\s3984)
-D 2007-05-11T12:30:04
+C Check\sin\ssome\schanges\sto\sfuzz.test.\sStill\sfailing.\s(CVS\s3985)
+D 2007-05-11T16:58:04
F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F test/fts2m.test 4b30142ead6f3ed076e880a2a464064c5ad58c51
F test/fts2n.test a70357e72742681eaebfdbe9007b87ff3b771638
F test/func.test bf30bac1c5ce10448ab739994268cf18f8b3fa30
-F test/fuzz.test e939852bfd1d2db7264d6a55ed9b17834a535728
+F test/fuzz.test 5bd59290ab42cabbfb2e0ad1683a480f0d8e8693
F test/fuzz2.test fdbea571808441c12c91e9cd038eb77b4692d42b
F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 4e1bb41f302c13095aa9c638e59ae11417f49682
-R 0ef77c803856268fd492e9a8b4d88856
-U drh
-Z 29baa4cb103abeeafa2097c522aa6ac6
+P 2f70159b1d6ded4a1ac446faa3baf7269f37703f
+R 0b013336ad3732dc516052d4aa155e80
+U danielk1977
+Z 5241c0f63790746ffd570aebaabc6267
# (a.k.a. "fuzz") and sending it into the parser to try to generate
# errors.
#
-# $Id: fuzz.test,v 1.6 2007/05/11 10:10:33 danielk1977 Exp $
+# $Id: fuzz.test,v 1.7 2007/05/11 16:58:04 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+set ::REPEATS 20
+set ::REPEATS 5000
+
proc fuzz {TemplateList} {
set n [llength $TemplateList]
set i [expr {int(rand()*$n)}]
incr ::ExprDepth
set TemplateList [concat $c {[Literal]}]
- if {$::ExprDepth < 25} {
+ if {$::ExprDepth < 5} {
lappend TemplateList \
{[Expr $c] [BinaryOp] [Expr $c]} \
{[UnaryOp] [Expr $c]} \
{CAST([Expr $c] AS text)} \
{CAST([Expr $c] AS integer)} \
{CAST([Expr $c] AS real)} \
+ {abs([Expr])} \
+ {coalesce([Expr], [Expr])} \
+ {hex([Expr])} \
+ {length([Expr])} \
+ {lower([Expr])} \
+ {upper([Expr])} \
+ {quote([Expr])} \
+ {random()} \
+ {randomblob(min(max([Expr],1), 500))} \
+ {typeof([Expr])} \
+ {substr([Expr],[Expr],[Expr])} \
{CASE WHEN [Expr $c] THEN [Expr $c] ELSE [Expr $c] END} \
{[Literal]} {[Literal]} {[Literal]}
}
# Return a SELECT statement.
#
set ::SelectDepth 0
+set ::ColumnList [list]
proc Select {{isExpr 0}} {
incr ::SelectDepth
set TemplateList {
if {$::SelectDepth < 5} {
lappend TemplateList \
{SELECT [Expr] FROM ([Select])} \
- {SELECT [Expr] FROM [Table]} \
+ {SELECT [Expr $::ColumnList] FROM [Table]} \
if {0 == $isExpr} {
lappend TemplateList \
{SELECT [Expr], [Expr] FROM ([Select]) ORDER BY [Expr]} \
{SELECT * FROM ([Select]) ORDER BY [Expr]} \
{SELECT * FROM [Table]} \
- {SELECT * FROM [Table] WHERE [Expr]} \
+ {SELECT * FROM [Table] WHERE [Expr $::ColumnList]} \
+{SELECT * FROM [Table],[Table] AS t2 WHERE [Expr $::ColumnList] LIMIT 1}
}
}
set res [fuzz $TemplateList]
fuzz $TemplateList
}
+proc Column {} {
+ fuzz $::ColumnList
+}
+
+# Generate and return a fuzzy UPDATE statement.
+#
+proc Update {} {
+ set TemplateList {
+ {UPDATE [Table]
+ SET [Column] = [Expr $::ColumnList]
+ WHERE [Expr $::ColumnList]}
+ }
+ fuzz $TemplateList
+}
+
+proc Delete {} {
+ set TemplateList {
+ {DELETE FROM [Table] WHERE [Expr $::ColumnList]}
+ }
+ fuzz $TemplateList
+}
+
+proc Statement {} {
+ set TemplateList {
+ {[Update]}
+ {[Insert]}
+ {[Select]}
+ {[Delete]}
+ }
+ fuzz $TemplateList
+}
+
########################################################################
set ::log [open fuzzy.log w]
array set ::fuzzyopts $args
lappend ::fuzzyopts(-errorlist) {parser stack overflow} {ORDER BY column}
- for {set ii 0} {$ii < 2000} {incr ii} {
+ for {set ii 0} {$ii < $::REPEATS} {incr ii} {
do_test ${testname}.$ii {
set ::sql [subst $::fuzzyopts(-template)]
puts $::log $::sql
} [execsql {SELECT zeroblob(1000)}]
do_test fuzz-1.8 {
+ # Problems with opcode OP_ToText (did not account for MEM_Zero).
+ # Also MemExpandBlob() was marking expanded blobs as nul-terminated.
+ # They are not.
execsql {
SELECT CAST(zeroblob(1000) AS text);
}
} {{}}
+do_test fuzz-1.9 {
+ # This was causing a NULL pointer dereference of Expr.pList.
+ execsql {
+ SELECT 1 FROM (SELECT * FROM sqlite_master WHERE random())
+ }
+} {}
+
+do_test fuzz-1.10 {
+ # Bug in calculation of Parse.ckOffset causing an assert()
+ # to fail. Probably harmless.
+ execsql {
+ SELECT coalesce(1, substr( 1, 2, length('in' IN (SELECT 1))))
+ }
+} {1}
+
#----------------------------------------------------------------
# Test some fuzzily generated expressions.
#
}
} {}
set ::TableList [list abc def ghi]
-set ::ColumnList [list a b c]
#----------------------------------------------------------------
# Test some fuzzily generated SELECT statements.
do_test fuzz-5.3 {execsql COMMIT} {}
integrity_check fuzz-5.4.integrity
-do_fuzzy_test fuzz-6.1 -template {[Select]}
+#----------------------------------------------------------------
+# Now that there is data in the datbase, run some more SELECT
+# statements
+#
+set ::ColumnList [list a b c]
+set E {{no such col} {ambiguous column name}}
+do_fuzzy_test fuzz-6.1 -template {[Select]} -errorlist $E
+
+#----------------------------------------------------------------
+# Run some SELECTs, INSERTs, UPDATEs and DELETEs in a transaction.
+#
+set E {{no such col} {ambiguous column name} {table}}
+do_test fuzz-7.1 {execsql BEGIN} {}
+do_fuzzy_test fuzz-7.2 -template {[Statement]} -errorlist $E
+integrity_check fuzz-7.3.integrity
+do_test fuzz-7.4 {execsql COMMIT} {}
+integrity_check fuzz-7.5.integrity
close $::log
finish_test