diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index ee849c3b821ceaf7bd4b071bb92ef05bd0fa27ac..ae0b8211b5e800ee0b2f8f159e856a021e750150 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -981,11 +981,24 @@ case OP_SCopy: { /* out2 */ * the result row. */ case OP_ResultRow: { - assert(p->nResColumn==pOp->p2); + assert(p->pFrame != NULL || p->nResColumn == pOp->p2); assert(pOp->p1>0); assert(pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1); assert(p->iStatement == 0 && p->anonymous_savepoint == NULL); + /* Copy the result into the parent VDBE program. */ + if (p->pFrame != NULL) { + VdbeFrame *pFrame = p->pFrame; + /* TODO: maybe pFrameOffset isn't that convenient in practice. */ + int pFrameOffset = pFrame->aOp[pFrame->pc].p1; + for (int i = 0; i < pOp->p2; i++) { + Mem *pIn = &p->aMem[pOp->p1 + i]; + pOut = &pFrame->aMem[pOp->p3 + pFrameOffset + i]; + mem_copy(pOut, pIn); + } + break; + } + /* Invalidate all ephemeral cursor row caches */ p->cacheCtr = (p->cacheCtr + 2)|1;