Fossil SCM
Update the built-in SQLite to the lastest 3.7.6 alpha out of the head of the SQLite trunk.
Commit
d1790d6954558d7c97c371dabc9fb60d915550da
Parent
fde81c6109780de…
2 files changed
+51
-28
+1
-1
+51
-28
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -650,11 +650,11 @@ | ||
| 650 | 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | 652 | */ |
| 653 | 653 | #define SQLITE_VERSION "3.7.6" |
| 654 | 654 | #define SQLITE_VERSION_NUMBER 3007006 |
| 655 | -#define SQLITE_SOURCE_ID "2011-02-16 23:32:24 31fc4ba66e76876b2e7b6b2b74c07f47571938ce" | |
| 655 | +#define SQLITE_SOURCE_ID "2011-02-19 23:18:12 e87d499a4f8a456111c1f96ca6da31d0810fb7c8" | |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| @@ -43796,14 +43796,35 @@ | ||
| 43796 | 43796 | int i; /* Loop counter */ |
| 43797 | 43797 | int rc = SQLITE_OK; /* Return code */ |
| 43798 | 43798 | |
| 43799 | 43799 | assert( pWal->readLock<0 ); /* Not currently locked */ |
| 43800 | 43800 | |
| 43801 | - /* Take steps to avoid spinning forever if there is a protocol error. */ | |
| 43801 | + /* Take steps to avoid spinning forever if there is a protocol error. | |
| 43802 | + ** | |
| 43803 | + ** Circumstances that cause a RETRY should only last for the briefest | |
| 43804 | + ** instances of time. No I/O or other system calls are done while the | |
| 43805 | + ** locks are held, so the locks should not be held for very long. But | |
| 43806 | + ** if we are unlucky, another process that is holding a lock might get | |
| 43807 | + ** paged out or take a page-fault that is time-consuming to resolve, | |
| 43808 | + ** during the few nanoseconds that it is holding the lock. In that case, | |
| 43809 | + ** it might take longer than normal for the lock to free. | |
| 43810 | + ** | |
| 43811 | + ** After 5 RETRYs, we begin calling sqlite3OsSleep(). The first few | |
| 43812 | + ** calls to sqlite3OsSleep() have a delay of 1 microsecond. Really this | |
| 43813 | + ** is more of a scheduler yield than an actual delay. But on the 10th | |
| 43814 | + ** an subsequent retries, the delays start becoming longer and longer, | |
| 43815 | + ** so that on the 100th (and last) RETRY we delay for 21 milliseconds. | |
| 43816 | + ** The total delay time before giving up is less than 1 second. | |
| 43817 | + */ | |
| 43802 | 43818 | if( cnt>5 ){ |
| 43803 | - if( cnt>100 ) return SQLITE_PROTOCOL; | |
| 43804 | - sqlite3OsSleep(pWal->pVfs, 1); | |
| 43819 | + int nDelay = 1; /* Pause time in microseconds */ | |
| 43820 | + if( cnt>100 ){ | |
| 43821 | + VVA_ONLY( pWal->lockError = 1; ) | |
| 43822 | + return SQLITE_PROTOCOL; | |
| 43823 | + } | |
| 43824 | + if( cnt>=10 ) nDelay = (cnt-9)*238; /* Max delay 21ms. Total delay 996ms */ | |
| 43825 | + sqlite3OsSleep(pWal->pVfs, nDelay); | |
| 43805 | 43826 | } |
| 43806 | 43827 | |
| 43807 | 43828 | if( !useWal ){ |
| 43808 | 43829 | rc = walIndexReadHdr(pWal, pChanged); |
| 43809 | 43830 | if( rc==SQLITE_BUSY ){ |
| @@ -43881,26 +43902,13 @@ | ||
| 43881 | 43902 | assert( thisMark!=READMARK_NOT_USED ); |
| 43882 | 43903 | mxReadMark = thisMark; |
| 43883 | 43904 | mxI = i; |
| 43884 | 43905 | } |
| 43885 | 43906 | } |
| 43886 | - if( mxI==0 ){ | |
| 43887 | - /* If we get here, it means that all of the aReadMark[] entries between | |
| 43888 | - ** 1 and WAL_NREADER-1 are zero. Try to initialize aReadMark[1] to | |
| 43889 | - ** be mxFrame, then retry. | |
| 43890 | - */ | |
| 43891 | - rc = walLockExclusive(pWal, WAL_READ_LOCK(1), 1); | |
| 43892 | - if( rc==SQLITE_OK ){ | |
| 43893 | - pInfo->aReadMark[1] = pWal->hdr.mxFrame; | |
| 43894 | - walUnlockExclusive(pWal, WAL_READ_LOCK(1), 1); | |
| 43895 | - rc = WAL_RETRY; | |
| 43896 | - }else if( rc==SQLITE_BUSY ){ | |
| 43897 | - rc = WAL_RETRY; | |
| 43898 | - } | |
| 43899 | - return rc; | |
| 43900 | - }else{ | |
| 43901 | - if( mxReadMark < pWal->hdr.mxFrame ){ | |
| 43907 | + /* There was once an "if" here. The extra "{" is to preserve indentation. */ | |
| 43908 | + { | |
| 43909 | + if( mxReadMark < pWal->hdr.mxFrame || mxI==0 ){ | |
| 43902 | 43910 | for(i=1; i<WAL_NREADER; i++){ |
| 43903 | 43911 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 43904 | 43912 | if( rc==SQLITE_OK ){ |
| 43905 | 43913 | mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame; |
| 43906 | 43914 | mxI = i; |
| @@ -43909,10 +43917,14 @@ | ||
| 43909 | 43917 | }else if( rc!=SQLITE_BUSY ){ |
| 43910 | 43918 | return rc; |
| 43911 | 43919 | } |
| 43912 | 43920 | } |
| 43913 | 43921 | } |
| 43922 | + if( mxI==0 ){ | |
| 43923 | + assert( rc==SQLITE_BUSY ); | |
| 43924 | + return WAL_RETRY; | |
| 43925 | + } | |
| 43914 | 43926 | |
| 43915 | 43927 | rc = walLockShared(pWal, WAL_READ_LOCK(mxI)); |
| 43916 | 43928 | if( rc ){ |
| 43917 | 43929 | return rc==SQLITE_BUSY ? WAL_RETRY : rc; |
| 43918 | 43930 | } |
| @@ -43969,10 +43981,14 @@ | ||
| 43969 | 43981 | int cnt = 0; /* Number of TryBeginRead attempts */ |
| 43970 | 43982 | |
| 43971 | 43983 | do{ |
| 43972 | 43984 | rc = walTryBeginRead(pWal, pChanged, 0, ++cnt); |
| 43973 | 43985 | }while( rc==WAL_RETRY ); |
| 43986 | + testcase( (rc&0xff)==SQLITE_BUSY ); | |
| 43987 | + testcase( (rc&0xff)==SQLITE_IOERR ); | |
| 43988 | + testcase( rc==SQLITE_PROTOCOL ); | |
| 43989 | + testcase( rc==SQLITE_OK ); | |
| 43974 | 43990 | return rc; |
| 43975 | 43991 | } |
| 43976 | 43992 | |
| 43977 | 43993 | /* |
| 43978 | 43994 | ** Finish with a read transaction. All this does is release the |
| @@ -44286,10 +44302,12 @@ | ||
| 44286 | 44302 | |
| 44287 | 44303 | if( pWal->readLock==0 ){ |
| 44288 | 44304 | volatile WalCkptInfo *pInfo = walCkptInfo(pWal); |
| 44289 | 44305 | assert( pInfo->nBackfill==pWal->hdr.mxFrame ); |
| 44290 | 44306 | if( pInfo->nBackfill>0 ){ |
| 44307 | + u32 salt1; | |
| 44308 | + sqlite3_randomness(4, &salt1); | |
| 44291 | 44309 | rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| 44292 | 44310 | if( rc==SQLITE_OK ){ |
| 44293 | 44311 | /* If all readers are using WAL_READ_LOCK(0) (in other words if no |
| 44294 | 44312 | ** readers are currently using the WAL), then the transactions |
| 44295 | 44313 | ** frames will overwrite the start of the existing log. Update the |
| @@ -44303,11 +44321,11 @@ | ||
| 44303 | 44321 | int i; /* Loop counter */ |
| 44304 | 44322 | u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */ |
| 44305 | 44323 | pWal->nCkpt++; |
| 44306 | 44324 | pWal->hdr.mxFrame = 0; |
| 44307 | 44325 | sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0])); |
| 44308 | - sqlite3_randomness(4, &aSalt[1]); | |
| 44326 | + aSalt[1] = salt1; | |
| 44309 | 44327 | walIndexWriteHdr(pWal); |
| 44310 | 44328 | pInfo->nBackfill = 0; |
| 44311 | 44329 | for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED; |
| 44312 | 44330 | assert( pInfo->aReadMark[0]==0 ); |
| 44313 | 44331 | walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| @@ -44320,10 +44338,14 @@ | ||
| 44320 | 44338 | cnt = 0; |
| 44321 | 44339 | do{ |
| 44322 | 44340 | int notUsed; |
| 44323 | 44341 | rc = walTryBeginRead(pWal, ¬Used, 1, ++cnt); |
| 44324 | 44342 | }while( rc==WAL_RETRY ); |
| 44343 | + assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */ | |
| 44344 | + testcase( (rc&0xff)==SQLITE_IOERR ); | |
| 44345 | + testcase( rc==SQLITE_PROTOCOL ); | |
| 44346 | + testcase( rc==SQLITE_OK ); | |
| 44325 | 44347 | } |
| 44326 | 44348 | return rc; |
| 44327 | 44349 | } |
| 44328 | 44350 | |
| 44329 | 44351 | /* |
| @@ -55589,10 +55611,11 @@ | ||
| 55589 | 55611 | pVal->r = (double)-1 * pVal->r; |
| 55590 | 55612 | sqlite3ValueApplyAffinity(pVal, affinity, enc); |
| 55591 | 55613 | } |
| 55592 | 55614 | }else if( op==TK_NULL ){ |
| 55593 | 55615 | pVal = sqlite3ValueNew(db); |
| 55616 | + if( pVal==0 ) goto no_mem; | |
| 55594 | 55617 | } |
| 55595 | 55618 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 55596 | 55619 | else if( op==TK_BLOB ){ |
| 55597 | 55620 | int nVal; |
| 55598 | 55621 | assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' ); |
| @@ -70417,20 +70440,21 @@ | ||
| 70417 | 70440 | ** in *pValue. If the expression is not an integer or if it is too big |
| 70418 | 70441 | ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. |
| 70419 | 70442 | */ |
| 70420 | 70443 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){ |
| 70421 | 70444 | int rc = 0; |
| 70445 | + | |
| 70446 | + /* If an expression is an integer literal that fits in a signed 32-bit | |
| 70447 | + ** integer, then the EP_IntValue flag will have already been set */ | |
| 70448 | + assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0 | |
| 70449 | + || sqlite3GetInt32(p->u.zToken, &rc)==0 ); | |
| 70450 | + | |
| 70422 | 70451 | if( p->flags & EP_IntValue ){ |
| 70423 | 70452 | *pValue = p->u.iValue; |
| 70424 | 70453 | return 1; |
| 70425 | 70454 | } |
| 70426 | 70455 | switch( p->op ){ |
| 70427 | - case TK_INTEGER: { | |
| 70428 | - rc = sqlite3GetInt32(p->u.zToken, pValue); | |
| 70429 | - assert( rc==0 ); | |
| 70430 | - break; | |
| 70431 | - } | |
| 70432 | 70456 | case TK_UPLUS: { |
| 70433 | 70457 | rc = sqlite3ExprIsInteger(p->pLeft, pValue); |
| 70434 | 70458 | break; |
| 70435 | 70459 | } |
| 70436 | 70460 | case TK_UMINUS: { |
| @@ -97870,12 +97894,11 @@ | ||
| 97870 | 97894 | if( (idxCols & cMask)==0 ){ |
| 97871 | 97895 | Expr *pX = pTerm->pExpr; |
| 97872 | 97896 | idxCols |= cMask; |
| 97873 | 97897 | pIdx->aiColumn[n] = pTerm->u.leftColumn; |
| 97874 | 97898 | pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); |
| 97875 | - assert( pColl!=0 || pParse->nErr>0 ); | |
| 97876 | - pIdx->azColl[n] = pColl ? pColl->zName : "BINARY"; | |
| 97899 | + pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : "BINARY"; | |
| 97877 | 97900 | n++; |
| 97878 | 97901 | } |
| 97879 | 97902 | } |
| 97880 | 97903 | } |
| 97881 | 97904 | assert( (u32)n==pLevel->plan.nEq ); |
| 97882 | 97905 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.6" |
| 654 | #define SQLITE_VERSION_NUMBER 3007006 |
| 655 | #define SQLITE_SOURCE_ID "2011-02-16 23:32:24 31fc4ba66e76876b2e7b6b2b74c07f47571938ce" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -43796,14 +43796,35 @@ | |
| 43796 | int i; /* Loop counter */ |
| 43797 | int rc = SQLITE_OK; /* Return code */ |
| 43798 | |
| 43799 | assert( pWal->readLock<0 ); /* Not currently locked */ |
| 43800 | |
| 43801 | /* Take steps to avoid spinning forever if there is a protocol error. */ |
| 43802 | if( cnt>5 ){ |
| 43803 | if( cnt>100 ) return SQLITE_PROTOCOL; |
| 43804 | sqlite3OsSleep(pWal->pVfs, 1); |
| 43805 | } |
| 43806 | |
| 43807 | if( !useWal ){ |
| 43808 | rc = walIndexReadHdr(pWal, pChanged); |
| 43809 | if( rc==SQLITE_BUSY ){ |
| @@ -43881,26 +43902,13 @@ | |
| 43881 | assert( thisMark!=READMARK_NOT_USED ); |
| 43882 | mxReadMark = thisMark; |
| 43883 | mxI = i; |
| 43884 | } |
| 43885 | } |
| 43886 | if( mxI==0 ){ |
| 43887 | /* If we get here, it means that all of the aReadMark[] entries between |
| 43888 | ** 1 and WAL_NREADER-1 are zero. Try to initialize aReadMark[1] to |
| 43889 | ** be mxFrame, then retry. |
| 43890 | */ |
| 43891 | rc = walLockExclusive(pWal, WAL_READ_LOCK(1), 1); |
| 43892 | if( rc==SQLITE_OK ){ |
| 43893 | pInfo->aReadMark[1] = pWal->hdr.mxFrame; |
| 43894 | walUnlockExclusive(pWal, WAL_READ_LOCK(1), 1); |
| 43895 | rc = WAL_RETRY; |
| 43896 | }else if( rc==SQLITE_BUSY ){ |
| 43897 | rc = WAL_RETRY; |
| 43898 | } |
| 43899 | return rc; |
| 43900 | }else{ |
| 43901 | if( mxReadMark < pWal->hdr.mxFrame ){ |
| 43902 | for(i=1; i<WAL_NREADER; i++){ |
| 43903 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 43904 | if( rc==SQLITE_OK ){ |
| 43905 | mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame; |
| 43906 | mxI = i; |
| @@ -43909,10 +43917,14 @@ | |
| 43909 | }else if( rc!=SQLITE_BUSY ){ |
| 43910 | return rc; |
| 43911 | } |
| 43912 | } |
| 43913 | } |
| 43914 | |
| 43915 | rc = walLockShared(pWal, WAL_READ_LOCK(mxI)); |
| 43916 | if( rc ){ |
| 43917 | return rc==SQLITE_BUSY ? WAL_RETRY : rc; |
| 43918 | } |
| @@ -43969,10 +43981,14 @@ | |
| 43969 | int cnt = 0; /* Number of TryBeginRead attempts */ |
| 43970 | |
| 43971 | do{ |
| 43972 | rc = walTryBeginRead(pWal, pChanged, 0, ++cnt); |
| 43973 | }while( rc==WAL_RETRY ); |
| 43974 | return rc; |
| 43975 | } |
| 43976 | |
| 43977 | /* |
| 43978 | ** Finish with a read transaction. All this does is release the |
| @@ -44286,10 +44302,12 @@ | |
| 44286 | |
| 44287 | if( pWal->readLock==0 ){ |
| 44288 | volatile WalCkptInfo *pInfo = walCkptInfo(pWal); |
| 44289 | assert( pInfo->nBackfill==pWal->hdr.mxFrame ); |
| 44290 | if( pInfo->nBackfill>0 ){ |
| 44291 | rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| 44292 | if( rc==SQLITE_OK ){ |
| 44293 | /* If all readers are using WAL_READ_LOCK(0) (in other words if no |
| 44294 | ** readers are currently using the WAL), then the transactions |
| 44295 | ** frames will overwrite the start of the existing log. Update the |
| @@ -44303,11 +44321,11 @@ | |
| 44303 | int i; /* Loop counter */ |
| 44304 | u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */ |
| 44305 | pWal->nCkpt++; |
| 44306 | pWal->hdr.mxFrame = 0; |
| 44307 | sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0])); |
| 44308 | sqlite3_randomness(4, &aSalt[1]); |
| 44309 | walIndexWriteHdr(pWal); |
| 44310 | pInfo->nBackfill = 0; |
| 44311 | for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED; |
| 44312 | assert( pInfo->aReadMark[0]==0 ); |
| 44313 | walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| @@ -44320,10 +44338,14 @@ | |
| 44320 | cnt = 0; |
| 44321 | do{ |
| 44322 | int notUsed; |
| 44323 | rc = walTryBeginRead(pWal, ¬Used, 1, ++cnt); |
| 44324 | }while( rc==WAL_RETRY ); |
| 44325 | } |
| 44326 | return rc; |
| 44327 | } |
| 44328 | |
| 44329 | /* |
| @@ -55589,10 +55611,11 @@ | |
| 55589 | pVal->r = (double)-1 * pVal->r; |
| 55590 | sqlite3ValueApplyAffinity(pVal, affinity, enc); |
| 55591 | } |
| 55592 | }else if( op==TK_NULL ){ |
| 55593 | pVal = sqlite3ValueNew(db); |
| 55594 | } |
| 55595 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 55596 | else if( op==TK_BLOB ){ |
| 55597 | int nVal; |
| 55598 | assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' ); |
| @@ -70417,20 +70440,21 @@ | |
| 70417 | ** in *pValue. If the expression is not an integer or if it is too big |
| 70418 | ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. |
| 70419 | */ |
| 70420 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){ |
| 70421 | int rc = 0; |
| 70422 | if( p->flags & EP_IntValue ){ |
| 70423 | *pValue = p->u.iValue; |
| 70424 | return 1; |
| 70425 | } |
| 70426 | switch( p->op ){ |
| 70427 | case TK_INTEGER: { |
| 70428 | rc = sqlite3GetInt32(p->u.zToken, pValue); |
| 70429 | assert( rc==0 ); |
| 70430 | break; |
| 70431 | } |
| 70432 | case TK_UPLUS: { |
| 70433 | rc = sqlite3ExprIsInteger(p->pLeft, pValue); |
| 70434 | break; |
| 70435 | } |
| 70436 | case TK_UMINUS: { |
| @@ -97870,12 +97894,11 @@ | |
| 97870 | if( (idxCols & cMask)==0 ){ |
| 97871 | Expr *pX = pTerm->pExpr; |
| 97872 | idxCols |= cMask; |
| 97873 | pIdx->aiColumn[n] = pTerm->u.leftColumn; |
| 97874 | pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); |
| 97875 | assert( pColl!=0 || pParse->nErr>0 ); |
| 97876 | pIdx->azColl[n] = pColl ? pColl->zName : "BINARY"; |
| 97877 | n++; |
| 97878 | } |
| 97879 | } |
| 97880 | } |
| 97881 | assert( (u32)n==pLevel->plan.nEq ); |
| 97882 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.6" |
| 654 | #define SQLITE_VERSION_NUMBER 3007006 |
| 655 | #define SQLITE_SOURCE_ID "2011-02-19 23:18:12 e87d499a4f8a456111c1f96ca6da31d0810fb7c8" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -43796,14 +43796,35 @@ | |
| 43796 | int i; /* Loop counter */ |
| 43797 | int rc = SQLITE_OK; /* Return code */ |
| 43798 | |
| 43799 | assert( pWal->readLock<0 ); /* Not currently locked */ |
| 43800 | |
| 43801 | /* Take steps to avoid spinning forever if there is a protocol error. |
| 43802 | ** |
| 43803 | ** Circumstances that cause a RETRY should only last for the briefest |
| 43804 | ** instances of time. No I/O or other system calls are done while the |
| 43805 | ** locks are held, so the locks should not be held for very long. But |
| 43806 | ** if we are unlucky, another process that is holding a lock might get |
| 43807 | ** paged out or take a page-fault that is time-consuming to resolve, |
| 43808 | ** during the few nanoseconds that it is holding the lock. In that case, |
| 43809 | ** it might take longer than normal for the lock to free. |
| 43810 | ** |
| 43811 | ** After 5 RETRYs, we begin calling sqlite3OsSleep(). The first few |
| 43812 | ** calls to sqlite3OsSleep() have a delay of 1 microsecond. Really this |
| 43813 | ** is more of a scheduler yield than an actual delay. But on the 10th |
| 43814 | ** an subsequent retries, the delays start becoming longer and longer, |
| 43815 | ** so that on the 100th (and last) RETRY we delay for 21 milliseconds. |
| 43816 | ** The total delay time before giving up is less than 1 second. |
| 43817 | */ |
| 43818 | if( cnt>5 ){ |
| 43819 | int nDelay = 1; /* Pause time in microseconds */ |
| 43820 | if( cnt>100 ){ |
| 43821 | VVA_ONLY( pWal->lockError = 1; ) |
| 43822 | return SQLITE_PROTOCOL; |
| 43823 | } |
| 43824 | if( cnt>=10 ) nDelay = (cnt-9)*238; /* Max delay 21ms. Total delay 996ms */ |
| 43825 | sqlite3OsSleep(pWal->pVfs, nDelay); |
| 43826 | } |
| 43827 | |
| 43828 | if( !useWal ){ |
| 43829 | rc = walIndexReadHdr(pWal, pChanged); |
| 43830 | if( rc==SQLITE_BUSY ){ |
| @@ -43881,26 +43902,13 @@ | |
| 43902 | assert( thisMark!=READMARK_NOT_USED ); |
| 43903 | mxReadMark = thisMark; |
| 43904 | mxI = i; |
| 43905 | } |
| 43906 | } |
| 43907 | /* There was once an "if" here. The extra "{" is to preserve indentation. */ |
| 43908 | { |
| 43909 | if( mxReadMark < pWal->hdr.mxFrame || mxI==0 ){ |
| 43910 | for(i=1; i<WAL_NREADER; i++){ |
| 43911 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 43912 | if( rc==SQLITE_OK ){ |
| 43913 | mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame; |
| 43914 | mxI = i; |
| @@ -43909,10 +43917,14 @@ | |
| 43917 | }else if( rc!=SQLITE_BUSY ){ |
| 43918 | return rc; |
| 43919 | } |
| 43920 | } |
| 43921 | } |
| 43922 | if( mxI==0 ){ |
| 43923 | assert( rc==SQLITE_BUSY ); |
| 43924 | return WAL_RETRY; |
| 43925 | } |
| 43926 | |
| 43927 | rc = walLockShared(pWal, WAL_READ_LOCK(mxI)); |
| 43928 | if( rc ){ |
| 43929 | return rc==SQLITE_BUSY ? WAL_RETRY : rc; |
| 43930 | } |
| @@ -43969,10 +43981,14 @@ | |
| 43981 | int cnt = 0; /* Number of TryBeginRead attempts */ |
| 43982 | |
| 43983 | do{ |
| 43984 | rc = walTryBeginRead(pWal, pChanged, 0, ++cnt); |
| 43985 | }while( rc==WAL_RETRY ); |
| 43986 | testcase( (rc&0xff)==SQLITE_BUSY ); |
| 43987 | testcase( (rc&0xff)==SQLITE_IOERR ); |
| 43988 | testcase( rc==SQLITE_PROTOCOL ); |
| 43989 | testcase( rc==SQLITE_OK ); |
| 43990 | return rc; |
| 43991 | } |
| 43992 | |
| 43993 | /* |
| 43994 | ** Finish with a read transaction. All this does is release the |
| @@ -44286,10 +44302,12 @@ | |
| 44302 | |
| 44303 | if( pWal->readLock==0 ){ |
| 44304 | volatile WalCkptInfo *pInfo = walCkptInfo(pWal); |
| 44305 | assert( pInfo->nBackfill==pWal->hdr.mxFrame ); |
| 44306 | if( pInfo->nBackfill>0 ){ |
| 44307 | u32 salt1; |
| 44308 | sqlite3_randomness(4, &salt1); |
| 44309 | rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| 44310 | if( rc==SQLITE_OK ){ |
| 44311 | /* If all readers are using WAL_READ_LOCK(0) (in other words if no |
| 44312 | ** readers are currently using the WAL), then the transactions |
| 44313 | ** frames will overwrite the start of the existing log. Update the |
| @@ -44303,11 +44321,11 @@ | |
| 44321 | int i; /* Loop counter */ |
| 44322 | u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */ |
| 44323 | pWal->nCkpt++; |
| 44324 | pWal->hdr.mxFrame = 0; |
| 44325 | sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0])); |
| 44326 | aSalt[1] = salt1; |
| 44327 | walIndexWriteHdr(pWal); |
| 44328 | pInfo->nBackfill = 0; |
| 44329 | for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED; |
| 44330 | assert( pInfo->aReadMark[0]==0 ); |
| 44331 | walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| @@ -44320,10 +44338,14 @@ | |
| 44338 | cnt = 0; |
| 44339 | do{ |
| 44340 | int notUsed; |
| 44341 | rc = walTryBeginRead(pWal, ¬Used, 1, ++cnt); |
| 44342 | }while( rc==WAL_RETRY ); |
| 44343 | assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */ |
| 44344 | testcase( (rc&0xff)==SQLITE_IOERR ); |
| 44345 | testcase( rc==SQLITE_PROTOCOL ); |
| 44346 | testcase( rc==SQLITE_OK ); |
| 44347 | } |
| 44348 | return rc; |
| 44349 | } |
| 44350 | |
| 44351 | /* |
| @@ -55589,10 +55611,11 @@ | |
| 55611 | pVal->r = (double)-1 * pVal->r; |
| 55612 | sqlite3ValueApplyAffinity(pVal, affinity, enc); |
| 55613 | } |
| 55614 | }else if( op==TK_NULL ){ |
| 55615 | pVal = sqlite3ValueNew(db); |
| 55616 | if( pVal==0 ) goto no_mem; |
| 55617 | } |
| 55618 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 55619 | else if( op==TK_BLOB ){ |
| 55620 | int nVal; |
| 55621 | assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' ); |
| @@ -70417,20 +70440,21 @@ | |
| 70440 | ** in *pValue. If the expression is not an integer or if it is too big |
| 70441 | ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. |
| 70442 | */ |
| 70443 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){ |
| 70444 | int rc = 0; |
| 70445 | |
| 70446 | /* If an expression is an integer literal that fits in a signed 32-bit |
| 70447 | ** integer, then the EP_IntValue flag will have already been set */ |
| 70448 | assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0 |
| 70449 | || sqlite3GetInt32(p->u.zToken, &rc)==0 ); |
| 70450 | |
| 70451 | if( p->flags & EP_IntValue ){ |
| 70452 | *pValue = p->u.iValue; |
| 70453 | return 1; |
| 70454 | } |
| 70455 | switch( p->op ){ |
| 70456 | case TK_UPLUS: { |
| 70457 | rc = sqlite3ExprIsInteger(p->pLeft, pValue); |
| 70458 | break; |
| 70459 | } |
| 70460 | case TK_UMINUS: { |
| @@ -97870,12 +97894,11 @@ | |
| 97894 | if( (idxCols & cMask)==0 ){ |
| 97895 | Expr *pX = pTerm->pExpr; |
| 97896 | idxCols |= cMask; |
| 97897 | pIdx->aiColumn[n] = pTerm->u.leftColumn; |
| 97898 | pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); |
| 97899 | pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : "BINARY"; |
| 97900 | n++; |
| 97901 | } |
| 97902 | } |
| 97903 | } |
| 97904 | assert( (u32)n==pLevel->plan.nEq ); |
| 97905 |
+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.6" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007006 |
| 112 | -#define SQLITE_SOURCE_ID "2011-02-16 23:32:24 31fc4ba66e76876b2e7b6b2b74c07f47571938ce" | |
| 112 | +#define SQLITE_SOURCE_ID "2011-02-19 23:18:12 e87d499a4f8a456111c1f96ca6da31d0810fb7c8" | |
| 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.6" |
| 111 | #define SQLITE_VERSION_NUMBER 3007006 |
| 112 | #define SQLITE_SOURCE_ID "2011-02-16 23:32:24 31fc4ba66e76876b2e7b6b2b74c07f47571938ce" |
| 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.6" |
| 111 | #define SQLITE_VERSION_NUMBER 3007006 |
| 112 | #define SQLITE_SOURCE_ID "2011-02-19 23:18:12 e87d499a4f8a456111c1f96ca6da31d0810fb7c8" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |