1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix the sqlite_offset() function so that it gives the correct answer even

if the argument is a virtual column in an index-only query.  Test cases
in TH3.

FossilOrigin-Name: 6029514b08b88e3fb3c0163813af38358490a6b6070b90f69975a324481394e5
This commit is contained in:
drh
2022-03-05 14:44:12 +00:00
parent 768ab1f296
commit a275e76696
3 changed files with 15 additions and 8 deletions

View File

@@ -2641,8 +2641,15 @@ case OP_Offset: { /* out3 */
VdbeCursor *pC; /* The VDBE cursor */
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
if( pC->deferredMoveto ){
rc = sqlite3VdbeFinishMoveto(pC);
if( rc ) goto abort_due_to_error;
}
pOut = &p->aMem[pOp->p3];
if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){
if( NEVER(pC==0)
|| pC->eCurType!=CURTYPE_BTREE
|| NEVER(sqlite3BtreeEof(pC->uc.pCursor))
){
sqlite3VdbeMemSetNull(pOut);
}else{
sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));