mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
:-) (CVS 52)
FossilOrigin-Name: c02268bdf4c28edc2542ce0ca1ba24fd6b5058fa
This commit is contained in:
27
src/expr.c
27
src/expr.c
@@ -23,7 +23,7 @@
|
||||
*************************************************************************
|
||||
** This file contains C code routines used for processing expressions
|
||||
**
|
||||
** $Id: expr.c,v 1.5 2000/06/04 12:58:37 drh Exp $
|
||||
** $Id: expr.c,v 1.6 2000/06/05 18:54:46 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -32,8 +32,13 @@
|
||||
** table fields. Nodes of the form ID.ID or ID resolve into an
|
||||
** index to the table in the table list and a field offset. The opcode
|
||||
** for such nodes is changed to TK_FIELD. The iTable value is changed
|
||||
** to the index of the referenced table in pTabList, and the iField value
|
||||
** is changed to the index of the field of the referenced table.
|
||||
** to the index of the referenced table in pTabList plus the pParse->nTab
|
||||
** value. The iField value is changed to the index of the field of the
|
||||
** referenced table.
|
||||
**
|
||||
** This routine also looks for SELECTs that are part of an expression.
|
||||
** If it finds any, it generates code to write the value of that select
|
||||
** into a memory cell.
|
||||
**
|
||||
** Unknown fields or tables provoke an error. The function returns
|
||||
** the number of errors seen and leaves an error message on pParse->zErrMsg.
|
||||
@@ -54,7 +59,7 @@ int sqliteExprResolveIds(Parse *pParse, IdList *pTabList, Expr *pExpr){
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
if( sqliteStrICmp(pTab->aCol[j].zName, z)==0 ){
|
||||
cnt++;
|
||||
pExpr->iTable = i;
|
||||
pExpr->iTable = i + pParse->nTab;
|
||||
pExpr->iField = j;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +109,7 @@ int sqliteExprResolveIds(Parse *pParse, IdList *pTabList, Expr *pExpr){
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
if( sqliteStrICmp(pTab->aCol[j].zName, zRight)==0 ){
|
||||
cnt++;
|
||||
pExpr->iTable = i;
|
||||
pExpr->iTable = i + pParse->nTab;
|
||||
pExpr->iField = j;
|
||||
}
|
||||
}
|
||||
@@ -132,6 +137,14 @@ int sqliteExprResolveIds(Parse *pParse, IdList *pTabList, Expr *pExpr){
|
||||
break;
|
||||
}
|
||||
|
||||
case TK_SELECT: {
|
||||
pExpr->iField = pParse->nMem++;
|
||||
if( sqliteSelect(pParse, pExpr->pSelect, -1, pExpr->iField) ){
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* For all else, just recursively walk the tree */
|
||||
default: {
|
||||
if( pExpr->pLeft
|
||||
@@ -385,6 +398,10 @@ void sqliteExprCode(Parse *pParse, Expr *pExpr){
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TK_SELECT: {
|
||||
sqliteVdbeAddOp(v, OP_MemLoad, pExpr->iField, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user