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

Side by Side Diff: third_party/sqlite/patches/0005-Modify-default-VFS-to-support-WebDatabase.patch

Issue 1485603003: Revert of "[sql] Remove part of WebDatabase SQLite patch." (patchset #1 of https://codereview.chrom… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « third_party/sqlite/amalgamation/sqlite3.c ('k') | third_party/sqlite/src/src/os_unix.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 From e646ccd23c9eaa86e4e6b0f5ee60867010407346 Mon Sep 17 00:00:00 2001 1 From 4b957c2c198a53498fe18ad9668e2817ace98b1e Mon Sep 17 00:00:00 2001
2 From: dumi <dumi@chromium.org> 2 From: dumi <dumi@chromium.org>
3 Date: Mon, 20 Jul 2009 23:40:51 +0000 3 Date: Mon, 20 Jul 2009 23:40:51 +0000
4 Subject: [PATCH 05/12] Modify default VFS to support WebDatabase. 4 Subject: [PATCH 05/11] Modify default VFS to support WebDatabase.
5 5
6 The renderer WebDatabase implementation needs to broker certain requests 6 The renderer WebDatabase implementation needs to broker certain requests
7 to the browser. This modifies SQLite to allow monkey-patching the VFS 7 to the browser. This modifies SQLite to allow monkey-patching the VFS
8 to support this. 8 to support this.
9 9
10 NOTE(shess): This patch relies on core SQLite implementation details 10 NOTE(shess): This patch relies on core SQLite implementation details
11 remaining unchanged. When importing a new version of SQLite, pay very 11 remaining unchanged. When importing a new version of SQLite, pay very
12 close attention to whether the change is still doing what is intended. 12 close attention to whether the change is still doing what is intended.
13 13
14 Original review URLs: 14 Original review URLs:
15 https://codereview.chromium.org/159044 15 https://codereview.chromium.org/159044
16 https://codereview.chromium.org/384075 16 https://codereview.chromium.org/384075
17 https://codereview.chromium.org/377039 17 https://codereview.chromium.org/377039
18 [Possibly not a complete list.] 18 [Possibly not a complete list.]
19 --- 19 ---
20 third_party/sqlite/src/src/os_unix.c | 57 ++++++++++++++++++++++++++++++---- 20 third_party/sqlite/src/src/os_unix.c | 100 +++++++++++++++++++++++++++------
21 third_party/sqlite/src/src/os_win.c | 8 +++++ 21 third_party/sqlite/src/src/os_win.c | 8 +++
22 third_party/sqlite/src/src/sqlite.h.in | 31 ++++++++++++++++++ 22 third_party/sqlite/src/src/sqlite.h.in | 36 ++++++++++++
23 3 files changed, 90 insertions(+), 6 deletions(-) 23 3 files changed, 128 insertions(+), 16 deletions(-)
24 24
25 diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/o s_unix.c 25 diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/o s_unix.c
26 index a9344ee..c6e1b6c 100644 26 index a9344ee..75b71dc 100644
27 --- a/third_party/sqlite/src/src/os_unix.c 27 --- a/third_party/sqlite/src/src/os_unix.c
28 +++ b/third_party/sqlite/src/src/os_unix.c 28 +++ b/third_party/sqlite/src/src/os_unix.c
29 @@ -1321,6 +1321,12 @@ static int fileHasMoved(unixFile *pFile){ 29 @@ -1321,6 +1321,12 @@ static int fileHasMoved(unixFile *pFile){
30 return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId; 30 return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId;
31 #else 31 #else
32 struct stat buf; 32 struct stat buf;
33 + 33 +
34 + /* TODO(shess): This check doesn't work when the Chromium's WebDB code is 34 + /* TODO(shess): This check doesn't work when the Chromium's WebDB code is
35 + ** running in the sandbox. 35 + ** running in the sandbox.
36 + */ 36 + */
37 + return 0; 37 + return 0;
38 + 38 +
39 return pFile->pInode!=0 && 39 return pFile->pInode!=0 &&
40 (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino); 40 (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino);
41 #endif 41 #endif
42 @@ -5615,6 +5621,48 @@ static int findCreateFileMode( 42 @@ -5615,6 +5621,78 @@ static int findCreateFileMode(
43 } 43 }
44 44
45 /* 45 /*
46 +** Initializes a unixFile structure with zeros. 46 +** Initializes a unixFile structure with zeros.
47 +*/ 47 +*/
48 +CHROMIUM_SQLITE_API 48 +CHROMIUM_SQLITE_API
49 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file) { 49 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file) {
50 + memset(file, 0, sizeof(unixFile)); 50 + memset(file, 0, sizeof(unixFile));
51 +} 51 +}
52 + 52 +
53 +CHROMIUM_SQLITE_API 53 +CHROMIUM_SQLITE_API
54 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs, 54 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs,
55 + int fd, 55 + int fd,
56 + int dirfd, 56 + int dirfd,
57 + sqlite3_file* file, 57 + sqlite3_file* file,
58 + const char* fileName, 58 + const char* fileName,
59 + int noLock) { 59 + int noLock) {
60 + int ctrlFlags = (noLock ? UNIXFILE_NOLOCK : 0); 60 + int ctrlFlags = (noLock ? UNIXFILE_NOLOCK : 0);
61 + return fillInUnixFile(vfs, fd, file, fileName, ctrlFlags); 61 + return fillInUnixFile(vfs, fd, file, fileName, ctrlFlags);
62 +} 62 +}
63 + 63 +
64 +/* 64 +/*
65 +** Search for an unused file descriptor that was opened on the database file.
66 +** If a suitable file descriptor if found, then it is stored in *fd; otherwise,
67 +** *fd is not modified.
68 +**
69 +** If a reusable file descriptor is not found, and a new UnixUnusedFd cannot
70 +** be allocated, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK is returned.
71 +*/
72 +CHROMIUM_SQLITE_API
73 +int chromium_sqlite3_get_reusable_file_handle(sqlite3_file* file,
74 + const char* fileName,
75 + int flags,
76 + int* fd) {
77 + unixFile* unixSQLite3File = (unixFile*)file;
78 + int fileType = flags & 0xFFFFFF00;
79 + if (fileType == SQLITE_OPEN_MAIN_DB) {
80 + UnixUnusedFd *unusedFd = findReusableFd(fileName, flags);
81 + if (unusedFd) {
82 + *fd = unusedFd->fd;
83 + } else {
84 + unusedFd = sqlite3_malloc(sizeof(*unusedFd));
85 + if (!unusedFd) {
86 + return SQLITE_NOMEM;
87 + }
88 + }
89 + unixSQLite3File->pUnused = unusedFd;
90 + }
91 + return SQLITE_OK;
92 +}
93 +
94 +/*
65 +** Marks 'fd' as the unused file descriptor for 'pFile'. 95 +** Marks 'fd' as the unused file descriptor for 'pFile'.
66 +*/ 96 +*/
67 +CHROMIUM_SQLITE_API 97 +CHROMIUM_SQLITE_API
68 +void chromium_sqlite3_update_reusable_file_handle(sqlite3_file* file, 98 +void chromium_sqlite3_update_reusable_file_handle(sqlite3_file* file,
69 + int fd, 99 + int fd,
70 + int flags) { 100 + int flags) {
71 + unixFile* unixSQLite3File = (unixFile*)file; 101 + unixFile* unixSQLite3File = (unixFile*)file;
72 + if (unixSQLite3File->pUnused) { 102 + if (unixSQLite3File->pUnused) {
73 + unixSQLite3File->pUnused->fd = fd; 103 + unixSQLite3File->pUnused->fd = fd;
74 + unixSQLite3File->pUnused->flags = flags; 104 + unixSQLite3File->pUnused->flags = flags;
75 + } 105 + }
76 +} 106 +}
77 + 107 +
78 +/* 108 +/*
79 +** Destroys pFile's field that keeps track of the unused file descriptor. 109 +** Destroys pFile's field that keeps track of the unused file descriptor.
80 +*/ 110 +*/
81 +CHROMIUM_SQLITE_API 111 +CHROMIUM_SQLITE_API
82 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file) { 112 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file) {
83 + unixFile* unixSQLite3File = (unixFile*)file; 113 + unixFile* unixSQLite3File = (unixFile*)file;
84 + sqlite3_free(unixSQLite3File->pUnused); 114 + sqlite3_free(unixSQLite3File->pUnused);
85 +} 115 +}
86 + 116 +
87 +/* 117 +/*
88 ** Open the file zPath. 118 ** Open the file zPath.
89 ** 119 **
90 ** Previously, the SQLite OS layer used three functions in place of this 120 ** Previously, the SQLite OS layer used three functions in place of this
91 @@ -5715,7 +5763,7 @@ static int unixOpen( 121 @@ -5715,20 +5793,13 @@ static int unixOpen(
92 sqlite3_randomness(0,0); 122 sqlite3_randomness(0,0);
93 } 123 }
94 124
95 - memset(p, 0, sizeof(unixFile)); 125 - memset(p, 0, sizeof(unixFile));
96 + chromium_sqlite3_initialize_unix_sqlite3_file(pFile); 126 + chromium_sqlite3_initialize_unix_sqlite3_file(pFile);
97 127
98 if( eType==SQLITE_OPEN_MAIN_DB ){ 128 if( eType==SQLITE_OPEN_MAIN_DB ){
99 UnixUnusedFd *pUnused; 129 - UnixUnusedFd *pUnused;
100 @@ -5798,10 +5846,7 @@ static int unixOpen( 130 - pUnused = findReusableFd(zName, flags);
131 - if( pUnused ){
132 - fd = pUnused->fd;
133 - }else{
134 - pUnused = sqlite3_malloc(sizeof(*pUnused));
135 - if( !pUnused ){
136 - return SQLITE_NOMEM;
137 - }
138 + rc = chromium_sqlite3_get_reusable_file_handle(pFile, zName, flags, &fd);
139 + if( rc!=SQLITE_OK ){
140 + return rc;
141 }
142 - p->pUnused = pUnused;
143
144 /* Database filenames are double-zero terminated if they are not
145 ** URIs with parameters. Hence, they can always be passed into
146 @@ -5798,10 +5869,7 @@ static int unixOpen(
101 *pOutFlags = flags; 147 *pOutFlags = flags;
102 } 148 }
103 149
104 - if( p->pUnused ){ 150 - if( p->pUnused ){
105 - p->pUnused->fd = fd; 151 - p->pUnused->fd = fd;
106 - p->pUnused->flags = flags; 152 - p->pUnused->flags = flags;
107 - } 153 - }
108 + chromium_sqlite3_update_reusable_file_handle(pFile, fd, flags); 154 + chromium_sqlite3_update_reusable_file_handle(pFile, fd, flags);
109 155
110 if( isDelete ){ 156 if( isDelete ){
111 #if OS_VXWORKS 157 #if OS_VXWORKS
112 @@ -5893,7 +5938,7 @@ static int unixOpen( 158 @@ -5893,7 +5961,7 @@ static int unixOpen(
113 159
114 open_finished: 160 open_finished:
115 if( rc!=SQLITE_OK ){ 161 if( rc!=SQLITE_OK ){
116 - sqlite3_free(p->pUnused); 162 - sqlite3_free(p->pUnused);
117 + chromium_sqlite3_destroy_reusable_file_handle(pFile); 163 + chromium_sqlite3_destroy_reusable_file_handle(pFile);
118 } 164 }
119 return rc; 165 return rc;
120 } 166 }
121 diff --git a/third_party/sqlite/src/src/os_win.c b/third_party/sqlite/src/src/os _win.c 167 diff --git a/third_party/sqlite/src/src/os_win.c b/third_party/sqlite/src/src/os _win.c
122 index 8ca2107..9320bfc 100644 168 index 8ca2107..9320bfc 100644
123 --- a/third_party/sqlite/src/src/os_win.c 169 --- a/third_party/sqlite/src/src/os_win.c
124 +++ b/third_party/sqlite/src/src/os_win.c 170 +++ b/third_party/sqlite/src/src/os_win.c
125 @@ -5546,4 +5546,12 @@ int sqlite3_os_end(void){ 171 @@ -5546,4 +5546,12 @@ int sqlite3_os_end(void){
126 return SQLITE_OK; 172 return SQLITE_OK;
127 } 173 }
128 174
129 +CHROMIUM_SQLITE_API 175 +CHROMIUM_SQLITE_API
130 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) { 176 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) {
131 + winFile* winSQLite3File = (winFile*)file; 177 + winFile* winSQLite3File = (winFile*)file;
132 + memset(file, 0, sizeof(*file)); 178 + memset(file, 0, sizeof(*file));
133 + winSQLite3File->pMethod = &winIoMethod; 179 + winSQLite3File->pMethod = &winIoMethod;
134 + winSQLite3File->h = handle; 180 + winSQLite3File->h = handle;
135 +} 181 +}
136 + 182 +
137 #endif /* SQLITE_OS_WIN */ 183 #endif /* SQLITE_OS_WIN */
138 diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src /sqlite.h.in 184 diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src /sqlite.h.in
139 index f1d4e40..00e4771 100644 185 index f1d4e40..36aa999 100644
140 --- a/third_party/sqlite/src/src/sqlite.h.in 186 --- a/third_party/sqlite/src/src/sqlite.h.in
141 +++ b/third_party/sqlite/src/src/sqlite.h.in 187 +++ b/third_party/sqlite/src/src/sqlite.h.in
142 @@ -7408,6 +7408,37 @@ int sqlite3_vtab_on_conflict(sqlite3 *); 188 @@ -7408,6 +7408,42 @@ int sqlite3_vtab_on_conflict(sqlite3 *);
143 189
144 190
145 191
146 +/* Begin WebDatabase patch for Chromium */ 192 +/* Begin WebDatabase patch for Chromium */
147 +/* Expose some SQLite internals for the WebDatabase vfs. 193 +/* Expose some SQLite internals for the WebDatabase vfs.
148 +** DO NOT EXTEND THE USE OF THIS. 194 +** DO NOT EXTEND THE USE OF THIS.
149 +*/ 195 +*/
150 +#ifndef CHROMIUM_SQLITE_API 196 +#ifndef CHROMIUM_SQLITE_API
151 +#define CHROMIUM_SQLITE_API SQLITE_API 197 +#define CHROMIUM_SQLITE_API SQLITE_API
152 +#endif 198 +#endif
153 +#if defined(CHROMIUM_SQLITE_INTERNALS) 199 +#if defined(CHROMIUM_SQLITE_INTERNALS)
154 +#ifdef _WIN32 200 +#ifdef _WIN32
155 +CHROMIUM_SQLITE_API 201 +CHROMIUM_SQLITE_API
156 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle); 202 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle);
157 +#else /* _WIN32 */ 203 +#else /* _WIN32 */
158 +CHROMIUM_SQLITE_API 204 +CHROMIUM_SQLITE_API
159 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file); 205 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file);
160 +CHROMIUM_SQLITE_API 206 +CHROMIUM_SQLITE_API
161 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs, 207 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs,
162 + int fd, 208 + int fd,
163 + int dirfd, 209 + int dirfd,
164 + sqlite3_file* file, 210 + sqlite3_file* file,
165 + const char* fileName, 211 + const char* fileName,
166 + int noLock); 212 + int noLock);
167 +CHROMIUM_SQLITE_API 213 +CHROMIUM_SQLITE_API
214 +int chromium_sqlite3_get_reusable_file_handle(sqlite3_file* file,
215 + const char* fileName,
216 + int flags,
217 + int* fd);
218 +CHROMIUM_SQLITE_API
168 +void chromium_sqlite3_update_reusable_file_handle(sqlite3_file* file, 219 +void chromium_sqlite3_update_reusable_file_handle(sqlite3_file* file,
169 + int fd, 220 + int fd,
170 + int flags); 221 + int flags);
171 +CHROMIUM_SQLITE_API 222 +CHROMIUM_SQLITE_API
172 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file); 223 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file);
173 +#endif /* _WIN32 */ 224 +#endif /* _WIN32 */
174 +#endif /* CHROMIUM_SQLITE_INTERNALS */ 225 +#endif /* CHROMIUM_SQLITE_INTERNALS */
175 +/* End WebDatabase patch for Chromium */ 226 +/* End WebDatabase patch for Chromium */
176 + 227 +
177 /* 228 /*
178 ** Undo the hack that converts floating point types to integer for 229 ** Undo the hack that converts floating point types to integer for
179 ** builds on processors without floating point support. 230 ** builds on processors without floating point support.
180 -- 231 --
181 2.6.1 232 2.4.5
182 233
OLDNEW
« no previous file with comments | « third_party/sqlite/amalgamation/sqlite3.c ('k') | third_party/sqlite/src/src/os_unix.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698