diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/third_party/sqlite/amalgamation | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/third_party/sqlite/amalgamation')
-rw-r--r-- | chromium/third_party/sqlite/amalgamation/sqlite3.c | 228 | ||||
-rw-r--r-- | chromium/third_party/sqlite/amalgamation/sqlite3.h | 15 |
2 files changed, 13 insertions, 230 deletions
diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.c b/chromium/third_party/sqlite/amalgamation/sqlite3.c index 7c835a69914..c0315fffb7d 100644 --- a/chromium/third_party/sqlite/amalgamation/sqlite3.c +++ b/chromium/third_party/sqlite/amalgamation/sqlite3.c @@ -5234,21 +5234,6 @@ struct sqlite3_index_info { double estimatedCost; /* Estimated cost of using this index */ }; -/* Begin preload-cache.patch for Chromium */ -/* -** Preload the databases into the pager cache, up to the maximum size of the -** pager cache. -** -** For a database to be loaded successfully, the pager must be active. That is, -** there must be an open statement on that database. See sqlite3pager_loadall -** -** There might be many databases attached to the given connection. We iterate -** them all and try to load them. If none are loadable successfully, we return -** an error. Otherwise, we return OK. -*/ -SQLITE_API int sqlite3_preload(sqlite3 *db); -/* End preload-cache.patch for Chromium */ - /* ** CAPI3REF: Virtual Table Constraint Operator Codes ** @@ -8459,8 +8444,6 @@ SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*); SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); -/* This function is for preload-cache.patch for Chromium: */ -SQLITE_PRIVATE int sqlite3PagerLoadall(Pager*); SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); @@ -8631,7 +8614,9 @@ SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHd ** of the suggested cache-sizes. */ SQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *, int); +#ifdef SQLITE_TEST SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *); +#endif #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT /* Try to return memory used by the pcache module to the main memory heap */ @@ -34893,12 +34878,14 @@ SQLITE_PRIVATE int sqlite3PcachePagecount(PCache *pCache){ return nPage; } +#ifdef SQLITE_TEST /* ** Get the suggested cache-size value. */ SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *pCache){ return pCache->nMax; } +#endif /* ** Set the suggested cache-size value. @@ -37234,16 +37221,6 @@ static int pagerUseWal(Pager *pPager){ # define pagerBeginReadTransaction(z) SQLITE_OK #endif -/* Begin preload-cache.patch for Chromium */ -/* See comments above the definition. */ -SQLITE_PRIVATE int sqlite3PagerAcquire2( - Pager *pPager, - Pgno pgno, - DbPage **ppPage, - int noContent, - unsigned char *pDataToFill); -/* End preload-cache.patch for Chromium */ - #ifndef NDEBUG /* ** Usage: @@ -41413,25 +41390,6 @@ SQLITE_PRIVATE int sqlite3PagerAcquire( DbPage **ppPage, /* Write a pointer to the page here */ int noContent /* Do not bother reading content from disk if true */ ){ - /* This just passes through to our modified version with NULL data. */ - return sqlite3PagerAcquire2(pPager, pgno, ppPage, noContent, 0); -} - -/* -** This is an internal version of sqlite3PagerAcquire that takes an extra -** parameter of data to use to fill the page with. This allows more efficient -** filling for preloaded data. If this extra parameter is NULL, we'll go to -** the file. -** -** See sqlite3PagerLoadall which uses this function. -*/ -SQLITE_PRIVATE int sqlite3PagerAcquire2( - Pager *pPager, /* The pager open on the database file */ - Pgno pgno, /* Page number to fetch */ - DbPage **ppPage, /* Write a pointer to the page here */ - int noContent, /* Do not bother reading content from disk if true */ - unsigned char* pDataToFill -){ int rc; PgHdr *pPg; @@ -41507,17 +41465,9 @@ SQLITE_PRIVATE int sqlite3PagerAcquire2( IOTRACE(("ZERO %p %d\n", pPager, pgno)); }else{ assert( pPg->pPager==pPager ); - if( pDataToFill ){ - /* Just copy from the given memory */ - memcpy(pPg->pData, pDataToFill, pPager->pageSize); - CODEC1(pPager, pPg->pData, pPg->pgno, 3, rc = SQLITE_NOMEM; - goto pager_acquire_err); - }else{ - /* Load from disk (old regular sqlite code path) */ - rc = readDbPage(pPg); - if( rc!=SQLITE_OK ){ - goto pager_acquire_err; - } + rc = readDbPage(pPg); + if( rc!=SQLITE_OK ){ + goto pager_acquire_err; } } pager_set_pagehash(pPg); @@ -42939,135 +42889,6 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i } #endif -/* Begin preload-cache.patch for Chromium */ -#if 1 -/* NOTE(shess): Testing to see if simply reading the data into the - * filesystem buffers will have the positive speed impact without the - * negative memory impact. - */ -SQLITE_PRIVATE int sqlite3PagerLoadall(Pager* pPager) -{ - int i, pageSize, loadPages, rc; - unsigned char *fileData; - - /* TODO(shess): This test may not be relevant for this - * implementation, but keep the invariant consistent. - */ - pageSize = pPager->pageSize; - if (pPager->dbSize < 0 || pageSize < 0) { - /* pager not initialized, this means a statement is not open */ - return SQLITE_MISUSE; - } - - /* Allocate a buffer to read pages into. */ - /* TODO(shess): No need to read by page, this could be a fixed-size - * buffer on stack. - */ - fileData = sqlite3Malloc(pageSize); - if (!fileData) - return SQLITE_NOMEM; - - /* Load the smaller of the entire cache or the entire database. */ - loadPages = sqlite3PcacheGetCachesize(pPager->pPCache); - if (loadPages > pPager->dbSize) - loadPages = pPager->dbSize; - - /* Read database page by page. */ - rc = SQLITE_OK; - for(i=0; i < loadPages; i++) { - rc = sqlite3OsRead(pPager->fd, fileData, pageSize, i*pageSize); - if (rc != SQLITE_OK) - break; - } - sqlite3_free(fileData); - return rc; -} -#else -/** -** When making large allocations, there is no need to stress the heap and -** potentially hold its lock while we allocate a bunch of memory. If we know -** the allocation will be large, go directly to the OS instead of the heap. -**/ -static void* allocLarge(size_t size) { -#if SQLITE_OS_WIN - return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); -#else - return sqlite3Malloc(size); -#endif -} - -static void freeLarge(void* ptr) { -#if SQLITE_OS_WIN - VirtualFree(ptr, 0, MEM_RELEASE); -#else - sqlite3_free(ptr); -#endif -} - -/** -** Addition: This will attempt to populate the database cache with -** the first N bytes of the file, where N is the total size of the cache. -** Because we can load this as one chunk from the disk, this is much faster -** than loading a subset of the pages one at a time in random order. -** -** The pager must be initialized before this function is called. This means a -* statement must be open that has initialized the pager and is keeping the -** cache in memory. -**/ -SQLITE_PRIVATE int sqlite3PagerLoadall(Pager* pPager) -{ - int i; - int rc; - int nMax; - int loadSize; - int loadPages; - unsigned char *fileData; - - if (pPager->dbSize < 0 || pPager->pageSize < 0) { - /* pager not initialized, this means a statement is not open */ - return SQLITE_MISUSE; - } - - /* compute sizes */ - nMax = sqlite3PcacheGetCachesize(pPager->pPCache); - if (nMax < pPager->dbSize) - loadPages = nMax; - else - loadPages = pPager->dbSize; - loadSize = loadPages * pPager->pageSize; - - /* load the file as one chunk */ - fileData = allocLarge(loadSize); - if (! fileData) - return SQLITE_NOMEM; - rc = sqlite3OsRead(pPager->fd, fileData, loadSize, 0); - if (rc != SQLITE_OK) { - freeLarge(fileData); - return rc; - } - - /* Copy the data to each page. Note that the page numbers we pass to _get - * are one-based, 0 is a marker for no page. We also need to check that we - * haven't loaded more pages than the cache can hold total. There may have - * already been a few pages loaded before, so we may fill the cache before - * loading all of the pages we want to. - */ - for(i=1; - i <= loadPages && sqlite3PcachePagecount(pPager->pPCache) < nMax; - i++) { - DbPage *pPage = 0; - rc = sqlite3PagerAcquire2(pPager, i, &pPage, 0, - &fileData[(i-1)*(i64)pPager->pageSize]); - if (rc != SQLITE_OK) - break; - sqlite3PagerUnref(pPage); - } - freeLarge(fileData); - return SQLITE_OK; -} -#endif -/* End preload-cache.patch for Chromium */ - /* ** Return a pointer to the data for the specified page. */ @@ -77042,7 +76863,6 @@ SQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext *pContext){ ** ROLLBACK */ - /* ** This routine is called when a new SQL statement is beginning to ** be parsed. Initialize the pParse structure as needed. @@ -80775,33 +80595,6 @@ SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){ return pKey; } -/* Begin preload-cache.patch for Chromium */ -/* See declaration in sqlite3.h for information */ -SQLITE_API int sqlite3_preload(sqlite3 *db) -{ - Pager *pPager; - Btree *pBt; - int rc; - int i; - int dbsLoaded = 0; - - for(i=0; i<db->nDb; i++) { - pBt = db->aDb[i].pBt; - if( !pBt ) - continue; - pPager = sqlite3BtreePager(pBt); - if( pPager ) { - rc = sqlite3PagerLoadall(pPager); - if (rc == SQLITE_OK) - dbsLoaded++; - } - } - if (dbsLoaded == 0) - return SQLITE_ERROR; - return SQLITE_OK; -} -/* End preload-cache.patch for Chromium */ - /************** End of build.c ***********************************************/ /************** Begin file callback.c ****************************************/ /* @@ -111728,6 +111521,7 @@ static int ValidateError(){ /* Setup the cursor for reading the information from cell iCell. */ static int leafCursorCellDecode(RecoverLeafCursor *pCursor){ const unsigned char *pPageHeader; /* Header of current page. */ + const unsigned char *pPageEnd; /* Byte after end of current page. */ const unsigned char *pCellOffsets; /* Pointer to page's cell offsets. */ unsigned iCellOffset; /* Offset of current cell (iCell). */ const unsigned char *pCell; /* Pointer to data at iCellOffset. */ @@ -111750,6 +111544,10 @@ static int leafCursorCellDecode(RecoverLeafCursor *pCursor){ /* Find the offset to the row. */ pPageHeader = PageHeader(pCursor->pPage); pCellOffsets = pPageHeader + knPageLeafHeaderBytes; + pPageEnd = PageData(pCursor->pPage, pCursor->nPageSize); + if( pCellOffsets + pCursor->iCell*2 + 2 > pPageEnd ){ + return ValidateError(); + } iCellOffset = decodeUnsigned16(pCellOffsets + pCursor->iCell*2); if( iCellOffset>=pCursor->nPageSize ){ return ValidateError(); @@ -111791,7 +111589,7 @@ static int leafCursorCellDecode(RecoverLeafCursor *pCursor){ /* Check that no other cell starts within this cell. */ iEndOffset = pCursor->iRecordOffset + pCursor->nLocalRecordBytes; - for( i=0; i<pCursor->nCells; ++i ){ + for( i=0; i<pCursor->nCells && pCellOffsets + i*2 + 2 <= pPageEnd; ++i ){ const unsigned iOtherOffset = decodeUnsigned16(pCellOffsets + i*2); if( iOtherOffset>iCellOffset && iOtherOffset<iEndOffset ){ return ValidateError(); diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.h b/chromium/third_party/sqlite/amalgamation/sqlite3.h index 5d56618caef..91ac9145f89 100644 --- a/chromium/third_party/sqlite/amalgamation/sqlite3.h +++ b/chromium/third_party/sqlite/amalgamation/sqlite3.h @@ -4691,21 +4691,6 @@ struct sqlite3_index_info { double estimatedCost; /* Estimated cost of using this index */ }; -/* Begin preload-cache.patch for Chromium */ -/* -** Preload the databases into the pager cache, up to the maximum size of the -** pager cache. -** -** For a database to be loaded successfully, the pager must be active. That is, -** there must be an open statement on that database. See sqlite3pager_loadall -** -** There might be many databases attached to the given connection. We iterate -** them all and try to load them. If none are loadable successfully, we return -** an error. Otherwise, we return OK. -*/ -SQLITE_API int sqlite3_preload(sqlite3 *db); -/* End preload-cache.patch for Chromium */ - /* ** CAPI3REF: Virtual Table Constraint Operator Codes ** |