Disable query flattening when the outer query is a compound SELECT and

the inner query has a LIMIT clause.  Ticket [02a8e81d44].

FossilOrigin-Name: f96782b389b5b97b488dc5814f7082e0393f64cd
This commit is contained in:
drh 2010-04-15 23:24:29 +00:00
parent ed808acd1b
commit f391327824
4 changed files with 45 additions and 13 deletions

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C The\squery\splanner\sfix\sof\scheck-in\s[33b1f584ef]\sshould\shave\sbeen\son\sthe\strunk.
D 2010-04-15T13:29:38
C Disable\squery\sflattening\swhen\sthe\souter\squery\sis\sa\scompound\sSELECT\sand\nthe\sinner\squery\shas\sa\sLIMIT\sclause.\s\sTicket\s[02a8e81d44].
D 2010-04-15T23:24:29
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -167,7 +167,7 @@ F src/printf.c 5f5b65a83e63f2096a541a340722a509fa0240a7
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c ac5f1a713cd1ae77f08b83cc69581e11bf5ae6f9
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c 5a08245cb18b7ddf2456274653599cbf738d3830
F src/select.c b7c9a40bc1567bceff52ad4b73108734ee4bf268
F src/shell.c c40427c7245535a04a9cb4a417b6cc05c022e6a4
F src/sqlite.h.in 0aeb53778e1591032fdf12ba7aa059250beb480a
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
@ -614,6 +614,7 @@ F test/thread2.test 6e0997f7beabb6a7e471bd18740ed04805c785f4
F test/thread_common.tcl b65e6b1d1d90dc885e10ad080896c6c56eef0819
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9
F test/tkt-02a8e81d44.test 58494de77be2cf249228ada3f313fa399821c6ab
F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28
F test/tkt-31338dca7e.test 5741cd48de500347a437ba1be58c8335e83c5a5e
F test/tkt-3fe897352e.test 10de1a67bd5c66b238a4c96abe55531b37bb4f00
@ -800,14 +801,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P defaf0d99a807027f8883bf821b6482025f9f54e
R a8916448766fe2dc0eee7acf074d6482
P f538d759beda67e042b66181b65bd432488f7650
R 34d0a17088c0fdff5f60f2ea4cf2882d
U drh
Z 28450adfa9ef42da4766c0ed11d89126
Z b46bcb95ee573d80fced144df93d24f1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLxxTGoxKgR168RlERAr/aAJwLuSD1d16efrb/1zmza7D1Lt3gJwCeMzR0
I06a/9mduq2NTfZ7gOTnT48=
=kB+a
iD8DBQFLx6AxoxKgR168RlERAq3yAJ9VLNfRM+IKVowVDGm7aiEH4HuZmQCaA/ai
zk4R64zbGoGnQ/UpEadFxjM=
=0vth
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
f538d759beda67e042b66181b65bd432488f7650
f96782b389b5b97b488dc5814f7082e0393f64cd

View File

@ -2526,8 +2526,8 @@ static void substSelect(
** (14) The subquery does not use OFFSET
**
** (15) The outer query is not part of a compound select or the
** subquery does not have both an ORDER BY and a LIMIT clause.
** (See ticket #2339)
** subquery does not have a LIMIT clause.
** (See ticket #2339 and ticket [02a8e81d44]).
**
** (16) The outer query is not an aggregate or the subquery does
** not contain ORDER BY. (Ticket #2942) This used to not matter
@ -2610,7 +2610,7 @@ static int flattenSubquery(
** and (14). */
if( pSub->pLimit && p->pLimit ) return 0; /* Restriction (13) */
if( pSub->pOffset ) return 0; /* Restriction (14) */
if( p->pRightmost && pSub->pLimit && pSub->pOrderBy ){
if( p->pRightmost && pSub->pLimit ){
return 0; /* Restriction (15) */
}
if( pSubSrc->nSrc==0 ) return 0; /* Restriction (7) */

31
test/tkt-02a8e81d44.test Normal file
View File

@ -0,0 +1,31 @@
# 2010 April 15
#
# 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.
#
# This file implements tests to verify that ticket [02a8e81d44] has been
# fixed.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test tkt-02a838-1.1 {
execsql {
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(4);
INSERT INTO t1 VALUES(5);
SELECT * FROM (SELECT a FROM t1 LIMIT 1) UNION ALL SELECT 3;
}
} {1 3}
finish_test