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
diff --git a/src/expr.c b/src/expr.c
index 7bfcf57..6fd08b2 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1462,8 +1462,7 @@
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 @@
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 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 @@
*/
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 @@
** 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 @@
}
if( testAddr ){
- sqlite3VdbeJumpHere(v, testAddr-1);
+ sqlite3VdbeJumpHere(v, testAddr);
}
sqlite3ExprCachePop(pParse, 1);