Fossil SCM
Pull in the latest trunk changes and the latest NGQP-SQLite from upstream.
Commit
03c5ec86159f85fcba42cc465edd95374fb2a5c0
Parent
d3d4e1117945db5…
9 files changed
+2
+1
-6
+1
-1
+25
-23
+25
-23
+1
-1
+1
-1
+1
-1
+1
-1
| --- .fossil-settings/ignore-glob | ||
| +++ .fossil-settings/ignore-glob | ||
| @@ -1,2 +1,4 @@ | ||
| 1 | +compat/openssl-1.0.1e/* | |
| 2 | +compat/tcl-8.6/* | |
| 1 | 3 | fossil |
| 2 | 4 | fossil.exe |
| 3 | 5 |
| --- .fossil-settings/ignore-glob | |
| +++ .fossil-settings/ignore-glob | |
| @@ -1,2 +1,4 @@ | |
| 1 | fossil |
| 2 | fossil.exe |
| 3 |
| --- .fossil-settings/ignore-glob | |
| +++ .fossil-settings/ignore-glob | |
| @@ -1,2 +1,4 @@ | |
| 1 | compat/openssl-1.0.1e/* |
| 2 | compat/tcl-8.6/* |
| 3 | fossil |
| 4 | fossil.exe |
| 5 |
+1
-6
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -785,29 +785,24 @@ | ||
| 785 | 785 | fossil_print("This is fossil version " RELEASE_VERSION " " |
| 786 | 786 | MANIFEST_VERSION " " MANIFEST_DATE " UTC\n"); |
| 787 | 787 | if(!find_option("verbose","v",0)){ |
| 788 | 788 | return; |
| 789 | 789 | }else{ |
| 790 | - int count = 0; | |
| 791 | 790 | fossil_print("Compiled on %s %s using %s (%d-bit)\n", |
| 792 | 791 | __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); |
| 793 | - fossil_print("SQLite %s [%s],\n", SQLITE_VERSION, SQLITE_SOURCE_ID); | |
| 792 | + fossil_print("SQLite %s %.30s\n", SQLITE_VERSION, SQLITE_SOURCE_ID); | |
| 794 | 793 | fossil_print("zlib %s\n", ZLIB_VERSION); |
| 795 | 794 | #if defined(FOSSIL_ENABLE_SSL) |
| 796 | - ++count; | |
| 797 | 795 | fossil_print("SSL (%s)\n", OPENSSL_VERSION_TEXT); |
| 798 | 796 | #endif |
| 799 | 797 | #if defined(FOSSIL_ENABLE_TCL) |
| 800 | - ++count; | |
| 801 | 798 | fossil_print("TCL (Tcl %s)\n", TCL_PATCH_LEVEL); |
| 802 | 799 | #endif |
| 803 | 800 | #if defined(FOSSIL_ENABLE_TCL_STUBS) |
| 804 | - ++count; | |
| 805 | 801 | fossil_print("TCL_STUBS\n"); |
| 806 | 802 | #endif |
| 807 | 803 | #if defined(FOSSIL_ENABLE_JSON) |
| 808 | - ++count; | |
| 809 | 804 | fossil_print("JSON (API %s)\n", FOSSIL_JSON_API_VERSION); |
| 810 | 805 | #endif |
| 811 | 806 | } |
| 812 | 807 | } |
| 813 | 808 | |
| 814 | 809 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -785,29 +785,24 @@ | |
| 785 | fossil_print("This is fossil version " RELEASE_VERSION " " |
| 786 | MANIFEST_VERSION " " MANIFEST_DATE " UTC\n"); |
| 787 | if(!find_option("verbose","v",0)){ |
| 788 | return; |
| 789 | }else{ |
| 790 | int count = 0; |
| 791 | fossil_print("Compiled on %s %s using %s (%d-bit)\n", |
| 792 | __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); |
| 793 | fossil_print("SQLite %s [%s],\n", SQLITE_VERSION, SQLITE_SOURCE_ID); |
| 794 | fossil_print("zlib %s\n", ZLIB_VERSION); |
| 795 | #if defined(FOSSIL_ENABLE_SSL) |
| 796 | ++count; |
| 797 | fossil_print("SSL (%s)\n", OPENSSL_VERSION_TEXT); |
| 798 | #endif |
| 799 | #if defined(FOSSIL_ENABLE_TCL) |
| 800 | ++count; |
| 801 | fossil_print("TCL (Tcl %s)\n", TCL_PATCH_LEVEL); |
| 802 | #endif |
| 803 | #if defined(FOSSIL_ENABLE_TCL_STUBS) |
| 804 | ++count; |
| 805 | fossil_print("TCL_STUBS\n"); |
| 806 | #endif |
| 807 | #if defined(FOSSIL_ENABLE_JSON) |
| 808 | ++count; |
| 809 | fossil_print("JSON (API %s)\n", FOSSIL_JSON_API_VERSION); |
| 810 | #endif |
| 811 | } |
| 812 | } |
| 813 | |
| 814 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -785,29 +785,24 @@ | |
| 785 | fossil_print("This is fossil version " RELEASE_VERSION " " |
| 786 | MANIFEST_VERSION " " MANIFEST_DATE " UTC\n"); |
| 787 | if(!find_option("verbose","v",0)){ |
| 788 | return; |
| 789 | }else{ |
| 790 | fossil_print("Compiled on %s %s using %s (%d-bit)\n", |
| 791 | __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); |
| 792 | fossil_print("SQLite %s %.30s\n", SQLITE_VERSION, SQLITE_SOURCE_ID); |
| 793 | fossil_print("zlib %s\n", ZLIB_VERSION); |
| 794 | #if defined(FOSSIL_ENABLE_SSL) |
| 795 | fossil_print("SSL (%s)\n", OPENSSL_VERSION_TEXT); |
| 796 | #endif |
| 797 | #if defined(FOSSIL_ENABLE_TCL) |
| 798 | fossil_print("TCL (Tcl %s)\n", TCL_PATCH_LEVEL); |
| 799 | #endif |
| 800 | #if defined(FOSSIL_ENABLE_TCL_STUBS) |
| 801 | fossil_print("TCL_STUBS\n"); |
| 802 | #endif |
| 803 | #if defined(FOSSIL_ENABLE_JSON) |
| 804 | fossil_print("JSON (API %s)\n", FOSSIL_JSON_API_VERSION); |
| 805 | #endif |
| 806 | } |
| 807 | } |
| 808 | |
| 809 |
+1
-1
| --- src/makemake.tcl | ||
| +++ src/makemake.tcl | ||
| @@ -430,11 +430,11 @@ | ||
| 430 | 430 | # here is to use the Sysinternals junction tool to create a hard |
| 431 | 431 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 432 | 432 | # directory and the target Tcl directory. This removes the need to |
| 433 | 433 | # hard-code the necessary paths in this Makefile. |
| 434 | 434 | # |
| 435 | -TCLDIR = $(SRCDIR)/../tcl-8.6 | |
| 435 | +TCLDIR = $(SRCDIR)/../compat/tcl-8.6 | |
| 436 | 436 | |
| 437 | 437 | #### The Tcl source code directory. This defaults to the same value as |
| 438 | 438 | # TCLDIR macro (above), which may not be correct. This value will |
| 439 | 439 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 440 | 440 | # |
| 441 | 441 |
| --- src/makemake.tcl | |
| +++ src/makemake.tcl | |
| @@ -430,11 +430,11 @@ | |
| 430 | # here is to use the Sysinternals junction tool to create a hard |
| 431 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 432 | # directory and the target Tcl directory. This removes the need to |
| 433 | # hard-code the necessary paths in this Makefile. |
| 434 | # |
| 435 | TCLDIR = $(SRCDIR)/../tcl-8.6 |
| 436 | |
| 437 | #### The Tcl source code directory. This defaults to the same value as |
| 438 | # TCLDIR macro (above), which may not be correct. This value will |
| 439 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 440 | # |
| 441 |
| --- src/makemake.tcl | |
| +++ src/makemake.tcl | |
| @@ -430,11 +430,11 @@ | |
| 430 | # here is to use the Sysinternals junction tool to create a hard |
| 431 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 432 | # directory and the target Tcl directory. This removes the need to |
| 433 | # hard-code the necessary paths in this Makefile. |
| 434 | # |
| 435 | TCLDIR = $(SRCDIR)/../compat/tcl-8.6 |
| 436 | |
| 437 | #### The Tcl source code directory. This defaults to the same value as |
| 438 | # TCLDIR macro (above), which may not be correct. This value will |
| 439 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 440 | # |
| 441 |
+25
-23
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -670,11 +670,11 @@ | ||
| 670 | 670 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 671 | 671 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 672 | 672 | */ |
| 673 | 673 | #define SQLITE_VERSION "3.7.17" |
| 674 | 674 | #define SQLITE_VERSION_NUMBER 3007017 |
| 675 | -#define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" | |
| 675 | +#define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" | |
| 676 | 676 | |
| 677 | 677 | /* |
| 678 | 678 | ** CAPI3REF: Run-Time Library Version Numbers |
| 679 | 679 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 680 | 680 | ** |
| @@ -108403,18 +108403,34 @@ | ||
| 108403 | 108403 | |
| 108404 | 108404 | /* Search for an existing WhereLoop to overwrite, or which takes |
| 108405 | 108405 | ** priority over pTemplate. |
| 108406 | 108406 | */ |
| 108407 | 108407 | for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){ |
| 108408 | - if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ) continue; | |
| 108408 | + if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){ | |
| 108409 | + /* If either the iTab or iSortIdx values for two WhereLoop are different | |
| 108410 | + ** then those WhereLoops need to be considered separately. Neither is | |
| 108411 | + ** a candidate to replace the other. */ | |
| 108412 | + continue; | |
| 108413 | + } | |
| 108414 | + /* In the current implementation, the rSetup value is either zero | |
| 108415 | + ** or the cost of building an automatic index (NlogN) and the NlogN | |
| 108416 | + ** is the same for compatible WhereLoops. */ | |
| 108417 | + assert( p->rSetup==0 || pTemplate->rSetup==0 | |
| 108418 | + || p->rSetup==pTemplate->rSetup ); | |
| 108419 | + | |
| 108420 | + /* whereLoopAddBtree() always generates and inserts the automatic index | |
| 108421 | + ** case first. Hence compatible candidate WhereLoops never have a larger | |
| 108422 | + ** rSetup. Call this SETUP-INVARIANT */ | |
| 108423 | + assert( p->rSetup>=pTemplate->rSetup ); | |
| 108424 | + | |
| 108409 | 108425 | if( (p->prereq & pTemplate->prereq)==p->prereq |
| 108410 | 108426 | && p->rSetup<=pTemplate->rSetup |
| 108411 | 108427 | && p->rRun<=pTemplate->rRun |
| 108412 | 108428 | ){ |
| 108413 | 108429 | /* This branch taken when p is equal or better than pTemplate in |
| 108414 | 108430 | ** all of (1) dependences (2) setup-cost, and (3) run-cost. */ |
| 108415 | - testcase( p->rRun==pTemplate->rRun ); | |
| 108431 | + assert( p->rSetup==pTemplate->rSetup ); | |
| 108416 | 108432 | if( p->nLTerm<pTemplate->nLTerm |
| 108417 | 108433 | && (p->wsFlags & WHERE_INDEXED)!=0 |
| 108418 | 108434 | && (pTemplate->wsFlags & WHERE_INDEXED)!=0 |
| 108419 | 108435 | && p->u.btree.pIndex==pTemplate->u.btree.pIndex |
| 108420 | 108436 | && p->prereq==pTemplate->prereq |
| @@ -108421,42 +108437,26 @@ | ||
| 108421 | 108437 | ){ |
| 108422 | 108438 | /* Overwrite an existing WhereLoop with an similar one that uses |
| 108423 | 108439 | ** more terms of the index */ |
| 108424 | 108440 | pNext = p->pNextLoop; |
| 108425 | 108441 | break; |
| 108426 | - }else if( p->nOut>pTemplate->nOut | |
| 108427 | - && p->rSetup==pTemplate->rSetup | |
| 108428 | - && p->rRun==pTemplate->rRun | |
| 108429 | - ){ | |
| 108430 | - /* Overwrite an existing WhereLoop with the same cost but more | |
| 108431 | - ** outputs */ | |
| 108432 | - pNext = p->pNextLoop; | |
| 108433 | - break; | |
| 108434 | 108442 | }else{ |
| 108435 | 108443 | /* pTemplate is not helpful. |
| 108436 | 108444 | ** Return without changing or adding anything */ |
| 108437 | 108445 | goto whereLoopInsert_noop; |
| 108438 | 108446 | } |
| 108439 | 108447 | } |
| 108440 | - testcase( (p->prereq & pTemplate->prereq)==p->prereq | |
| 108441 | - && p->rSetup<=pTemplate->rSetup | |
| 108442 | - && p->rRun==pTemplate->rRun+1 ); | |
| 108443 | 108448 | if( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108444 | - && p->rSetup>=pTemplate->rSetup | |
| 108445 | 108449 | && p->rRun>=pTemplate->rRun |
| 108450 | + && ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */ | |
| 108446 | 108451 | ){ |
| 108447 | 108452 | /* Overwrite an existing WhereLoop with a better one: one that is |
| 108448 | 108453 | ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost |
| 108449 | 108454 | ** and is no worse in any of those categories. */ |
| 108450 | - testcase( p->rSetup==pTemplate->rSetup ); | |
| 108451 | - testcase( p->rRun==pTemplate->rRun ); | |
| 108452 | 108455 | pNext = p->pNextLoop; |
| 108453 | 108456 | break; |
| 108454 | 108457 | } |
| 108455 | - testcase( (p->prereq & pTemplate->prereq)==pTemplate->prereq | |
| 108456 | - && p->rSetup>=pTemplate->rSetup | |
| 108457 | - && p->rRun==pTemplate->rRun-1 ); | |
| 108458 | 108458 | } |
| 108459 | 108459 | |
| 108460 | 108460 | /* If we reach this point it means that either p[] should be overwritten |
| 108461 | 108461 | ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new |
| 108462 | 108462 | ** WhereLoop and insert it. |
| @@ -108525,11 +108525,11 @@ | ||
| 108525 | 108525 | WhereCost saved_nOut; /* Original value of pNew->nOut */ |
| 108526 | 108526 | int iCol; /* Index of the column in the table */ |
| 108527 | 108527 | int rc = SQLITE_OK; /* Return code */ |
| 108528 | 108528 | WhereCost nRowEst; /* Estimated index selectivity */ |
| 108529 | 108529 | WhereCost rLogSize; /* Logarithm of table size */ |
| 108530 | - WhereTerm *pTop, *pBtm; /* Top and bottom range constraints */ | |
| 108530 | + WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */ | |
| 108531 | 108531 | |
| 108532 | 108532 | pNew = pBuilder->pNew; |
| 108533 | 108533 | if( db->mallocFailed ) return SQLITE_NOMEM; |
| 108534 | 108534 | |
| 108535 | 108535 | assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); |
| @@ -109075,11 +109075,11 @@ | ||
| 109075 | 109075 | iCur = pItem->iCursor; |
| 109076 | 109076 | sSubBuild = *pBuilder; |
| 109077 | 109077 | sSubBuild.pOrderBy = 0; |
| 109078 | 109078 | sSubBuild.pBest = &sBest; |
| 109079 | 109079 | |
| 109080 | - for(pOrTerm=pOrWC->a; rc==SQLITE_OK && pOrTerm<pOrWCEnd; pOrTerm++){ | |
| 109080 | + for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){ | |
| 109081 | 109081 | if( (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 109082 | 109082 | sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc; |
| 109083 | 109083 | }else if( pOrTerm->leftCursor==iCur ){ |
| 109084 | 109084 | tempWC.pWInfo = pWC->pWInfo; |
| 109085 | 109085 | tempWC.pOuter = pWC; |
| @@ -109099,10 +109099,12 @@ | ||
| 109099 | 109099 | }else |
| 109100 | 109100 | #endif |
| 109101 | 109101 | { |
| 109102 | 109102 | rc = whereLoopAddBtree(&sSubBuild, mExtra); |
| 109103 | 109103 | } |
| 109104 | + /* sBest.maskSelf is always zero if an error occurs */ | |
| 109105 | + assert( rc==SQLITE_OK || sBest.maskSelf==0 ); | |
| 109104 | 109106 | if( sBest.maskSelf==0 ) break; |
| 109105 | 109107 | assert( sBest.rSetup==0 ); |
| 109106 | 109108 | rTotal = whereCostAdd(rTotal, sBest.rRun); |
| 109107 | 109109 | nRow = whereCostAdd(nRow, sBest.nOut); |
| 109108 | 109110 | prereq |= sBest.prereq; |
| @@ -109439,11 +109441,11 @@ | ||
| 109439 | 109441 | Parse *pParse; /* Parsing context */ |
| 109440 | 109442 | sqlite3 *db; /* The database connection */ |
| 109441 | 109443 | int iLoop; /* Loop counter over the terms of the join */ |
| 109442 | 109444 | int ii, jj; /* Loop counters */ |
| 109443 | 109445 | WhereCost rCost; /* Cost of a path */ |
| 109444 | - WhereCost mxCost; /* Maximum cost of a set of paths */ | |
| 109446 | + WhereCost mxCost = 0; /* Maximum cost of a set of paths */ | |
| 109445 | 109447 | WhereCost rSortCost; /* Cost to do a sort */ |
| 109446 | 109448 | int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ |
| 109447 | 109449 | WherePath *aFrom; /* All nFrom paths at the previous level */ |
| 109448 | 109450 | WherePath *aTo; /* The nTo best paths at the current level */ |
| 109449 | 109451 | WherePath *pFrom; /* An element of aFrom[] that we are working on */ |
| 109450 | 109452 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -670,11 +670,11 @@ | |
| 670 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 671 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 672 | */ |
| 673 | #define SQLITE_VERSION "3.7.17" |
| 674 | #define SQLITE_VERSION_NUMBER 3007017 |
| 675 | #define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" |
| 676 | |
| 677 | /* |
| 678 | ** CAPI3REF: Run-Time Library Version Numbers |
| 679 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 680 | ** |
| @@ -108403,18 +108403,34 @@ | |
| 108403 | |
| 108404 | /* Search for an existing WhereLoop to overwrite, or which takes |
| 108405 | ** priority over pTemplate. |
| 108406 | */ |
| 108407 | for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){ |
| 108408 | if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ) continue; |
| 108409 | if( (p->prereq & pTemplate->prereq)==p->prereq |
| 108410 | && p->rSetup<=pTemplate->rSetup |
| 108411 | && p->rRun<=pTemplate->rRun |
| 108412 | ){ |
| 108413 | /* This branch taken when p is equal or better than pTemplate in |
| 108414 | ** all of (1) dependences (2) setup-cost, and (3) run-cost. */ |
| 108415 | testcase( p->rRun==pTemplate->rRun ); |
| 108416 | if( p->nLTerm<pTemplate->nLTerm |
| 108417 | && (p->wsFlags & WHERE_INDEXED)!=0 |
| 108418 | && (pTemplate->wsFlags & WHERE_INDEXED)!=0 |
| 108419 | && p->u.btree.pIndex==pTemplate->u.btree.pIndex |
| 108420 | && p->prereq==pTemplate->prereq |
| @@ -108421,42 +108437,26 @@ | |
| 108421 | ){ |
| 108422 | /* Overwrite an existing WhereLoop with an similar one that uses |
| 108423 | ** more terms of the index */ |
| 108424 | pNext = p->pNextLoop; |
| 108425 | break; |
| 108426 | }else if( p->nOut>pTemplate->nOut |
| 108427 | && p->rSetup==pTemplate->rSetup |
| 108428 | && p->rRun==pTemplate->rRun |
| 108429 | ){ |
| 108430 | /* Overwrite an existing WhereLoop with the same cost but more |
| 108431 | ** outputs */ |
| 108432 | pNext = p->pNextLoop; |
| 108433 | break; |
| 108434 | }else{ |
| 108435 | /* pTemplate is not helpful. |
| 108436 | ** Return without changing or adding anything */ |
| 108437 | goto whereLoopInsert_noop; |
| 108438 | } |
| 108439 | } |
| 108440 | testcase( (p->prereq & pTemplate->prereq)==p->prereq |
| 108441 | && p->rSetup<=pTemplate->rSetup |
| 108442 | && p->rRun==pTemplate->rRun+1 ); |
| 108443 | if( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108444 | && p->rSetup>=pTemplate->rSetup |
| 108445 | && p->rRun>=pTemplate->rRun |
| 108446 | ){ |
| 108447 | /* Overwrite an existing WhereLoop with a better one: one that is |
| 108448 | ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost |
| 108449 | ** and is no worse in any of those categories. */ |
| 108450 | testcase( p->rSetup==pTemplate->rSetup ); |
| 108451 | testcase( p->rRun==pTemplate->rRun ); |
| 108452 | pNext = p->pNextLoop; |
| 108453 | break; |
| 108454 | } |
| 108455 | testcase( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108456 | && p->rSetup>=pTemplate->rSetup |
| 108457 | && p->rRun==pTemplate->rRun-1 ); |
| 108458 | } |
| 108459 | |
| 108460 | /* If we reach this point it means that either p[] should be overwritten |
| 108461 | ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new |
| 108462 | ** WhereLoop and insert it. |
| @@ -108525,11 +108525,11 @@ | |
| 108525 | WhereCost saved_nOut; /* Original value of pNew->nOut */ |
| 108526 | int iCol; /* Index of the column in the table */ |
| 108527 | int rc = SQLITE_OK; /* Return code */ |
| 108528 | WhereCost nRowEst; /* Estimated index selectivity */ |
| 108529 | WhereCost rLogSize; /* Logarithm of table size */ |
| 108530 | WhereTerm *pTop, *pBtm; /* Top and bottom range constraints */ |
| 108531 | |
| 108532 | pNew = pBuilder->pNew; |
| 108533 | if( db->mallocFailed ) return SQLITE_NOMEM; |
| 108534 | |
| 108535 | assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); |
| @@ -109075,11 +109075,11 @@ | |
| 109075 | iCur = pItem->iCursor; |
| 109076 | sSubBuild = *pBuilder; |
| 109077 | sSubBuild.pOrderBy = 0; |
| 109078 | sSubBuild.pBest = &sBest; |
| 109079 | |
| 109080 | for(pOrTerm=pOrWC->a; rc==SQLITE_OK && pOrTerm<pOrWCEnd; pOrTerm++){ |
| 109081 | if( (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 109082 | sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc; |
| 109083 | }else if( pOrTerm->leftCursor==iCur ){ |
| 109084 | tempWC.pWInfo = pWC->pWInfo; |
| 109085 | tempWC.pOuter = pWC; |
| @@ -109099,10 +109099,12 @@ | |
| 109099 | }else |
| 109100 | #endif |
| 109101 | { |
| 109102 | rc = whereLoopAddBtree(&sSubBuild, mExtra); |
| 109103 | } |
| 109104 | if( sBest.maskSelf==0 ) break; |
| 109105 | assert( sBest.rSetup==0 ); |
| 109106 | rTotal = whereCostAdd(rTotal, sBest.rRun); |
| 109107 | nRow = whereCostAdd(nRow, sBest.nOut); |
| 109108 | prereq |= sBest.prereq; |
| @@ -109439,11 +109441,11 @@ | |
| 109439 | Parse *pParse; /* Parsing context */ |
| 109440 | sqlite3 *db; /* The database connection */ |
| 109441 | int iLoop; /* Loop counter over the terms of the join */ |
| 109442 | int ii, jj; /* Loop counters */ |
| 109443 | WhereCost rCost; /* Cost of a path */ |
| 109444 | WhereCost mxCost; /* Maximum cost of a set of paths */ |
| 109445 | WhereCost rSortCost; /* Cost to do a sort */ |
| 109446 | int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ |
| 109447 | WherePath *aFrom; /* All nFrom paths at the previous level */ |
| 109448 | WherePath *aTo; /* The nTo best paths at the current level */ |
| 109449 | WherePath *pFrom; /* An element of aFrom[] that we are working on */ |
| 109450 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -670,11 +670,11 @@ | |
| 670 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 671 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 672 | */ |
| 673 | #define SQLITE_VERSION "3.7.17" |
| 674 | #define SQLITE_VERSION_NUMBER 3007017 |
| 675 | #define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" |
| 676 | |
| 677 | /* |
| 678 | ** CAPI3REF: Run-Time Library Version Numbers |
| 679 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 680 | ** |
| @@ -108403,18 +108403,34 @@ | |
| 108403 | |
| 108404 | /* Search for an existing WhereLoop to overwrite, or which takes |
| 108405 | ** priority over pTemplate. |
| 108406 | */ |
| 108407 | for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){ |
| 108408 | if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){ |
| 108409 | /* If either the iTab or iSortIdx values for two WhereLoop are different |
| 108410 | ** then those WhereLoops need to be considered separately. Neither is |
| 108411 | ** a candidate to replace the other. */ |
| 108412 | continue; |
| 108413 | } |
| 108414 | /* In the current implementation, the rSetup value is either zero |
| 108415 | ** or the cost of building an automatic index (NlogN) and the NlogN |
| 108416 | ** is the same for compatible WhereLoops. */ |
| 108417 | assert( p->rSetup==0 || pTemplate->rSetup==0 |
| 108418 | || p->rSetup==pTemplate->rSetup ); |
| 108419 | |
| 108420 | /* whereLoopAddBtree() always generates and inserts the automatic index |
| 108421 | ** case first. Hence compatible candidate WhereLoops never have a larger |
| 108422 | ** rSetup. Call this SETUP-INVARIANT */ |
| 108423 | assert( p->rSetup>=pTemplate->rSetup ); |
| 108424 | |
| 108425 | if( (p->prereq & pTemplate->prereq)==p->prereq |
| 108426 | && p->rSetup<=pTemplate->rSetup |
| 108427 | && p->rRun<=pTemplate->rRun |
| 108428 | ){ |
| 108429 | /* This branch taken when p is equal or better than pTemplate in |
| 108430 | ** all of (1) dependences (2) setup-cost, and (3) run-cost. */ |
| 108431 | assert( p->rSetup==pTemplate->rSetup ); |
| 108432 | if( p->nLTerm<pTemplate->nLTerm |
| 108433 | && (p->wsFlags & WHERE_INDEXED)!=0 |
| 108434 | && (pTemplate->wsFlags & WHERE_INDEXED)!=0 |
| 108435 | && p->u.btree.pIndex==pTemplate->u.btree.pIndex |
| 108436 | && p->prereq==pTemplate->prereq |
| @@ -108421,42 +108437,26 @@ | |
| 108437 | ){ |
| 108438 | /* Overwrite an existing WhereLoop with an similar one that uses |
| 108439 | ** more terms of the index */ |
| 108440 | pNext = p->pNextLoop; |
| 108441 | break; |
| 108442 | }else{ |
| 108443 | /* pTemplate is not helpful. |
| 108444 | ** Return without changing or adding anything */ |
| 108445 | goto whereLoopInsert_noop; |
| 108446 | } |
| 108447 | } |
| 108448 | if( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108449 | && p->rRun>=pTemplate->rRun |
| 108450 | && ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */ |
| 108451 | ){ |
| 108452 | /* Overwrite an existing WhereLoop with a better one: one that is |
| 108453 | ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost |
| 108454 | ** and is no worse in any of those categories. */ |
| 108455 | pNext = p->pNextLoop; |
| 108456 | break; |
| 108457 | } |
| 108458 | } |
| 108459 | |
| 108460 | /* If we reach this point it means that either p[] should be overwritten |
| 108461 | ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new |
| 108462 | ** WhereLoop and insert it. |
| @@ -108525,11 +108525,11 @@ | |
| 108525 | WhereCost saved_nOut; /* Original value of pNew->nOut */ |
| 108526 | int iCol; /* Index of the column in the table */ |
| 108527 | int rc = SQLITE_OK; /* Return code */ |
| 108528 | WhereCost nRowEst; /* Estimated index selectivity */ |
| 108529 | WhereCost rLogSize; /* Logarithm of table size */ |
| 108530 | WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */ |
| 108531 | |
| 108532 | pNew = pBuilder->pNew; |
| 108533 | if( db->mallocFailed ) return SQLITE_NOMEM; |
| 108534 | |
| 108535 | assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); |
| @@ -109075,11 +109075,11 @@ | |
| 109075 | iCur = pItem->iCursor; |
| 109076 | sSubBuild = *pBuilder; |
| 109077 | sSubBuild.pOrderBy = 0; |
| 109078 | sSubBuild.pBest = &sBest; |
| 109079 | |
| 109080 | for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){ |
| 109081 | if( (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 109082 | sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc; |
| 109083 | }else if( pOrTerm->leftCursor==iCur ){ |
| 109084 | tempWC.pWInfo = pWC->pWInfo; |
| 109085 | tempWC.pOuter = pWC; |
| @@ -109099,10 +109099,12 @@ | |
| 109099 | }else |
| 109100 | #endif |
| 109101 | { |
| 109102 | rc = whereLoopAddBtree(&sSubBuild, mExtra); |
| 109103 | } |
| 109104 | /* sBest.maskSelf is always zero if an error occurs */ |
| 109105 | assert( rc==SQLITE_OK || sBest.maskSelf==0 ); |
| 109106 | if( sBest.maskSelf==0 ) break; |
| 109107 | assert( sBest.rSetup==0 ); |
| 109108 | rTotal = whereCostAdd(rTotal, sBest.rRun); |
| 109109 | nRow = whereCostAdd(nRow, sBest.nOut); |
| 109110 | prereq |= sBest.prereq; |
| @@ -109439,11 +109441,11 @@ | |
| 109441 | Parse *pParse; /* Parsing context */ |
| 109442 | sqlite3 *db; /* The database connection */ |
| 109443 | int iLoop; /* Loop counter over the terms of the join */ |
| 109444 | int ii, jj; /* Loop counters */ |
| 109445 | WhereCost rCost; /* Cost of a path */ |
| 109446 | WhereCost mxCost = 0; /* Maximum cost of a set of paths */ |
| 109447 | WhereCost rSortCost; /* Cost to do a sort */ |
| 109448 | int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ |
| 109449 | WherePath *aFrom; /* All nFrom paths at the previous level */ |
| 109450 | WherePath *aTo; /* The nTo best paths at the current level */ |
| 109451 | WherePath *pFrom; /* An element of aFrom[] that we are working on */ |
| 109452 |
+25
-23
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -670,11 +670,11 @@ | ||
| 670 | 670 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 671 | 671 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 672 | 672 | */ |
| 673 | 673 | #define SQLITE_VERSION "3.7.17" |
| 674 | 674 | #define SQLITE_VERSION_NUMBER 3007017 |
| 675 | -#define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" | |
| 675 | +#define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" | |
| 676 | 676 | |
| 677 | 677 | /* |
| 678 | 678 | ** CAPI3REF: Run-Time Library Version Numbers |
| 679 | 679 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 680 | 680 | ** |
| @@ -108403,18 +108403,34 @@ | ||
| 108403 | 108403 | |
| 108404 | 108404 | /* Search for an existing WhereLoop to overwrite, or which takes |
| 108405 | 108405 | ** priority over pTemplate. |
| 108406 | 108406 | */ |
| 108407 | 108407 | for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){ |
| 108408 | - if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ) continue; | |
| 108408 | + if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){ | |
| 108409 | + /* If either the iTab or iSortIdx values for two WhereLoop are different | |
| 108410 | + ** then those WhereLoops need to be considered separately. Neither is | |
| 108411 | + ** a candidate to replace the other. */ | |
| 108412 | + continue; | |
| 108413 | + } | |
| 108414 | + /* In the current implementation, the rSetup value is either zero | |
| 108415 | + ** or the cost of building an automatic index (NlogN) and the NlogN | |
| 108416 | + ** is the same for compatible WhereLoops. */ | |
| 108417 | + assert( p->rSetup==0 || pTemplate->rSetup==0 | |
| 108418 | + || p->rSetup==pTemplate->rSetup ); | |
| 108419 | + | |
| 108420 | + /* whereLoopAddBtree() always generates and inserts the automatic index | |
| 108421 | + ** case first. Hence compatible candidate WhereLoops never have a larger | |
| 108422 | + ** rSetup. Call this SETUP-INVARIANT */ | |
| 108423 | + assert( p->rSetup>=pTemplate->rSetup ); | |
| 108424 | + | |
| 108409 | 108425 | if( (p->prereq & pTemplate->prereq)==p->prereq |
| 108410 | 108426 | && p->rSetup<=pTemplate->rSetup |
| 108411 | 108427 | && p->rRun<=pTemplate->rRun |
| 108412 | 108428 | ){ |
| 108413 | 108429 | /* This branch taken when p is equal or better than pTemplate in |
| 108414 | 108430 | ** all of (1) dependences (2) setup-cost, and (3) run-cost. */ |
| 108415 | - testcase( p->rRun==pTemplate->rRun ); | |
| 108431 | + assert( p->rSetup==pTemplate->rSetup ); | |
| 108416 | 108432 | if( p->nLTerm<pTemplate->nLTerm |
| 108417 | 108433 | && (p->wsFlags & WHERE_INDEXED)!=0 |
| 108418 | 108434 | && (pTemplate->wsFlags & WHERE_INDEXED)!=0 |
| 108419 | 108435 | && p->u.btree.pIndex==pTemplate->u.btree.pIndex |
| 108420 | 108436 | && p->prereq==pTemplate->prereq |
| @@ -108421,42 +108437,26 @@ | ||
| 108421 | 108437 | ){ |
| 108422 | 108438 | /* Overwrite an existing WhereLoop with an similar one that uses |
| 108423 | 108439 | ** more terms of the index */ |
| 108424 | 108440 | pNext = p->pNextLoop; |
| 108425 | 108441 | break; |
| 108426 | - }else if( p->nOut>pTemplate->nOut | |
| 108427 | - && p->rSetup==pTemplate->rSetup | |
| 108428 | - && p->rRun==pTemplate->rRun | |
| 108429 | - ){ | |
| 108430 | - /* Overwrite an existing WhereLoop with the same cost but more | |
| 108431 | - ** outputs */ | |
| 108432 | - pNext = p->pNextLoop; | |
| 108433 | - break; | |
| 108434 | 108442 | }else{ |
| 108435 | 108443 | /* pTemplate is not helpful. |
| 108436 | 108444 | ** Return without changing or adding anything */ |
| 108437 | 108445 | goto whereLoopInsert_noop; |
| 108438 | 108446 | } |
| 108439 | 108447 | } |
| 108440 | - testcase( (p->prereq & pTemplate->prereq)==p->prereq | |
| 108441 | - && p->rSetup<=pTemplate->rSetup | |
| 108442 | - && p->rRun==pTemplate->rRun+1 ); | |
| 108443 | 108448 | if( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108444 | - && p->rSetup>=pTemplate->rSetup | |
| 108445 | 108449 | && p->rRun>=pTemplate->rRun |
| 108450 | + && ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */ | |
| 108446 | 108451 | ){ |
| 108447 | 108452 | /* Overwrite an existing WhereLoop with a better one: one that is |
| 108448 | 108453 | ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost |
| 108449 | 108454 | ** and is no worse in any of those categories. */ |
| 108450 | - testcase( p->rSetup==pTemplate->rSetup ); | |
| 108451 | - testcase( p->rRun==pTemplate->rRun ); | |
| 108452 | 108455 | pNext = p->pNextLoop; |
| 108453 | 108456 | break; |
| 108454 | 108457 | } |
| 108455 | - testcase( (p->prereq & pTemplate->prereq)==pTemplate->prereq | |
| 108456 | - && p->rSetup>=pTemplate->rSetup | |
| 108457 | - && p->rRun==pTemplate->rRun-1 ); | |
| 108458 | 108458 | } |
| 108459 | 108459 | |
| 108460 | 108460 | /* If we reach this point it means that either p[] should be overwritten |
| 108461 | 108461 | ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new |
| 108462 | 108462 | ** WhereLoop and insert it. |
| @@ -108525,11 +108525,11 @@ | ||
| 108525 | 108525 | WhereCost saved_nOut; /* Original value of pNew->nOut */ |
| 108526 | 108526 | int iCol; /* Index of the column in the table */ |
| 108527 | 108527 | int rc = SQLITE_OK; /* Return code */ |
| 108528 | 108528 | WhereCost nRowEst; /* Estimated index selectivity */ |
| 108529 | 108529 | WhereCost rLogSize; /* Logarithm of table size */ |
| 108530 | - WhereTerm *pTop, *pBtm; /* Top and bottom range constraints */ | |
| 108530 | + WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */ | |
| 108531 | 108531 | |
| 108532 | 108532 | pNew = pBuilder->pNew; |
| 108533 | 108533 | if( db->mallocFailed ) return SQLITE_NOMEM; |
| 108534 | 108534 | |
| 108535 | 108535 | assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); |
| @@ -109075,11 +109075,11 @@ | ||
| 109075 | 109075 | iCur = pItem->iCursor; |
| 109076 | 109076 | sSubBuild = *pBuilder; |
| 109077 | 109077 | sSubBuild.pOrderBy = 0; |
| 109078 | 109078 | sSubBuild.pBest = &sBest; |
| 109079 | 109079 | |
| 109080 | - for(pOrTerm=pOrWC->a; rc==SQLITE_OK && pOrTerm<pOrWCEnd; pOrTerm++){ | |
| 109080 | + for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){ | |
| 109081 | 109081 | if( (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 109082 | 109082 | sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc; |
| 109083 | 109083 | }else if( pOrTerm->leftCursor==iCur ){ |
| 109084 | 109084 | tempWC.pWInfo = pWC->pWInfo; |
| 109085 | 109085 | tempWC.pOuter = pWC; |
| @@ -109099,10 +109099,12 @@ | ||
| 109099 | 109099 | }else |
| 109100 | 109100 | #endif |
| 109101 | 109101 | { |
| 109102 | 109102 | rc = whereLoopAddBtree(&sSubBuild, mExtra); |
| 109103 | 109103 | } |
| 109104 | + /* sBest.maskSelf is always zero if an error occurs */ | |
| 109105 | + assert( rc==SQLITE_OK || sBest.maskSelf==0 ); | |
| 109104 | 109106 | if( sBest.maskSelf==0 ) break; |
| 109105 | 109107 | assert( sBest.rSetup==0 ); |
| 109106 | 109108 | rTotal = whereCostAdd(rTotal, sBest.rRun); |
| 109107 | 109109 | nRow = whereCostAdd(nRow, sBest.nOut); |
| 109108 | 109110 | prereq |= sBest.prereq; |
| @@ -109439,11 +109441,11 @@ | ||
| 109439 | 109441 | Parse *pParse; /* Parsing context */ |
| 109440 | 109442 | sqlite3 *db; /* The database connection */ |
| 109441 | 109443 | int iLoop; /* Loop counter over the terms of the join */ |
| 109442 | 109444 | int ii, jj; /* Loop counters */ |
| 109443 | 109445 | WhereCost rCost; /* Cost of a path */ |
| 109444 | - WhereCost mxCost; /* Maximum cost of a set of paths */ | |
| 109446 | + WhereCost mxCost = 0; /* Maximum cost of a set of paths */ | |
| 109445 | 109447 | WhereCost rSortCost; /* Cost to do a sort */ |
| 109446 | 109448 | int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ |
| 109447 | 109449 | WherePath *aFrom; /* All nFrom paths at the previous level */ |
| 109448 | 109450 | WherePath *aTo; /* The nTo best paths at the current level */ |
| 109449 | 109451 | WherePath *pFrom; /* An element of aFrom[] that we are working on */ |
| 109450 | 109452 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -670,11 +670,11 @@ | |
| 670 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 671 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 672 | */ |
| 673 | #define SQLITE_VERSION "3.7.17" |
| 674 | #define SQLITE_VERSION_NUMBER 3007017 |
| 675 | #define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" |
| 676 | |
| 677 | /* |
| 678 | ** CAPI3REF: Run-Time Library Version Numbers |
| 679 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 680 | ** |
| @@ -108403,18 +108403,34 @@ | |
| 108403 | |
| 108404 | /* Search for an existing WhereLoop to overwrite, or which takes |
| 108405 | ** priority over pTemplate. |
| 108406 | */ |
| 108407 | for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){ |
| 108408 | if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ) continue; |
| 108409 | if( (p->prereq & pTemplate->prereq)==p->prereq |
| 108410 | && p->rSetup<=pTemplate->rSetup |
| 108411 | && p->rRun<=pTemplate->rRun |
| 108412 | ){ |
| 108413 | /* This branch taken when p is equal or better than pTemplate in |
| 108414 | ** all of (1) dependences (2) setup-cost, and (3) run-cost. */ |
| 108415 | testcase( p->rRun==pTemplate->rRun ); |
| 108416 | if( p->nLTerm<pTemplate->nLTerm |
| 108417 | && (p->wsFlags & WHERE_INDEXED)!=0 |
| 108418 | && (pTemplate->wsFlags & WHERE_INDEXED)!=0 |
| 108419 | && p->u.btree.pIndex==pTemplate->u.btree.pIndex |
| 108420 | && p->prereq==pTemplate->prereq |
| @@ -108421,42 +108437,26 @@ | |
| 108421 | ){ |
| 108422 | /* Overwrite an existing WhereLoop with an similar one that uses |
| 108423 | ** more terms of the index */ |
| 108424 | pNext = p->pNextLoop; |
| 108425 | break; |
| 108426 | }else if( p->nOut>pTemplate->nOut |
| 108427 | && p->rSetup==pTemplate->rSetup |
| 108428 | && p->rRun==pTemplate->rRun |
| 108429 | ){ |
| 108430 | /* Overwrite an existing WhereLoop with the same cost but more |
| 108431 | ** outputs */ |
| 108432 | pNext = p->pNextLoop; |
| 108433 | break; |
| 108434 | }else{ |
| 108435 | /* pTemplate is not helpful. |
| 108436 | ** Return without changing or adding anything */ |
| 108437 | goto whereLoopInsert_noop; |
| 108438 | } |
| 108439 | } |
| 108440 | testcase( (p->prereq & pTemplate->prereq)==p->prereq |
| 108441 | && p->rSetup<=pTemplate->rSetup |
| 108442 | && p->rRun==pTemplate->rRun+1 ); |
| 108443 | if( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108444 | && p->rSetup>=pTemplate->rSetup |
| 108445 | && p->rRun>=pTemplate->rRun |
| 108446 | ){ |
| 108447 | /* Overwrite an existing WhereLoop with a better one: one that is |
| 108448 | ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost |
| 108449 | ** and is no worse in any of those categories. */ |
| 108450 | testcase( p->rSetup==pTemplate->rSetup ); |
| 108451 | testcase( p->rRun==pTemplate->rRun ); |
| 108452 | pNext = p->pNextLoop; |
| 108453 | break; |
| 108454 | } |
| 108455 | testcase( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108456 | && p->rSetup>=pTemplate->rSetup |
| 108457 | && p->rRun==pTemplate->rRun-1 ); |
| 108458 | } |
| 108459 | |
| 108460 | /* If we reach this point it means that either p[] should be overwritten |
| 108461 | ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new |
| 108462 | ** WhereLoop and insert it. |
| @@ -108525,11 +108525,11 @@ | |
| 108525 | WhereCost saved_nOut; /* Original value of pNew->nOut */ |
| 108526 | int iCol; /* Index of the column in the table */ |
| 108527 | int rc = SQLITE_OK; /* Return code */ |
| 108528 | WhereCost nRowEst; /* Estimated index selectivity */ |
| 108529 | WhereCost rLogSize; /* Logarithm of table size */ |
| 108530 | WhereTerm *pTop, *pBtm; /* Top and bottom range constraints */ |
| 108531 | |
| 108532 | pNew = pBuilder->pNew; |
| 108533 | if( db->mallocFailed ) return SQLITE_NOMEM; |
| 108534 | |
| 108535 | assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); |
| @@ -109075,11 +109075,11 @@ | |
| 109075 | iCur = pItem->iCursor; |
| 109076 | sSubBuild = *pBuilder; |
| 109077 | sSubBuild.pOrderBy = 0; |
| 109078 | sSubBuild.pBest = &sBest; |
| 109079 | |
| 109080 | for(pOrTerm=pOrWC->a; rc==SQLITE_OK && pOrTerm<pOrWCEnd; pOrTerm++){ |
| 109081 | if( (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 109082 | sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc; |
| 109083 | }else if( pOrTerm->leftCursor==iCur ){ |
| 109084 | tempWC.pWInfo = pWC->pWInfo; |
| 109085 | tempWC.pOuter = pWC; |
| @@ -109099,10 +109099,12 @@ | |
| 109099 | }else |
| 109100 | #endif |
| 109101 | { |
| 109102 | rc = whereLoopAddBtree(&sSubBuild, mExtra); |
| 109103 | } |
| 109104 | if( sBest.maskSelf==0 ) break; |
| 109105 | assert( sBest.rSetup==0 ); |
| 109106 | rTotal = whereCostAdd(rTotal, sBest.rRun); |
| 109107 | nRow = whereCostAdd(nRow, sBest.nOut); |
| 109108 | prereq |= sBest.prereq; |
| @@ -109439,11 +109441,11 @@ | |
| 109439 | Parse *pParse; /* Parsing context */ |
| 109440 | sqlite3 *db; /* The database connection */ |
| 109441 | int iLoop; /* Loop counter over the terms of the join */ |
| 109442 | int ii, jj; /* Loop counters */ |
| 109443 | WhereCost rCost; /* Cost of a path */ |
| 109444 | WhereCost mxCost; /* Maximum cost of a set of paths */ |
| 109445 | WhereCost rSortCost; /* Cost to do a sort */ |
| 109446 | int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ |
| 109447 | WherePath *aFrom; /* All nFrom paths at the previous level */ |
| 109448 | WherePath *aTo; /* The nTo best paths at the current level */ |
| 109449 | WherePath *pFrom; /* An element of aFrom[] that we are working on */ |
| 109450 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -670,11 +670,11 @@ | |
| 670 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 671 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 672 | */ |
| 673 | #define SQLITE_VERSION "3.7.17" |
| 674 | #define SQLITE_VERSION_NUMBER 3007017 |
| 675 | #define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" |
| 676 | |
| 677 | /* |
| 678 | ** CAPI3REF: Run-Time Library Version Numbers |
| 679 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 680 | ** |
| @@ -108403,18 +108403,34 @@ | |
| 108403 | |
| 108404 | /* Search for an existing WhereLoop to overwrite, or which takes |
| 108405 | ** priority over pTemplate. |
| 108406 | */ |
| 108407 | for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){ |
| 108408 | if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){ |
| 108409 | /* If either the iTab or iSortIdx values for two WhereLoop are different |
| 108410 | ** then those WhereLoops need to be considered separately. Neither is |
| 108411 | ** a candidate to replace the other. */ |
| 108412 | continue; |
| 108413 | } |
| 108414 | /* In the current implementation, the rSetup value is either zero |
| 108415 | ** or the cost of building an automatic index (NlogN) and the NlogN |
| 108416 | ** is the same for compatible WhereLoops. */ |
| 108417 | assert( p->rSetup==0 || pTemplate->rSetup==0 |
| 108418 | || p->rSetup==pTemplate->rSetup ); |
| 108419 | |
| 108420 | /* whereLoopAddBtree() always generates and inserts the automatic index |
| 108421 | ** case first. Hence compatible candidate WhereLoops never have a larger |
| 108422 | ** rSetup. Call this SETUP-INVARIANT */ |
| 108423 | assert( p->rSetup>=pTemplate->rSetup ); |
| 108424 | |
| 108425 | if( (p->prereq & pTemplate->prereq)==p->prereq |
| 108426 | && p->rSetup<=pTemplate->rSetup |
| 108427 | && p->rRun<=pTemplate->rRun |
| 108428 | ){ |
| 108429 | /* This branch taken when p is equal or better than pTemplate in |
| 108430 | ** all of (1) dependences (2) setup-cost, and (3) run-cost. */ |
| 108431 | assert( p->rSetup==pTemplate->rSetup ); |
| 108432 | if( p->nLTerm<pTemplate->nLTerm |
| 108433 | && (p->wsFlags & WHERE_INDEXED)!=0 |
| 108434 | && (pTemplate->wsFlags & WHERE_INDEXED)!=0 |
| 108435 | && p->u.btree.pIndex==pTemplate->u.btree.pIndex |
| 108436 | && p->prereq==pTemplate->prereq |
| @@ -108421,42 +108437,26 @@ | |
| 108437 | ){ |
| 108438 | /* Overwrite an existing WhereLoop with an similar one that uses |
| 108439 | ** more terms of the index */ |
| 108440 | pNext = p->pNextLoop; |
| 108441 | break; |
| 108442 | }else{ |
| 108443 | /* pTemplate is not helpful. |
| 108444 | ** Return without changing or adding anything */ |
| 108445 | goto whereLoopInsert_noop; |
| 108446 | } |
| 108447 | } |
| 108448 | if( (p->prereq & pTemplate->prereq)==pTemplate->prereq |
| 108449 | && p->rRun>=pTemplate->rRun |
| 108450 | && ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */ |
| 108451 | ){ |
| 108452 | /* Overwrite an existing WhereLoop with a better one: one that is |
| 108453 | ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost |
| 108454 | ** and is no worse in any of those categories. */ |
| 108455 | pNext = p->pNextLoop; |
| 108456 | break; |
| 108457 | } |
| 108458 | } |
| 108459 | |
| 108460 | /* If we reach this point it means that either p[] should be overwritten |
| 108461 | ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new |
| 108462 | ** WhereLoop and insert it. |
| @@ -108525,11 +108525,11 @@ | |
| 108525 | WhereCost saved_nOut; /* Original value of pNew->nOut */ |
| 108526 | int iCol; /* Index of the column in the table */ |
| 108527 | int rc = SQLITE_OK; /* Return code */ |
| 108528 | WhereCost nRowEst; /* Estimated index selectivity */ |
| 108529 | WhereCost rLogSize; /* Logarithm of table size */ |
| 108530 | WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */ |
| 108531 | |
| 108532 | pNew = pBuilder->pNew; |
| 108533 | if( db->mallocFailed ) return SQLITE_NOMEM; |
| 108534 | |
| 108535 | assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); |
| @@ -109075,11 +109075,11 @@ | |
| 109075 | iCur = pItem->iCursor; |
| 109076 | sSubBuild = *pBuilder; |
| 109077 | sSubBuild.pOrderBy = 0; |
| 109078 | sSubBuild.pBest = &sBest; |
| 109079 | |
| 109080 | for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){ |
| 109081 | if( (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 109082 | sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc; |
| 109083 | }else if( pOrTerm->leftCursor==iCur ){ |
| 109084 | tempWC.pWInfo = pWC->pWInfo; |
| 109085 | tempWC.pOuter = pWC; |
| @@ -109099,10 +109099,12 @@ | |
| 109099 | }else |
| 109100 | #endif |
| 109101 | { |
| 109102 | rc = whereLoopAddBtree(&sSubBuild, mExtra); |
| 109103 | } |
| 109104 | /* sBest.maskSelf is always zero if an error occurs */ |
| 109105 | assert( rc==SQLITE_OK || sBest.maskSelf==0 ); |
| 109106 | if( sBest.maskSelf==0 ) break; |
| 109107 | assert( sBest.rSetup==0 ); |
| 109108 | rTotal = whereCostAdd(rTotal, sBest.rRun); |
| 109109 | nRow = whereCostAdd(nRow, sBest.nOut); |
| 109110 | prereq |= sBest.prereq; |
| @@ -109439,11 +109441,11 @@ | |
| 109441 | Parse *pParse; /* Parsing context */ |
| 109442 | sqlite3 *db; /* The database connection */ |
| 109443 | int iLoop; /* Loop counter over the terms of the join */ |
| 109444 | int ii, jj; /* Loop counters */ |
| 109445 | WhereCost rCost; /* Cost of a path */ |
| 109446 | WhereCost mxCost = 0; /* Maximum cost of a set of paths */ |
| 109447 | WhereCost rSortCost; /* Cost to do a sort */ |
| 109448 | int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ |
| 109449 | WherePath *aFrom; /* All nFrom paths at the previous level */ |
| 109450 | WherePath *aTo; /* The nTo best paths at the current level */ |
| 109451 | WherePath *pFrom; /* An element of aFrom[] that we are working on */ |
| 109452 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.17" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007017 |
| 112 | -#define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.17" |
| 111 | #define SQLITE_VERSION_NUMBER 3007017 |
| 112 | #define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.17" |
| 111 | #define SQLITE_VERSION_NUMBER 3007017 |
| 112 | #define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.17" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007017 |
| 112 | -#define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.17" |
| 111 | #define SQLITE_VERSION_NUMBER 3007017 |
| 112 | #define SQLITE_SOURCE_ID "2013-06-18 20:06:23 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.17" |
| 111 | #define SQLITE_VERSION_NUMBER 3007017 |
| 112 | #define SQLITE_SOURCE_ID "2013-06-19 12:34:13 8f27f35f288434b9e7bc503c608f1e2b590ade4d" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
+1
-1
| --- win/Makefile.mingw | ||
| +++ win/Makefile.mingw | ||
| @@ -94,11 +94,11 @@ | ||
| 94 | 94 | # here is to use the Sysinternals junction tool to create a hard |
| 95 | 95 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 96 | 96 | # directory and the target Tcl directory. This removes the need to |
| 97 | 97 | # hard-code the necessary paths in this Makefile. |
| 98 | 98 | # |
| 99 | -TCLDIR = $(SRCDIR)/../tcl-8.6 | |
| 99 | +TCLDIR = $(SRCDIR)/../compat/tcl-8.6 | |
| 100 | 100 | |
| 101 | 101 | #### The Tcl source code directory. This defaults to the same value as |
| 102 | 102 | # TCLDIR macro (above), which may not be correct. This value will |
| 103 | 103 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 104 | 104 | # |
| 105 | 105 |
| --- win/Makefile.mingw | |
| +++ win/Makefile.mingw | |
| @@ -94,11 +94,11 @@ | |
| 94 | # here is to use the Sysinternals junction tool to create a hard |
| 95 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 96 | # directory and the target Tcl directory. This removes the need to |
| 97 | # hard-code the necessary paths in this Makefile. |
| 98 | # |
| 99 | TCLDIR = $(SRCDIR)/../tcl-8.6 |
| 100 | |
| 101 | #### The Tcl source code directory. This defaults to the same value as |
| 102 | # TCLDIR macro (above), which may not be correct. This value will |
| 103 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 104 | # |
| 105 |
| --- win/Makefile.mingw | |
| +++ win/Makefile.mingw | |
| @@ -94,11 +94,11 @@ | |
| 94 | # here is to use the Sysinternals junction tool to create a hard |
| 95 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 96 | # directory and the target Tcl directory. This removes the need to |
| 97 | # hard-code the necessary paths in this Makefile. |
| 98 | # |
| 99 | TCLDIR = $(SRCDIR)/../compat/tcl-8.6 |
| 100 | |
| 101 | #### The Tcl source code directory. This defaults to the same value as |
| 102 | # TCLDIR macro (above), which may not be correct. This value will |
| 103 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 104 | # |
| 105 |
+1
-1
| --- win/Makefile.mingw.mistachkin | ||
| +++ win/Makefile.mingw.mistachkin | ||
| @@ -94,11 +94,11 @@ | ||
| 94 | 94 | # here is to use the Sysinternals junction tool to create a hard |
| 95 | 95 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 96 | 96 | # directory and the target Tcl directory. This removes the need to |
| 97 | 97 | # hard-code the necessary paths in this Makefile. |
| 98 | 98 | # |
| 99 | -TCLDIR = $(SRCDIR)/../tcl-8.6 | |
| 99 | +TCLDIR = $(SRCDIR)/../compat/tcl-8.6 | |
| 100 | 100 | |
| 101 | 101 | #### The Tcl source code directory. This defaults to the same value as |
| 102 | 102 | # TCLDIR macro (above), which may not be correct. This value will |
| 103 | 103 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 104 | 104 | # |
| 105 | 105 |
| --- win/Makefile.mingw.mistachkin | |
| +++ win/Makefile.mingw.mistachkin | |
| @@ -94,11 +94,11 @@ | |
| 94 | # here is to use the Sysinternals junction tool to create a hard |
| 95 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 96 | # directory and the target Tcl directory. This removes the need to |
| 97 | # hard-code the necessary paths in this Makefile. |
| 98 | # |
| 99 | TCLDIR = $(SRCDIR)/../tcl-8.6 |
| 100 | |
| 101 | #### The Tcl source code directory. This defaults to the same value as |
| 102 | # TCLDIR macro (above), which may not be correct. This value will |
| 103 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 104 | # |
| 105 |
| --- win/Makefile.mingw.mistachkin | |
| +++ win/Makefile.mingw.mistachkin | |
| @@ -94,11 +94,11 @@ | |
| 94 | # here is to use the Sysinternals junction tool to create a hard |
| 95 | # link between a "tcl-8.x" sub-directory of the Fossil source code |
| 96 | # directory and the target Tcl directory. This removes the need to |
| 97 | # hard-code the necessary paths in this Makefile. |
| 98 | # |
| 99 | TCLDIR = $(SRCDIR)/../compat/tcl-8.6 |
| 100 | |
| 101 | #### The Tcl source code directory. This defaults to the same value as |
| 102 | # TCLDIR macro (above), which may not be correct. This value will |
| 103 | # only be used if the FOSSIL_TCL_SOURCE macro is defined. |
| 104 | # |
| 105 |