aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/btree.c3
-rw-r--r--src/expr.c2
-rw-r--r--src/vdbe.c19
-rw-r--r--src/where.c2
4 files changed, 15 insertions, 11 deletions
diff --git a/src/btree.c b/src/btree.c
index d17cbde84..a8d91cc0c 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -4439,9 +4439,8 @@ i64 sqlite3BtreeIntegerKey(BtCursor *pCur){
i64 sqlite3BtreeLocation(BtCursor *pCur){
assert( cursorHoldsMutex(pCur) );
assert( pCur->eState==CURSOR_VALID );
- assert( pCur->curIntKey );
getCellInfo(pCur);
- return (i64)pCur->pBt->pageSize*(i64)pCur->pPage->pgno +
+ return (i64)pCur->pBt->pageSize*((i64)pCur->pPage->pgno - 1) +
(i64)(pCur->info.pPayload - pCur->pPage->aData);
}
diff --git a/src/expr.c b/src/expr.c
index dbfc1b7ed..dd7d548ed 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3873,7 +3873,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
if( pDef->funcFlags & SQLITE_FUNC_LOCATION ){
Expr *pArg = pFarg->a[0].pExpr;
if( pArg->op==TK_COLUMN ){
- sqlite3VdbeAddOp2(v, OP_Location, pArg->iTable, target);
+ sqlite3VdbeAddOp3(v, OP_Location, pArg->iTable, pArg->iColumn,target);
}else{
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
}
diff --git a/src/vdbe.c b/src/vdbe.c
index 975a09819..68762ae5e 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -2349,22 +2349,27 @@ case OP_IfNullRow: { /* jump */
break;
}
-/* Opcode: Location P1 P2 * * *
-** Synopsis: r[P2] = location(P1)
+/* Opcode: Location P1 P2 P3 * *
+** Synopsis: r[P3] = location(P1)
**
-** Store in register r[P2] the location in the database file that is the
+** Store in register r[P3] the location in the database file that is the
** start of the payload for the record at which that cursor P1 is currently
** pointing.
+**
+** P2 is the column number for the argument to the location() function.
+** This opcode does not use P2 itself, but the P2 value is used by the
+** code generator. The P1, P2, and P3 operands to this opcode are the
+** as as for OP_Column.
*/
-case OP_Location: { /* out2 */
+case OP_Location: { /* out3 */
VdbeCursor *pC; /* The VDBE cursor */
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
- pOut = out2Prerelease(p, pOp);
+ pOut = &p->aMem[pOp->p3];
if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
- pOut->flags = MEM_Null;
+ sqlite3VdbeMemSetNull(pOut);
}else{
- pOut->u.i = sqlite3BtreeLocation(pC->uc.pCursor);
+ sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeLocation(pC->uc.pCursor));
}
break;
}
diff --git a/src/where.c b/src/where.c
index d3aec354b..146c8124c 100644
--- a/src/where.c
+++ b/src/where.c
@@ -5146,7 +5146,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
pOp = sqlite3VdbeGetOp(v, k);
for(; k<last; k++, pOp++){
if( pOp->p1!=pLevel->iTabCur ) continue;
- if( pOp->opcode==OP_Column ){
+ if( pOp->opcode==OP_Column || pOp->opcode==OP_Location ){
int x = pOp->p2;
assert( pIdx->pTable==pTab );
if( !HasRowid(pTab) ){