SQLite

Check-in [25acd9658b]
Login

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

Overview
Comment:Fix the exprCompareVariable() routine so that it works for non-UTF8 text.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | partial-index-variables
Files: files | file ages | folders
SHA3-256: 25acd9658be792d686b3ebfaa8c3692f9830e043538ed0afecf97110a07758a4
User & Date: drh 2017-06-29 01:23:12.291
Context
2017-06-29
12:59
The query planner examines the values of bound parameters to help determine if a partial index is usable. Reprepares may happen if the bindings change. This behavior is disabled by the QPSG setting. (check-in: c322bfa27e user: drh tags: trunk)
01:23
Fix the exprCompareVariable() routine so that it works for non-UTF8 text. (Closed-Leaf check-in: 25acd9658b user: drh tags: partial-index-variables)
2017-06-28
21:47
Alternative implementation of exprCompareVariable(). (check-in: b959c6297c user: drh tags: partial-index-variables)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
4679
4680
4681
4682
4683
4684
4685
4686



4687
4688
4689
4690
4691
4692
4693
4694
  sqlite3_value *pL, *pR = 0;
  
  sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);
  if( pR ){
    iVar = pVar->iColumn;
    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
    pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);
    if( pL && 0==sqlite3MemCompare(pL, pR, 0) ){



      res = 1;
    }
    sqlite3ValueFree(pR);
    sqlite3ValueFree(pL);
  }

  return res;
}







|
>
>
>
|







4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
  sqlite3_value *pL, *pR = 0;
  
  sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);
  if( pR ){
    iVar = pVar->iColumn;
    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
    pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);
    if( pL ){
      if( sqlite3_value_type(pL)==SQLITE_TEXT ){
        sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */
      }
      res =  0==sqlite3MemCompare(pL, pR, 0);
    }
    sqlite3ValueFree(pR);
    sqlite3ValueFree(pL);
  }

  return res;
}