-C Fix\sa\stypo\sin\sa\scomment.\s\sTicket\s#2348.\s(CVS\s3966)
-D 2007-05-09T20:35:31
+C Make\ssure\scompound\squeries\sinside\sa\ssubquery\sonly\sreturn\sa\ssingle\sresult\ncolumn.\s\sTicket\s#2347.\s(CVS\s3967)
+D 2007-05-09T22:56:39
F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089
F src/printf.c 67de0dcb40ef3297f4a047b434b81585c0f7062d
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
-F src/select.c 114e7ebaa2e41d83687f0c7c5f53daa7e7af8d3a
+F src/select.c 87bcf7406ab55baec791c49f8926def7bb1c07e2
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
F src/sqlite.h.in 664b8702c27dc742584788823c548491ac8935d6
F test/select4.test 305ba0a6e97efc5544def5e5cb49b54e1bf87fd9
F test/select5.test 0b47058d3e916c1fc9fe81f44b438e02bade21ce
F test/select6.test 399f14b9ba37b768afe5d2cd8c12e4f340a69db8
-F test/select7.test 95697d8e8355ef7538e2fe768da16838bbd0fcde
+F test/select7.test ea2af8688973c6cf801c6db137f74fde54a8777f
F test/server1.test e328b8e641ba8fe9273132cfef497383185dc1f5
F test/shared.test 5c39f216ce85d723eda5875804bbf5ef8a03fcfc
F test/shared2.test 8b48f8d33494413ef4cf250110d89403e2bf6b23
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 0c91dc9ee0c5d441a7789b631476515260cb887f
-R 46e17a3ab70f103cc105842211d40f7b
+P c0dbac46301039246afd4bebb71dd8184fc5c0c7
+R ce1d9a31f5642fc3adec7a89c841905a
U drh
-Z 79e08606393f6895398b258e63ee3fab
+Z f08cc8911b7b4f7d10aa7482cf6b823e
-c0dbac46301039246afd4bebb71dd8184fc5c0c7
\ No newline at end of file
+66954bdd81dabfb60306de8480b5477a4acb1d9e
\ No newline at end of file
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.342 2007/05/08 13:58:28 drh Exp $
+** $Id: select.c,v 1.343 2007/05/09 22:56:39 drh Exp $
*/
#include "sqliteInt.h"
sqlite3VdbeAddOp(v, OP_IdxInsert, iTab, 0);
}
+/*
+** Generate an error message when a SELECT is used within a subexpression
+** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
+** column. We do this in a subroutine because the error occurs in multiple
+** places.
+*/
+static int checkForMultiColumnSelectError(Parse *pParse, int eDest, int nExpr){
+ if( nExpr>1 && (eDest==SRT_Mem || eDest==SRT_Set) ){
+ sqlite3ErrorMsg(pParse, "only a single result allowed for "
+ "a SELECT that is part of an expression");
+ return 1;
+ }else{
+ return 0;
+ }
+}
/*
** This routine generates the code for the inside of the inner loop
}
}
+ if( checkForMultiColumnSelectError(pParse, eDest, pEList->nExpr) ){
+ return 0;
+ }
+
switch( eDest ){
/* In this mode, write each query result to the key of the temporary
** table iParm.
** only a single column may be output.
*/
#ifndef SQLITE_OMIT_SUBQUERY
- if( (eDest==SRT_Mem || eDest==SRT_Set) && pEList->nExpr>1 ){
- sqlite3ErrorMsg(pParse, "only a single result allowed for "
- "a SELECT that is part of an expression");
+ if( checkForMultiColumnSelectError(pParse, eDest, pEList->nExpr) ){
goto select_end;
}
#endif
# focus of this file is testing compute SELECT statements and nested
# views.
#
-# $Id: select7.test,v 1.8 2006/10/13 15:34:17 drh Exp $
+# $Id: select7.test,v 1.9 2007/05/09 22:56:39 drh Exp $
set testdir [file dirname $argv0]
);
}
} {2 3}
+}
+# ticket #2347
+#
+ifcapable {subquery && compound} {
+ do_test select7-5.1 {
+ catchsql {
+ CREATE TABLE t2(a,b);
+ SELECT 5 IN (SELECT a,b FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.2 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.3 {
+ catchsql {
+ SELECT 5 IN (SELECT a,b FROM t2 UNION SELECT b,a FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.4 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2 UNION SELECT * FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
}
finish_test