mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Implement FROM-clause subqueries as co-routines whenever they are guaranteed
to be the outer-most loop of the join. FossilOrigin-Name: c7bae50bdccb5bcf3bc22e8ac5bb6725ef13db39
This commit is contained in:
@ -12,7 +12,6 @@
|
||||
# focus of this file is testing UNION, INTERSECT and EXCEPT operators
|
||||
# in SELECT statements.
|
||||
#
|
||||
# $Id: select4.test,v 1.30 2009/04/16 00:24:24 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -936,4 +935,40 @@ do_execsql_test select4-15.1 {
|
||||
ORDER BY 1;
|
||||
} {1 33 456 2 33 789}
|
||||
|
||||
# Enhancement (2016-03-15): Use a co-routine for subqueries if the
|
||||
# subquery is guaranteed to be the outer-most query
|
||||
#
|
||||
do_execsql_test select4-16.1 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(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,
|
||||
PRIMARY KEY(a,b DESC)) WITHOUT ROWID;
|
||||
|
||||
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
|
||||
INSERT INTO t1(a,b,c,d)
|
||||
SELECT x%10, x/10, x, printf('xyz%dabc',x) FROM c;
|
||||
|
||||
SELECT t3.c FROM
|
||||
(SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
|
||||
JOIN t1 AS t3
|
||||
WHERE t2.a=t3.a AND t2.m=t3.b
|
||||
ORDER BY t3.a;
|
||||
} {95 96 97 98 99}
|
||||
do_execsql_test select4-16.2 {
|
||||
SELECT t3.c FROM
|
||||
(SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
|
||||
CROSS JOIN t1 AS t3
|
||||
WHERE t2.a=t3.a AND t2.m=t3.b
|
||||
ORDER BY t3.a;
|
||||
} {95 96 97 98 99}
|
||||
do_execsql_test select4-16.3 {
|
||||
SELECT t3.c FROM
|
||||
(SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
|
||||
LEFT JOIN t1 AS t3
|
||||
WHERE t2.a=t3.a AND t2.m=t3.b
|
||||
ORDER BY t3.a;
|
||||
} {95 96 97 98 99}
|
||||
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user