1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

After code is generated for a subquery, delete the Select structure in order

to force the temporary table to be used and to prevent the subquery from
being evaluated a second time.  Ticket #601. (CVS 1216)

FossilOrigin-Name: 1cff18868dab5f8ead8ed8d07e088d7fdda04569
This commit is contained in:
drh
2004-02-09 14:37:50 +00:00
parent e2201971ac
commit f620b4e2cb
3 changed files with 20 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
C Add\stest\scase\sfor\sticket\s#601.\s(CVS\s1215) C After\scode\sis\sgenerated\sfor\sa\ssubquery,\sdelete\sthe\sSelect\sstructure\sin\sorder\nto\sforce\sthe\stemporary\stable\sto\sbe\sused\sand\sto\sprevent\sthe\ssubquery\sfrom\nbeing\sevaluated\sa\ssecond\stime.\s\sTicket\s#601.\s(CVS\s1216)
D 2004-02-09T14:35:28 D 2004-02-09T14:37:50
F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -46,7 +46,7 @@ F src/parse.y 7a121554c0c0c0150a77ab05417b01fa44813ac4
F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a
F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f
F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
F src/select.c b7694067df8d57fd0c85ddcc0840532d181552ad F src/select.c a0211d1a6a94f6c3e611096e77f2d689a641495e
F src/shell.c a069d35277983d54348105aa3c73be3c45eb9c38 F src/shell.c a069d35277983d54348105aa3c73be3c45eb9c38
F src/sqlite.h.in 1798588cab21ebf9fac3aad7fc1539b396c1f91d F src/sqlite.h.in 1798588cab21ebf9fac3aad7fc1539b396c1f91d
F src/sqliteInt.h c5b727d5d07b88654c204c0fc1ae79c9f635a008 F src/sqliteInt.h c5b727d5d07b88654c204c0fc1ae79c9f635a008
@@ -183,7 +183,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 2f0c122cfb84dea58d112324a0bdd8b85552a9fa P 096312dacb9eb2f8da3cec1504aef8629b505e7f
R d18a2a09d807f6210998c6b4e404fd9c R 485fc15d5916c254834a6d63a2aa701b
U drh U drh
Z 427bc38262d3a60f06bbf19ed3ec6be5 Z 235197ea178a89eec5c2077e08869e28

View File

@@ -1 +1 @@
096312dacb9eb2f8da3cec1504aef8629b505e7f 1cff18868dab5f8ead8ed8d07e088d7fdda04569

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite. ** to handle SELECT statements in SQLite.
** **
** $Id: select.c,v 1.150 2004/01/30 02:01:04 drh Exp $ ** $Id: select.c,v 1.151 2004/02/09 14:37:50 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -2404,6 +2404,18 @@ int sqliteSelect(
sqliteVdbeAddOp(v, OP_NullCallback, pEList->nExpr, 0); sqliteVdbeAddOp(v, OP_NullCallback, pEList->nExpr, 0);
} }
/* If this was a subquery, we have now converted the subquery into a
** temporary table. So delete the subquery structure from the parent
** to prevent this subquery from being evaluated again and to force the
** the use of the temporary table.
*/
if( pParent ){
assert( pParent->pSrc->nSrc>parentTab );
assert( pParent->pSrc->a[parentTab].pSelect==p );
sqliteSelectDelete(p);
pParent->pSrc->a[parentTab].pSelect = 0;
}
/* The SELECT was successfully coded. Set the return code to 0 /* The SELECT was successfully coded. Set the return code to 0
** to indicate no errors. ** to indicate no errors.
*/ */