]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Performance optimizations.
authordrh <drh@noemail.net>
Sat, 3 Sep 2016 01:46:15 +0000 (01:46 +0000)
committerdrh <drh@noemail.net>
Sat, 3 Sep 2016 01:46:15 +0000 (01:46 +0000)
FossilOrigin-Name: f1d06c49ba0d814dc7ffb538aac3f4e6251fd8f0

manifest
manifest.uuid
src/expr.c
src/select.c
src/vdbe.c

index 0d346f639b63446d9fab3690eafd0063de9549b1..e6005476d07daf483204c6efa8913d66bc622c5d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\srecent\schanges\sfrom\strunk.
-D 2016-09-02T23:56:32.342
+C Performance\soptimizations.
+D 2016-09-03T01:46:15.276
 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 5017381e4853b1472e01d5bb926be1268eba429c
@@ -338,7 +338,7 @@ F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7
 F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b
 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
 F src/delete.c 76c084f0265f4a3cd1ecf17eee112a94f1ccbc05
-F src/expr.c 6ac2955b85fb32934b5505904da3d4be39d5d877
+F src/expr.c 7e0470e2b82af8d6544132d81da18990d9b9c09d
 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
 F src/fkey.c e2be0968c1adc679c87e467aa5b4f167588f38a8
 F src/func.c 29cc9acb170ec1387b9f63eb52cd85f8de96c771
@@ -385,7 +385,7 @@ F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1
 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
 F src/resolve.c d67b9a5cc33339256e2088c5a722745fc2ff5219
 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
-F src/select.c cf90abce32567023c940ecabf5707c4714c61c92
+F src/select.c 38216d0b2d42a0f475abf86a84c3499e6421ba29
 F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7
 F src/sqlite.h.in 4a030e254e204570444b34bf7d40fb4a5416089e
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@@ -451,7 +451,7 @@ F src/update.c 8179e699dbd45b92934fd02d3d8e3732e8da8802
 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
 F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d
 F src/vacuum.c 913970b9d86dd6c2b8063ef1af421880f1464ec3
-F src/vdbe.c 4be39068ea1412a21a2566c71007c87b67928d67
+F src/vdbe.c d8fb59a3ef10636df2447f55c1e82be7b8ad1604
 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10
 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d
 F src/vdbeapi.c a32d61b7dd05e6890d8fd44d2805f55e2f5ba9f3
@@ -1521,7 +1521,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 082fd5f8ac227dbb983da0a772485268af40a484 9bdf7ca1b317fe0ba7efea38fb395bf6130ac89a
-R 5ef4ae610db43c409abf4a916ff574b9
+P c7271fbde1aebb15daaedb7f1fa75fe410fd46f6
+R 617c8c8681735b3b6f061557d07c266d
 U drh
