diff options
author | drh <drh@noemail.net> | 2011-09-16 01:34:43 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2011-09-16 01:34:43 +0000 |
commit | 48f2d3b10a5ac48ae2a1a24f77c7cb1aab6ea978 (patch) | |
tree | 0b02d36b1ecb60c458133c090c14df3c131b6151 /src/expr.c | |
parent | 5b6a9ed49556deac6d48be80b6ef2816102f1951 (diff) | |
download | sqlite-48f2d3b10a5ac48ae2a1a24f77c7cb1aab6ea978.tar.gz sqlite-48f2d3b10a5ac48ae2a1a24f77c7cb1aab6ea978.zip |
Add the new OP_Once opcode. Use it to clean up and simplify various
one-time initialization sections in the code, including the fix for
ticket [002caede898ae].
FossilOrigin-Name: 7f00552b739fad79517b042a6ed61abe743a917b
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/expr.c b/src/expr.c index 7bfcf5733..6fd08b27f 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1462,8 +1462,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){ int iMem = ++pParse->nMem; int iAddr; - iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); - sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); + iAddr = sqlite3VdbeAddOp1(v, OP_Once, iMem); sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); eType = IN_INDEX_ROWID; @@ -1494,8 +1493,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){ char *pKey; pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx); - iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); - sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); + iAddr = sqlite3VdbeAddOp1(v, OP_Once, iMem); sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb, pKey,P4_KEYINFO_HANDOFF); @@ -1580,6 +1578,7 @@ int sqlite3CodeSubselect( int rReg = 0; /* Register storing resulting */ Vdbe *v = sqlite3GetVdbe(pParse); if( NEVER(v==0) ) return 0; + assert( sqlite3VdbeCurrentAddr(v)>0 ); sqlite3ExprCachePush(pParse); /* This code must be run in its entirety every time it is encountered @@ -1594,8 +1593,7 @@ int sqlite3CodeSubselect( */ if( !ExprHasAnyProperty(pExpr, EP_VarSelect) && !pParse->pTriggerTab ){ int mem = ++pParse->nMem; - sqlite3VdbeAddOp1(v, OP_If, mem); - testAddr = sqlite3VdbeAddOp2(v, OP_Integer, 1, mem); + testAddr = sqlite3VdbeAddOp1(v, OP_Once, mem); assert( testAddr>0 || pParse->db->mallocFailed ); } @@ -1695,7 +1693,7 @@ int sqlite3CodeSubselect( ** expression we need to rerun this code each time. */ if( testAddr && !sqlite3ExprIsConstant(pE2) ){ - sqlite3VdbeChangeToNoop(v, testAddr-1, 2); + sqlite3VdbeChangeToNoop(v, testAddr); testAddr = 0; } @@ -1766,7 +1764,7 @@ int sqlite3CodeSubselect( } if( testAddr ){ - sqlite3VdbeJumpHere(v, testAddr-1); + sqlite3VdbeJumpHere(v, testAddr); } sqlite3ExprCachePop(pParse, 1); |