1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

A fix for queries that used correlated, compound sub-queries in the HAVING clause. Also update fuzz.test some more. (CVS 4001)

FossilOrigin-Name: da0c1ab4deedd2b952a43b3af6962a9403f8c9ee
This commit is contained in:
danielk1977
2007-05-15 07:00:34 +00:00
parent 4e5dd85135
commit 15d7982ad8
4 changed files with 76 additions and 21 deletions

View File

@ -19,13 +19,15 @@
#
# The most complicated trees are for SELECT statements.
#
# $Id: fuzz.test,v 1.10 2007/05/14 16:50:49 danielk1977 Exp $
# $Id: fuzz.test,v 1.11 2007/05/15 07:00:34 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# set ::REPEATS 20
set ::REPEATS 5000
if {[info exists $::ISQUICK]} {
if {$::ISQUICK} { set ::REPEATS 20 }
}
proc fuzz {TemplateList} {
set n [llength $TemplateList]
@ -179,8 +181,8 @@ proc SimpleSelect {{nRes 0}} {
if {$::SelectDepth < 4} {
lappend TemplateList \
{[SelectKw] [ResultSet $nRes $::ColumnList] FROM ([Select])} \
{[SelectKw] [ResultSet $nRes] FROM ([Select])} \
{[SelectKw] [ResultSet $nRes $::ColumnList] FROM [Table]} \
{[SelectKw] [ResultSet $nRes] FROM ([Select])} \
{[SelectKw] [ResultSet $nRes $::ColumnList] FROM [Table]} \
{
[SelectKw] [ResultSet $nRes $::ColumnList]
FROM ([Select])
@ -189,10 +191,10 @@ proc SimpleSelect {{nRes 0}} {
} \
if {0 == $nRes} {
lappend TemplateList \
{[SelectKw] * FROM ([Select])} \
{[SelectKw] * FROM [Table]} \
{[SelectKw] * FROM [Table] WHERE [Expr $::ColumnList]} \
lappend TemplateList \
{[SelectKw] * FROM ([Select])} \
{[SelectKw] * FROM [Table]} \
{[SelectKw] * FROM [Table] WHERE [Expr $::ColumnList]} \
{
[SelectKw] *
FROM [Table],[Table] AS t2
@ -321,6 +323,26 @@ proc Coltype {} {
fuzz $TemplateList
}
proc DropTable {} {
set TemplateList {
{DROP TABLE IF EXISTS [Identifier]}
}
fuzz $TemplateList
}
proc CreateView {} {
set TemplateList {
{CREATE VIEW [Identifier] AS [Select]}
}
fuzz $TemplateList
}
proc DropView {} {
set TemplateList {
{DROP VIEW IF EXISTS [Identifier]}
}
fuzz $TemplateList
}
proc CreateTable {} {
set TemplateList {
{CREATE TABLE [Identifier]([Identifier] [Coltype], [Identifier] [Coltype])}
@ -329,6 +351,16 @@ proc CreateTable {} {
fuzz $TemplateList
}
proc CreateOrDropTableOrView {} {
set TemplateList {
{[CreateTable]}
{[DropTable]}
{[CreateView]}
{[DropView]}
}
fuzz $TemplateList
}
########################################################################
set ::log [open fuzzy.log w]
@ -496,6 +528,26 @@ do_test fuzz-1.13 {
}
} {abcd efgh}
do_test fuzz-1.14.1 {
execsql {
CREATE TABLE abc(a, b, c);
INSERT INTO abc VALUES(123, 456, 789);
}
# The [a] reference in the sub-select was causing a problem. Because
# the internal walkSelectExpr() function was not considering compound
# SELECT operators.
execsql {
SELECT 1 FROM abc
GROUP BY c HAVING EXISTS (SELECT a UNION SELECT 123);
}
} {1}
do_test fuzz-1.14.2 {
execsql {
DROP TABLE abc;
}
} {}
#----------------------------------------------------------------
# Test some fuzzily generated expressions.
#
@ -565,10 +617,10 @@ do_test fuzz-7.4 {execsql COMMIT} {}
integrity_check fuzz-7.5.integrity
#----------------------------------------------------------------
# Many CREATE TABLE statements:
# Many CREATE and DROP TABLE statements:
#
do_fuzzy_test fuzz-8.1 -template {[CreateTable]} \
-errorlist {table duplicate} -repeats 1000
set E [list table duplicate {no such col} {ambiguous column name}]
do_fuzzy_test fuzz-8.1 -template {[CreateOrDropTableOrView]} -errorlist $E
close $::log
finish_test