-Z 8a1867c9ed1b748f87443a20db67a6e2
+Z dbe31dcf0712b654c7c10b1471579b28
index f54ff68f8fb068c0ea56a5d3ca7effc0fef98116..eb5bf868a4507df92ccc5c5a401e5b7bd68d09a8 100644 (file)
@@ -1 +1 @@
-c7271fbde1aebb15daaedb7f1fa75fe410fd46f6
\ No newline at end of file
+f1d06c49ba0d814dc7ffb538aac3f4e6251fd8f0
\ No newline at end of file
index 8e74fff61bbbf7935722498c8702a613fb646428..31df95c0577e22f46bdb280bce51f4692b1e77d1 100644 (file)
@@ -1021,7 +1021,7 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
   if( !ExprHasProperty(p, EP_TokenOnly) ){
     /* The Expr.x union is never used at the same time as Expr.pRight */
     assert( p->x.pList==0 || p->pRight==0 );
-    if( p->op!=TK_SELECT_COLUMN ) sqlite3ExprDelete(db, p->pLeft);
+    if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
     sqlite3ExprDelete(db, p->pRight);
     if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
     if( ExprHasProperty(p, EP_xIsSelect) ){
index 6e51494f77327857627ab1bce49f8d1a35790b16..809285ea8996ace3cf885f12c12ca406de96e696 100644 (file)
@@ -1796,7 +1796,7 @@ Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
 */
 static SQLITE_NOINLINE Vdbe *allocVdbe(Parse *pParse){
   Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
-  if( v ) sqlite3VdbeAddOp0(v, OP_Init);
+  if( v ) sqlite3VdbeAddOp2(v, OP_Init, 0, 1);
   if( pParse->pToplevel==0
    && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)
   ){
index b640e0b4f568105142fc1c2bb14e1c21ac643d58..443ecbce1d96b2607bb0bd573d64f8e7e767f94f 100644 (file)
@@ -1980,7 +1980,7 @@ case OP_Lt:               /* same as TK_LT, jump, in1, in3 */
 case OP_Le:               /* same as TK_LE, jump, in1, in3 */
 case OP_Gt:               /* same as TK_GT, jump, in1, in3 */
 case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
-  int res;            /* Result of the comparison of pIn1 against pIn3 */
+  int res, res2;      /* Result of the comparison of pIn1 against pIn3 */
   char affinity;      /* Affinity to use for comparison */
   u16 flags1;         /* Copy of initial value of pIn1->flags */
   u16 flags3;         /* Copy of initial value of pIn3->flags */
@@ -2003,18 +2003,18 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
        && (flags3&MEM_Null)!=0
        && (flags3&MEM_Cleared)==0
       ){
-        iCompare = 0;  /* Operands are equal */
+        res = 0;  /* Operands are equal */
       }else{
-        iCompare = 1;  /* Operands are not equal */
+        res = 1;  /* Operands are not equal */
       }
     }else{
       /* SQLITE_NULLEQ is clear and at least one operand is NULL,
       ** then the result is always NULL.
       ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
       */
-      iCompare = 1;    /* Operands are not equal */
       if( pOp->p5 & SQLITE_STOREP2 ){
         pOut = &aMem[pOp->p2];
+        iCompare = 1;    /* Operands are not equal */
         memAboutToChange(p, pOut);
         MemSetTypeFlag(pOut, MEM_Null);
         REGISTER_TRACE(pOp->p2, pOut);
@@ -2065,15 +2065,15 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
       sqlite3VdbeMemExpandBlob(pIn3);
       flags3 &= ~MEM_Zero;
     }
-    iCompare = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
+    res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
   }
   switch( pOp->opcode ){
-    case OP_Eq:    res = iCompare==0;     break;
-    case OP_Ne:    res = iCompare!=0;     break;
-    case OP_Lt:    res = iCompare<0;      break;
-    case OP_Le:    res = iCompare<=0;     break;
-    case OP_Gt:    res = iCompare>0;      break;
-    default:       res = iCompare>=0;     break;
+    case OP_Eq:    res2 = res==0;     break;
+    case OP_Ne:    res2 = res;        break;
+    case OP_Lt:    res2 = res<0;      break;
+    case OP_Le:    res2 = res<=0;     break;
+    case OP_Gt:    res2 = res>0;      break;
+    default:       res2 = res>=0;     break;
   }
 
   /* Undo any changes made by applyAffinity() to the input registers. */
@@ -2084,20 +2084,22 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
 
   if( pOp->p5 & SQLITE_STOREP2 ){
     pOut = &aMem[pOp->p2];
+    iCompare = res;
+    res2 = res2!=0;  /* For this path res2 must be exactly 0 or 1 */
     if( (pOp->p5 & SQLITE_KEEPNULL)!=0 && (pOut->flags & MEM_Null)!=0 ){
       /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1
       ** and prevents OP_Ne from overwriting NULL with 0. */
       assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq );
-      assert( res==0 || res==1 );
-      if( (pOp->opcode==OP_Eq)==res ) break;
+      assert( res2==0 || res2==1 );
+      if( (pOp->opcode==OP_Eq)==res2 ) break;
     }
     memAboutToChange(p, pOut);
     MemSetTypeFlag(pOut, MEM_Int);
-    pOut->u.i = res;
+    pOut->u.i = res2;
     REGISTER_TRACE(pOp->p2, pOut);
   }else{
     VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
-    if( res ){
+    if( res2 ){
       goto jump_to_p2;
     }
   }
@@ -2115,6 +2117,7 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
 case OP_ElseNotEq: {       /* same as TK_ESCAPE, jump */
   assert( pOp>aOp );
   assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );
+  assert( pOp[-1].p5 & SQLITE_STOREP2 );
   VdbeBranchTaken(iCompare!=0, 2);
   if( iCompare!=0 ) goto jump_to_p2;
   break;
@@ -6864,8 +6867,8 @@ case OP_Init: {          /* jump */
   }
 #endif /* SQLITE_DEBUG */
 #endif /* SQLITE_OMIT_TRACE */
-  if( pOp->p2 ) goto jump_to_p2;
-  break;
+  assert( pOp->p2>0 );
+  goto jump_to_p2;
 }
 
 #ifdef SQLITE_ENABLE_CURSOR_HINTS