Merge support for table-valued functions.
FossilOrigin-Name: 96a5d44d9fcb7b159c04630ad2d956fe27df5a43
This commit is contained in:
+54
-38
@@ -286,6 +286,22 @@ foreach {key value} [array get ::Platforms] {
|
||||
}
|
||||
}
|
||||
|
||||
# Output log
|
||||
#
|
||||
set LOG [open releasetest-out.txt w]
|
||||
proc PUTS {args} {
|
||||
if {[llength $args]==2} {
|
||||
puts [lindex $args 0] [lindex $args 1]
|
||||
puts [lindex $args 0] $::LOG [lindex $args 1]
|
||||
} else {
|
||||
puts [lindex $args 0]
|
||||
puts $::LOG [lindex $args 0]
|
||||
}
|
||||
}
|
||||
puts $LOG "$argv0 $argv"
|
||||
set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]
|
||||
puts $LOG "start-time: $tm0 UTC"
|
||||
|
||||
# Open the file $logfile and look for a report on the number of errors
|
||||
# and the number of test cases run. Add these values to the global
|
||||
# $::NERRCASE and $::NTESTCASE variables.
|
||||
@@ -408,7 +424,7 @@ proc run_test_suite {name testtarget config} {
|
||||
|
||||
if {!$::TRACE} {
|
||||
set n [string length $title]
|
||||
puts -nonewline "${title}[string repeat . [expr {63-$n}]]"
|
||||
PUTS -nonewline "${title}[string repeat . [expr {63-$n}]]"
|
||||
flush stdout
|
||||
}
|
||||
|
||||
@@ -433,12 +449,12 @@ proc run_test_suite {name testtarget config} {
|
||||
set seconds [expr {($tm2-$tm1)%60}]
|
||||
set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
|
||||
if {$rc} {
|
||||
puts " FAIL $tm"
|
||||
PUTS " FAIL $tm"
|
||||
incr ::NERR
|
||||
} else {
|
||||
puts " Ok $tm"
|
||||
PUTS " Ok $tm"
|
||||
}
|
||||
if {$errmsg!=""} {puts " $errmsg"}
|
||||
if {$errmsg!=""} {PUTS " $errmsg"}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,7 +496,7 @@ proc makeCommand { targets cflags opts } {
|
||||
#
|
||||
proc trace_cmd {args} {
|
||||
if {$::TRACE} {
|
||||
puts $args
|
||||
PUTS $args
|
||||
}
|
||||
if {!$::DRYRUN} {
|
||||
uplevel 1 $args
|
||||
@@ -548,25 +564,25 @@ proc process_options {argv} {
|
||||
}
|
||||
|
||||
-info {
|
||||
puts "Command-line Options:"
|
||||
puts " --srcdir $::SRCDIR"
|
||||
puts " --platform [list $platform]"
|
||||
puts " --config [list $config]"
|
||||
PUTS "Command-line Options:"
|
||||
PUTS " --srcdir $::SRCDIR"
|
||||
PUTS " --platform [list $platform]"
|
||||
PUTS " --config [list $config]"
|
||||
if {$::QUICK} {
|
||||
if {$::QUICK==1} {puts " --quick"}
|
||||
if {$::QUICK==2} {puts " --veryquick"}
|
||||
if {$::QUICK==1} {PUTS " --quick"}
|
||||
if {$::QUICK==2} {PUTS " --veryquick"}
|
||||
}
|
||||
if {$::MSVC} {puts " --msvc"}
|
||||
if {$::BUILDONLY} {puts " --buildonly"}
|
||||
if {$::DRYRUN} {puts " --dryrun"}
|
||||
if {$::TRACE} {puts " --trace"}
|
||||
puts "\nAvailable --platform options:"
|
||||
if {$::MSVC} {PUTS " --msvc"}
|
||||
if {$::BUILDONLY} {PUTS " --buildonly"}
|
||||
if {$::DRYRUN} {PUTS " --dryrun"}
|
||||
if {$::TRACE} {PUTS " --trace"}
|
||||
PUTS "\nAvailable --platform options:"
|
||||
foreach y [lsort [array names ::Platforms]] {
|
||||
puts " [list $y]"
|
||||
PUTS " [list $y]"
|
||||
}
|
||||
puts "\nAvailable --config options:"
|
||||
PUTS "\nAvailable --config options:"
|
||||
foreach y [lsort [array names ::Configs]] {
|
||||
puts " [list $y]"
|
||||
PUTS " [list $y]"
|
||||
}
|
||||
exit
|
||||
}
|
||||
@@ -592,22 +608,22 @@ proc process_options {argv} {
|
||||
}
|
||||
|
||||
default {
|
||||
puts stderr ""
|
||||
puts stderr [string trim $::USAGE_MESSAGE]
|
||||
PUTS stderr ""
|
||||
PUTS stderr [string trim $::USAGE_MESSAGE]
|
||||
exit -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if {0==[info exists ::Platforms($platform)]} {
|
||||
puts "Unknown platform: $platform"
|
||||
puts -nonewline "Set the -platform option to "
|
||||
PUTS "Unknown platform: $platform"
|
||||
PUTS -nonewline "Set the -platform option to "
|
||||
set print [list]
|
||||
foreach p [array names ::Platforms] {
|
||||
lappend print "\"$p\""
|
||||
}
|
||||
lset print end "or [lindex $print end]"
|
||||
puts "[join $print {, }]."
|
||||
PUTS "[join $print {, }]."
|
||||
exit
|
||||
}
|
||||
|
||||
@@ -617,17 +633,17 @@ proc process_options {argv} {
|
||||
} else {
|
||||
set ::CONFIGLIST $::Platforms($platform)
|
||||
}
|
||||
puts "Running the following test configurations for $platform:"
|
||||
puts " [string trim $::CONFIGLIST]"
|
||||
puts -nonewline "Flags:"
|
||||
if {$::DRYRUN} {puts -nonewline " --dryrun"}
|
||||
if {$::BUILDONLY} {puts -nonewline " --buildonly"}
|
||||
if {$::MSVC} {puts -nonewline " --msvc"}
|
||||
PUTS "Running the following test configurations for $platform:"
|
||||
PUTS " [string trim $::CONFIGLIST]"
|
||||
PUTS -nonewline "Flags:"
|
||||
if {$::DRYRUN} {PUTS -nonewline " --dryrun"}
|
||||
if {$::BUILDONLY} {PUTS -nonewline " --buildonly"}
|
||||
if {$::MSVC} {PUTS -nonewline " --msvc"}
|
||||
switch -- $::QUICK {
|
||||
1 {puts -nonewline " --quick"}
|
||||
2 {puts -nonewline " --veryquick"}
|
||||
1 {PUTS -nonewline " --quick"}
|
||||
2 {PUTS -nonewline " --veryquick"}
|
||||
}
|
||||
puts ""
|
||||
PUTS ""
|
||||
}
|
||||
|
||||
# Main routine.
|
||||
@@ -637,7 +653,7 @@ proc main {argv} {
|
||||
# Process any command line options.
|
||||
set ::EXTRACONFIG {}
|
||||
process_options $argv
|
||||
puts [string repeat * 79]
|
||||
PUTS [string repeat * 79]
|
||||
|
||||
set ::NERR 0
|
||||
set ::NTEST 0
|
||||
@@ -648,7 +664,7 @@ proc main {argv} {
|
||||
foreach {zConfig target} $::CONFIGLIST {
|
||||
if {$::MSVC && ($zConfig eq "Sanitize" || "checksymbols" in $target
|
||||
|| "valgrindtest" in $target)} {
|
||||
puts "Skipping $zConfig / $target for MSVC..."
|
||||
PUTS "Skipping $zConfig / $target for MSVC..."
|
||||
continue
|
||||
}
|
||||
if {$target ne "checksymbols"} {
|
||||
@@ -693,10 +709,10 @@ proc main {argv} {
|
||||
set min [expr {($elapsetime/60)%60}]
|
||||
set sec [expr {$elapsetime%60}]
|
||||
set etime [format (%02d:%02d:%02d) $hr $min $sec]
|
||||
puts [string repeat * 79]
|
||||
puts "$::NERRCASE failures out of $::NTESTCASE tests in $etime"
|
||||
PUTS [string repeat * 79]
|
||||
PUTS "$::NERRCASE failures out of $::NTESTCASE tests in $etime"
|
||||
if {$::SQLITE_VERSION ne ""} {
|
||||
puts "SQLite $::SQLITE_VERSION"
|
||||
PUTS "SQLite $::SQLITE_VERSION"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
# 2012 July 12
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix spellfix2
|
||||
|
||||
ifcapable !vtab { finish_test ; return }
|
||||
load_static_extension db spellfix nextchar
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE VIRTUAL TABLE demo USING spellfix1;
|
||||
INSERT INTO demo(word) VALUES ('amsterdam');
|
||||
INSERT INTO demo(word) VALUES ('amsterdammetje');
|
||||
INSERT INTO demo(word) VALUES ('amsterdamania');
|
||||
INSERT INTO demo(word) VALUES ('amsterdamweg');
|
||||
INSERT INTO demo(word) VALUES ('amsterdamsestraat');
|
||||
INSERT INTO demo(word) VALUES ('amsterdamlaan');
|
||||
}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
SELECT word, distance, matchlen FROM demo
|
||||
WHERE word MATCH 'amstedam*' AND top=3;
|
||||
} {
|
||||
amsterdam 100 9
|
||||
amsterdammetje 100 9
|
||||
amsterdamania 100 9
|
||||
}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
SELECT word, distance, matchlen FROM demo WHERE
|
||||
word MATCH 'amstedam*' AND top=3 AND distance <= 100;
|
||||
} {
|
||||
amsterdam 100 9
|
||||
amsterdammetje 100 9
|
||||
amsterdamania 100 9
|
||||
}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
SELECT word, distance, matchlen FROM demo WHERE
|
||||
word MATCH 'amstedam*' AND distance <= 100;
|
||||
} {
|
||||
amsterdam 100 9
|
||||
amsterdammetje 100 9
|
||||
amsterdamania 100 9
|
||||
amsterdamweg 100 9
|
||||
amsterdamsestraat 100 9
|
||||
amsterdamlaan 100 9
|
||||
}
|
||||
|
||||
do_test 1.4 {
|
||||
foreach l {a b c d e f g h i j k l m n o p q r s t u v w x y z} {
|
||||
execsql { INSERT INTO demo(word) VALUES ('amsterdam' || $l) }
|
||||
}
|
||||
} {}
|
||||
|
||||
do_execsql_test 1.5 {
|
||||
SELECT count(*) FROM demo WHERE word MATCH 'amstedam*' AND distance <= 100;
|
||||
SELECT count(*) FROM demo
|
||||
WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20;
|
||||
} {
|
||||
32 20
|
||||
}
|
||||
|
||||
do_execsql_test 1.6 {
|
||||
SELECT word, distance, matchlen FROM demo
|
||||
WHERE word MATCH 'amstedam*' AND distance <= 100;
|
||||
} {
|
||||
amsterdam 100 9 amsterdamh 100 9
|
||||
amsterdamm 100 9 amsterdamn 100 9
|
||||
amsterdama 100 9 amsterdame 100 9
|
||||
amsterdami 100 9 amsterdamo 100 9
|
||||
amsterdamu 100 9 amsterdamy 100 9
|
||||
amsterdammetje 100 9 amsterdamania 100 9
|
||||
amsterdamb 100 9 amsterdamf 100 9
|
||||
amsterdamp 100 9 amsterdamv 100 9
|
||||
amsterdamw 100 9 amsterdamweg 100 9
|
||||
amsterdamc 100 9 amsterdamg 100 9
|
||||
amsterdamj 100 9 amsterdamk 100 9
|
||||
amsterdamq 100 9 amsterdams 100 9
|
||||
amsterdamx 100 9 amsterdamz 100 9
|
||||
amsterdamsestraat 100 9 amsterdamd 100 9
|
||||
amsterdamt 100 9 amsterdaml 100 9
|
||||
amsterdamlaan 100 9 amsterdamr 100 9
|
||||
}
|
||||
|
||||
do_execsql_test 1.7 {
|
||||
SELECT word, distance, matchlen FROM demo
|
||||
WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20;
|
||||
} {
|
||||
amsterdam 100 9 amsterdamh 100 9
|
||||
amsterdamm 100 9 amsterdamn 100 9
|
||||
amsterdama 100 9 amsterdame 100 9
|
||||
amsterdami 100 9 amsterdamo 100 9
|
||||
amsterdamu 100 9 amsterdamy 100 9
|
||||
amsterdammetje 100 9 amsterdamania 100 9
|
||||
amsterdamb 100 9 amsterdamf 100 9
|
||||
amsterdamp 100 9 amsterdamv 100 9
|
||||
amsterdamw 100 9 amsterdamweg 100 9
|
||||
amsterdamc 100 9 amsterdamg 100 9
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# 2015-08-19
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements tests for table-valued-functions implemented using
|
||||
# eponymous virtual tables.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix tabfunc01
|
||||
|
||||
ifcapable !vtab {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
load_static_extension db series
|
||||
|
||||
do_execsql_test tabfunc01-1.1 {
|
||||
SELECT *, '|' FROM generate_series WHERE start=1 AND stop=9 AND step=2;
|
||||
} {1 | 3 | 5 | 7 | 9 |}
|
||||
do_execsql_test tabfunc01-1.2 {
|
||||
SELECT *, '|' FROM generate_series LIMIT 5;
|
||||
} {0 | 1 | 2 | 3 | 4 |}
|
||||
do_catchsql_test tabfunc01-1.3 {
|
||||
CREATE VIRTUAL TABLE t1 USING generate_series;
|
||||
} {1 {no such module: generate_series}}
|
||||
do_execsql_test tabfunc01-1.4 {
|
||||
SELECT * FROM generate_series(1,9,2);
|
||||
} {1 3 5 7 9}
|
||||
do_execsql_test tabfunc01-1.5 {
|
||||
SELECT * FROM generate_series(1,9);
|
||||
} {1 2 3 4 5 6 7 8 9}
|
||||
do_execsql_test tabfunc01-1.6 {
|
||||
SELECT * FROM generate_series(1,10) WHERE step=3;
|
||||
} {1 4 7 10}
|
||||
do_catchsql_test tabfunc01-1.7 {
|
||||
SELECT * FROM generate_series(1,9,2,11);
|
||||
} {1 {too many arguments on generate_series - max 3}}
|
||||
|
||||
do_execsql_test tabfunc01-1.8 {
|
||||
SELECT * FROM generate_series(0,32,5) ORDER BY rowid DESC;
|
||||
} {30 25 20 15 10 5 0}
|
||||
|
||||
do_execsql_test tabfunc01-2.1 {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1(x) VALUES(2),(3);
|
||||
SELECT *, '|' FROM t1, generate_series(1,x) ORDER BY 1, 2
|
||||
} {2 1 | 2 2 | 3 1 | 3 2 | 3 3 |}
|
||||
|
||||
finish_test
|
||||
Reference in New Issue
Block a user