diff options
author | drh <> | 2025-07-08 19:53:36 +0000 |
---|---|---|
committer | drh <> | 2025-07-08 19:53:36 +0000 |
commit | 9a13a21223bdfc123dfd537c999822ff3077cfa8 (patch) | |
tree | 51b5ecfae9ceb57f879fb478574d5589765897be /test/existsfault.test | |
parent | 9b91aac83b3db7a108ed203ee43b40e2e735ac0e (diff) | |
parent | 449b34571e9022333eb0cd0ce403a4636719194d (diff) | |
download | sqlite-9a13a21223bdfc123dfd537c999822ff3077cfa8.tar.gz sqlite-9a13a21223bdfc123dfd537c999822ff3077cfa8.zip |
New optimizations to detect early when queries return no rows due to
tables being empty. This includes the EXISTS-to-JOIN optimization that
tries to transform EXISTS constraints into additional terms of the FROM
clause.
FossilOrigin-Name: e33da6d5dc964db817d1bc63c9083aecd93d49ee14d5198600b47eaf7c5b9331
Diffstat (limited to 'test/existsfault.test')
-rw-r--r-- | test/existsfault.test | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/existsfault.test b/test/existsfault.test new file mode 100644 index 000000000..4b335d84c --- /dev/null +++ b/test/existsfault.test @@ -0,0 +1,49 @@ +# 2024 May 25 +# +# 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 +source $testdir/lock_common.tcl +source $testdir/malloc_common.tcl +set testprefix existsfault + +db close +sqlite3_shutdown +sqlite3_config_lookaside 0 0 +sqlite3_initialize +autoinstall_test_functions +sqlite3 db test.db + +do_execsql_test 1.0 { + CREATE TABLE x1(a, b); + INSERT INTO x1 VALUES(1, 2), (3, 4), (5, 6); + CREATE UNIQUE INDEX x1a ON x1(a); + CREATE INDEX x1b ON x1(b); + + CREATE TABLE x2(x, y); + INSERT INTO x2 VALUES(1, 2), (3, 4), (5, 6); +} + +do_faultsim_test 1 -faults oom* -prep { + sqlite3 db test.db + execsql { SELECT * FROM sqlite_schema } +} -body { + execsql { + SELECT count(*) FROM x2 WHERE EXISTS (SELECT 1 FROM x1 WHERE a=x) AND y!=11 + } +} -test { + faultsim_test_result {0 3} +} + +finish_test + + |