3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # Test cases to show that a join involving an empty table is very fast.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
18 # Build some test data
20 do_execsql_test emptytable-100 {
22 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
23 INSERT INTO t1(a) SELECT x FROM c;
24 CREATE TABLE empty(x);
25 SELECT count(*) FROM t1;
28 # Interrupt queries after 1M cycles to prevent burning excess CPU
32 db progress 1000000 {stopDb}
34 # Prior to the query planner optimization on 2017-02-15, this query would
35 # take a ridiculous amount of time. If that optimization stops working,
36 # the result here will be in interrupt for running too long.
38 do_catchsql_test emptytable-110 {
39 SELECT count(*) FROM t1, t1, t1, t1, t1, t1, empty;
42 do_catchsql_test emptytable-120 {
43 SELECT count(*) FROM t1, t1 LEFT JOIN empty;
45 do_catchsql_test emptytable-121 {
46 SELECT count(*) FROM t1, t1 LEFT JOIN t1, empty;