Fossil SCM
Update to the latest SQLite containing storage engine performance enhancements.
Commit
3957e9610f806e5a0b3a75d6967da044454e627b
Parent
9f58fc6528a4019…
2 files changed
+92
-120
+1
-1
+92
-120
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -135,11 +135,11 @@ | ||
| 135 | 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | 137 | */ |
| 138 | 138 | #define SQLITE_VERSION "3.8.2" |
| 139 | 139 | #define SQLITE_VERSION_NUMBER 3008002 |
| 140 | -#define SQLITE_SOURCE_ID "2013-11-21 23:37:02 3d47a556f0074e39b880186fb7661b1b8955f742" | |
| 140 | +#define SQLITE_SOURCE_ID "2013-11-25 20:50:23 032e89934f36de10652d3454a0065a337827221a" | |
| 141 | 141 | |
| 142 | 142 | /* |
| 143 | 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | 145 | ** |
| @@ -17497,29 +17497,10 @@ | ||
| 17497 | 17497 | iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE)); |
| 17498 | 17498 | } |
| 17499 | 17499 | return iSize; |
| 17500 | 17500 | } |
| 17501 | 17501 | |
| 17502 | -/* | |
| 17503 | -** Find the first entry on the freelist iLogsize. Unlink that | |
| 17504 | -** entry and return its index. | |
| 17505 | -*/ | |
| 17506 | -static int memsys5UnlinkFirst(int iLogsize){ | |
| 17507 | - int i; | |
| 17508 | - int iFirst; | |
| 17509 | - | |
| 17510 | - assert( iLogsize>=0 && iLogsize<=LOGMAX ); | |
| 17511 | - i = iFirst = mem5.aiFreelist[iLogsize]; | |
| 17512 | - assert( iFirst>=0 ); | |
| 17513 | - while( i>0 ){ | |
| 17514 | - if( i<iFirst ) iFirst = i; | |
| 17515 | - i = MEM5LINK(i)->next; | |
| 17516 | - } | |
| 17517 | - memsys5Unlink(iFirst, iLogsize); | |
| 17518 | - return iFirst; | |
| 17519 | -} | |
| 17520 | - | |
| 17521 | 17502 | /* |
| 17522 | 17503 | ** Return a block of memory of at least nBytes in size. |
| 17523 | 17504 | ** Return NULL if unable. Return NULL if nBytes==0. |
| 17524 | 17505 | ** |
| 17525 | 17506 | ** The caller guarantees that nByte is positive. |
| @@ -17561,11 +17542,12 @@ | ||
| 17561 | 17542 | if( iBin>LOGMAX ){ |
| 17562 | 17543 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 17563 | 17544 | sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte); |
| 17564 | 17545 | return 0; |
| 17565 | 17546 | } |
| 17566 | - i = memsys5UnlinkFirst(iBin); | |
| 17547 | + i = mem5.aiFreelist[iBin]; | |
| 17548 | + memsys5Unlink(i, iBin); | |
| 17567 | 17549 | while( iBin>iLogsize ){ |
| 17568 | 17550 | int newSize; |
| 17569 | 17551 | |
| 17570 | 17552 | iBin--; |
| 17571 | 17553 | newSize = 1 << iBin; |
| @@ -35013,11 +34995,11 @@ | ||
| 35013 | 34995 | ** |
| 35014 | 34996 | ** This division contains the implementation of methods on the |
| 35015 | 34997 | ** sqlite3_vfs object. |
| 35016 | 34998 | */ |
| 35017 | 34999 | |
| 35018 | -#if defined(__CYGWIN__) | |
| 35000 | +#if 0 | |
| 35019 | 35001 | /* |
| 35020 | 35002 | ** Convert a filename from whatever the underlying operating system |
| 35021 | 35003 | ** supports for filenames into UTF-8. Space to hold the result is |
| 35022 | 35004 | ** obtained from malloc and must be freed by the calling function. |
| 35023 | 35005 | */ |
| @@ -35189,21 +35171,27 @@ | ||
| 35189 | 35171 | if( winIsDir(zConverted) ){ |
| 35190 | 35172 | /* At this point, we know the candidate directory exists and should |
| 35191 | 35173 | ** be used. However, we may need to convert the string containing |
| 35192 | 35174 | ** its name into UTF-8 (i.e. if it is UTF-16 right now). |
| 35193 | 35175 | */ |
| 35194 | - char *zUtf8 = winConvertToUtf8Filename(zConverted); | |
| 35195 | - if( !zUtf8 ){ | |
| 35196 | - sqlite3_free(zConverted); | |
| 35197 | - sqlite3_free(zBuf); | |
| 35198 | - OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); | |
| 35199 | - return SQLITE_IOERR_NOMEM; | |
| 35200 | - } | |
| 35201 | - sqlite3_snprintf(nMax, zBuf, "%s", zUtf8); | |
| 35202 | - sqlite3_free(zUtf8); | |
| 35203 | - sqlite3_free(zConverted); | |
| 35204 | - break; | |
| 35176 | + if( osIsNT() ){ | |
| 35177 | + char *zUtf8 = winUnicodeToUtf8(zConverted); | |
| 35178 | + if( !zUtf8 ){ | |
| 35179 | + sqlite3_free(zConverted); | |
| 35180 | + sqlite3_free(zBuf); | |
| 35181 | + OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); | |
| 35182 | + return SQLITE_IOERR_NOMEM; | |
| 35183 | + } | |
| 35184 | + sqlite3_snprintf(nMax, zBuf, "%s", zUtf8); | |
| 35185 | + sqlite3_free(zUtf8); | |
| 35186 | + sqlite3_free(zConverted); | |
| 35187 | + break; | |
| 35188 | + }else{ | |
| 35189 | + sqlite3_snprintf(nMax, zBuf, "%s", zConverted); | |
| 35190 | + sqlite3_free(zConverted); | |
| 35191 | + break; | |
| 35192 | + } | |
| 35205 | 35193 | } |
| 35206 | 35194 | sqlite3_free(zConverted); |
| 35207 | 35195 | } |
| 35208 | 35196 | } |
| 35209 | 35197 | } |
| @@ -35884,47 +35872,23 @@ | ||
| 35884 | 35872 | */ |
| 35885 | 35873 | char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 ); |
| 35886 | 35874 | if( !zOut ){ |
| 35887 | 35875 | return SQLITE_IOERR_NOMEM; |
| 35888 | 35876 | } |
| 35889 | - if( cygwin_conv_path( | |
| 35890 | - (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) | | |
| 35891 | - CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){ | |
| 35877 | + if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, | |
| 35878 | + pVfs->mxPathname+1)<0 ){ | |
| 35892 | 35879 | sqlite3_free(zOut); |
| 35893 | 35880 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35894 | 35881 | "winFullPathname1", zRelative); |
| 35895 | - }else{ | |
| 35896 | - char *zUtf8 = winConvertToUtf8Filename(zOut); | |
| 35897 | - if( !zUtf8 ){ | |
| 35898 | - sqlite3_free(zOut); | |
| 35899 | - return SQLITE_IOERR_NOMEM; | |
| 35900 | - } | |
| 35901 | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", | |
| 35902 | - sqlite3_data_directory, winGetDirSep(), zUtf8); | |
| 35903 | - sqlite3_free(zUtf8); | |
| 35904 | - sqlite3_free(zOut); | |
| 35905 | - } | |
| 35906 | - }else{ | |
| 35907 | - char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 ); | |
| 35908 | - if( !zOut ){ | |
| 35909 | - return SQLITE_IOERR_NOMEM; | |
| 35910 | - } | |
| 35911 | - if( cygwin_conv_path( | |
| 35912 | - (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A), | |
| 35913 | - zRelative, zOut, pVfs->mxPathname+1)<0 ){ | |
| 35914 | - sqlite3_free(zOut); | |
| 35882 | + } | |
| 35883 | + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", | |
| 35884 | + sqlite3_data_directory, winGetDirSep(), zOut); | |
| 35885 | + sqlite3_free(zOut); | |
| 35886 | + }else{ | |
| 35887 | + if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ | |
| 35915 | 35888 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35916 | 35889 | "winFullPathname2", zRelative); |
| 35917 | - }else{ | |
| 35918 | - char *zUtf8 = winConvertToUtf8Filename(zOut); | |
| 35919 | - if( !zUtf8 ){ | |
| 35920 | - sqlite3_free(zOut); | |
| 35921 | - return SQLITE_IOERR_NOMEM; | |
| 35922 | - } | |
| 35923 | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zUtf8); | |
| 35924 | - sqlite3_free(zUtf8); | |
| 35925 | - sqlite3_free(zOut); | |
| 35926 | 35890 | } |
| 35927 | 35891 | } |
| 35928 | 35892 | return SQLITE_OK; |
| 35929 | 35893 | #endif |
| 35930 | 35894 | |
| @@ -54942,14 +54906,14 @@ | ||
| 54942 | 54906 | assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 ); |
| 54943 | 54907 | return SQLITE_OK; |
| 54944 | 54908 | } |
| 54945 | 54909 | assert( pCur->apPage[0]->intKey || pIdxKey ); |
| 54946 | 54910 | for(;;){ |
| 54947 | - int lwr, upr, idx; | |
| 54911 | + int lwr, upr, idx, c; | |
| 54948 | 54912 | Pgno chldPg; |
| 54949 | 54913 | MemPage *pPage = pCur->apPage[pCur->iPage]; |
| 54950 | - int c; | |
| 54914 | + u8 *pCell; /* Pointer to current cell in pPage */ | |
| 54951 | 54915 | |
| 54952 | 54916 | /* pPage->nCell must be greater than zero. If this is the root-page |
| 54953 | 54917 | ** the cursor would have been INVALID above and this for(;;) loop |
| 54954 | 54918 | ** not run. If this is not the root-page, then the moveToChild() routine |
| 54955 | 54919 | ** would have already detected db corruption. Similarly, pPage must |
| @@ -54957,48 +54921,60 @@ | ||
| 54957 | 54921 | ** a moveToChild() or moveToRoot() call would have detected corruption. */ |
| 54958 | 54922 | assert( pPage->nCell>0 ); |
| 54959 | 54923 | assert( pPage->intKey==(pIdxKey==0) ); |
| 54960 | 54924 | lwr = 0; |
| 54961 | 54925 | upr = pPage->nCell-1; |
| 54962 | - if( biasRight ){ | |
| 54963 | - pCur->aiIdx[pCur->iPage] = (u16)(idx = upr); | |
| 54964 | - }else{ | |
| 54965 | - pCur->aiIdx[pCur->iPage] = (u16)(idx = (upr+lwr)/2); | |
| 54966 | - } | |
| 54967 | - for(;;){ | |
| 54968 | - u8 *pCell; /* Pointer to current cell in pPage */ | |
| 54969 | - | |
| 54970 | - assert( idx==pCur->aiIdx[pCur->iPage] ); | |
| 54971 | - pCur->info.nSize = 0; | |
| 54972 | - pCell = findCell(pPage, idx) + pPage->childPtrSize; | |
| 54973 | - if( pPage->intKey ){ | |
| 54926 | + assert( biasRight==0 || biasRight==1 ); | |
| 54927 | + idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */ | |
| 54928 | + pCur->aiIdx[pCur->iPage] = (u16)idx; | |
| 54929 | + if( pPage->intKey ){ | |
| 54930 | + for(;;){ | |
| 54974 | 54931 | i64 nCellKey; |
| 54932 | + pCell = findCell(pPage, idx) + pPage->childPtrSize; | |
| 54975 | 54933 | if( pPage->hasData ){ |
| 54976 | - u32 dummy; | |
| 54977 | - pCell += getVarint32(pCell, dummy); | |
| 54934 | + while( 0x80 <= *(pCell++) ){ | |
| 54935 | + if( pCell>=pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT; | |
| 54936 | + } | |
| 54978 | 54937 | } |
| 54979 | 54938 | getVarint(pCell, (u64*)&nCellKey); |
| 54980 | - if( nCellKey==intKey ){ | |
| 54981 | - c = 0; | |
| 54982 | - }else if( nCellKey<intKey ){ | |
| 54983 | - c = -1; | |
| 54984 | - }else{ | |
| 54985 | - assert( nCellKey>intKey ); | |
| 54986 | - c = +1; | |
| 54987 | - } | |
| 54988 | - pCur->validNKey = 1; | |
| 54989 | - pCur->info.nKey = nCellKey; | |
| 54990 | - }else{ | |
| 54939 | + if( nCellKey<intKey ){ | |
| 54940 | + lwr = idx+1; | |
| 54941 | + if( lwr>upr ){ c = -1; break; } | |
| 54942 | + }else if( nCellKey>intKey ){ | |
| 54943 | + upr = idx-1; | |
| 54944 | + if( lwr>upr ){ c = +1; break; } | |
| 54945 | + }else{ | |
| 54946 | + assert( nCellKey==intKey ); | |
| 54947 | + pCur->validNKey = 1; | |
| 54948 | + pCur->info.nKey = nCellKey; | |
| 54949 | + pCur->aiIdx[pCur->iPage] = (u16)idx; | |
| 54950 | + if( !pPage->leaf ){ | |
| 54951 | + lwr = idx; | |
| 54952 | + goto moveto_next_layer; | |
| 54953 | + }else{ | |
| 54954 | + *pRes = 0; | |
| 54955 | + rc = SQLITE_OK; | |
| 54956 | + goto moveto_finish; | |
| 54957 | + } | |
| 54958 | + } | |
| 54959 | + assert( lwr+upr>=0 ); | |
| 54960 | + idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */ | |
| 54961 | + } | |
| 54962 | + }else{ | |
| 54963 | + for(;;){ | |
| 54964 | + int nCell; | |
| 54965 | + pCell = findCell(pPage, idx) + pPage->childPtrSize; | |
| 54966 | + | |
| 54991 | 54967 | /* The maximum supported page-size is 65536 bytes. This means that |
| 54992 | 54968 | ** the maximum number of record bytes stored on an index B-Tree |
| 54993 | 54969 | ** page is less than 16384 bytes and may be stored as a 2-byte |
| 54994 | 54970 | ** varint. This information is used to attempt to avoid parsing |
| 54995 | 54971 | ** the entire cell by checking for the cases where the record is |
| 54996 | 54972 | ** stored entirely within the b-tree page by inspecting the first |
| 54997 | 54973 | ** 2 bytes of the cell. |
| 54998 | 54974 | */ |
| 54999 | - int nCell = pCell[0]; | |
| 54975 | + nCell = pCell[0]; | |
| 55000 | 54976 | if( nCell<=pPage->max1bytePayload |
| 55001 | 54977 | /* && (pCell+nCell)<pPage->aDataEnd */ |
| 55002 | 54978 | ){ |
| 55003 | 54979 | /* This branch runs if the record-size field of the cell is a |
| 55004 | 54980 | ** single byte varint and the record fits entirely on the main |
| @@ -55025,61 +55001,57 @@ | ||
| 55025 | 55001 | pCellKey = sqlite3Malloc( nCell ); |
| 55026 | 55002 | if( pCellKey==0 ){ |
| 55027 | 55003 | rc = SQLITE_NOMEM; |
| 55028 | 55004 | goto moveto_finish; |
| 55029 | 55005 | } |
| 55006 | + pCur->aiIdx[pCur->iPage] = (u16)idx; | |
| 55030 | 55007 | rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0); |
| 55031 | 55008 | if( rc ){ |
| 55032 | 55009 | sqlite3_free(pCellKey); |
| 55033 | 55010 | goto moveto_finish; |
| 55034 | 55011 | } |
| 55035 | 55012 | c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); |
| 55036 | 55013 | sqlite3_free(pCellKey); |
| 55037 | 55014 | } |
| 55038 | - } | |
| 55039 | - if( c==0 ){ | |
| 55040 | - if( pPage->intKey && !pPage->leaf ){ | |
| 55041 | - lwr = idx; | |
| 55042 | - break; | |
| 55015 | + if( c<0 ){ | |
| 55016 | + lwr = idx+1; | |
| 55017 | + }else if( c>0 ){ | |
| 55018 | + upr = idx-1; | |
| 55043 | 55019 | }else{ |
| 55020 | + assert( c==0 ); | |
| 55044 | 55021 | *pRes = 0; |
| 55045 | 55022 | rc = SQLITE_OK; |
| 55023 | + pCur->aiIdx[pCur->iPage] = (u16)idx; | |
| 55046 | 55024 | goto moveto_finish; |
| 55047 | 55025 | } |
| 55048 | - } | |
| 55049 | - if( c<0 ){ | |
| 55050 | - lwr = idx+1; | |
| 55051 | - }else{ | |
| 55052 | - upr = idx-1; | |
| 55053 | - } | |
| 55054 | - if( lwr>upr ){ | |
| 55055 | - break; | |
| 55056 | - } | |
| 55057 | - pCur->aiIdx[pCur->iPage] = (u16)(idx = (lwr+upr)/2); | |
| 55026 | + if( lwr>upr ) break; | |
| 55027 | + assert( lwr+upr>=0 ); | |
| 55028 | + idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */ | |
| 55029 | + } | |
| 55058 | 55030 | } |
| 55059 | 55031 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); |
| 55060 | 55032 | assert( pPage->isInit ); |
| 55061 | 55033 | if( pPage->leaf ){ |
| 55062 | - chldPg = 0; | |
| 55063 | - }else if( lwr>=pPage->nCell ){ | |
| 55064 | - chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); | |
| 55065 | - }else{ | |
| 55066 | - chldPg = get4byte(findCell(pPage, lwr)); | |
| 55067 | - } | |
| 55068 | - if( chldPg==0 ){ | |
| 55069 | 55034 | assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 55035 | + pCur->aiIdx[pCur->iPage] = (u16)idx; | |
| 55070 | 55036 | *pRes = c; |
| 55071 | 55037 | rc = SQLITE_OK; |
| 55072 | 55038 | goto moveto_finish; |
| 55073 | 55039 | } |
| 55040 | +moveto_next_layer: | |
| 55041 | + if( lwr>=pPage->nCell ){ | |
| 55042 | + chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); | |
| 55043 | + }else{ | |
| 55044 | + chldPg = get4byte(findCell(pPage, lwr)); | |
| 55045 | + } | |
| 55074 | 55046 | pCur->aiIdx[pCur->iPage] = (u16)lwr; |
| 55075 | - pCur->info.nSize = 0; | |
| 55076 | - pCur->validNKey = 0; | |
| 55077 | 55047 | rc = moveToChild(pCur, chldPg); |
| 55078 | - if( rc ) goto moveto_finish; | |
| 55048 | + if( rc ) break; | |
| 55079 | 55049 | } |
| 55080 | 55050 | moveto_finish: |
| 55051 | + pCur->info.nSize = 0; | |
| 55052 | + pCur->validNKey = 0; | |
| 55081 | 55053 | return rc; |
| 55082 | 55054 | } |
| 55083 | 55055 | |
| 55084 | 55056 | |
| 55085 | 55057 | /* |
| @@ -70643,11 +70615,11 @@ | ||
| 70643 | 70615 | u.bi.nZero = 0; |
| 70644 | 70616 | } |
| 70645 | 70617 | sqlite3BtreeSetCachedRowid(u.bi.pC->pCursor, 0); |
| 70646 | 70618 | rc = sqlite3BtreeInsert(u.bi.pC->pCursor, 0, u.bi.iKey, |
| 70647 | 70619 | u.bi.pData->z, u.bi.pData->n, u.bi.nZero, |
| 70648 | - pOp->p5 & OPFLAG_APPEND, u.bi.seekResult | |
| 70620 | + (pOp->p5 & OPFLAG_APPEND)!=0, u.bi.seekResult | |
| 70649 | 70621 | ); |
| 70650 | 70622 | u.bi.pC->rowidIsValid = 0; |
| 70651 | 70623 | u.bi.pC->deferredMoveto = 0; |
| 70652 | 70624 | u.bi.pC->cacheStatus = CACHE_STALE; |
| 70653 | 70625 | |
| @@ -89144,11 +89116,11 @@ | ||
| 89144 | 89116 | int rcauth; /* Value returned by authorization callback */ |
| 89145 | 89117 | int okOnePass; /* True for one-pass algorithm without the FIFO */ |
| 89146 | 89118 | int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */ |
| 89147 | 89119 | u8 *aToOpen = 0; /* Open cursor iTabCur+j if aToOpen[j] is true */ |
| 89148 | 89120 | Index *pPk; /* The PRIMARY KEY index on the table */ |
| 89149 | - int iPk; /* First of nPk registers holding PRIMARY KEY value */ | |
| 89121 | + int iPk = 0; /* First of nPk registers holding PRIMARY KEY value */ | |
| 89150 | 89122 | i16 nPk = 1; /* Number of columns in the PRIMARY KEY */ |
| 89151 | 89123 | int iKey; /* Memory cell holding key of row to be deleted */ |
| 89152 | 89124 | i16 nKey; /* Number of memory cells in the row key */ |
| 89153 | 89125 | int iEphCur = 0; /* Ephemeral table holding all primary key values */ |
| 89154 | 89126 | int iRowSet = 0; /* Register for rowset of rows to delete */ |
| 89155 | 89127 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | */ |
| 138 | #define SQLITE_VERSION "3.8.2" |
| 139 | #define SQLITE_VERSION_NUMBER 3008002 |
| 140 | #define SQLITE_SOURCE_ID "2013-11-21 23:37:02 3d47a556f0074e39b880186fb7661b1b8955f742" |
| 141 | |
| 142 | /* |
| 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | ** |
| @@ -17497,29 +17497,10 @@ | |
| 17497 | iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE)); |
| 17498 | } |
| 17499 | return iSize; |
| 17500 | } |
| 17501 | |
| 17502 | /* |
| 17503 | ** Find the first entry on the freelist iLogsize. Unlink that |
| 17504 | ** entry and return its index. |
| 17505 | */ |
| 17506 | static int memsys5UnlinkFirst(int iLogsize){ |
| 17507 | int i; |
| 17508 | int iFirst; |
| 17509 | |
| 17510 | assert( iLogsize>=0 && iLogsize<=LOGMAX ); |
| 17511 | i = iFirst = mem5.aiFreelist[iLogsize]; |
| 17512 | assert( iFirst>=0 ); |
| 17513 | while( i>0 ){ |
| 17514 | if( i<iFirst ) iFirst = i; |
| 17515 | i = MEM5LINK(i)->next; |
| 17516 | } |
| 17517 | memsys5Unlink(iFirst, iLogsize); |
| 17518 | return iFirst; |
| 17519 | } |
| 17520 | |
| 17521 | /* |
| 17522 | ** Return a block of memory of at least nBytes in size. |
| 17523 | ** Return NULL if unable. Return NULL if nBytes==0. |
| 17524 | ** |
| 17525 | ** The caller guarantees that nByte is positive. |
| @@ -17561,11 +17542,12 @@ | |
| 17561 | if( iBin>LOGMAX ){ |
| 17562 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 17563 | sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte); |
| 17564 | return 0; |
| 17565 | } |
| 17566 | i = memsys5UnlinkFirst(iBin); |
| 17567 | while( iBin>iLogsize ){ |
| 17568 | int newSize; |
| 17569 | |
| 17570 | iBin--; |
| 17571 | newSize = 1 << iBin; |
| @@ -35013,11 +34995,11 @@ | |
| 35013 | ** |
| 35014 | ** This division contains the implementation of methods on the |
| 35015 | ** sqlite3_vfs object. |
| 35016 | */ |
| 35017 | |
| 35018 | #if defined(__CYGWIN__) |
| 35019 | /* |
| 35020 | ** Convert a filename from whatever the underlying operating system |
| 35021 | ** supports for filenames into UTF-8. Space to hold the result is |
| 35022 | ** obtained from malloc and must be freed by the calling function. |
| 35023 | */ |
| @@ -35189,21 +35171,27 @@ | |
| 35189 | if( winIsDir(zConverted) ){ |
| 35190 | /* At this point, we know the candidate directory exists and should |
| 35191 | ** be used. However, we may need to convert the string containing |
| 35192 | ** its name into UTF-8 (i.e. if it is UTF-16 right now). |
| 35193 | */ |
| 35194 | char *zUtf8 = winConvertToUtf8Filename(zConverted); |
| 35195 | if( !zUtf8 ){ |
| 35196 | sqlite3_free(zConverted); |
| 35197 | sqlite3_free(zBuf); |
| 35198 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 35199 | return SQLITE_IOERR_NOMEM; |
| 35200 | } |
| 35201 | sqlite3_snprintf(nMax, zBuf, "%s", zUtf8); |
| 35202 | sqlite3_free(zUtf8); |
| 35203 | sqlite3_free(zConverted); |
| 35204 | break; |
| 35205 | } |
| 35206 | sqlite3_free(zConverted); |
| 35207 | } |
| 35208 | } |
| 35209 | } |
| @@ -35884,47 +35872,23 @@ | |
| 35884 | */ |
| 35885 | char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 ); |
| 35886 | if( !zOut ){ |
| 35887 | return SQLITE_IOERR_NOMEM; |
| 35888 | } |
| 35889 | if( cygwin_conv_path( |
| 35890 | (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) | |
| 35891 | CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){ |
| 35892 | sqlite3_free(zOut); |
| 35893 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35894 | "winFullPathname1", zRelative); |
| 35895 | }else{ |
| 35896 | char *zUtf8 = winConvertToUtf8Filename(zOut); |
| 35897 | if( !zUtf8 ){ |
| 35898 | sqlite3_free(zOut); |
| 35899 | return SQLITE_IOERR_NOMEM; |
| 35900 | } |
| 35901 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35902 | sqlite3_data_directory, winGetDirSep(), zUtf8); |
| 35903 | sqlite3_free(zUtf8); |
| 35904 | sqlite3_free(zOut); |
| 35905 | } |
| 35906 | }else{ |
| 35907 | char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 ); |
| 35908 | if( !zOut ){ |
| 35909 | return SQLITE_IOERR_NOMEM; |
| 35910 | } |
| 35911 | if( cygwin_conv_path( |
| 35912 | (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A), |
| 35913 | zRelative, zOut, pVfs->mxPathname+1)<0 ){ |
| 35914 | sqlite3_free(zOut); |
| 35915 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35916 | "winFullPathname2", zRelative); |
| 35917 | }else{ |
| 35918 | char *zUtf8 = winConvertToUtf8Filename(zOut); |
| 35919 | if( !zUtf8 ){ |
| 35920 | sqlite3_free(zOut); |
| 35921 | return SQLITE_IOERR_NOMEM; |
| 35922 | } |
| 35923 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zUtf8); |
| 35924 | sqlite3_free(zUtf8); |
| 35925 | sqlite3_free(zOut); |
| 35926 | } |
| 35927 | } |
| 35928 | return SQLITE_OK; |
| 35929 | #endif |
| 35930 | |
| @@ -54942,14 +54906,14 @@ | |
| 54942 | assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 ); |
| 54943 | return SQLITE_OK; |
| 54944 | } |
| 54945 | assert( pCur->apPage[0]->intKey || pIdxKey ); |
| 54946 | for(;;){ |
| 54947 | int lwr, upr, idx; |
| 54948 | Pgno chldPg; |
| 54949 | MemPage *pPage = pCur->apPage[pCur->iPage]; |
| 54950 | int c; |
| 54951 | |
| 54952 | /* pPage->nCell must be greater than zero. If this is the root-page |
| 54953 | ** the cursor would have been INVALID above and this for(;;) loop |
| 54954 | ** not run. If this is not the root-page, then the moveToChild() routine |
| 54955 | ** would have already detected db corruption. Similarly, pPage must |
| @@ -54957,48 +54921,60 @@ | |
| 54957 | ** a moveToChild() or moveToRoot() call would have detected corruption. */ |
| 54958 | assert( pPage->nCell>0 ); |
| 54959 | assert( pPage->intKey==(pIdxKey==0) ); |
| 54960 | lwr = 0; |
| 54961 | upr = pPage->nCell-1; |
| 54962 | if( biasRight ){ |
| 54963 | pCur->aiIdx[pCur->iPage] = (u16)(idx = upr); |
| 54964 | }else{ |
| 54965 | pCur->aiIdx[pCur->iPage] = (u16)(idx = (upr+lwr)/2); |
| 54966 | } |
| 54967 | for(;;){ |
| 54968 | u8 *pCell; /* Pointer to current cell in pPage */ |
| 54969 | |
| 54970 | assert( idx==pCur->aiIdx[pCur->iPage] ); |
| 54971 | pCur->info.nSize = 0; |
| 54972 | pCell = findCell(pPage, idx) + pPage->childPtrSize; |
| 54973 | if( pPage->intKey ){ |
| 54974 | i64 nCellKey; |
| 54975 | if( pPage->hasData ){ |
| 54976 | u32 dummy; |
| 54977 | pCell += getVarint32(pCell, dummy); |
| 54978 | } |
| 54979 | getVarint(pCell, (u64*)&nCellKey); |
| 54980 | if( nCellKey==intKey ){ |
| 54981 | c = 0; |
| 54982 | }else if( nCellKey<intKey ){ |
| 54983 | c = -1; |
| 54984 | }else{ |
| 54985 | assert( nCellKey>intKey ); |
| 54986 | c = +1; |
| 54987 | } |
| 54988 | pCur->validNKey = 1; |
| 54989 | pCur->info.nKey = nCellKey; |
| 54990 | }else{ |
| 54991 | /* The maximum supported page-size is 65536 bytes. This means that |
| 54992 | ** the maximum number of record bytes stored on an index B-Tree |
| 54993 | ** page is less than 16384 bytes and may be stored as a 2-byte |
| 54994 | ** varint. This information is used to attempt to avoid parsing |
| 54995 | ** the entire cell by checking for the cases where the record is |
| 54996 | ** stored entirely within the b-tree page by inspecting the first |
| 54997 | ** 2 bytes of the cell. |
| 54998 | */ |
| 54999 | int nCell = pCell[0]; |
| 55000 | if( nCell<=pPage->max1bytePayload |
| 55001 | /* && (pCell+nCell)<pPage->aDataEnd */ |
| 55002 | ){ |
| 55003 | /* This branch runs if the record-size field of the cell is a |
| 55004 | ** single byte varint and the record fits entirely on the main |
| @@ -55025,61 +55001,57 @@ | |
| 55025 | pCellKey = sqlite3Malloc( nCell ); |
| 55026 | if( pCellKey==0 ){ |
| 55027 | rc = SQLITE_NOMEM; |
| 55028 | goto moveto_finish; |
| 55029 | } |
| 55030 | rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0); |
| 55031 | if( rc ){ |
| 55032 | sqlite3_free(pCellKey); |
| 55033 | goto moveto_finish; |
| 55034 | } |
| 55035 | c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); |
| 55036 | sqlite3_free(pCellKey); |
| 55037 | } |
| 55038 | } |
| 55039 | if( c==0 ){ |
| 55040 | if( pPage->intKey && !pPage->leaf ){ |
| 55041 | lwr = idx; |
| 55042 | break; |
| 55043 | }else{ |
| 55044 | *pRes = 0; |
| 55045 | rc = SQLITE_OK; |
| 55046 | goto moveto_finish; |
| 55047 | } |
| 55048 | } |
| 55049 | if( c<0 ){ |
| 55050 | lwr = idx+1; |
| 55051 | }else{ |
| 55052 | upr = idx-1; |
| 55053 | } |
| 55054 | if( lwr>upr ){ |
| 55055 | break; |
| 55056 | } |
| 55057 | pCur->aiIdx[pCur->iPage] = (u16)(idx = (lwr+upr)/2); |
| 55058 | } |
| 55059 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); |
| 55060 | assert( pPage->isInit ); |
| 55061 | if( pPage->leaf ){ |
| 55062 | chldPg = 0; |
| 55063 | }else if( lwr>=pPage->nCell ){ |
| 55064 | chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); |
| 55065 | }else{ |
| 55066 | chldPg = get4byte(findCell(pPage, lwr)); |
| 55067 | } |
| 55068 | if( chldPg==0 ){ |
| 55069 | assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 55070 | *pRes = c; |
| 55071 | rc = SQLITE_OK; |
| 55072 | goto moveto_finish; |
| 55073 | } |
| 55074 | pCur->aiIdx[pCur->iPage] = (u16)lwr; |
| 55075 | pCur->info.nSize = 0; |
| 55076 | pCur->validNKey = 0; |
| 55077 | rc = moveToChild(pCur, chldPg); |
| 55078 | if( rc ) goto moveto_finish; |
| 55079 | } |
| 55080 | moveto_finish: |
| 55081 | return rc; |
| 55082 | } |
| 55083 | |
| 55084 | |
| 55085 | /* |
| @@ -70643,11 +70615,11 @@ | |
| 70643 | u.bi.nZero = 0; |
| 70644 | } |
| 70645 | sqlite3BtreeSetCachedRowid(u.bi.pC->pCursor, 0); |
| 70646 | rc = sqlite3BtreeInsert(u.bi.pC->pCursor, 0, u.bi.iKey, |
| 70647 | u.bi.pData->z, u.bi.pData->n, u.bi.nZero, |
| 70648 | pOp->p5 & OPFLAG_APPEND, u.bi.seekResult |
| 70649 | ); |
| 70650 | u.bi.pC->rowidIsValid = 0; |
| 70651 | u.bi.pC->deferredMoveto = 0; |
| 70652 | u.bi.pC->cacheStatus = CACHE_STALE; |
| 70653 | |
| @@ -89144,11 +89116,11 @@ | |
| 89144 | int rcauth; /* Value returned by authorization callback */ |
| 89145 | int okOnePass; /* True for one-pass algorithm without the FIFO */ |
| 89146 | int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */ |
| 89147 | u8 *aToOpen = 0; /* Open cursor iTabCur+j if aToOpen[j] is true */ |
| 89148 | Index *pPk; /* The PRIMARY KEY index on the table */ |
| 89149 | int iPk; /* First of nPk registers holding PRIMARY KEY value */ |
| 89150 | i16 nPk = 1; /* Number of columns in the PRIMARY KEY */ |
| 89151 | int iKey; /* Memory cell holding key of row to be deleted */ |
| 89152 | i16 nKey; /* Number of memory cells in the row key */ |
| 89153 | int iEphCur = 0; /* Ephemeral table holding all primary key values */ |
| 89154 | int iRowSet = 0; /* Register for rowset of rows to delete */ |
| 89155 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | */ |
| 138 | #define SQLITE_VERSION "3.8.2" |
| 139 | #define SQLITE_VERSION_NUMBER 3008002 |
| 140 | #define SQLITE_SOURCE_ID "2013-11-25 20:50:23 032e89934f36de10652d3454a0065a337827221a" |
| 141 | |
| 142 | /* |
| 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | ** |
| @@ -17497,29 +17497,10 @@ | |
| 17497 | iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE)); |
| 17498 | } |
| 17499 | return iSize; |
| 17500 | } |
| 17501 | |
| 17502 | /* |
| 17503 | ** Return a block of memory of at least nBytes in size. |
| 17504 | ** Return NULL if unable. Return NULL if nBytes==0. |
| 17505 | ** |
| 17506 | ** The caller guarantees that nByte is positive. |
| @@ -17561,11 +17542,12 @@ | |
| 17542 | if( iBin>LOGMAX ){ |
| 17543 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 17544 | sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte); |
| 17545 | return 0; |
| 17546 | } |
| 17547 | i = mem5.aiFreelist[iBin]; |
| 17548 | memsys5Unlink(i, iBin); |
| 17549 | while( iBin>iLogsize ){ |
| 17550 | int newSize; |
| 17551 | |
| 17552 | iBin--; |
| 17553 | newSize = 1 << iBin; |
| @@ -35013,11 +34995,11 @@ | |
| 34995 | ** |
| 34996 | ** This division contains the implementation of methods on the |
| 34997 | ** sqlite3_vfs object. |
| 34998 | */ |
| 34999 | |
| 35000 | #if 0 |
| 35001 | /* |
| 35002 | ** Convert a filename from whatever the underlying operating system |
| 35003 | ** supports for filenames into UTF-8. Space to hold the result is |
| 35004 | ** obtained from malloc and must be freed by the calling function. |
| 35005 | */ |
| @@ -35189,21 +35171,27 @@ | |
| 35171 | if( winIsDir(zConverted) ){ |
| 35172 | /* At this point, we know the candidate directory exists and should |
| 35173 | ** be used. However, we may need to convert the string containing |
| 35174 | ** its name into UTF-8 (i.e. if it is UTF-16 right now). |
| 35175 | */ |
| 35176 | if( osIsNT() ){ |
| 35177 | char *zUtf8 = winUnicodeToUtf8(zConverted); |
| 35178 | if( !zUtf8 ){ |
| 35179 | sqlite3_free(zConverted); |
| 35180 | sqlite3_free(zBuf); |
| 35181 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 35182 | return SQLITE_IOERR_NOMEM; |
| 35183 | } |
| 35184 | sqlite3_snprintf(nMax, zBuf, "%s", zUtf8); |
| 35185 | sqlite3_free(zUtf8); |
| 35186 | sqlite3_free(zConverted); |
| 35187 | break; |
| 35188 | }else{ |
| 35189 | sqlite3_snprintf(nMax, zBuf, "%s", zConverted); |
| 35190 | sqlite3_free(zConverted); |
| 35191 | break; |
| 35192 | } |
| 35193 | } |
| 35194 | sqlite3_free(zConverted); |
| 35195 | } |
| 35196 | } |
| 35197 | } |
| @@ -35884,47 +35872,23 @@ | |
| 35872 | */ |
| 35873 | char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 ); |
| 35874 | if( !zOut ){ |
| 35875 | return SQLITE_IOERR_NOMEM; |
| 35876 | } |
| 35877 | if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, |
| 35878 | pVfs->mxPathname+1)<0 ){ |
| 35879 | sqlite3_free(zOut); |
| 35880 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35881 | "winFullPathname1", zRelative); |
| 35882 | } |
| 35883 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35884 | sqlite3_data_directory, winGetDirSep(), zOut); |
| 35885 | sqlite3_free(zOut); |
| 35886 | }else{ |
| 35887 | if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ |
| 35888 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35889 | "winFullPathname2", zRelative); |
| 35890 | } |
| 35891 | } |
| 35892 | return SQLITE_OK; |
| 35893 | #endif |
| 35894 | |
| @@ -54942,14 +54906,14 @@ | |
| 54906 | assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 ); |
| 54907 | return SQLITE_OK; |
| 54908 | } |
| 54909 | assert( pCur->apPage[0]->intKey || pIdxKey ); |
| 54910 | for(;;){ |
| 54911 | int lwr, upr, idx, c; |
| 54912 | Pgno chldPg; |
| 54913 | MemPage *pPage = pCur->apPage[pCur->iPage]; |
| 54914 | u8 *pCell; /* Pointer to current cell in pPage */ |
| 54915 | |
| 54916 | /* pPage->nCell must be greater than zero. If this is the root-page |
| 54917 | ** the cursor would have been INVALID above and this for(;;) loop |
| 54918 | ** not run. If this is not the root-page, then the moveToChild() routine |
| 54919 | ** would have already detected db corruption. Similarly, pPage must |
| @@ -54957,48 +54921,60 @@ | |
| 54921 | ** a moveToChild() or moveToRoot() call would have detected corruption. */ |
| 54922 | assert( pPage->nCell>0 ); |
| 54923 | assert( pPage->intKey==(pIdxKey==0) ); |
| 54924 | lwr = 0; |
| 54925 | upr = pPage->nCell-1; |
| 54926 | assert( biasRight==0 || biasRight==1 ); |
| 54927 | idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */ |
| 54928 | pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 54929 | if( pPage->intKey ){ |
| 54930 | for(;;){ |
| 54931 | i64 nCellKey; |
| 54932 | pCell = findCell(pPage, idx) + pPage->childPtrSize; |
| 54933 | if( pPage->hasData ){ |
| 54934 | while( 0x80 <= *(pCell++) ){ |
| 54935 | if( pCell>=pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT; |
| 54936 | } |
| 54937 | } |
| 54938 | getVarint(pCell, (u64*)&nCellKey); |
| 54939 | if( nCellKey<intKey ){ |
| 54940 | lwr = idx+1; |
| 54941 | if( lwr>upr ){ c = -1; break; } |
| 54942 | }else if( nCellKey>intKey ){ |
| 54943 | upr = idx-1; |
| 54944 | if( lwr>upr ){ c = +1; break; } |
| 54945 | }else{ |
| 54946 | assert( nCellKey==intKey ); |
| 54947 | pCur->validNKey = 1; |
| 54948 | pCur->info.nKey = nCellKey; |
| 54949 | pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 54950 | if( !pPage->leaf ){ |
| 54951 | lwr = idx; |
| 54952 | goto moveto_next_layer; |
| 54953 | }else{ |
| 54954 | *pRes = 0; |
| 54955 | rc = SQLITE_OK; |
| 54956 | goto moveto_finish; |
| 54957 | } |
| 54958 | } |
| 54959 | assert( lwr+upr>=0 ); |
| 54960 | idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */ |
| 54961 | } |
| 54962 | }else{ |
| 54963 | for(;;){ |
| 54964 | int nCell; |
| 54965 | pCell = findCell(pPage, idx) + pPage->childPtrSize; |
| 54966 | |
| 54967 | /* The maximum supported page-size is 65536 bytes. This means that |
| 54968 | ** the maximum number of record bytes stored on an index B-Tree |
| 54969 | ** page is less than 16384 bytes and may be stored as a 2-byte |
| 54970 | ** varint. This information is used to attempt to avoid parsing |
| 54971 | ** the entire cell by checking for the cases where the record is |
| 54972 | ** stored entirely within the b-tree page by inspecting the first |
| 54973 | ** 2 bytes of the cell. |
| 54974 | */ |
| 54975 | nCell = pCell[0]; |
| 54976 | if( nCell<=pPage->max1bytePayload |
| 54977 | /* && (pCell+nCell)<pPage->aDataEnd */ |
| 54978 | ){ |
| 54979 | /* This branch runs if the record-size field of the cell is a |
| 54980 | ** single byte varint and the record fits entirely on the main |
| @@ -55025,61 +55001,57 @@ | |
| 55001 | pCellKey = sqlite3Malloc( nCell ); |
| 55002 | if( pCellKey==0 ){ |
| 55003 | rc = SQLITE_NOMEM; |
| 55004 | goto moveto_finish; |
| 55005 | } |
| 55006 | pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 55007 | rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0); |
| 55008 | if( rc ){ |
| 55009 | sqlite3_free(pCellKey); |
| 55010 | goto moveto_finish; |
| 55011 | } |
| 55012 | c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); |
| 55013 | sqlite3_free(pCellKey); |
| 55014 | } |
| 55015 | if( c<0 ){ |
| 55016 | lwr = idx+1; |
| 55017 | }else if( c>0 ){ |
| 55018 | upr = idx-1; |
| 55019 | }else{ |
| 55020 | assert( c==0 ); |
| 55021 | *pRes = 0; |
| 55022 | rc = SQLITE_OK; |
| 55023 | pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 55024 | goto moveto_finish; |
| 55025 | } |
| 55026 | if( lwr>upr ) break; |
| 55027 | assert( lwr+upr>=0 ); |
| 55028 | idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */ |
| 55029 | } |
| 55030 | } |
| 55031 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); |
| 55032 | assert( pPage->isInit ); |
| 55033 | if( pPage->leaf ){ |
| 55034 | assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 55035 | pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 55036 | *pRes = c; |
| 55037 | rc = SQLITE_OK; |
| 55038 | goto moveto_finish; |
| 55039 | } |
| 55040 | moveto_next_layer: |
| 55041 | if( lwr>=pPage->nCell ){ |
| 55042 | chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); |
| 55043 | }else{ |
| 55044 | chldPg = get4byte(findCell(pPage, lwr)); |
| 55045 | } |
| 55046 | pCur->aiIdx[pCur->iPage] = (u16)lwr; |
| 55047 | rc = moveToChild(pCur, chldPg); |
| 55048 | if( rc ) break; |
| 55049 | } |
| 55050 | moveto_finish: |
| 55051 | pCur->info.nSize = 0; |
| 55052 | pCur->validNKey = 0; |
| 55053 | return rc; |
| 55054 | } |
| 55055 | |
| 55056 | |
| 55057 | /* |
| @@ -70643,11 +70615,11 @@ | |
| 70615 | u.bi.nZero = 0; |
| 70616 | } |
| 70617 | sqlite3BtreeSetCachedRowid(u.bi.pC->pCursor, 0); |
| 70618 | rc = sqlite3BtreeInsert(u.bi.pC->pCursor, 0, u.bi.iKey, |
| 70619 | u.bi.pData->z, u.bi.pData->n, u.bi.nZero, |
| 70620 | (pOp->p5 & OPFLAG_APPEND)!=0, u.bi.seekResult |
| 70621 | ); |
| 70622 | u.bi.pC->rowidIsValid = 0; |
| 70623 | u.bi.pC->deferredMoveto = 0; |
| 70624 | u.bi.pC->cacheStatus = CACHE_STALE; |
| 70625 | |
| @@ -89144,11 +89116,11 @@ | |
| 89116 | int rcauth; /* Value returned by authorization callback */ |
| 89117 | int okOnePass; /* True for one-pass algorithm without the FIFO */ |
| 89118 | int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */ |
| 89119 | u8 *aToOpen = 0; /* Open cursor iTabCur+j if aToOpen[j] is true */ |
| 89120 | Index *pPk; /* The PRIMARY KEY index on the table */ |
| 89121 | int iPk = 0; /* First of nPk registers holding PRIMARY KEY value */ |
| 89122 | i16 nPk = 1; /* Number of columns in the PRIMARY KEY */ |
| 89123 | int iKey; /* Memory cell holding key of row to be deleted */ |
| 89124 | i16 nKey; /* Number of memory cells in the row key */ |
| 89125 | int iEphCur = 0; /* Ephemeral table holding all primary key values */ |
| 89126 | int iRowSet = 0; /* Register for rowset of rows to delete */ |
| 89127 |
+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.2" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3008002 |
| 112 | -#define SQLITE_SOURCE_ID "2013-11-21 23:37:02 3d47a556f0074e39b880186fb7661b1b8955f742" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-11-25 20:50:23 032e89934f36de10652d3454a0065a337827221a" | |
| 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.2" |
| 111 | #define SQLITE_VERSION_NUMBER 3008002 |
| 112 | #define SQLITE_SOURCE_ID "2013-11-21 23:37:02 3d47a556f0074e39b880186fb7661b1b8955f742" |
| 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.2" |
| 111 | #define SQLITE_VERSION_NUMBER 3008002 |
| 112 | #define SQLITE_SOURCE_ID "2013-11-25 20:50:23 032e89934f36de10652d3454a0065a337827221a" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |