| | @@ -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.3" |
| 654 | 654 | #define SQLITE_VERSION_NUMBER 3007003 |
| 655 | | -#define SQLITE_SOURCE_ID "2010-10-04 23:55:51 ece641eb8951c6314cedbdb3243f91cb199c3239" |
| 655 | +#define SQLITE_SOURCE_ID "2010-10-07 13:29:13 e55ada89246d4cc5f476891c70572dc7c1c3643e" |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| | @@ -26956,16 +26956,26 @@ |
| 26956 | 26956 | |
| 26957 | 26957 | /* Parameter isDelete is only used on vxworks. Express this explicitly |
| 26958 | 26958 | ** here to prevent compiler warnings about unused parameters. |
| 26959 | 26959 | */ |
| 26960 | 26960 | UNUSED_PARAMETER(isDelete); |
| 26961 | + |
| 26962 | + /* Usually the path zFilename should not be a relative pathname. The |
| 26963 | + ** exception is when opening the proxy "conch" file in builds that |
| 26964 | + ** include the special Apple locking styles. |
| 26965 | + */ |
| 26966 | +#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE |
| 26967 | + assert( zFilename==0 || zFilename[0]=='/' |
| 26968 | + || pVfs->pAppData==(void*)&autolockIoFinder ); |
| 26969 | +#else |
| 26970 | + assert( zFilename==0 || zFilename[0]=='/' ); |
| 26971 | +#endif |
| 26961 | 26972 | |
| 26962 | 26973 | OSTRACE(("OPEN %-3d %s\n", h, zFilename)); |
| 26963 | 26974 | pNew->h = h; |
| 26964 | 26975 | pNew->dirfd = dirfd; |
| 26965 | 26976 | pNew->fileFlags = 0; |
| 26966 | | - assert( zFilename==0 || zFilename[0]=='/' ); /* Never a relative pathname */ |
| 26967 | 26977 | pNew->zPath = zFilename; |
| 26968 | 26978 | |
| 26969 | 26979 | #if OS_VXWORKS |
| 26970 | 26980 | pNew->pId = vxworksFindFileId(zFilename); |
| 26971 | 26981 | if( pNew->pId==0 ){ |
| | @@ -39764,34 +39774,34 @@ |
| 39764 | 39774 | /* Higher-level routines never call this function if database is not |
| 39765 | 39775 | ** writable. But check anyway, just for robustness. */ |
| 39766 | 39776 | if( NEVER(pPager->readOnly) ) return SQLITE_PERM; |
| 39767 | 39777 | |
| 39768 | 39778 | CHECK_PAGE(pPg); |
| 39779 | + |
| 39780 | + /* The journal file needs to be opened. Higher level routines have already |
| 39781 | + ** obtained the necessary locks to begin the write-transaction, but the |
| 39782 | + ** rollback journal might not yet be open. Open it now if this is the case. |
| 39783 | + ** |
| 39784 | + ** This is done before calling sqlite3PcacheMakeDirty() on the page. |
| 39785 | + ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then |
| 39786 | + ** an error might occur and the pager would end up in WRITER_LOCKED state |
| 39787 | + ** with pages marked as dirty in the cache. |
| 39788 | + */ |
| 39789 | + if( pPager->eState==PAGER_WRITER_LOCKED ){ |
| 39790 | + rc = pager_open_journal(pPager); |
| 39791 | + if( rc!=SQLITE_OK ) return rc; |
| 39792 | + } |
| 39793 | + assert( pPager->eState>=PAGER_WRITER_CACHEMOD ); |
| 39794 | + assert( assert_pager_state(pPager) ); |
| 39769 | 39795 | |
| 39770 | 39796 | /* Mark the page as dirty. If the page has already been written |
| 39771 | 39797 | ** to the journal then we can return right away. |
| 39772 | 39798 | */ |
| 39773 | 39799 | sqlite3PcacheMakeDirty(pPg); |
| 39774 | 39800 | if( pageInJournal(pPg) && !subjRequiresPage(pPg) ){ |
| 39775 | 39801 | assert( !pagerUseWal(pPager) ); |
| 39776 | | - assert( pPager->eState>=PAGER_WRITER_CACHEMOD ); |
| 39777 | 39802 | }else{ |
| 39778 | | - |
| 39779 | | - /* If we get this far, it means that the page needs to be |
| 39780 | | - ** written to the transaction journal or the checkpoint journal |
| 39781 | | - ** or both. |
| 39782 | | - ** |
| 39783 | | - ** Higher level routines have already obtained the necessary locks |
| 39784 | | - ** to begin the write-transaction, but the rollback journal might not |
| 39785 | | - ** yet be open. Open it now if this is the case. |
| 39786 | | - */ |
| 39787 | | - if( pPager->eState==PAGER_WRITER_LOCKED ){ |
| 39788 | | - rc = pager_open_journal(pPager); |
| 39789 | | - if( rc!=SQLITE_OK ) return rc; |
| 39790 | | - } |
| 39791 | | - assert( pPager->eState>=PAGER_WRITER_CACHEMOD ); |
| 39792 | | - assert( assert_pager_state(pPager) ); |
| 39793 | 39803 | |
| 39794 | 39804 | /* The transaction journal now exists and we have a RESERVED or an |
| 39795 | 39805 | ** EXCLUSIVE lock on the main database file. Write the current page to |
| 39796 | 39806 | ** the transaction journal if it is not there already. |
| 39797 | 39807 | */ |
| | @@ -43589,11 +43599,11 @@ |
| 43589 | 43599 | ** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left |
| 43590 | 43600 | ** unchanged. |
| 43591 | 43601 | ** |
| 43592 | 43602 | ** SQLITE_OK is returned if no error is encountered (regardless of whether |
| 43593 | 43603 | ** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned |
| 43594 | | -** if some error |
| 43604 | +** if an error occurs. |
| 43595 | 43605 | */ |
| 43596 | 43606 | static int walRestartLog(Wal *pWal){ |
| 43597 | 43607 | int rc = SQLITE_OK; |
| 43598 | 43608 | int cnt; |
| 43599 | 43609 | |
| | @@ -43622,10 +43632,12 @@ |
| 43622 | 43632 | walIndexWriteHdr(pWal); |
| 43623 | 43633 | pInfo->nBackfill = 0; |
| 43624 | 43634 | for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED; |
| 43625 | 43635 | assert( pInfo->aReadMark[0]==0 ); |
| 43626 | 43636 | walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| 43637 | + }else if( rc!=SQLITE_BUSY ){ |
| 43638 | + return rc; |
| 43627 | 43639 | } |
| 43628 | 43640 | } |
| 43629 | 43641 | walUnlockShared(pWal, WAL_READ_LOCK(0)); |
| 43630 | 43642 | pWal->readLock = -1; |
| 43631 | 43643 | cnt = 0; |
| | @@ -54130,18 +54142,11 @@ |
| 54130 | 54142 | }else if( pMem->flags & MEM_Int ){ |
| 54131 | 54143 | return (double)pMem->u.i; |
| 54132 | 54144 | }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ |
| 54133 | 54145 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54134 | 54146 | double val = (double)0; |
| 54135 | | - pMem->flags |= MEM_Str; |
| 54136 | | - if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8) |
| 54137 | | - || sqlite3VdbeMemNulTerminate(pMem) ){ |
| 54138 | | - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54139 | | - return (double)0; |
| 54140 | | - } |
| 54141 | | - assert( pMem->z ); |
| 54142 | | - sqlite3AtoF(pMem->z, &val, pMem->n, SQLITE_UTF8); |
| 54147 | + sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc); |
| 54143 | 54148 | return val; |
| 54144 | 54149 | }else{ |
| 54145 | 54150 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54146 | 54151 | return (double)0; |
| 54147 | 54152 | } |
| | @@ -87647,11 +87652,10 @@ |
| 87647 | 87652 | addr2 = sqlite3VdbeAddOp0(v, OP_Goto); |
| 87648 | 87653 | sqlite3VdbeJumpHere(v, addr1); |
| 87649 | 87654 | sqlite3VdbeAddOp1(v, OP_Last, pOrderBy->iECursor); |
| 87650 | 87655 | sqlite3VdbeAddOp1(v, OP_Delete, pOrderBy->iECursor); |
| 87651 | 87656 | sqlite3VdbeJumpHere(v, addr2); |
| 87652 | | - pSelect->iLimit = 0; |
| 87653 | 87657 | } |
| 87654 | 87658 | } |
| 87655 | 87659 | |
| 87656 | 87660 | /* |
| 87657 | 87661 | ** Add code to implement the OFFSET |
| | @@ -87926,15 +87930,15 @@ |
| 87926 | 87930 | break; |
| 87927 | 87931 | } |
| 87928 | 87932 | #endif |
| 87929 | 87933 | } |
| 87930 | 87934 | |
| 87931 | | - /* Jump to the end of the loop if the LIMIT is reached. |
| 87935 | + /* Jump to the end of the loop if the LIMIT is reached. Except, if |
| 87936 | + ** there is a sorter, in which case the sorter has already limited |
| 87937 | + ** the output for us. |
| 87932 | 87938 | */ |
| 87933 | | - if( p->iLimit ){ |
| 87934 | | - assert( pOrderBy==0 ); /* If there is an ORDER BY, the call to |
| 87935 | | - ** pushOntoSorter() would have cleared p->iLimit */ |
| 87939 | + if( pOrderBy==0 && p->iLimit ){ |
| 87936 | 87940 | sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); |
| 87937 | 87941 | } |
| 87938 | 87942 | } |
| 87939 | 87943 | |
| 87940 | 87944 | /* |
| | @@ -88065,14 +88069,10 @@ |
| 88065 | 88069 | } |
| 88066 | 88070 | } |
| 88067 | 88071 | sqlite3ReleaseTempReg(pParse, regRow); |
| 88068 | 88072 | sqlite3ReleaseTempReg(pParse, regRowid); |
| 88069 | 88073 | |
| 88070 | | - /* LIMIT has been implemented by the pushOntoSorter() routine. |
| 88071 | | - */ |
| 88072 | | - assert( p->iLimit==0 ); |
| 88073 | | - |
| 88074 | 88074 | /* The bottom of the loop |
| 88075 | 88075 | */ |
| 88076 | 88076 | sqlite3VdbeResolveLabel(v, addrContinue); |
| 88077 | 88077 | sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); |
| 88078 | 88078 | sqlite3VdbeResolveLabel(v, addrBreak); |
| | @@ -89386,11 +89386,10 @@ |
| 89386 | 89386 | } |
| 89387 | 89387 | |
| 89388 | 89388 | /* Separate the left and the right query from one another |
| 89389 | 89389 | */ |
| 89390 | 89390 | p->pPrior = 0; |
| 89391 | | - pPrior->pRightmost = 0; |
| 89392 | 89391 | sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, "ORDER"); |
| 89393 | 89392 | if( pPrior->pPrior==0 ){ |
| 89394 | 89393 | sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER"); |
| 89395 | 89394 | } |
| 89396 | 89395 | |
| 89397 | 89396 | |