Fossil SCM
Update the built-in SQLite from upstream, taking over Joe's fix fror MSVC (reported by Ross Berteig)
Commit
9aae838b8b4a18e5c4beb86066fe5c58ea233022
Parent
f2ce086b5dd1957…
2 files changed
+14
-7
+1
-1
+14
-7
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -656,11 +656,11 @@ | ||
| 656 | 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | 658 | */ |
| 659 | 659 | #define SQLITE_VERSION "3.8.1" |
| 660 | 660 | #define SQLITE_VERSION_NUMBER 3008001 |
| 661 | -#define SQLITE_SOURCE_ID "2013-09-03 14:43:12 d59f580904e6e7e90fc0a692a3dd4eeff5942479" | |
| 661 | +#define SQLITE_SOURCE_ID "2013-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939" | |
| 662 | 662 | |
| 663 | 663 | /* |
| 664 | 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | 666 | ** |
| @@ -81512,10 +81512,11 @@ | ||
| 81512 | 81512 | Stat4Sample *pSample; |
| 81513 | 81513 | int i; |
| 81514 | 81514 | |
| 81515 | 81515 | assert( IsStat4 || nEqZero==0 ); |
| 81516 | 81516 | |
| 81517 | +#ifdef SQLITE_ENABLE_STAT4 | |
| 81517 | 81518 | if( pNew->isPSample==0 ){ |
| 81518 | 81519 | Stat4Sample *pUpgrade = 0; |
| 81519 | 81520 | assert( pNew->anEq[pNew->iCol]>0 ); |
| 81520 | 81521 | |
| 81521 | 81522 | /* This sample is being added because the prefix that ends in column |
| @@ -81538,10 +81539,11 @@ | ||
| 81538 | 81539 | pUpgrade->iCol = pNew->iCol; |
| 81539 | 81540 | pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol]; |
| 81540 | 81541 | goto find_new_min; |
| 81541 | 81542 | } |
| 81542 | 81543 | } |
| 81544 | +#endif | |
| 81543 | 81545 | |
| 81544 | 81546 | /* If necessary, remove sample iMin to make room for the new sample. */ |
| 81545 | 81547 | if( p->nSample>=p->mxSample ){ |
| 81546 | 81548 | Stat4Sample *pMin = &p->a[p->iMin]; |
| 81547 | 81549 | tRowcnt *anEq = pMin->anEq; |
| @@ -81569,11 +81571,13 @@ | ||
| 81569 | 81571 | p->nSample++; |
| 81570 | 81572 | |
| 81571 | 81573 | /* Zero the first nEqZero entries in the anEq[] array. */ |
| 81572 | 81574 | memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero); |
| 81573 | 81575 | |
| 81576 | +#ifdef SQLITE_ENABLE_STAT4 | |
| 81574 | 81577 | find_new_min: |
| 81578 | +#endif | |
| 81575 | 81579 | if( p->nSample>=p->mxSample ){ |
| 81576 | 81580 | int iMin = -1; |
| 81577 | 81581 | for(i=0; i<p->mxSample; i++){ |
| 81578 | 81582 | if( p->a[i].isPSample ) continue; |
| 81579 | 81583 | if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){ |
| @@ -108194,16 +108198,19 @@ | ||
| 108194 | 108198 | UnpackedRecord *pRec, /* Vector of values to consider */ |
| 108195 | 108199 | int roundUp, /* Round up if true. Round down if false */ |
| 108196 | 108200 | tRowcnt *aStat /* OUT: stats written here */ |
| 108197 | 108201 | ){ |
| 108198 | 108202 | IndexSample *aSample = pIdx->aSample; |
| 108199 | - int iCol = pRec->nField-1; /* Index of required stats in anEq[] etc. */ | |
| 108203 | + int iCol; /* Index of required stats in anEq[] etc. */ | |
| 108200 | 108204 | int iMin = 0; /* Smallest sample not yet tested */ |
| 108201 | 108205 | int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */ |
| 108202 | 108206 | int iTest; /* Next sample to test */ |
| 108203 | 108207 | int res; /* Result of comparison operation */ |
| 108204 | 108208 | |
| 108209 | + assert( pRec!=0 || pParse->db->mallocFailed ); | |
| 108210 | + if( pRec==0 ) return; | |
| 108211 | + iCol = pRec->nField - 1; | |
| 108205 | 108212 | assert( pIdx->nSample>0 ); |
| 108206 | 108213 | assert( pRec->nField>0 && iCol<pIdx->nSampleCol ); |
| 108207 | 108214 | do{ |
| 108208 | 108215 | iTest = (iMin+i)/2; |
| 108209 | 108216 | res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec); |
| @@ -108327,15 +108334,10 @@ | ||
| 108327 | 108334 | && OptimizationEnabled(pParse->db, SQLITE_Stat3) |
| 108328 | 108335 | ){ |
| 108329 | 108336 | UnpackedRecord *pRec = pBuilder->pRec; |
| 108330 | 108337 | tRowcnt a[2]; |
| 108331 | 108338 | u8 aff; |
| 108332 | - if( nEq==p->nColumn ){ | |
| 108333 | - aff = SQLITE_AFF_INTEGER; | |
| 108334 | - }else{ | |
| 108335 | - aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; | |
| 108336 | - } | |
| 108337 | 108339 | |
| 108338 | 108340 | /* Variable iLower will be set to the estimate of the number of rows in |
| 108339 | 108341 | ** the index that are less than the lower bound of the range query. The |
| 108340 | 108342 | ** lower bound being the concatenation of $P and $L, where $P is the |
| 108341 | 108343 | ** key-prefix formed by the nEq values matched against the nEq left-most |
| @@ -108353,10 +108355,15 @@ | ||
| 108353 | 108355 | ** of iUpper are requested of whereKeyStats() and the smaller used. |
| 108354 | 108356 | */ |
| 108355 | 108357 | tRowcnt iLower; |
| 108356 | 108358 | tRowcnt iUpper; |
| 108357 | 108359 | |
| 108360 | + if( nEq==p->nColumn ){ | |
| 108361 | + aff = SQLITE_AFF_INTEGER; | |
| 108362 | + }else{ | |
| 108363 | + aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; | |
| 108364 | + } | |
| 108358 | 108365 | /* Determine iLower and iUpper using ($P) only. */ |
| 108359 | 108366 | if( nEq==0 ){ |
| 108360 | 108367 | iLower = 0; |
| 108361 | 108368 | iUpper = p->aiRowEst[0]; |
| 108362 | 108369 | }else{ |
| 108363 | 108370 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -656,11 +656,11 @@ | |
| 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | */ |
| 659 | #define SQLITE_VERSION "3.8.1" |
| 660 | #define SQLITE_VERSION_NUMBER 3008001 |
| 661 | #define SQLITE_SOURCE_ID "2013-09-03 14:43:12 d59f580904e6e7e90fc0a692a3dd4eeff5942479" |
| 662 | |
| 663 | /* |
| 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | ** |
| @@ -81512,10 +81512,11 @@ | |
| 81512 | Stat4Sample *pSample; |
| 81513 | int i; |
| 81514 | |
| 81515 | assert( IsStat4 || nEqZero==0 ); |
| 81516 | |
| 81517 | if( pNew->isPSample==0 ){ |
| 81518 | Stat4Sample *pUpgrade = 0; |
| 81519 | assert( pNew->anEq[pNew->iCol]>0 ); |
| 81520 | |
| 81521 | /* This sample is being added because the prefix that ends in column |
| @@ -81538,10 +81539,11 @@ | |
| 81538 | pUpgrade->iCol = pNew->iCol; |
| 81539 | pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol]; |
| 81540 | goto find_new_min; |
| 81541 | } |
| 81542 | } |
| 81543 | |
| 81544 | /* If necessary, remove sample iMin to make room for the new sample. */ |
| 81545 | if( p->nSample>=p->mxSample ){ |
| 81546 | Stat4Sample *pMin = &p->a[p->iMin]; |
| 81547 | tRowcnt *anEq = pMin->anEq; |
| @@ -81569,11 +81571,13 @@ | |
| 81569 | p->nSample++; |
| 81570 | |
| 81571 | /* Zero the first nEqZero entries in the anEq[] array. */ |
| 81572 | memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero); |
| 81573 | |
| 81574 | find_new_min: |
| 81575 | if( p->nSample>=p->mxSample ){ |
| 81576 | int iMin = -1; |
| 81577 | for(i=0; i<p->mxSample; i++){ |
| 81578 | if( p->a[i].isPSample ) continue; |
| 81579 | if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){ |
| @@ -108194,16 +108198,19 @@ | |
| 108194 | UnpackedRecord *pRec, /* Vector of values to consider */ |
| 108195 | int roundUp, /* Round up if true. Round down if false */ |
| 108196 | tRowcnt *aStat /* OUT: stats written here */ |
| 108197 | ){ |
| 108198 | IndexSample *aSample = pIdx->aSample; |
| 108199 | int iCol = pRec->nField-1; /* Index of required stats in anEq[] etc. */ |
| 108200 | int iMin = 0; /* Smallest sample not yet tested */ |
| 108201 | int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */ |
| 108202 | int iTest; /* Next sample to test */ |
| 108203 | int res; /* Result of comparison operation */ |
| 108204 | |
| 108205 | assert( pIdx->nSample>0 ); |
| 108206 | assert( pRec->nField>0 && iCol<pIdx->nSampleCol ); |
| 108207 | do{ |
| 108208 | iTest = (iMin+i)/2; |
| 108209 | res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec); |
| @@ -108327,15 +108334,10 @@ | |
| 108327 | && OptimizationEnabled(pParse->db, SQLITE_Stat3) |
| 108328 | ){ |
| 108329 | UnpackedRecord *pRec = pBuilder->pRec; |
| 108330 | tRowcnt a[2]; |
| 108331 | u8 aff; |
| 108332 | if( nEq==p->nColumn ){ |
| 108333 | aff = SQLITE_AFF_INTEGER; |
| 108334 | }else{ |
| 108335 | aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; |
| 108336 | } |
| 108337 | |
| 108338 | /* Variable iLower will be set to the estimate of the number of rows in |
| 108339 | ** the index that are less than the lower bound of the range query. The |
| 108340 | ** lower bound being the concatenation of $P and $L, where $P is the |
| 108341 | ** key-prefix formed by the nEq values matched against the nEq left-most |
| @@ -108353,10 +108355,15 @@ | |
| 108353 | ** of iUpper are requested of whereKeyStats() and the smaller used. |
| 108354 | */ |
| 108355 | tRowcnt iLower; |
| 108356 | tRowcnt iUpper; |
| 108357 | |
| 108358 | /* Determine iLower and iUpper using ($P) only. */ |
| 108359 | if( nEq==0 ){ |
| 108360 | iLower = 0; |
| 108361 | iUpper = p->aiRowEst[0]; |
| 108362 | }else{ |
| 108363 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -656,11 +656,11 @@ | |
| 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | */ |
| 659 | #define SQLITE_VERSION "3.8.1" |
| 660 | #define SQLITE_VERSION_NUMBER 3008001 |
| 661 | #define SQLITE_SOURCE_ID "2013-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939" |
| 662 | |
| 663 | /* |
| 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | ** |
| @@ -81512,10 +81512,11 @@ | |
| 81512 | Stat4Sample *pSample; |
| 81513 | int i; |
| 81514 | |
| 81515 | assert( IsStat4 || nEqZero==0 ); |
| 81516 | |
| 81517 | #ifdef SQLITE_ENABLE_STAT4 |
| 81518 | if( pNew->isPSample==0 ){ |
| 81519 | Stat4Sample *pUpgrade = 0; |
| 81520 | assert( pNew->anEq[pNew->iCol]>0 ); |
| 81521 | |
| 81522 | /* This sample is being added because the prefix that ends in column |
| @@ -81538,10 +81539,11 @@ | |
| 81539 | pUpgrade->iCol = pNew->iCol; |
| 81540 | pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol]; |
| 81541 | goto find_new_min; |
| 81542 | } |
| 81543 | } |
| 81544 | #endif |
| 81545 | |
| 81546 | /* If necessary, remove sample iMin to make room for the new sample. */ |
| 81547 | if( p->nSample>=p->mxSample ){ |
| 81548 | Stat4Sample *pMin = &p->a[p->iMin]; |
| 81549 | tRowcnt *anEq = pMin->anEq; |
| @@ -81569,11 +81571,13 @@ | |
| 81571 | p->nSample++; |
| 81572 | |
| 81573 | /* Zero the first nEqZero entries in the anEq[] array. */ |
| 81574 | memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero); |
| 81575 | |
| 81576 | #ifdef SQLITE_ENABLE_STAT4 |
| 81577 | find_new_min: |
| 81578 | #endif |
| 81579 | if( p->nSample>=p->mxSample ){ |
| 81580 | int iMin = -1; |
| 81581 | for(i=0; i<p->mxSample; i++){ |
| 81582 | if( p->a[i].isPSample ) continue; |
| 81583 | if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){ |
| @@ -108194,16 +108198,19 @@ | |
| 108198 | UnpackedRecord *pRec, /* Vector of values to consider */ |
| 108199 | int roundUp, /* Round up if true. Round down if false */ |
| 108200 | tRowcnt *aStat /* OUT: stats written here */ |
| 108201 | ){ |
| 108202 | IndexSample *aSample = pIdx->aSample; |
| 108203 | int iCol; /* Index of required stats in anEq[] etc. */ |
| 108204 | int iMin = 0; /* Smallest sample not yet tested */ |
| 108205 | int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */ |
| 108206 | int iTest; /* Next sample to test */ |
| 108207 | int res; /* Result of comparison operation */ |
| 108208 | |
| 108209 | assert( pRec!=0 || pParse->db->mallocFailed ); |
| 108210 | if( pRec==0 ) return; |
| 108211 | iCol = pRec->nField - 1; |
| 108212 | assert( pIdx->nSample>0 ); |
| 108213 | assert( pRec->nField>0 && iCol<pIdx->nSampleCol ); |
| 108214 | do{ |
| 108215 | iTest = (iMin+i)/2; |
| 108216 | res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec); |
| @@ -108327,15 +108334,10 @@ | |
| 108334 | && OptimizationEnabled(pParse->db, SQLITE_Stat3) |
| 108335 | ){ |
| 108336 | UnpackedRecord *pRec = pBuilder->pRec; |
| 108337 | tRowcnt a[2]; |
| 108338 | u8 aff; |
| 108339 | |
| 108340 | /* Variable iLower will be set to the estimate of the number of rows in |
| 108341 | ** the index that are less than the lower bound of the range query. The |
| 108342 | ** lower bound being the concatenation of $P and $L, where $P is the |
| 108343 | ** key-prefix formed by the nEq values matched against the nEq left-most |
| @@ -108353,10 +108355,15 @@ | |
| 108355 | ** of iUpper are requested of whereKeyStats() and the smaller used. |
| 108356 | */ |
| 108357 | tRowcnt iLower; |
| 108358 | tRowcnt iUpper; |
| 108359 | |
| 108360 | if( nEq==p->nColumn ){ |
| 108361 | aff = SQLITE_AFF_INTEGER; |
| 108362 | }else{ |
| 108363 | aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; |
| 108364 | } |
| 108365 | /* Determine iLower and iUpper using ($P) only. */ |
| 108366 | if( nEq==0 ){ |
| 108367 | iLower = 0; |
| 108368 | iUpper = p->aiRowEst[0]; |
| 108369 | }else{ |
| 108370 |
+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.8.1" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3008001 |
| 112 | -#define SQLITE_SOURCE_ID "2013-09-03 14:43:12 d59f580904e6e7e90fc0a692a3dd4eeff5942479" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939" | |
| 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.8.1" |
| 111 | #define SQLITE_VERSION_NUMBER 3008001 |
| 112 | #define SQLITE_SOURCE_ID "2013-09-03 14:43:12 d59f580904e6e7e90fc0a692a3dd4eeff5942479" |
| 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.8.1" |
| 111 | #define SQLITE_VERSION_NUMBER 3008001 |
| 112 | #define SQLITE_SOURCE_ID "2013-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |