Cache the sqlite3_context structure in the P4 operand of VDBE programs

for faster SQL function dispatch.

FossilOrigin-Name: 2abc44eb3b9d489321baa50bc25e17dafbda3687
This commit is contained in:
drh
2015-06-26 18:16:52 +00:00
parent 68cdd0eda2
commit 9c7c913cd6
11 changed files with 179 additions and 106 deletions
+9 -5
View File
@@ -489,11 +489,6 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
/* NOTE: Be sure to update mkopcodeh.awk when adding or removing
** cases from this switch! */
switch( opcode ){
case OP_Function:
case OP_AggStep: {
if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
break;
}
case OP_Transaction: {
if( pOp->p2!=0 ) p->readOnly = 0;
/* fall thru */
@@ -737,6 +732,10 @@ static void freeP4(sqlite3 *db, int p4type, void *p4){
if( p4 ){
assert( db );
switch( p4type ){
case P4_FUNCCTX: {
freeEphemeralFunction(db, ((sqlite3_context*)p4)->pFunc);
/* Fall through into the next case */
}
case P4_REAL:
case P4_INT64:
case P4_DYNAMIC:
@@ -1121,6 +1120,11 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
sqlite3_snprintf(nTemp, zTemp, "%s(%d)", pDef->zName, pDef->nArg);
break;
}
case P4_FUNCCTX: {
FuncDef *pDef = pOp->p4.pCtx->pFunc;
sqlite3_snprintf(nTemp, zTemp, "%s(%d)", pDef->zName, pDef->nArg);
break;
}
case P4_INT64: {
sqlite3_snprintf(nTemp, zTemp, "%lld", *pOp->p4.pI64);
break;