4 KeyInfo *pKeyInfo; /* Collation and sort-order information */
5 u16 nField; /* Number of entries in apMem[] */
6 u16 flags; /* Boolean settings. UNPACKED_... below */
7 - i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */
8 Mem *aMem; /* Values */
12 #define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */
13 #define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */
14 #define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */
15 -#define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */
18 ** Each SQL index is represented in memory by an
23 UnpackedRecord r; /* B-Tree index search key */
24 i64 R; /* Rowid stored in register P3 */
25 + i64 rowid; /* Rowid found */
27 pIn3 = &aMem[pOp->p3];
28 aMx = &aMem[pOp->p4.i];
31 /* Populate the index search key. */
32 r.pKeyInfo = pCx->pKeyInfo;
33 - r.nField = nField + 1;
34 - r.flags = UNPACKED_PREFIX_SEARCH;
36 + r.flags = UNPACKED_PREFIX_MATCH;
39 { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
40 @@ -3570,10 +3571,14 @@
41 ** to P2. Otherwise, copy the rowid of the conflicting record to
42 ** register P3 and fall through to the next instruction. */
43 rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &pCx->seekResult);
44 - if( (r.flags & UNPACKED_PREFIX_SEARCH) || r.rowid==R ){
47 - pIn3->u.i = r.rowid;
48 + if( rc != SQLITE_OK || pCx->seekResult != 0 ){
51 + rc = sqlite3VdbeIdxRowid(db, pCrsr, &rowid);
52 + if (rc == SQLITE_OK && rowid == R)
61 @@ -2916,18 +2916,6 @@
65 - /* If the PREFIX_SEARCH flag is set and all fields except the final
66 - ** rowid field were equal, then clear the PREFIX_SEARCH flag and set
67 - ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1).
68 - ** This is used by the OP_IsUnique opcode.
70 - if( (pPKey2->flags & UNPACKED_PREFIX_SEARCH) && i==(pPKey2->nField-1) ){
71 - assert( idx1==szHdr1 && rc );
72 - assert( mem1.flags & MEM_Int );
73 - pPKey2->flags &= ~UNPACKED_PREFIX_SEARCH;
74 - pPKey2->rowid = mem1.u.i;