Add the sqlite3VdbeAppendP4() method for adding P4 content to the most recently

coded instruction.

FossilOrigin-Name: 28883e8f3e92a8015fb5f6c8ae8580833931543d
This commit is contained in:
drh
2016-12-07 21:35:55 +00:00
parent 861b1307cb
commit f14b7fb73b
8 changed files with 47 additions and 20 deletions
+28 -2
View File
@@ -972,16 +972,42 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){
}
}
/*
** Change the P4 operand of the most recently coded instruction
** to the value defined by the arguments. This is a high-speed
** version of sqlite3VdbeChangeP4().
**
** The P4 operand must not have been previously defined. And the new
** P4 must not be P4_INT32. Use sqlite3VdbeChangeP4() in either of
** those cases.
*/
void sqlite3VdbeAppendP4(Vdbe *p, void *pP4, int n){
VdbeOp *pOp;
assert( n!=P4_INT32 && n!=P4_VTAB );
assert( n<=0 );
if( p->db->mallocFailed ){
freeP4(p->db, n, pP4);
}else{
assert( pP4!=0 );
assert( p->nOp>0 );
pOp = &p->aOp[p->nOp-1];
assert( pOp->p4type==P4_NOTUSED );
pOp->p4type = n;
pOp->p4.p = pP4;
}
}
/*
** Set the P4 on the most recently added opcode to the KeyInfo for the
** index given.
*/
void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
Vdbe *v = pParse->pVdbe;
KeyInfo *pKeyInfo;
assert( v!=0 );
assert( pIdx!=0 );
sqlite3VdbeChangeP4(v, -1, (char*)sqlite3KeyInfoOfIndex(pParse, pIdx),
P4_KEYINFO);
pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx);
if( pKeyInfo ) sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
}
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS