diff options
author | drh <drh@noemail.net> | 2002-03-23 00:31:29 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2002-03-23 00:31:29 +0000 |
commit | 1cc3d75f69c12c8bb3a82670b5c6d2d432d3ef6c (patch) | |
tree | 262e38af6fa17f5defbcc1d727068a31f6065270 | |
parent | 545c23dc4235f22549bf714658dc39f5ad1e5630 (diff) | |
download | sqlite-1cc3d75f69c12c8bb3a82670b5c6d2d432d3ef6c.tar.gz sqlite-1cc3d75f69c12c8bb3a82670b5c6d2d432d3ef6c.zip |
Fix a bug in subquery generation when the subquery is a compound select.
Also added new tests to cover this case. (CVS 435)
FossilOrigin-Name: aaf7fd4cef04d3d70a0444aad1b606bfc663c3e8
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | manifest | 20 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/select.c | 9 | ||||
-rw-r--r-- | test/select6.test | 46 | ||||
-rw-r--r-- | www/changes.tcl | 5 | ||||
-rw-r--r-- | www/faq.tcl | 13 |
7 files changed, 76 insertions, 21 deletions
@@ -1 +1 @@ -2.4.2 +2.4.3 @@ -1,9 +1,9 @@ -C Version\s2.4.2\s(CVS\s441) -D 2002-03-20T01:05:00 +C Fix\sa\sbug\sin\ssubquery\sgeneration\swhen\sthe\ssubquery\sis\sa\scompound\sselect.\nAlso\sadded\snew\stests\sto\scover\sthis\scase.\s(CVS\s435) +D 2002-03-23T00:31:29 F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0 -F VERSION 0ca6986d9c1379523ecd35eec51f54857a8afd48 +F VERSION 50919ab26b7c119efb3f2fa5000696e75a9fb378 F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d F config.guess f38b1e93d1e0fa6f5a6913e9e7b12774b9232588 F config.log 6a73d03433669b10a3f0c221198c3f26b9413914 @@ -37,7 +37,7 @@ F src/pager.h 6fddfddd3b73aa8abc081b973886320e3c614f0e F src/parse.y 9a8be2eebad16f636292967d328882c2d07e30a9 F src/printf.c 300a90554345751f26e1fc0c0333b90a66110a1d F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe -F src/select.c 08b9d8acf75ad985dabde1b3c53025f59d5b09c6 +F src/select.c 9323800e2937e84b52c198fffc51995d822b1779 F src/shell.c b3454229599246b944cdb5b95753af3fca5d8bb0 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/sqlite.h.in 1dae50411aee9439860d7fbe315183c582d27197 @@ -88,7 +88,7 @@ F test/select2.test ed2c1882857106b85478f54f67000e14966be4c4 F test/select3.test 9469c332250a75a0ef1771fb5da62dc04ec77f18 F test/select4.test 29a2ffb187f3d8b6ca42a0a6b619e9cabe12e228 F test/select5.test c2a6c4a003316ee42cbbd689eebef8fdce0db2ac -F test/select6.test cc9e2efeefe73399b757d952800df2032560be87 +F test/select6.test 5b9b52e84c1f44fd3a4eeb75e78deceb085b78b0 F test/sort.test 3b996ce7ca385f9cd559944ac0f4027a23aa546b F test/subselect.test 335d3dad8d585726c447dfee8d9c4f7383c76b78 F test/table.test 17b0b6eafa3faaee5545b7a94e6c1ff73f0880f3 @@ -115,12 +115,12 @@ F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4 F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b F www/c_interface.tcl 567cda531aac9d68a61ef02e26c6b202bd856db2 -F www/changes.tcl d2530398b3f7d12de2dc1083fe6d082309184389 +F www/changes.tcl 65c1e63566ddbe09ef016c4c78ed21b6537af512 F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2 F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060 F www/download.tcl a6d75b8b117cd33dcb090bef7e80d7556d28ebe0 F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c -F www/faq.tcl c6d1d6d69a9083734ee73d1b5ee4253ae8f10074 +F www/faq.tcl fb1e92e2f604546694f83a36d969492f52fb685d F www/formatchng.tcl 2ce21ff30663fad6618198fe747ce675df577590 F www/index.tcl eacd99bcc3132d6e6b74a51422d415cc0bf7bfdf F www/lang.tcl d589f9a39c925d81fa9198b9215b4fd56da4192b @@ -130,7 +130,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279 F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P c2e0b79057c9c643e7432e62c90399c8f34339f9 -R febee3eb313aa60c56ad4221de74bd94 +P 49d032325553fa1dd7f31b852753cc6c9226d8f7 +R afbadc87908df7153445a9059806e384 U drh -Z 108938d1bedd485ef53334a9e6726bd8 +Z 20aa27678bc9a0889ed47e36fd4764d7 diff --git a/manifest.uuid b/manifest.uuid index d0fab06c0..2958797de 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -49d032325553fa1dd7f31b852753cc6c9226d8f7
\ No newline at end of file +aaf7fd4cef04d3d70a0444aad1b606bfc663c3e8
\ No newline at end of file diff --git a/src/select.c b/src/select.c index 41e5da555..d7f88f701 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.76 2002/03/14 14:33:31 drh Exp $ +** $Id: select.c,v 1.77 2002/03/23 00:31:29 drh Exp $ */ #include "sqliteInt.h" @@ -610,6 +610,13 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){ v = sqliteGetVdbe(pParse); if( v==0 ) return 1; + /* Create the destination temporary table if necessary + */ + if( eDest==SRT_TempTable ){ + sqliteVdbeAddOp(v, OP_OpenTemp, iParm, 0); + eDest = SRT_Table; + } + /* Process the UNION or INTERSECTION */ base = pParse->nTab; diff --git a/test/select6.test b/test/select6.test index 959bb2236..909167745 100644 --- a/test/select6.test +++ b/test/select6.test @@ -12,7 +12,7 @@ # focus of this file is testing SELECT statements that contain # subqueries in their FROM clause. # -# $Id: select6.test,v 1.7 2002/03/13 18:54:09 drh Exp $ +# $Id: select6.test,v 1.8 2002/03/23 00:31:29 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -292,4 +292,48 @@ do_test select6-5.2 { } } {8 5 8 9 6 9 10 7 10} +# Tests of compound sub-selects +# +do_test select5-6.1 { + execsql { + DELETE FROM t1 WHERE x>4; + SELECT * FROM t1 + } +} {1 1 2 2 3 2 4 3} +do_test select6-6.2 { + execsql { + SELECT * FROM ( + SELECT x AS 'a' FROM t1 UNION ALL SELECT x+10 AS 'a' FROM t1 + ) ORDER BY a; + } +} {1 2 3 4 11 12 13 14} +do_test select6-6.3 { + execsql { + SELECT * FROM ( + SELECT x AS 'a' FROM t1 UNION ALL SELECT x+1 AS 'a' FROM t1 + ) ORDER BY a; + } +} {1 2 2 3 3 4 4 5} +do_test select6-6.4 { + execsql { + SELECT * FROM ( + SELECT x AS 'a' FROM t1 UNION SELECT x+1 AS 'a' FROM t1 + ) ORDER BY a; + } +} {1 2 3 4 5} +do_test select6-6.5 { + execsql { + SELECT * FROM ( + SELECT x AS 'a' FROM t1 INTERSECT SELECT x+1 AS 'a' FROM t1 + ) ORDER BY a; + } +} {2 3 4} +do_test select6-6.6 { + execsql { + SELECT * FROM ( + SELECT x AS 'a' FROM t1 EXCEPT SELECT x*2 AS 'a' FROM t1 + ) ORDER BY a; + } +} {1 3} + finish_test diff --git a/www/changes.tcl b/www/changes.tcl index 6324f8e7f..9947a844b 100644 --- a/www/changes.tcl +++ b/www/changes.tcl @@ -17,6 +17,11 @@ proc chng {date desc} { puts "<DD><P><UL>$desc</UL></P></DD>" } +chng {2002 Mar 122 (2.4.3)} { +<li>Fix a bug in SELECT that occurs when a compound SELECT is used as a + subquery in the FROM of a SELECT.</li> +} + chng {2002 Mar 14 (2.4.2)} { <li>Bug fix: Fix an assertion failure that occurred when ROWID was a column in a SELECT statement on a view.</li> diff --git a/www/faq.tcl b/www/faq.tcl index e7df25087..9626ab8b6 100644 --- a/www/faq.tcl +++ b/www/faq.tcl @@ -1,7 +1,7 @@ # # Run this script to generated a faq.html output file # -set rcsid {$Id: faq.tcl,v 1.8 2002/02/19 22:42:06 drh Exp $} +set rcsid {$Id: faq.tcl,v 1.9 2002/03/23 00:31:29 drh Exp $} puts {<html> <head> @@ -194,12 +194,11 @@ faq { faq { Is SQLite threadsafe? } { - <p>Almost. In the source file named "<b>os.c</b>" there are two functions - named <b>sqliteOsEnterMutex()</b> and <b>sqliteOsLeaveMutex()</b>. In - the default distribution these functions are stubs. They do not do anything. - If you change them so that they actually implement a mutex, then SQLite - will be threadsafe. But because these routines are stubs, the default - SQLite distribution is not threadsafe.</p> + <p>Yes. Sometimes. In order to be thread-safe, SQLite must be compiled + with the THREADSAFE preprocessor macro set to 1. In the default + distribution, the windows binaries are compiled to be threadsafe but + the linux binaries are not. If you want to change this, you'll have to + recompile.</p> <p>"Threadsafe" in the previous paragraph means that two or more threads can run SQLite at the same time on different "<b>sqlite</b>" structures |