Fossil SCM

Update to the latest SQLite containing storage engine performance enhancements.

drh 2013-11-25 21:22 UTC trunk
Commit 3957e9610f806e5a0b3a75d6967da044454e627b
2 files changed +92 -120 +1 -1
+92 -120
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135135
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136136
** [sqlite_version()] and [sqlite_source_id()].
137137
*/
138138
#define SQLITE_VERSION "3.8.2"
139139
#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"
141141
142142
/*
143143
** CAPI3REF: Run-Time Library Version Numbers
144144
** KEYWORDS: sqlite3_version, sqlite3_sourceid
145145
**
@@ -17497,29 +17497,10 @@
1749717497
iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));
1749817498
}
1749917499
return iSize;
1750017500
}
1750117501
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
-
1752117502
/*
1752217503
** Return a block of memory of at least nBytes in size.
1752317504
** Return NULL if unable. Return NULL if nBytes==0.
1752417505
**
1752517506
** The caller guarantees that nByte is positive.
@@ -17561,11 +17542,12 @@
1756117542
if( iBin>LOGMAX ){
1756217543
testcase( sqlite3GlobalConfig.xLog!=0 );
1756317544
sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte);
1756417545
return 0;
1756517546
}
17566
- i = memsys5UnlinkFirst(iBin);
17547
+ i = mem5.aiFreelist[iBin];
17548
+ memsys5Unlink(i, iBin);
1756717549
while( iBin>iLogsize ){
1756817550
int newSize;
1756917551
1757017552
iBin--;
1757117553
newSize = 1 << iBin;
@@ -35013,11 +34995,11 @@
3501334995
**
3501434996
** This division contains the implementation of methods on the
3501534997
** sqlite3_vfs object.
3501634998
*/
3501734999
35018
-#if defined(__CYGWIN__)
35000
+#if 0
3501935001
/*
3502035002
** Convert a filename from whatever the underlying operating system
3502135003
** supports for filenames into UTF-8. Space to hold the result is
3502235004
** obtained from malloc and must be freed by the calling function.
3502335005
*/
@@ -35189,21 +35171,27 @@
3518935171
if( winIsDir(zConverted) ){
3519035172
/* At this point, we know the candidate directory exists and should
3519135173
** be used. However, we may need to convert the string containing
3519235174
** its name into UTF-8 (i.e. if it is UTF-16 right now).
3519335175
*/
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
+ }
3520535193
}
3520635194
sqlite3_free(zConverted);
3520735195
}
3520835196
}
3520935197
}
@@ -35884,47 +35872,23 @@
3588435872
*/
3588535873
char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
3588635874
if( !zOut ){
3588735875
return SQLITE_IOERR_NOMEM;
3588835876
}
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 ){
3589235879
sqlite3_free(zOut);
3589335880
return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
3589435881
"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 ){
3591535888
return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
3591635889
"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);
3592635890
}
3592735891
}
3592835892
return SQLITE_OK;
3592935893
#endif
3593035894
@@ -54942,14 +54906,14 @@
5494254906
assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 );
5494354907
return SQLITE_OK;
5494454908
}
5494554909
assert( pCur->apPage[0]->intKey || pIdxKey );
5494654910
for(;;){
54947
- int lwr, upr, idx;
54911
+ int lwr, upr, idx, c;
5494854912
Pgno chldPg;
5494954913
MemPage *pPage = pCur->apPage[pCur->iPage];
54950
- int c;
54914
+ u8 *pCell; /* Pointer to current cell in pPage */
5495154915
5495254916
/* pPage->nCell must be greater than zero. If this is the root-page
5495354917
** the cursor would have been INVALID above and this for(;;) loop
5495454918
** not run. If this is not the root-page, then the moveToChild() routine
5495554919
** would have already detected db corruption. Similarly, pPage must
@@ -54957,48 +54921,60 @@
5495754921
** a moveToChild() or moveToRoot() call would have detected corruption. */
5495854922
assert( pPage->nCell>0 );
5495954923
assert( pPage->intKey==(pIdxKey==0) );
5496054924
lwr = 0;
5496154925
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(;;){
5497454931
i64 nCellKey;
54932
+ pCell = findCell(pPage, idx) + pPage->childPtrSize;
5497554933
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
+ }
5497854937
}
5497954938
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
+
5499154967
/* The maximum supported page-size is 65536 bytes. This means that
5499254968
** the maximum number of record bytes stored on an index B-Tree
5499354969
** page is less than 16384 bytes and may be stored as a 2-byte
5499454970
** varint. This information is used to attempt to avoid parsing
5499554971
** the entire cell by checking for the cases where the record is
5499654972
** stored entirely within the b-tree page by inspecting the first
5499754973
** 2 bytes of the cell.
5499854974
*/
54999
- int nCell = pCell[0];
54975
+ nCell = pCell[0];
5500054976
if( nCell<=pPage->max1bytePayload
5500154977
/* && (pCell+nCell)<pPage->aDataEnd */
5500254978
){
5500354979
/* This branch runs if the record-size field of the cell is a
5500454980
** single byte varint and the record fits entirely on the main
@@ -55025,61 +55001,57 @@
5502555001
pCellKey = sqlite3Malloc( nCell );
5502655002
if( pCellKey==0 ){
5502755003
rc = SQLITE_NOMEM;
5502855004
goto moveto_finish;
5502955005
}
55006
+ pCur->aiIdx[pCur->iPage] = (u16)idx;
5503055007
rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
5503155008
if( rc ){
5503255009
sqlite3_free(pCellKey);
5503355010
goto moveto_finish;
5503455011
}
5503555012
c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey);
5503655013
sqlite3_free(pCellKey);
5503755014
}
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;
5504355019
}else{
55020
+ assert( c==0 );
5504455021
*pRes = 0;
5504555022
rc = SQLITE_OK;
55023
+ pCur->aiIdx[pCur->iPage] = (u16)idx;
5504655024
goto moveto_finish;
5504755025
}
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
+ }
5505855030
}
5505955031
assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );
5506055032
assert( pPage->isInit );
5506155033
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 ){
5506955034
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
55035
+ pCur->aiIdx[pCur->iPage] = (u16)idx;
5507055036
*pRes = c;
5507155037
rc = SQLITE_OK;
5507255038
goto moveto_finish;
5507355039
}
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
+ }
5507455046
pCur->aiIdx[pCur->iPage] = (u16)lwr;
55075
- pCur->info.nSize = 0;
55076
- pCur->validNKey = 0;
5507755047
rc = moveToChild(pCur, chldPg);
55078
- if( rc ) goto moveto_finish;
55048
+ if( rc ) break;
5507955049
}
5508055050
moveto_finish:
55051
+ pCur->info.nSize = 0;
55052
+ pCur->validNKey = 0;
5508155053
return rc;
5508255054
}
5508355055
5508455056
5508555057
/*
@@ -70643,11 +70615,11 @@
7064370615
u.bi.nZero = 0;
7064470616
}
7064570617
sqlite3BtreeSetCachedRowid(u.bi.pC->pCursor, 0);
7064670618
rc = sqlite3BtreeInsert(u.bi.pC->pCursor, 0, u.bi.iKey,
7064770619
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
7064970621
);
7065070622
u.bi.pC->rowidIsValid = 0;
7065170623
u.bi.pC->deferredMoveto = 0;
7065270624
u.bi.pC->cacheStatus = CACHE_STALE;
7065370625
@@ -89144,11 +89116,11 @@
8914489116
int rcauth; /* Value returned by authorization callback */
8914589117
int okOnePass; /* True for one-pass algorithm without the FIFO */
8914689118
int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */
8914789119
u8 *aToOpen = 0; /* Open cursor iTabCur+j if aToOpen[j] is true */
8914889120
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 */
8915089122
i16 nPk = 1; /* Number of columns in the PRIMARY KEY */
8915189123
int iKey; /* Memory cell holding key of row to be deleted */
8915289124
i16 nKey; /* Number of memory cells in the row key */
8915389125
int iEphCur = 0; /* Ephemeral table holding all primary key values */
8915489126
int iRowSet = 0; /* Register for rowset of rows to delete */
8915589127
--- 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 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.2"
111111
#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"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button