/ Check-in [cff1f55c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix issues with quering from an auxiliary index that must refer back to the PRIMARY KEY index of a WITHOUT ROWID table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | omit-rowid
Files: files | file ages | folders
SHA1: cff1f55c52ff57557d9b728a5cd830a367091794
User & Date: drh 2013-10-31 17:38:01
Context
2013-10-31
20:34
Fix the Synopsis on OP_Concat. Added test_addop_breakpoint() during SQLITE_DEBUG. Enhanced sqlite3VdbeChangeToNoop() to omit the instruction if it is the most recent added. Continue to fix problems with UPDATE and WITHOUT ROWID. check-in: 9b6d9e10 user: drh tags: omit-rowid
17:38
Fix issues with quering from an auxiliary index that must refer back to the PRIMARY KEY index of a WITHOUT ROWID table. check-in: cff1f55c user: drh tags: omit-rowid
15:37
Improved comments and variable names in infrastructure routines of UPDATE, DELETE, and INSERT. check-in: ad90e762 user: drh tags: omit-rowid
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  2218   2218     int iCol,       /* Index of the column to extract */
  2219   2219     int regOut      /* Extract the valud into this register */
  2220   2220   ){
  2221   2221     if( iCol<0 || iCol==pTab->iPKey ){
  2222   2222       sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
  2223   2223     }else{
  2224   2224       int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
  2225         -    sqlite3VdbeAddOp3(v, op, iTabCur, iCol, regOut);
         2225  +    int x = iCol;
         2226  +    if( !HasRowid(pTab) ){
         2227  +      x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
         2228  +    }
         2229  +    sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
  2226   2230     }
  2227   2231     if( iCol>=0 ){
  2228   2232       sqlite3ColumnDefault(v, pTab, iCol, regOut);
  2229   2233     }
  2230   2234   }
  2231   2235   
  2232   2236   /*

Changes to src/vdbe.c.

  4308   4308     if( pC->isIndex ){
  4309   4309       rc = sqlite3BtreeKey(pCrsr, 0, n, pOut->z);
  4310   4310     }else{
  4311   4311       rc = sqlite3BtreeData(pCrsr, 0, n, pOut->z);
  4312   4312     }
  4313   4313     pOut->enc = SQLITE_UTF8;  /* In case the blob is ever cast to text */
  4314   4314     UPDATE_MAX_BLOBSIZE(pOut);
         4315  +  REGISTER_TRACE(pOp->p2, pOut);
  4315   4316     break;
  4316   4317   }
  4317   4318   
  4318   4319   /* Opcode: Rowid P1 P2 * * *
  4319   4320   ** Synopsis: r[P2]=rowid
  4320   4321   **
  4321   4322   ** Store in register P2 an integer which is the key of the table entry that

Changes to src/where.c.

  6187   6187   
  6188   6188         last = sqlite3VdbeCurrentAddr(v);
  6189   6189         k = pLevel->addrBody;
  6190   6190         pOp = sqlite3VdbeGetOp(v, k);
  6191   6191         for(; k<last; k++, pOp++){
  6192   6192           if( pOp->p1!=pLevel->iTabCur ) continue;
  6193   6193           if( pOp->opcode==OP_Column ){
  6194         -          i16 x = sqlite3ColumnOfIndex(pIdx, pOp->p2);
         6194  +          int x = pOp->p2;
         6195  +          Table *pTab = pIdx->pTable;
         6196  +          if( !HasRowid(pTab) ){
         6197  +            Index *pPk = sqlite3PrimaryKeyIndex(pTab);
         6198  +            x = pPk->aiColumn[x];
         6199  +          }
         6200  +          x = sqlite3ColumnOfIndex(pIdx, x);
  6195   6201             if( x>=0 ){
  6196   6202               pOp->p2 = x;
  6197   6203               pOp->p1 = pLevel->iIdxCur;
  6198   6204             }
  6199   6205             assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 );
  6200   6206           }else if( pOp->opcode==OP_Rowid ){
  6201   6207             pOp->p1 = pLevel->iIdxCur;