1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Fix a VDBE stack leak in LEFT OUTER JOIN. Fix a bug in the code generator

for JOIN ... USING(...). (CVS 638)

FossilOrigin-Name: d861489e1f7dffd1105c271fe8597f73e5b1703c
This commit is contained in:
drh
2002-06-24 12:20:23 +00:00
parent f46f905a1e
commit bf5cd97ed7
4 changed files with 17 additions and 17 deletions

View File

@ -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.97 2002/06/22 02:33:38 drh Exp $
** $Id: select.c,v 1.98 2002/06/24 12:20:23 drh Exp $
*/
#include "sqliteInt.h"
@ -244,14 +244,14 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){
assert( i<pSrc->nSrc-1 );
pList = pTerm->pUsing;
for(j=0; j<pList->nId; j++){
if( columnIndex(pTerm->pTab, pList->a[i].zName)<0 ||
columnIndex(pOther->pTab, pList->a[i].zName)<0 ){
if( columnIndex(pTerm->pTab, pList->a[j].zName)<0 ||
columnIndex(pOther->pTab, pList->a[j].zName)<0 ){
sqliteSetString(&pParse->zErrMsg, "cannot join using column ",
pList->a[i].zName, " - column not present in both tables", 0);
pList->a[j].zName, " - column not present in both tables", 0);
pParse->nErr++;
return 1;
}
addWhereTerm(pList->a[i].zName, pTerm->pTab, pOther->pTab, &p->pWhere);
addWhereTerm(pList->a[j].zName, pTerm->pTab, pOther->pTab, &p->pWhere);
}
}
}
@ -1745,14 +1745,14 @@ int sqliteSelect(
}else{
int iMem = pParse->nMem++;
sqliteVdbeAddOp(v, OP_Integer, -p->nLimit, 0);
sqliteVdbeAddOp(v, OP_MemStore, iMem, 0);
sqliteVdbeAddOp(v, OP_MemStore, iMem, 1);
p->nLimit = iMem;
if( p->nOffset<=0 ){
p->nOffset = 0;
}else{
iMem = pParse->nMem++;
sqliteVdbeAddOp(v, OP_Integer, -p->nOffset, 0);
sqliteVdbeAddOp(v, OP_MemStore, iMem, 0);
sqliteVdbeAddOp(v, OP_MemStore, iMem, 1);
p->nOffset = iMem;
}
}

View File

@ -13,7 +13,7 @@
** the WHERE clause of SQL statements. Also found here are subroutines
** to generate VDBE code to evaluate expressions.
**
** $Id: where.c,v 1.53 2002/06/19 14:27:06 drh Exp $
** $Id: where.c,v 1.54 2002/06/24 12:20:23 drh Exp $
*/
#include "sqliteInt.h"
@ -1057,7 +1057,7 @@ void sqliteWhereEnd(WhereInfo *pWInfo){
if( pLevel->iLeftJoin ){
int addr;
addr = sqliteVdbeAddOp(v, OP_MemLoad, pLevel->iLeftJoin, 0);
sqliteVdbeAddOp(v, OP_NotNull, 0, addr+4);
sqliteVdbeAddOp(v, OP_NotNull, 1, addr+4);
sqliteVdbeAddOp(v, OP_NullRow, base+i, 0);
sqliteVdbeAddOp(v, OP_Goto, 0, pLevel->top);
}