OLD | NEW |
---|---|
1 From 0a5da8cd79a6b502edc01c40037ae418b2d5c828 Mon Sep 17 00:00:00 2001 | 1 From dfb453c3fe580a2e42cdbdb5196273f41563d562 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 04/10] Modify default VFS to support WebDatabase. | 4 Subject: [PATCH 03/10] 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 | 49 ++++++++++++++++++++++++++++++++++ | 20 third_party/sqlite/src/src/os_unix.c | 49 ++++++++++++++++++++++++++++++++++ |
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 | 23 ++++++++++++++++ | 22 third_party/sqlite/src/src/sqlite.h.in | 23 ++++++++++++++++ |
23 3 files changed, 80 insertions(+) | 23 3 files changed, 80 insertions(+) |
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 791ba5d..fa85638 100644 | 26 index 7f0ebdba6fdf..60981af7e738 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 @@ -1297,6 +1297,12 @@ static int fileHasMoved(unixFile *pFile){ | 29 @@ -1346,6 +1346,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 |
41 #endif | 41 || (u64)buf.st_ino!=pFile->pInode->fileId.ino); |
42 @@ -5554,6 +5560,44 @@ static int findCreateFileMode( | 42 @@ -5640,6 +5646,44 @@ static int findCreateFileMode( |
43 } | 43 } |
44 | 44 |
45 /* | 45 /* |
46 +** Initialize |unixFile| internals of |file| on behalf of chromiumOpen() in | 46 +** Initialize |unixFile| internals of |file| on behalf of chromiumOpen() in |
47 +** WebDatabase SQLiteFileSystemPosix.cpp. Function is a subset of unixOpen(), | 47 +** WebDatabase SQLiteFileSystemPosix.cpp. Function is a subset of unixOpen(), |
48 +** each duplicated piece is marked by "Duplicated in" comment in unixOpen(). | 48 +** each duplicated piece is marked by "Duplicated in" comment in unixOpen(). |
49 +*/ | 49 +*/ |
50 +CHROMIUM_SQLITE_API | 50 +CHROMIUM_SQLITE_API |
51 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* pVfs, | 51 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* pVfs, |
52 + int fd, | 52 + int fd, |
53 + sqlite3_file* pFile, | 53 + sqlite3_file* pFile, |
54 + const char* zPath, | 54 + const char* zPath, |
55 + int noLock, | 55 + int noLock, |
56 + int flags) { | 56 + int flags) { |
57 + unixFile *p = (unixFile *)pFile; | 57 + unixFile *p = (unixFile *)pFile; |
58 + const int eType = flags&0xFFFFFF00; /* Type of file to open */ | 58 + const int eType = flags&0xFFFFFF00; /* Type of file to open */ |
59 + const int ctrlFlags = (noLock ? UNIXFILE_NOLOCK : 0); | 59 + const int ctrlFlags = (noLock ? UNIXFILE_NOLOCK : 0); |
60 + int rc; | 60 + int rc; |
61 + | 61 + |
62 + memset(p, 0, sizeof(unixFile)); | 62 + memset(p, 0, sizeof(unixFile)); |
63 + | 63 + |
64 + /* osStat() will not work in the sandbox, so findReusableFd() will always | 64 + /* osStat() will not work in the sandbox, so findReusableFd() will always |
65 + ** fail, so directly include the failure-case setup then initialize pUnused. | 65 + ** fail, so directly include the failure-case setup then initialize pUnused. |
66 + */ | 66 + */ |
67 + if( eType==SQLITE_OPEN_MAIN_DB ){ | 67 + if( eType==SQLITE_OPEN_MAIN_DB ){ |
68 + p->pUnused = sqlite3_malloc(sizeof(*p->pUnused)); | 68 + p->pUnused = sqlite3_malloc(sizeof(*p->pUnused)); |
69 + if (!p->pUnused) { | 69 + if (!p->pUnused) { |
70 + return SQLITE_NOMEM; | 70 + return SQLITE_NOMEM_BKPT; |
Scott Hess - ex-Googler
2017/03/16 00:40:57
The _BKPT versions are coded so that you can set a
| |
71 + } | 71 + } |
72 + p->pUnused->fd = fd; | 72 + p->pUnused->fd = fd; |
73 + p->pUnused->flags = flags; | 73 + p->pUnused->flags = flags; |
74 + } | 74 + } |
75 + | 75 + |
76 + rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags); | 76 + rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags); |
77 + if( rc!=SQLITE_OK ){ | 77 + if( rc!=SQLITE_OK ){ |
78 + sqlite3_free(p->pUnused); | 78 + sqlite3_free(p->pUnused); |
79 + } | 79 + } |
80 + return rc; | 80 + return rc; |
81 +} | 81 +} |
82 + | 82 + |
83 +/* | 83 +/* |
84 ** Open the file zPath. | 84 ** Open the file zPath. |
85 ** | 85 ** |
86 ** Previously, the SQLite OS layer used three functions in place of this | 86 ** Previously, the SQLite OS layer used three functions in place of this |
87 @@ -5654,6 +5698,7 @@ static int unixOpen( | 87 @@ -5740,6 +5784,7 @@ static int unixOpen( |
88 sqlite3_randomness(0,0); | 88 sqlite3_randomness(0,0); |
89 } | 89 } |
90 | 90 |
91 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ | 91 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ |
92 memset(p, 0, sizeof(unixFile)); | 92 memset(p, 0, sizeof(unixFile)); |
93 | 93 |
94 if( eType==SQLITE_OPEN_MAIN_DB ){ | 94 if( eType==SQLITE_OPEN_MAIN_DB ){ |
95 @@ -5662,6 +5707,7 @@ static int unixOpen( | 95 @@ -5748,6 +5793,7 @@ static int unixOpen( |
96 if( pUnused ){ | 96 if( pUnused ){ |
97 fd = pUnused->fd; | 97 fd = pUnused->fd; |
98 }else{ | 98 }else{ |
99 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ | 99 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ |
100 pUnused = sqlite3_malloc64(sizeof(*pUnused)); | 100 pUnused = sqlite3_malloc64(sizeof(*pUnused)); |
101 if( !pUnused ){ | 101 if( !pUnused ){ |
102 return SQLITE_NOMEM; | 102 return SQLITE_NOMEM_BKPT; |
103 @@ -5739,6 +5785,7 @@ static int unixOpen( | 103 @@ -5825,6 +5871,7 @@ static int unixOpen( |
104 } | 104 } |
105 | 105 |
106 if( p->pUnused ){ | 106 if( p->pUnused ){ |
107 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ | 107 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ |
108 p->pUnused->fd = fd; | 108 p->pUnused->fd = fd; |
109 p->pUnused->flags = flags; | 109 p->pUnused->flags = flags; |
110 } | 110 } |
111 @@ -5819,10 +5866,12 @@ static int unixOpen( | 111 @@ -5903,10 +5950,12 @@ static int unixOpen( |
112 } | 112 } |
113 #endif | 113 #endif |
114 | 114 |
115 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ | 115 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ |
116 rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags); | 116 rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags); |
117 | 117 |
118 open_finished: | 118 open_finished: |
119 if( rc!=SQLITE_OK ){ | 119 if( rc!=SQLITE_OK ){ |
120 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ | 120 + /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */ |
121 sqlite3_free(p->pUnused); | 121 sqlite3_free(p->pUnused); |
122 } | 122 } |
123 return rc; | 123 return rc; |
124 diff --git a/third_party/sqlite/src/src/os_win.c b/third_party/sqlite/src/src/os _win.c | 124 diff --git a/third_party/sqlite/src/src/os_win.c b/third_party/sqlite/src/src/os _win.c |
125 index c54bfd6..00ad6fd 100644 | 125 index 2cb5f7b0c836..94dcd0e047f9 100644 |
126 --- a/third_party/sqlite/src/src/os_win.c | 126 --- a/third_party/sqlite/src/src/os_win.c |
127 +++ b/third_party/sqlite/src/src/os_win.c | 127 +++ b/third_party/sqlite/src/src/os_win.c |
128 @@ -5639,4 +5639,12 @@ int sqlite3_os_end(void){ | 128 @@ -5960,4 +5960,12 @@ int sqlite3_os_end(void){ |
129 return SQLITE_OK; | 129 return SQLITE_OK; |
130 } | 130 } |
131 | 131 |
132 +CHROMIUM_SQLITE_API | 132 +CHROMIUM_SQLITE_API |
133 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) { | 133 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) { |
134 + winFile* winSQLite3File = (winFile*)file; | 134 + winFile* winSQLite3File = (winFile*)file; |
135 + memset(file, 0, sizeof(*file)); | 135 + memset(file, 0, sizeof(*file)); |
136 + winSQLite3File->pMethod = &winIoMethod; | 136 + winSQLite3File->pMethod = &winIoMethod; |
137 + winSQLite3File->h = handle; | 137 + winSQLite3File->h = handle; |
138 +} | 138 +} |
139 + | 139 + |
140 #endif /* SQLITE_OS_WIN */ | 140 #endif /* SQLITE_OS_WIN */ |
141 diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src /sqlite.h.in | 141 diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src /sqlite.h.in |
142 index 59b30cd..e5673fd 100644 | 142 index eaa75fc249e1..fbbf4b9f2db3 100644 |
143 --- a/third_party/sqlite/src/src/sqlite.h.in | 143 --- a/third_party/sqlite/src/src/sqlite.h.in |
144 +++ b/third_party/sqlite/src/src/sqlite.h.in | 144 +++ b/third_party/sqlite/src/src/sqlite.h.in |
145 @@ -7411,6 +7411,29 @@ int sqlite3_strnicmp(const char *, const char *, int); | 145 @@ -7697,6 +7697,29 @@ int sqlite3_strnicmp(const char *, const char *, int); |
146 */ | 146 */ |
147 int sqlite3_strglob(const char *zGlob, const char *zStr); | 147 int sqlite3_strglob(const char *zGlob, const char *zStr); |
148 | 148 |
149 +/* Begin WebDatabase patch for Chromium */ | 149 +/* Begin WebDatabase patch for Chromium */ |
150 +/* Expose some SQLite internals for the WebDatabase vfs. | 150 +/* Expose some SQLite internals for the WebDatabase vfs. |
151 +** DO NOT EXTEND THE USE OF THIS. | 151 +** DO NOT EXTEND THE USE OF THIS. |
152 +*/ | 152 +*/ |
153 +#ifndef CHROMIUM_SQLITE_API | 153 +#ifndef CHROMIUM_SQLITE_API |
154 +#define CHROMIUM_SQLITE_API SQLITE_API | 154 +#define CHROMIUM_SQLITE_API SQLITE_API |
155 +#endif | 155 +#endif |
(...skipping 10 matching lines...) Expand all Loading... | |
166 + int noLock, | 166 + int noLock, |
167 + int flags); | 167 + int flags); |
168 +#endif /* _WIN32 */ | 168 +#endif /* _WIN32 */ |
169 +#endif /* CHROMIUM_SQLITE_INTERNALS */ | 169 +#endif /* CHROMIUM_SQLITE_INTERNALS */ |
170 +/* End WebDatabase patch for Chromium */ | 170 +/* End WebDatabase patch for Chromium */ |
171 + | 171 + |
172 /* | 172 /* |
173 ** CAPI3REF: String LIKE Matching | 173 ** CAPI3REF: String LIKE Matching |
174 * | 174 * |
175 -- | 175 -- |
176 2.7.0 | 176 2.11.0 |
177 | 177 |
OLD | NEW |