/ Check-in [7a0b9413]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Small size and performance optimization to the VDBE comparison opcodes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7a0b9413fa94d3f4fa9751ddf9b213a1238954f1
User & Date: drh 2015-12-31 04:34:26
Context
2015-12-31
15:34
Fix harmless compiler warnings associated with SQLITE_ENABLE_HIDDEN_COLUMNS. check-in: 9c392c10 user: drh tags: trunk
04:34
Small size and performance optimization to the VDBE comparison opcodes. check-in: 7a0b9413 user: drh tags: trunk
2015-12-30
18:18
Reduce the size of the CellInfo object from 32 to 24 bytes on 64-bit machines, for a small performance increase and library size reduction. check-in: 6a4cfc7a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

  1518   1518     char *zName;     /* Name of this column */
  1519   1519     Expr *pDflt;     /* Default value of this column */
  1520   1520     char *zDflt;     /* Original text of the default value */
  1521   1521     char *zType;     /* Data type for this column */
  1522   1522     char *zColl;     /* Collating sequence.  If NULL, use the default */
  1523   1523     u8 notNull;      /* An OE_ code for handling a NOT NULL constraint */
  1524   1524     char affinity;   /* One of the SQLITE_AFF_... values */
  1525         -  u8 szEst;        /* Estimated size of this column.  INT==1 */
         1525  +  u8 szEst;        /* Estimated size of value in this column. sizeof(INT)==1 */
  1526   1526     u8 colFlags;     /* Boolean properties.  See COLFLAG_ defines below */
  1527   1527   };
  1528   1528   
  1529   1529   /* Allowed values for Column.colFlags:
  1530   1530   */
  1531   1531   #define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */
  1532   1532   #define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */

Changes to src/vdbe.c.

  1992   1992         }
  1993   1993         break;
  1994   1994       }
  1995   1995     }else{
  1996   1996       /* Neither operand is NULL.  Do a comparison. */
  1997   1997       affinity = pOp->p5 & SQLITE_AFF_MASK;
  1998   1998       if( affinity>=SQLITE_AFF_NUMERIC ){
  1999         -      if( (pIn1->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
         1999  +      if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
  2000   2000           applyNumericAffinity(pIn1,0);
  2001   2001         }
  2002         -      if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
         2002  +      if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
  2003   2003           applyNumericAffinity(pIn3,0);
  2004   2004         }
  2005   2005       }else if( affinity==SQLITE_AFF_TEXT ){
  2006         -      if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){
         2006  +      if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){
  2007   2007           testcase( pIn1->flags & MEM_Int );
  2008   2008           testcase( pIn1->flags & MEM_Real );
  2009   2009           sqlite3VdbeMemStringify(pIn1, encoding, 1);
  2010   2010           testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
  2011   2011           flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
  2012   2012         }
  2013         -      if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
         2013  +      if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
  2014   2014           testcase( pIn3->flags & MEM_Int );
  2015   2015           testcase( pIn3->flags & MEM_Real );
  2016   2016           sqlite3VdbeMemStringify(pIn3, encoding, 1);
  2017   2017           testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
  2018   2018           flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);
  2019   2019         }
  2020   2020       }
  2021   2021       assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
  2022         -    if( pIn1->flags & MEM_Zero ){
         2022  +    if( flags1 & MEM_Zero ){
  2023   2023         sqlite3VdbeMemExpandBlob(pIn1);
  2024   2024         flags1 &= ~MEM_Zero;
  2025   2025       }
  2026         -    if( pIn3->flags & MEM_Zero ){
         2026  +    if( flags3 & MEM_Zero ){
  2027   2027         sqlite3VdbeMemExpandBlob(pIn3);
  2028   2028         flags3 &= ~MEM_Zero;
  2029   2029       }
  2030         -    if( db->mallocFailed ) goto no_mem;
  2031   2030       res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
  2032   2031     }
  2033   2032     switch( pOp->opcode ){
  2034   2033       case OP_Eq:    res = res==0;     break;
  2035   2034       case OP_Ne:    res = res!=0;     break;
  2036   2035       case OP_Lt:    res = res<0;      break;
  2037   2036       case OP_Le:    res = res<=0;     break;

Changes to src/vdbeaux.c.

  3744   3744       if( (f1 & MEM_Str)==0 ){
  3745   3745         return 1;
  3746   3746       }
  3747   3747       if( (f2 & MEM_Str)==0 ){
  3748   3748         return -1;
  3749   3749       }
  3750   3750   
  3751         -    assert( pMem1->enc==pMem2->enc );
         3751  +    assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed );
  3752   3752       assert( pMem1->enc==SQLITE_UTF8 || 
  3753   3753               pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );
  3754   3754   
  3755   3755       /* The collation sequence must be defined at this point, even if
  3756   3756       ** the user deletes the collation sequence after the vdbe program is
  3757   3757       ** compiled (this was not always the case).
  3758   3758       */