1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Merge the latest trunk enhancements into the reuse-schema branch.

FossilOrigin-Name: c2d4adabb929b6088808b05a2f031d045eb4839b44548a66006dc21e358e71f4
This commit is contained in:
drh
2024-03-18 18:56:10 +00:00
22 changed files with 1251 additions and 184 deletions

View File

@@ -736,4 +736,31 @@ do_execsql_test 29.7 {
END}
}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 30.0 {
CREATE TABLE t1(a, b);
CREATE VIEW v1 AS
SELECT ( VALUES(a), (b) ) FROM (
SELECT a, b FROM t1
)
;
}
do_execsql_test 30.1 {
SELECT * FROM v1
}
do_execsql_test 30.1 {
ALTER TABLE t1 RENAME TO t2;
}
do_execsql_test 30.2 {
SELECT sql FROM sqlite_schema WHERE type='view'
} {
{CREATE VIEW v1 AS
SELECT ( VALUES(a), (b) ) FROM (
SELECT a, b FROM "t2"
)}
}
finish_test

View File

@@ -1,4 +1,4 @@
# 2013 March 10
# 2023-03-10
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
@@ -9,7 +9,10 @@
#
#***********************************************************************
# This file implements regression tests for SQLite library. The focus of
# this file is testing the tointeger() and toreal() functions.
# this file is testing the tointeger() and toreal() functions that are
# part of the "totype.c" extension. This file does not test the core
# SQLite library. Failures of tests in this file are related to the
# ext/misc/totype.c extension.
#
# Several of the toreal() tests are disabled on platforms where floating
# point precision is not high enough to represent their constant integer
@@ -23,6 +26,20 @@ load_static_extension db totype
set highPrecision(1) [expr \
{[db eval {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}]
set highPrecision(2) [expr \
{[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}]
# highPrecision(3) is only known to be false on i586 with gcc-13 and -O2.
# It is true on the exact same platform with -O0. Both results seem
# reasonable, so we'll just very the expectation accordingly.
#
set highPrecision(3) [expr \
{[db eval {SELECT toreal(9007199254740992 + 1);}] eq {{}}}]
if {!$highPrecision(1) || !$highPrecision(2) || !$highPrecision(3)} {
puts "NOTICE: use_long_double: [use_long_double] \
highPrecision: $highPrecision(1) $highPrecision(2) $highPrecision(3)"
}
do_execsql_test func4-1.1 {
SELECT tointeger(NULL);
@@ -195,8 +212,6 @@ do_execsql_test func4-1.55 {
} {{}}
ifcapable floatingpoint {
set highPrecision(2) [expr \
{[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}]
do_execsql_test func4-2.1 {
SELECT toreal(NULL);
@@ -341,10 +356,14 @@ ifcapable floatingpoint {
do_execsql_test func4-2.45 {
SELECT toreal(9007199254740992);
} {9007199254740992.0}
if {$highPrecision(2)} {
if {$highPrecision(3)} {
do_execsql_test func4-2.46 {
SELECT toreal(9007199254740992 + 1);
} {{}}
} else {
do_execsql_test func4-2.46 {
SELECT toreal(9007199254740992 + 1);
} {9007199254740992.0}
}
do_execsql_test func4-2.47 {
SELECT toreal(9007199254740992 + 2);
@@ -626,10 +645,14 @@ ifcapable floatingpoint {
do_execsql_test func4-5.22 {
SELECT tointeger(toreal(9007199254740992));
} {9007199254740992}
if {$highPrecision(2)} {
if {$highPrecision(3)} {
do_execsql_test func4-5.23 {
SELECT tointeger(toreal(9007199254740992 + 1));
} {{}}
} else {
do_execsql_test func4-5.23 {
SELECT tointeger(toreal(9007199254740992 + 1));
} {9007199254740992}
}
do_execsql_test func4-5.24 {
SELECT tointeger(toreal(9007199254740992 + 2));

View File

@@ -458,14 +458,14 @@ do_execsql_test 11.0 {
do_execsql_test 11.1 {
SELECT * FROM t1
WHERE b IN (345, (SELECT 1 FROM t1
WHERE b IN (345 NOT GLOB 510)
WHERE b IN (coalesce(1,random()))
AND c GLOB 'abc*xyz'))
AND c BETWEEN 'abc' AND 'xyz';
} {xyz 1 abcdefxyz 99}
do_execsql_test 11.2 {
EXPLAIN SELECT * FROM t1
WHERE b IN (345, (SELECT 1 FROM t1
WHERE b IN (345 NOT GLOB 510)
WHERE b IN (coalesce(1,random()))
AND c GLOB 'abc*xyz'))
AND c BETWEEN 'abc' AND 'xyz';
} {/ SeekScan /}

View File

@@ -922,7 +922,7 @@ do_catchsql_test sqllimits1-18.1 {
do_catchsql_test sqllimits1-18.2 {
INSERT INTO b1 VALUES(1), (2), (3), (4), (5), (6), (7), (8), (9), (10)
UNION VALUES(11);
} {1 {too many terms in compound SELECT}}
} {0 {}}
#-------------------------------------------------------------------------
#

View File

@@ -64,6 +64,8 @@ Usage:
--dryrun
--explain
--jobs NUMBER-OF-JOBS
--stop-on-coredump
--stop-on-error
--zipvfs ZIPVFS-SOURCE-DIR
Special values for PERMUTATION that work with plain tclsh:
@@ -172,6 +174,8 @@ set TRG(zipvfs) "" ;# -zipvfs option, if any
set TRG(buildonly) 0 ;# True if --buildonly option
set TRG(dryrun) 0 ;# True if --dryrun option
set TRG(explain) 0 ;# True for the --explain option
set TRG(stopOnError) 0 ;# Stop running at first failure
set TRG(stopOnCore) 0 ;# Stop on a core-dump
switch -nocase -glob -- $tcl_platform(os) {
*darwin* {
@@ -468,6 +472,10 @@ for {set ii 0} {$ii < [llength $argv]} {incr ii} {
set TRG(dryrun) 1
} elseif {($n>2 && [string match "$a*" --explain]) || $a=="-e"} {
set TRG(explain) 1
} elseif {[string match "$a*" --stop-on-error]} {
set TRG(stopOnError) 1
} elseif {[string match "$a*" --stop-on-coredump]} {
set TRG(stopOnCore) 1
} else {
usage
}
@@ -993,6 +1001,14 @@ proc script_input_ready {fd iJob jobid} {
}
puts "FAILED: $job(displayname) ($iJob)"
set state "failed"
if {$TRG(stopOnError)} {
puts "OUTPUT: $O($iJob)"
exit 1
}
if {$TRG(stopOnCore) && [string first {core dumped} $O($iJob)]>0} {
puts "OUTPUT: $O($iJob)"
exit 1
}
}
set tm [clock_milliseconds]

583
test/values.test Normal file
View File

@@ -0,0 +1,583 @@
# 2024 March 3
#
# 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 regression tests for SQLite library.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix values
do_execsql_test 1.0 {
CREATE TABLE x1(a, b, c);
}
explain_i {
INSERT INTO x1(a, b, c) VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4);
}
do_execsql_test 1.1.1 {
INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4);
}
do_execsql_test 1.1.2 {
SELECT * FROM x1;
} {
1 1 1
2 2 2
3 3 3
4 4 4
}
do_execsql_test 1.2.0 {
DELETE FROM x1
}
do_execsql_test 1.2.1 {
INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3) UNION ALL SELECT 4, 4, 4;
SELECT * FROM x1;
} {1 1 1 2 2 2 3 3 3 4 4 4}
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 4
do_execsql_test 1.2.2 {
DELETE FROM x1;
INSERT INTO x1
VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5)
UNION ALL SELECT 6, 6, 6;
SELECT * FROM x1;
} {1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6}
do_execsql_test 1.2.3 {
DELETE FROM x1;
INSERT INTO x1
VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)
UNION ALL SELECT 6, 6, 6;
SELECT * FROM x1;
} {1 1 1 2 2 2 3 3 3 4 4 4 6 6 6}
do_execsql_test 1.2.4 {
DELETE FROM x1;
INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3) UNION ALL SELECT 6, 6, 6;
SELECT * FROM x1;
} {
1 1 1
2 2 2
3 3 3
6 6 6
}
set a 4
set b 5
set c 6
do_execsql_test 1.2.5 {
DELETE FROM x1;
INSERT INTO x1
VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3),
(4, 4, $a), (5, 5, $b), (6, 6, $c)
}
do_execsql_test 1.2.6 {
SELECT * FROM x1;
} {
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
}
#-------------------------------------------------------------------------
# SQLITE_LIMIT_COMPOUND_SELECT set to 0.
#
reset_db
do_execsql_test 2.0 {
CREATE TABLE x1(a, b, c);
}
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 3
do_catchsql_test 2.1.1 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10, 10)
} {1 {all VALUES must have the same number of terms}}
do_catchsql_test 2.1.2 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10)
} {1 {all VALUES must have the same number of terms}}
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 0
do_execsql_test 2.2 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10)
} {}
do_execsql_test 2.3 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10)
UNION ALL
SELECT 5, 12, 12
ORDER BY 1
} {}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 3.0 {
CREATE TABLE y1(x, y);
}
do_execsql_test 3.1.1 {
DELETE FROM y1;
INSERT INTO y1 VALUES(1, 2), (3, 4), (row_number() OVER (), 5);
}
do_execsql_test 3.1.2 {
SELECT * FROM y1;
} {1 2 3 4 1 5}
do_execsql_test 3.2.1 {
DELETE FROM y1;
INSERT INTO y1 VALUES(1, 2), (3, 4), (row_number() OVER (), 6)
, (row_number() OVER (), 7)
}
do_execsql_test 3.1.2 {
SELECT * FROM y1;
} {1 2 3 4 1 6 1 7}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 4.0 {
CREATE TABLE x1(a PRIMARY KEY, b) WITHOUT ROWID;
}
foreach {tn iLimit} {1 0 2 3} {
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT $iLimit
do_execsql_test 4.1.1 {
DELETE FROM x1;
INSERT INTO x1 VALUES
(1, 1),
(2, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d')) ))
}
do_execsql_test 4.1.2 {
SELECT * FROM x1
} {1 1 2 a}
do_execsql_test 4.2.1 {
DELETE FROM x1;
INSERT INTO x1 VALUES
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d')) ))
}
do_execsql_test 4.2.2 {
SELECT * FROM x1
} {1 1 2 2 3 3 4 4 5 a}
do_execsql_test 4.3.1 {
DELETE FROM x1;
INSERT INTO x1 VALUES
(1, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d'), ('e')) ))
}
do_execsql_test 4.3.2 {
SELECT * FROM x1
} {1 a}
}
#------------------------------------------------------------------------
reset_db
do_execsql_test 5.0 {
CREATE VIEW v1 AS VALUES(1, 2, 3), (4, 5, 6), (7, 8, 9);
}
do_execsql_test 5.1 {
SELECT * FROM v1
} {1 2 3 4 5 6 7 8 9}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 6.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1), (2);
}
do_execsql_test 6.1 {
SELECT ( VALUES( x ), ( x ) ) FROM t1;
} {1 2}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 6.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('x'), ('y');
}
do_execsql_test 6.1 {
SELECT * FROM t1, (VALUES(1), (2))
} {x 1 x 2 y 1 y 2}
do_execsql_test 6.2 {
VALUES(CAST(44 AS REAL)),(55);
} {44.0 55}
#------------------------------------------------------------------------
do_execsql_test 7.1 {
WITH x1(a, b) AS (
VALUES(1, 2), ('a', 'b')
)
SELECT * FROM x1 one, x1 two
} {
1 2 1 2
1 2 a b
a b 1 2
a b a b
}
#-------------------------------------------------------------------------
reset_db
set VVV {
( VALUES('a', 'b'), ('c', 'd'), (123, NULL) )
}
set VVV2 {
(
SELECT 'a' AS column1, 'b' AS column2
UNION ALL SELECT 'c', 'd' UNION ALL SELECT 123, NULL
)
}
do_execsql_test 8.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('d'), (NULL), (123)
}
foreach {tn q res} {
1 "SELECT * FROM t1 LEFT JOIN VVV" {
d a b d c d d 123 {}
{} a b {} c d {} 123 {}
123 a b 123 c d 123 123 {}
}
2 "SELECT * FROM t1 LEFT JOIN VVV ON (column1=x)" {
d {} {}
{} {} {}
123 123 {}
}
3 "SELECT * FROM t1 RIGHT JOIN VVV" {
d a b d c d d 123 {}
{} a b {} c d {} 123 {}
123 a b 123 c d 123 123 {}
}
4 "SELECT * FROM t1 RIGHT JOIN VVV ON (column1=x)" {
123 123 {}
{} a b
{} c d
}
5 "SELECT * FROM t1 FULL OUTER JOIN VVV ON (column1=x)" {
d {} {}
{} {} {}
123 123 {}
{} a b
{} c d
}
6 "SELECT count(*) FROM VVV" { 3 }
7 "SELECT (SELECT column1 FROM VVV)" { a }
8 "SELECT * FROM VVV UNION ALL SELECT * FROM VVV" {
a b c d 123 {}
a b c d 123 {}
}
9 "SELECT * FROM VVV INTERSECT SELECT * FROM VVV" {
123 {} a b c d
}
10 "SELECT * FROM VVV eXCEPT SELECT * FROM VVV" { }
11 "SELECT * FROM VVV eXCEPT SELECT 'a', 'b'" { 123 {} c d }
} {
set q1 [string map [list VVV $VVV] $q]
set q2 [string map [list VVV $VVV2] $q]
set q3 "WITH VVV AS $VVV $q"
do_execsql_test 8.1.$tn.1 $q1 $res
do_execsql_test 8.1.$tn.2 $q2 $res
do_execsql_test 8.1.$tn.3 $q3 $res
}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 9.1 {
VALUES(456), (123), (NULL) UNION ALL SELECT 122 ORDER BY 1
} { {} 122 123 456 }
do_execsql_test 9.2 {
VALUES (1, 2), (3, 4), (
( SELECT column1 FROM ( VALUES (5, 6), (7, 8) ) ),
( SELECT max(column2) FROM ( VALUES (5, 1), (7, 6) ) )
)
} { 1 2 3 4 5 6 }
do_execsql_test 10.1 {
CREATE TABLE a2(a, b, c DEFAULT 'xyz');
}
do_execsql_test 10.2 {
INSERT INTO a2(a) VALUES(3),(4);
}
#-------------------------------------------------------------------------
reset_db
ifcapable fts5 {
do_execsql_test 11.0 {
CREATE VIRTUAL TABLE ft USING fts3(x);
}
do_execsql_test 11.1 {
INSERT INTO ft VALUES('one'), ('two');
}
}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 12.0 {
CREATE TABLE t1(a, b);
}
do_execsql_test 12.1 {
INSERT INTO t1 SELECT 1, 2 UNION ALL VALUES(3, 4), (5, 6);
}
do_execsql_test 12.2 {
SELECT * FROM t1
} {1 2 3 4 5 6}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 13.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('xyz');
SELECT (
VALUES( (max(substr('abc', 1, 1), x)) ),
(123),
(456)
)
FROM t1;
} {xyz}
do_catchsql_test 13.1 {
VALUES(300), (zeroblob(300) OVER win);
} {1 {zeroblob() may not be used as a window function}}
#--------------------------------------------------------------------------
reset_db
do_execsql_test 14.1 {
PRAGMA encoding = utf16;
CREATE TABLE t1(a, b);
} {}
db close
sqlite3 db test.db
do_execsql_test 14.2 {
INSERT INTO t1 VALUES
(17, 'craft'),
(16, 'urtlek' IN(1,2,3));
}
#--------------------------------------------------------------------------
#
reset_db
do_eqp_test 15.1 {
VALUES(1),(2),(3),(4),(5);
} {
QUERY PLAN
`--SCAN 5-ROW VALUES CLAUSE
}
do_execsql_test 15.2 {
CREATE TABLE t1(a,b);
}
do_eqp_test 15.3 {
INSERT INTO t1 VALUES
(1,2),(3,4),(7,8);
} {
QUERY PLAN
`--SCAN 3-ROW VALUES CLAUSE
}
do_eqp_test 15.4 {
INSERT INTO t1 VALUES
(1,2),(3,4),(7,8),
(5,row_number()OVER());
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN 3-ROW VALUES CLAUSE
`--UNION ALL
|--CO-ROUTINE (subquery-xxxxxx)
| `--SCAN CONSTANT ROW
`--SCAN (subquery-xxxxxx)
}
do_eqp_test 15.5 {
SELECT * FROM (VALUES(1),(2),(3),(4),(5),(6)), (VALUES('a'),('b'),('c'));
} {
QUERY PLAN
|--SCAN 6-ROW VALUES CLAUSE
`--SCAN 3-ROW VALUES CLAUSE
}
do_execsql_test 15.6 {
CREATE TABLE t2(x,y);
}
do_eqp_test 15.7 {
SELECT * FROM t2 UNION ALL VALUES(1,2),(3,4),(5,6),(7,8);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN t2
`--UNION ALL
`--SCAN 4-ROW VALUES CLAUSE
}
#--------------------------------------------------------------------------
# The VALUES-as-coroutine optimization can be applied to later rows of
# a VALUES clause even if earlier rows do not qualify.
#
reset_db
do_execsql_test 16.1 {
CREATE TABLE t1(a,b);
}
do_execsql_test 16.2 {
BEGIN;
INSERT INTO t1 VALUES(1,2),(3,4),(5,6),
(7,row_number()OVER()),
(9,10), (11,12), (13,14), (15,16);
SELECT * FROM t1 ORDER BY a, b;
ROLLBACK;
} {1 2 3 4 5 6 7 1 9 10 11 12 13 14 15 16}
do_eqp_test 16.3 {
INSERT INTO t1 VALUES(1,2),(3,4),(5,6),
(7,row_number()OVER()),
(9,10), (11,12), (13,14), (15,16);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN 3-ROW VALUES CLAUSE
|--UNION ALL
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
`--UNION ALL
`--SCAN 4-ROW VALUES CLAUSE
}
do_execsql_test 16.4 {
BEGIN;
INSERT INTO t1 VALUES
(1,row_number()OVER()),
(2,3), (4,5), (6,7);
SELECT * FROM t1 ORDER BY a, b;
ROLLBACK;
} {1 1 2 3 4 5 6 7}
do_eqp_test 16.5 {
INSERT INTO t1 VALUES
(1,row_number()OVER()),
(2,3), (4,5), (6,7);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
`--UNION ALL
`--SCAN 3-ROW VALUES CLAUSE
}
do_execsql_test 16.6 {
BEGIN;
INSERT INTO t1 VALUES
(1,2),(3,4),
(5,row_number()OVER()),
(7,8),(9,10),(11,12),
(13,row_number()OVER()),
(15,16),(17,18),(19,20),(21,22);
SELECT * FROM t1 ORDER BY a, b;
ROLLBACK;
} { 1 2 3 4 5 1 7 8 9 10 11 12 13 1 15 16 17 18 19 20 21 22}
do_eqp_test 16.7 {
INSERT INTO t1 VALUES
(1,2),(3,4),
(5,row_number()OVER()),
(7,8),(9,10),(11,12),
(13,row_number()OVER()),
(15,16),(17,18),(19,20),(21,22);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN 2-ROW VALUES CLAUSE
|--UNION ALL
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
|--UNION ALL
| `--SCAN 3-ROW VALUES CLAUSE
|--UNION ALL
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
`--UNION ALL
`--SCAN 4-ROW VALUES CLAUSE
}
finish_test

37
test/valuesfault.test Normal file
View File

@@ -0,0 +1,37 @@
# 2024 March 3
#
# 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 regression tests for SQLite library.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix valuesfault
source $testdir/malloc_common.tcl
do_execsql_test 1.0 {
CREATE TABLE x1(a, b, c);
}
faultsim_save_and_close
do_faultsim_test 1 -prep {
faultsim_restore_and_reopen
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 2
} -body {
execsql {
INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4);
}
} -test {
faultsim_test_result {0 {}}
}
finish_test

View File

@@ -49,6 +49,33 @@ do_eqp_test 120 {
|--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
`--SCAN t3
}
do_eqp_test 121 {
SELECT * FROM t1, t2, t3
WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=abs(5)
ORDER BY t1.a;
} {
QUERY PLAN
|--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?)
|--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
`--SCAN t3
}
# The sqlite3ExprIsConstant() routine does not believe that
# the expression "coalesce(5,random())" is constant. So the
# optimization does not apply in this case.
#
sqlite3_create_function db
do_eqp_test 122 {
SELECT * FROM t1, t2, t3
WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=coalesce(5,random())
ORDER BY t1.a;
} {
QUERY PLAN
|--SCAN t3
|--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?)
|--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
`--USE TEMP B-TREE FOR ORDER BY
}
# Constant propagation in the face of collating sequences:
#