Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: third_party/sqlite/preload-cache.patch

Issue 5626002: Update sqlite to 3.7.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/third_party/sqlite/src
Patch Set: Remove misc change. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/misc.patch ('k') | third_party/sqlite/preprocessed/keywordhash.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Index: src/build.c 1 diff --git a/third_party/sqlite/src/src/build.c b/third_party/sqlite/src/src/bui ld.c
2 =================================================================== 2 index 2cfb1f4..c9eed5e 100644
3 --- src/build.c»2009-09-11 07:02:46.000000000 -0700 3 --- a/third_party/sqlite/src/src/build.c
4 +++ src/build.c»2009-09-14 18:16:46.000000000 -0700 4 +++ b/third_party/sqlite/src/src/build.c
5 @@ -26,6 +26,9 @@ 5 @@ -24,6 +24,9 @@
6 */ 6 */
7 #include "sqliteInt.h" 7 #include "sqliteInt.h"
8 8
9 +#include "pager.h" 9 +#include "pager.h"
10 +#include "btree.h" 10 +#include "btree.h"
11 + 11 +
12 /* 12 /*
13 ** This routine is called when a new SQL statement is beginning to 13 ** This routine is called when a new SQL statement is beginning to
14 ** be parsed. Initialize the pParse structure as needed. 14 ** be parsed. Initialize the pParse structure as needed.
15 @@ -3659,3 +3662,30 @@ 15 @@ -3688,3 +3691,30 @@ KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
16 } 16 }
17 return pKey; 17 return pKey;
18 } 18 }
19 + 19 +
20 +/* Begin preload-cache.patch for Chromium */ 20 +/* Begin preload-cache.patch for Chromium */
21 +/* See declaration in sqlite3.h for information */ 21 +/* See declaration in sqlite3.h for information */
22 +int sqlite3Preload(sqlite3 *db) 22 +int sqlite3Preload(sqlite3 *db)
23 +{ 23 +{
24 + Pager *pPager; 24 + Pager *pPager;
25 + Btree *pBt; 25 + Btree *pBt;
(...skipping 10 matching lines...) Expand all
36 + rc = sqlite3PagerLoadall(pPager); 36 + rc = sqlite3PagerLoadall(pPager);
37 + if (rc == SQLITE_OK) 37 + if (rc == SQLITE_OK)
38 + dbsLoaded++; 38 + dbsLoaded++;
39 + } 39 + }
40 + } 40 + }
41 + if (dbsLoaded == 0) 41 + if (dbsLoaded == 0)
42 + return SQLITE_ERROR; 42 + return SQLITE_ERROR;
43 + return SQLITE_OK; 43 + return SQLITE_OK;
44 +} 44 +}
45 +/* End preload-cache.patch for Chromium */ 45 +/* End preload-cache.patch for Chromium */
46 Index: src/sqlite3.h.in 46 diff --git a/third_party/sqlite/src/src/pager.c b/third_party/sqlite/src/src/pag er.c
47 =================================================================== 47 index 2faeb15..ba88923 100644
48 --- src/sqlite.h.in» 2009-09-09 07:03:20.000000000 -0700 48 --- a/third_party/sqlite/src/src/pager.c
49 +++ src/sqlite.h.in» 2009-09-15 11:34:26.000000000 -0700 49 +++ b/third_party/sqlite/src/src/pager.c
50 @@ -4677,6 +4677,21 @@ 50 @@ -790,6 +790,16 @@ static int pagerUseWal(Pager *pPager){
51 */ 51 # define pagerBeginReadTransaction(z) SQLITE_OK
52 int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); 52 #endif
53
54 +/* Begin preload-cache.patch for Chromium */
55 +/*
56 +** Preload the databases into the pager cache, up to the maximum size of the
57 +** pager cache.
58 +**
59 +** For a database to be loaded successfully, the pager must be active. That is,
60 +** there must be an open statement on that database. See sqlite3pager_loadall
61 +**
62 +** There might be many databases attached to the given connection. We iterate
63 +** them all and try to load them. If none are loadable successfully, we return
64 +** an error. Otherwise, we return OK.
65 +*/
66 +int sqlite3Preload(sqlite3 *db);
67 +/* End preload-cache.patch for Chromium */
68 +
69 /*
70 ** CAPI3REF: Virtual File System Objects {H11200} <S20100>
71 **
72 Index: src/pager.c
73 ===================================================================
74 --- src/pager.c»2009-09-07 08:58:09.000000000 -0700
75 +++ src/pager.c»2009-09-15 16:43:07.000000000 -0700
76 @@ -388,6 +388,16 @@
77 */
78 #define PAGER_MAX_PGNO 2147483647
79 53
80 +/* Begin preload-cache.patch for Chromium */ 54 +/* Begin preload-cache.patch for Chromium */
81 +/* See comments above the definition. */ 55 +/* See comments above the definition. */
82 +int sqlite3PagerAcquire2( 56 +int sqlite3PagerAcquire2(
83 + Pager *pPager, 57 + Pager *pPager,
84 + Pgno pgno, 58 + Pgno pgno,
85 + DbPage **ppPage, 59 + DbPage **ppPage,
86 + int noContent, 60 + int noContent,
87 + unsigned char *pDataToFill); 61 + unsigned char *pDataToFill);
88 +/* End preload-cache.patch for Chromium */ 62 +/* End preload-cache.patch for Chromium */
89 + 63 +
90 #ifndef NDEBUG 64 #ifndef NDEBUG
91 /* 65 /*
92 ** Usage: 66 ** Usage:
93 @@ -3788,6 +3798,25 @@ 67 @@ -4869,6 +4879,25 @@ int sqlite3PagerAcquire(
94 DbPage **ppPage, /* Write a pointer to the page here */ 68 DbPage **ppPage, /* Write a pointer to the page here */
95 int noContent /* Do not bother reading content from disk if true */ 69 int noContent /* Do not bother reading content from disk if true */
96 ){ 70 ){
97 + /* This just passes through to our modified version with NULL data. */ 71 + /* This just passes through to our modified version with NULL data. */
98 + return sqlite3PagerAcquire2(pPager, pgno, ppPage, noContent, 0); 72 + return sqlite3PagerAcquire2(pPager, pgno, ppPage, noContent, 0);
99 +} 73 +}
100 + 74 +
101 +/* 75 +/*
102 +** This is an internal version of sqlite3PagerAcquire that takes an extra 76 +** This is an internal version of sqlite3PagerAcquire that takes an extra
103 +** parameter of data to use to fill the page with. This allows more efficient 77 +** parameter of data to use to fill the page with. This allows more efficient
104 +** filling for preloaded data. If this extra parameter is NULL, we'll go to 78 +** filling for preloaded data. If this extra parameter is NULL, we'll go to
105 +** the file. 79 +** the file.
106 +** 80 +**
107 +** See sqlite3PagerLoadall which uses this function. 81 +** See sqlite3PagerLoadall which uses this function.
108 +*/ 82 +*/
109 +int sqlite3PagerAcquire2( 83 +int sqlite3PagerAcquire2(
110 + Pager *pPager, /* The pager open on the database file */ 84 + Pager *pPager, /* The pager open on the database file */
111 + Pgno pgno, /* Page number to fetch */ 85 + Pgno pgno, /* Page number to fetch */
112 + DbPage **ppPage, /* Write a pointer to the page here */ 86 + DbPage **ppPage, /* Write a pointer to the page here */
113 + int noContent, /* Do not bother reading content from disk if true */ 87 + int noContent, /* Do not bother reading content from disk if true */
114 + unsigned char* pDataToFill 88 + unsigned char* pDataToFill
115 +){ 89 +){
116 int rc; 90 int rc;
117 PgHdr *pPg; 91 PgHdr *pPg;
118 92
119 @@ -3870,9 +3899,17 @@ 93 @@ -4944,9 +4973,17 @@ int sqlite3PagerAcquire(
120 IOTRACE(("ZERO %p %d\n", pPager, pgno)); 94 IOTRACE(("ZERO %p %d\n", pPager, pgno));
121 }else{ 95 }else{
122 assert( pPg->pPager==pPager ); 96 assert( pPg->pPager==pPager );
123 - rc = readDbPage(pPg); 97 - rc = readDbPage(pPg);
124 - if( rc!=SQLITE_OK ){ 98 - if( rc!=SQLITE_OK ){
125 - goto pager_acquire_err; 99 - goto pager_acquire_err;
126 + if( pDataToFill ){ 100 + if( pDataToFill ){
127 + /* Just copy from the given memory */ 101 + /* Just copy from the given memory */
128 + memcpy(pPg->pData, pDataToFill, pPager->pageSize); 102 + memcpy(pPg->pData, pDataToFill, pPager->pageSize);
129 + CODEC1(pPager, pPg->pData, pPg->pgno, 3, rc = SQLITE_NOMEM; 103 + CODEC1(pPager, pPg->pData, pPg->pgno, 3, rc = SQLITE_NOMEM;
130 + goto pager_acquire_err); 104 + goto pager_acquire_err);
131 + }else{ 105 + }else{
132 + /* Load from disk (old regular sqlite code path) */ 106 + /* Load from disk (old regular sqlite code path) */
133 + rc = readDbPage(pPg); 107 + rc = readDbPage(pPg);
134 + if( rc!=SQLITE_OK ){ 108 + if( rc!=SQLITE_OK ){
135 + goto pager_acquire_err; 109 + goto pager_acquire_err;
136 + } 110 + }
137 } 111 }
138 } 112 }
139 #ifdef SQLITE_CHECK_PAGES 113 pager_set_pagehash(pPg);
140 @@ -5221,6 +5258,91 @@ 114 @@ -6318,6 +6355,91 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
141 } 115 }
142 #endif 116 #endif
143 117
144 +/* Begin preload-cache.patch for Chromium */ 118 +/* Begin preload-cache.patch for Chromium */
145 +/** 119 +/**
146 +** When making large allocations, there is no need to stress the heap and 120 +** When making large allocations, there is no need to stress the heap and
147 +** potentially hold its lock while we allocate a bunch of memory. If we know 121 +** potentially hold its lock while we allocate a bunch of memory. If we know
148 +** the allocation will be large, go directly to the OS instead of the heap. 122 +** the allocation will be large, go directly to the OS instead of the heap.
149 +**/ 123 +**/
150 +static void* allocLarge(size_t size) { 124 +static void* allocLarge(size_t size) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 + sqlite3PagerUnref(pPage); 196 + sqlite3PagerUnref(pPage);
223 + } 197 + }
224 + freeLarge(fileData); 198 + freeLarge(fileData);
225 + return SQLITE_OK; 199 + return SQLITE_OK;
226 +} 200 +}
227 +/* End preload-cache.patch for Chromium */ 201 +/* End preload-cache.patch for Chromium */
228 + 202 +
229 /* 203 /*
230 ** Return a pointer to the data for the specified page. 204 ** Return a pointer to the data for the specified page.
231 */ 205 */
232 Index: src/pager.h 206 diff --git a/third_party/sqlite/src/src/pager.h b/third_party/sqlite/src/src/pag er.h
233 =================================================================== 207 index c12afa7..f451a47 100644
234 --- src/pager.h»2009-09-04 13:37:42.000000000 -0700 208 --- a/third_party/sqlite/src/src/pager.h
235 +++ src/pager.h»2009-09-15 11:31:55.000000000 -0700 209 +++ b/third_party/sqlite/src/src/pager.h
236 @@ -143,6 +143,8 @@ 210 @@ -153,6 +153,8 @@ const sqlite3_vfs *sqlite3PagerVfs(Pager*);
237 sqlite3_file *sqlite3PagerFile(Pager*); 211 sqlite3_file *sqlite3PagerFile(Pager*);
238 const char *sqlite3PagerJournalname(Pager*); 212 const char *sqlite3PagerJournalname(Pager*);
239 int sqlite3PagerNosync(Pager*); 213 int sqlite3PagerNosync(Pager*);
240 +/* This function is for preload-cache.patch for Chromium: */ 214 +/* This function is for preload-cache.patch for Chromium: */
241 +int sqlite3PagerLoadall(Pager*); 215 +int sqlite3PagerLoadall(Pager*);
242 void *sqlite3PagerTempSpace(Pager*); 216 void *sqlite3PagerTempSpace(Pager*);
243 int sqlite3PagerIsMemdb(Pager*); 217 int sqlite3PagerIsMemdb(Pager*);
244 218
219 diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src /sqlite.h.in
220 index 2bbd687..25012ad 100644
221 --- a/third_party/sqlite/src/src/sqlite.h.in
222 +++ b/third_party/sqlite/src/src/sqlite.h.in
223 @@ -4683,6 +4683,21 @@ int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
224 */
225 int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
226
227 +/* Begin preload-cache.patch for Chromium */
228 +/*
229 +** Preload the databases into the pager cache, up to the maximum size of the
230 +** pager cache.
231 +**
232 +** For a database to be loaded successfully, the pager must be active. That is,
233 +** there must be an open statement on that database. See sqlite3pager_loadall
234 +**
235 +** There might be many databases attached to the given connection. We iterate
236 +** them all and try to load them. If none are loadable successfully, we return
237 +** an error. Otherwise, we return OK.
238 +*/
239 +int sqlite3Preload(sqlite3 *db);
240 +/* End preload-cache.patch for Chromium */
241 +
242 /*
243 ** The interface to the virtual-table mechanism defined above (back up
244 ** to a comment remarkably similar to this one) is currently considered
OLDNEW
« no previous file with comments | « third_party/sqlite/misc.patch ('k') | third_party/sqlite/preprocessed/keywordhash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698