Extend out-of-memory testing with fuzzily generated sql some. One fix for a problem found by the same. (CVS 4044)

FossilOrigin-Name: d2282e64f1320913797dfb4dae4db0428a15a200
This commit is contained in:
danielk1977 2007-05-31 08:20:43 +00:00
parent c9cf901d8c
commit 9afe689ea4
5 changed files with 48 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Add\ssome\sextra\stests\sfor\smalloc\sfailure\sduring\sexpression\sparsing\sand\sexecution\susing\sfuzzily\sgenerated\sSQL.\s(CVS\s4043)
D 2007-05-30T10:36:47
C Extend\sout-of-memory\stesting\swith\sfuzzily\sgenerated\ssql\ssome.\sOne\sfix\sfor\sa\sproblem\sfound\sby\sthe\ssame.\s(CVS\s4044)
D 2007-05-31T08:20:44
F Makefile.in a42354804b50c2708ce72cf79e4daa30f50191b5
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -100,7 +100,7 @@ F src/pragma.c 0d25dad58bdfd6789943a10f1b9663c2eb85b96d
F src/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089
F src/printf.c cd91e057fa7e2661673eecd4eeecf4900b1e5cfe
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
F src/select.c c10b98aeccc67a9724c37bbecd6553e5a8da5bf6
F src/select.c 6d40db6c1fe9be9f6f45e5436e73cd22f161980a
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
F src/sqlite.h.in b174b5508467deec4034c6c8a21f0354b498b46b
@ -253,7 +253,7 @@ F test/func.test 605989453d1b42cec1d05c17aa232dc98e3e04e6
F test/fuzz.test 62fc19dd36a427777fd671b569df07166548628a
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
F test/fuzz_common.tcl ff4bc2dfc465f6878f8e2d819620914365382731
F test/fuzz_malloc.test 41ef1135f2c319b4963b1524f1bdd4a3553b827d
F test/fuzz_malloc.test 9f48048eeac5f8984a513aa289bd3e89b70a6bd7
F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329
F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
@ -301,7 +301,7 @@ F test/malloc7.test 1cf52834509eac7ebeb92105dacd4669f9ca9869
F test/malloc8.test e4054ca2a87ab1d42255bec009b177ba20b5a487
F test/malloc9.test 8381041fd89c31fba60c8a1a1c776bb022108572
F test/mallocA.test 525674e6e0775a9bf85a33f1da1c6bbddc712c30
F test/mallocB.test 5a96951a5f06cfdbd48d61ac3add8aa77461b812
F test/mallocB.test 975ef7b76af7c8e2b3e635951c8fe9cd5139cb05
F test/malloc_common.tcl 3cda97d63fbf370061ffa9795a24e5027367fef3
F test/manydb.test 8de36b8d33aab5ef295b11d9e95310aeded31af8
F test/memdb.test a67bda4ff90a38f2b19f6c7f95aa7289e051d893
@ -500,7 +500,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 5d0b247ca1667f5d773bda337cb6f58c3b14676a
R a618a8ac57ff1c991566b3aa8912d34a
P 7522d2fb3204d107b8b4816d7f39c88741f20230
R 6c217896681fcecc432bcce6bb26f9b0
U danielk1977
Z 5fc3b63bae0e892acacf6621f7949f54
Z 71f138b002ad8359e64307b90b5d152a

View File

@ -1 +1 @@
7522d2fb3204d107b8b4816d7f39c88741f20230
d2282e64f1320913797dfb4dae4db0428a15a200

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.348 2007/05/14 16:50:49 danielk1977 Exp $
** $Id: select.c,v 1.349 2007/05/31 08:20:44 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -2650,6 +2650,10 @@ int sqlite3SelectResolve(
}
}
if( sqlite3MallocFailed() ){
return SQLITE_NOMEM;
}
/* Make sure the GROUP BY clause does not contain aggregate functions.
*/
if( pGroupBy ){

View File

@ -12,7 +12,7 @@
#
# This file tests malloc failures in concert with fuzzy SQL generation.
#
# $Id: fuzz_malloc.test,v 1.1 2007/05/30 10:36:47 danielk1977 Exp $
# $Id: fuzz_malloc.test,v 1.2 2007/05/31 08:20:44 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -25,18 +25,26 @@ set ::REPEATS 20
# Usage: do_fuzzy_malloc_test <testname> ?<options>?
#
# -template
# -sqlprep
# -repeats
#
proc do_fuzzy_malloc_test {testname args} {
set ::fuzzyopts(-repeats) $::REPEATS
set ::fuzzyopts(-sqlprep) {}
array set ::fuzzyopts $args
sqlite_malloc_fail 0
db close
file delete test.db test.db-journal
sqlite3 db test.db
set ::prep $::fuzzyopts(-sqlprep)
execsql $::prep
for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
set ::sql [subst $::fuzzyopts(-template)]
# puts $::sql
foreach {rc res} [catchsql $::sql] {}
foreach {rc res} [catchsql "$::sql"] {}
if {$rc==0} {
do_malloc_test $testname-$ii -sqlbody $::sql
do_malloc_test $testname-$ii -sqlbody $::sql -sqlprep $::prep
} else {
incr ii -1
}
@ -48,6 +56,26 @@ proc do_fuzzy_malloc_test {testname args} {
# generated expressions.
#
do_fuzzy_malloc_test fuzzy_malloc-1 -template {Select [Expr]}
do_fuzzy_malloc_test fuzzy_malloc-2 -template {[Select]}
set ::SQLPREP {
BEGIN;
CREATE TABLE abc(a, b, c);
CREATE TABLE def(a, b, c);
CREATE TABLE ghi(a, b, c);
INSERT INTO abc VALUES(1.5, 3, 'a short string');
INSERT INTO def VALUES(NULL, X'ABCDEF',
'a longer string. Long enough that it doesn''t fit in Mem.zShort');
INSERT INTO ghi VALUES(zeroblob(1000), 'hello world', -1257900987654321);
COMMIT;
}
set ::TableList [list abc def ghi]
set ::ColumnList [list a b c]
do_fuzzy_malloc_test fuzzy_malloc-3 \
-template {[Select]} \
-sqlprep $::SQLPREP
sqlite_malloc_fail 0
finish_test

View File

@ -12,7 +12,7 @@
# These were all discovered by fuzzy generation of SQL. Apart from
# that they have little in common.
#
# $Id: mallocB.test,v 1.1 2007/05/30 10:36:47 danielk1977 Exp $
# $Id: mallocB.test,v 1.2 2007/05/31 08:20:44 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -30,6 +30,7 @@ do_malloc_test mallocB-1 -sqlbody {SELECT - 456}
do_malloc_test mallocB-2 -sqlbody {SELECT - 456.1}
do_malloc_test mallocB-3 -sqlbody {SELECT random()}
do_malloc_test mallocB-4 -sqlbody {SELECT zeroblob(1000)}
do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;}
sqlite_malloc_fail 0
finish_test