SQLite

Check-in [be05d0db09]
Login

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

Overview
Comment:Faster implementation of sqlite3IsBinary().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | propagate-const-opt
Files: files | file ages | folders
SHA3-256: be05d0db09f43cc3362c28273463d1d236af737a4f8a494cf1050da07ed0df47
User & Date: drh 2018-07-27 18:12:40.840
Context
2018-07-27
18:19
Performance improvement to sqlite3ExprCollSeq(). With this change, the performance of speed-check.sh is within 400,000 cycles of trunk. (check-in: a5f86f49b7 user: drh tags: propagate-const-opt)
18:12
Faster implementation of sqlite3IsBinary(). (check-in: be05d0db09 user: drh tags: propagate-const-opt)
17:51
Only run the constant propagation optimization on joins since that is the only scenario where it is useful. This saves prepare time for the common case of a simple query. (check-in: 598d608359 user: drh tags: propagate-const-opt)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
    if( !pColl ){
      pColl = sqlite3ExprCollSeq(pParse, pRight);
    }
  }
  return pColl;
}

/*
** Return true if CollSeq is the default built-in BINARY.
*/
int sqlite3IsBinary(const CollSeq *p){
  return p==0 || sqlite3StrICmp(p->zName,sqlite3StrBINARY)==0;
}

/*
** Generate code for a comparison operator.
*/
static int codeCompare(
  Parse *pParse,    /* The parsing (and code generating) context */
  Expr *pLeft,      /* The left operand */
  Expr *pRight,     /* The right operand */







<
<
<
<
<
<
<







324
325
326
327
328
329
330







331
332
333
334
335
336
337
    if( !pColl ){
      pColl = sqlite3ExprCollSeq(pParse, pRight);
    }
  }
  return pColl;
}








/*
** Generate code for a comparison operator.
*/
static int codeCompare(
  Parse *pParse,    /* The parsing (and code generating) context */
  Expr *pLeft,      /* The left operand */
  Expr *pRight,     /* The right operand */
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
        return target;
      }
      /* Otherwise, fall thru into the TK_COLUMN case */
    }
    case TK_COLUMN: {
      int iTab = pExpr->iTable;
      if( ExprHasProperty(pExpr, EP_FixedCol) ){
        pExpr = pExpr->pLeft;
        goto expr_code_doover;
      }
      if( iTab<0 ){
        if( pParse->iSelfTab<0 ){
          /* Generating CHECK constraints or inserting into partial index */
          return pExpr->iColumn - pParse->iSelfTab;
        }else{
          /* Coding an expression that is part of an index where column names







|
<







3581
3582
3583
3584
3585
3586
3587
3588

3589
3590
3591
3592
3593
3594
3595
        return target;
      }
      /* Otherwise, fall thru into the TK_COLUMN case */
    }
    case TK_COLUMN: {
      int iTab = pExpr->iTable;
      if( ExprHasProperty(pExpr, EP_FixedCol) ){
        return sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);

      }
      if( iTab<0 ){
        if( pParse->iSelfTab<0 ){
          /* Generating CHECK constraints or inserting into partial index */
          return pExpr->iColumn - pParse->iSelfTab;
        }else{
          /* Coding an expression that is part of an index where column names
Changes to src/main.c.
905
906
907
908
909
910
911









912
913
914
915
916
917
918
      */
    }else{
      rc = nKey1 - nKey2;
    }
  }
  return rc;
}










/*
** Another built-in collating sequence: NOCASE. 
**
** This collating sequence is intended to be used for "case independent
** comparison". SQLite's knowledge of upper and lower case equivalents
** extends only to the 26 characters used in the English language.







>
>
>
>
>
>
>
>
>







905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
      */
    }else{
      rc = nKey1 - nKey2;
    }
  }
  return rc;
}

/*
** Return true if CollSeq is the default built-in BINARY.
*/
int sqlite3IsBinary(const CollSeq *p){
  assert( p==0 || p->xCmp!=binCollFunc || p->pUser!=0
            || strcmp(p->zName,"BINARY")==0 );
  return p==0 || (p->xCmp==binCollFunc && p->pUser==0);
}

/*
** Another built-in collating sequence: NOCASE. 
**
** This collating sequence is intended to be used for "case independent
** comparison". SQLite's knowledge of upper and lower case equivalents
** extends only to the 26 characters used in the English language.