aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2005-10-06 16:53:14 +0000
committerdrh <drh@noemail.net>2005-10-06 16:53:14 +0000
commitec7429ae275e752c8fe65e93aa5815e98edf7e17 (patch)
treecc92c709df0a1158b59c7e17a4f9de11f41db55b /src/expr.c
parent23cc57f6a3b234545d65763694cf21cd07e2eeeb (diff)
downloadsqlite-ec7429ae275e752c8fe65e93aa5815e98edf7e17.tar.gz
sqlite-ec7429ae275e752c8fe65e93aa5815e98edf7e17.zip
More efficient handling of the LIMIT clause. Scalar subqueries and EXISTS
on compound SELECT statements now working properly. Ticket #1473. (CVS 2747) FossilOrigin-Name: edca8913ca012fc0c17343a27f819de95147b1bd
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/expr.c b/src/expr.c
index c415e7ab5..f1eae86d6 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.230 2005/09/23 21:11:54 drh Exp $
+** $Id: expr.c,v 1.231 2005/10/06 16:53:15 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1390,21 +1390,25 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
** value of this select in a memory cell and record the number
** of the memory cell in iColumn.
*/
- int sop;
+ static const Token one = { "1", 0, 1 };
Select *pSel;
+ int iMem;
+ int sop;
- pExpr->iColumn = pParse->nMem++;
+ pExpr->iColumn = iMem = pParse->nMem++;
pSel = pExpr->pSelect;
if( pExpr->op==TK_SELECT ){
sop = SRT_Mem;
+ sqlite3VdbeAddOp(v, OP_MemNull, iMem, 0);
+ VdbeComment((v, "# Init subquery result"));
}else{
- static const Token one = { "1", 0, 1 };
sop = SRT_Exists;
- sqlite3ExprListDelete(pSel->pEList);
- pSel->pEList = sqlite3ExprListAppend(0,
- sqlite3Expr(TK_INTEGER, 0, 0, &one), 0);
+ sqlite3VdbeAddOp(v, OP_MemInt, 0, iMem);
+ VdbeComment((v, "# Init EXISTS result"));
}
- sqlite3Select(pParse, pSel, sop, pExpr->iColumn, 0, 0, 0, 0);
+ sqlite3ExprDelete(pSel->pLimit);
+ pSel->pLimit = sqlite3Expr(TK_INTEGER, 0, 0, &one);
+ sqlite3Select(pParse, pSel, sop, iMem, 0, 0, 0, 0);
break;
}
}