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

Side by Side Diff: third_party/sqlite/README.chromium

Issue 885473002: [sql] Rewrite sqlite patching "system". (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo in readme. Created 5 years, 10 months 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 | « no previous file | third_party/sqlite/amalgamation/sqlite3.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 Name: sqlite 1 Name: sqlite
2 URL: http://sqlite.org/ 2 URL: http://sqlite.org/
3 Version: 3.7.6.3 3 Version: 3.7.6.3
4 Included In Release: Yes 4 Included In Release: Yes
5 Security Critical: Yes 5 Security Critical: Yes
6 License: Public domain 6 License: Public domain
7 7
8 Instructions for importing a new release of SQLite from sqlite.org. 8 1) Managing differences between SQLite core and Chromium's version.
9 9 2) Making changes to Chromium SQLite.
10 Note: our current base version is 3.7.6.3. 10 3) Import new release of SQLite.
11 11 4) Running SQLite's test suite within the Chromium checkout.
12 First, you need to be on Linux. 12
13 13 ---
14 # Determine the versions of the release you want and the release we currently 14
15 # have. (See the VERSION file to determine which release we currently have.) 15 1) Managing differences between SQLite core and Chromium's version.
16 # You may wish to consult http://www.sqlite.org/changes.html to find out what 16
17 # changes have been made in each release. 17 Chromium maintains some differences WRT SQLite, for reasons beyond this
18 # Note - this is just an example. Always refer to the version above for our 18 document's remit. Some differences are bugs we have found and fixed (and
19 # real current version. 19 hopefully upstreamed), some are fixes we've backported from a later version of
20 # Set some variables to remember the versions, e.g.: 20 SQLite, and some our local changes unlikely to ever be upstreamed. New versions
21 BASE=3.7.6.3 21 of SQLite are imported every year or two, at which point the changes need to be
22 LATEST=3.7.6.4 22 reviewed for continued applicability, and sometimes adjusted to reflect upstream
23 23 code changes.
24 # Get to the src/third_party directory in your Chromium client: 24
25 cd src/third_party 25 To this end, the repository contains a reference copy of the SQLite source code
26 26 as of the last import, plus a series of patches which can be applied to
27 # Download the .tar.gz files for the releases: 27 re-create the current trunk code. These patches are generated and processed by
28 # (If the URL changes you might need to find the new one.) 28 git, with the intention of re-creating a changelist series so that importers can
29 # TODO(shess): Rewrite this to track the new naming format. Meanwhile, 29 use their regular revision-control knowledge to manage import merges.
30 # manually navigate to www.sqlite.org and find downloads, use "legacy" version. 30
31 wget http://www.sqlite.org/sqlite-$BASE.tar.gz 31 ---
32 wget http://www.sqlite.org/sqlite-$LATEST.tar.gz 32
33 33 2) Making changes to Chromium SQLite.
34 # Extract the vanilla current and desired versions: 34
35 tar xzf sqlite-$BASE.tar.gz 35 third_party/sqlite/src is the patched source from SQLite. This is used to
36 tar xzf sqlite-$LATEST.tar.gz 36 generate the amalgamation, a concatenation of all of the files into a giant
37 37 sqlite3.c. To prototype, edit in src/, then call
38 # Use kdiff3 to merge the changes: 38 ./google_generate_amalgamation.sh
39 kdiff3 -m sqlite-$BASE sqlite-$LATEST sqlite 39 to regenerate sqlite3.c. The code in src/ is much easier to edit, and the
40 40 SQLite test framework can easily be run. During development it may be
41 # Resolve any conflicts. Figure out if we've got everything we should 41 convenient to modify sqlite.gyp (or BUILD.gn) based on src/main.mk to just pull
42 # have (see below), or if we can omit any changes we no longer need. 42 in the src/ files rather than sqlite3.c.
43 43
44 # Change to the sqlite directory: 44 Once your patch is complete, squash it down into a reasonable CL, then
45 cd sqlite 45 re-generate the patches. This is a truncated version of the import flow. The
46 46 following is written like a shell script to allow copy/paste to a shell, ignore
47 # Run the google_generate_amalgamation.sh script: 47 comments and change the obvious lines. These instructions should work on Linux
48 or OSX. They may assume a modern version of git (I'm using 2.2.1).
49
50 # Everything based in sqlite subdir.
51 cd third_party/sqlite
52
53 BASE=3070603
54
55 #### Create a reference branch.
56 git checkout -b sqlite_${BASE} master
57 git rm -rf src
58 cp -a sqlite-src-${BASE} src
59 # -f includes ignored files, of which there are a couple.
60 git add -f src/
61 git commit -m "Reset to sqlite-src-${BASE}"
62 # This branch is unlikely to build.
63
64 #### Create a reference branch with patches applied.
65 git checkout -b sqlite_${BASE}_patched master
66 git rebase sqlite_${BASE}
67 git am --keep-non-patch patches/*.patch
68 git diff master
69 # This branch should be identical to master, unless someone forgot to export
70 # their changes into a patch. If so, do that as a separate CL and start over.
71
72 #### Cherry-pick your change.
73 git cherry-pick <your change>
74 # This branch should be identical to your development branch, except
75 # amalgamation.
76
77 # Rebuild the patch set.
78 git rm patches/*
79 git format-patch --output-directory=patches sqlite_${BASE}..HEAD
80 git add patches/*.patch
81 git commit -m "Rebuild patches for sqlite_${VERSION}"
82
83 # Re-generate the amalgamation.
48 ./google_generate_amalgamation.sh 84 ./google_generate_amalgamation.sh
85 git commit -m 'google_generate_amalgamation.sh' amalgamation/
86 # At this point everything should build and work.
87
88 # Do a squash upload. This should add your single patch to patches/, and apply
89 # the changes your patch represents to src/ and amalgamation/. Other patches
90 # will have hash changes. A sensible check-in comment would be something like
91 # the patch's checkin comment, plus "regenerate amalgamation and generate patch
92 # file."
93 # TODO(shess): Should hash changes be checked in, or backed out?
49 94
50 # Find a sucker. Send review. 95 # Find a sucker. Send review.
51 # TODO(shess) Describe an appropriate comment style. Seems like it 96
52 # should at least include the SQLite version number. 97 ---
98
99 3) Import new release of SQLite.
100
101 Importing a new SQLite involves merging our local changes with SQLite's changes.
102 Like any other merge, this may involve dropping some CLs while modifying others.
103 The basic idea below is to generate git branches to work with:
104 sqlite_${BASE} - current version without patches
105 sqlite_${BASE}_patched - current version with patches applied via git CLs
106 sqlite_${VERSION} - new version without patches
107 sqlite_${VERSION}_patched - new version with patches applied via git CLs
108 At this point, squashing sqlite_${VERSION}_patched to master gives exactly a CL
109 suitable for committing.
110
111 # Everything based in sqlite subdir.
112 cd third_party/sqlite
113
114 BASE=3070603
115 VERSION=3080704
116
117 #### Create current-SQLite reference branch.
118 git checkout -b sqlite_${BASE} master
119 rm -rf src
120 cp -a sqlite-src-${BASE} src
121 # -f includes ignored files, of which there are a couple.
122 git add -f src/
123 git commit -m "Reset to sqlite-src-${BASE}"
124 # This branch is unlikely to build.
125
126 #### Convert patches into CLs.
127 git checkout -b sqlite_${BASE}_patched master
128 git rebase sqlite_${BASE}
129 git am patches/*.patch
130 git diff master
131 # This branch should be identical to master.
132
133 #### Create new-SQLite reference branch.
134 git checkout -b sqlite_${VERSION} master
135 git rebase sqlite_${BASE}
136 # SQLite's download page is at <http://www.sqlite.org/download.html>. Scroll to
137 # "Legacy Source Code Distribution Formats", and grab sqlite-src-<VERSION>.zip.
138 # Unzip it and pull it into the repo.
139 wget http://www.sqlite.org/2014/sqlite-src-${VERSION}.zip
140 unzip sqlite-src-${VERSION}.zip
141 rm sqlite-src-${VERSION}.zip
142 # -f includes ignored files, of which there are a couple.
143 git add -f sqlite-src-${VERSION}/
144 git commit -m "Begin import of sqlite-src-${VERSION}" sqlite-src-${VERSION}
145 rm -rf src
146 cp -a sqlite-src-${VERSION} src
147 # -f includes ignored files, of which there are a couple.
148 git add -f src/
149 git commit -m "Update src to sqlite-src-${VERSION}" src/
150 # This branch is unlikely to build.
151
152 #### Create a branch for merging the CLs to the new SQLite.
153 git checkout -b sqlite_${VERSION}_patched master
154 git rebase sqlite_${VERSION}
155
156 # Replay the patches onto this branch. There will be merge conflicts to fix.
157 # My approach is generally to just accept them prefering the patch's change in
158 # case of conflicts, and then resolve the conflicts as a second pass.
159 git rebase --onto zsqlite_${VERSION}_patched zsqlite_${BASE} zsqlite_${BASE}_pat ched
160 # Once everything is resolved, re-generate the amalgamation.
161 ./google_generate_amalgamation.sh
162 git commit -a -m "google_generate_amalgamation.sh"
163
164 # The goal is to have a set of reasonably-independent CLs which can be
165 # understood separately, so that future importers can sensibly determine how to
166 # handle conflicts. So use git-rebase and slipstream fixups back into their
167 # original CL until things are relatively clean.
168
169 # Rebuild the patch set.
170 git rm patches/*
171 # This assumes that HEAD is still the google_generate_amalgamation.sh checkin.
172 git format-patch --output-directory=patches sqlite_${VERSION}..HEAD^
173 git add patches/*.patch
174 git commit -m "Rebuild patches for sqlite_${VERSION}"
175
176 # Drop the old version of SQLite.
177 git rm -r sqlite_${BASE}
178 git commit -m 'Remove sqlite_${BASE}' -- sqlite_${BASE}
179
180 # Do a squash upload. Edit the commit message appropriately to reflect anything
181 # from <http://www.sqlite.org/changes.html> which might be deemed important.
182 # Don't enumerate all of the patch messages, those are assumed, but do reference
183 # any material changes made.
184 # TODO(shess) Describe an appropriate comment style. Seems like it should at
185 # least include the SQLite version number. Meanwhile, look in the logs for past
186 # commits to model things on.
187
188 Find a sucker. Send review.
189
190 TODO(shess): It is basically impossible to trybot the entire change, it takes
191 forever to upload and sqlite3.c breaks things because it's too large. I have a
192 nasty Perl script to break up sqlite3.c into pieces which are then included by a
193 single .c file, but there must be a better way. Perhaps just have sqlite.gyp
194 include all the .c files directly?
195
196 Note that things can be broken down differently, if you prefer. For instance,
197 adding the new version of the SQLite distro and removing the old one can be
198 distinct CLs.
53 199
54 -------------------------------------------- 200 --------------------------------------------
55 201
56 For reference, all of our local patches are also kept as .patch files in the 202 4) Running SQLite's test suite within the Chromium checkout.
57 sqlite directory. Here is a list of the patches, in the order they should be 203
58 applied to a vanilla SQLite (of the version we currently have) to get, in 204 Prerequisites: The test suite requires tcl-dev and libicu-dev. Install those on
59 principle, exactly what is checked in: 205 Ubuntu like:
60 206 sudo apt-get install tcl8.5-dev libicu-dev
61 misc.patch 207 On OSX, I use Homebrew:
62 safe-tolower.patch 208 sudo port install tcl
63 fts2.patch 209 TODO(shess): OSX works fine with either tcl8.5 or tcl8.6, but on Ubuntu 14.04.1
64 fts3.patch 210 with tcl8.6, I see crashes in some of the WAL tests. Revisit using tcl8.6 on
65 fts3_85522.patch 211 next import of SQLite.
66 icu-regexp.patch 212 TODO(shess): That Homebrew command has installed tcl8.6 for a few years, so the
67 icu-shell.patch 213 above may require some adaptation of the build files.
68 attach-integer.patch 214
69 webdb.patch 215 cd third_party/sqlite/src
70 test.patch
71 mac_time_machine.patch
72 system-sqlite.patch
73 sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch
74 misalignment.patch
75 memcmp.patch
76 separate_cache_pool.patch
77 recover.patch
78
79 So, e.g. you could do this to apply all our patches to vanilla SQLite:
80
81 cd sqlite-$LATEST
82 patch -p0 < ../sqlite/misc.patch
83 patch -p0 < ../sqlite/fts2.patch
84 patch -p0 < ../sqlite/fts3.patch
85 patch -p0 < ../sqlite/fts3_85522.patch
86 patch -p0 < ../sqlite/icu-shell.patch
87 patch -p0 < ../sqlite/webdb.patch
88 patch -p0 < ../sqlite/test.patch
89 patch -p0 < ../sqlite/mac_time_machine.patch
90 patch -p0 < ../sqlite/system-sqlite.patch
91 patch -p0 < ../sqlite/sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch
92 patch -p0 < ../sqlite/misalignment.patch
93 patch -p0 < ../sqlite/memcmp.patch
94 patch -p0 < ../sqlite/separate_cache_pool.patch
95 patch -p0 < ../sqlite/recover.patch
96
97 This will only be the case if all changes we make also update the corresponding
98 patch files. Therefore please remember to do that whenever you make a change!
99
100 Descriptions of the changes we've made can be found at the bottom of this file.
101
102 --------------------------------------------
103
104 How to run the SQLite tests for the Chromium version of SQLite on Linux.
105
106 Prerequisties: On my corp Ubuntu 8.04 workstation, I needed to install the
107 following packages:
108 sudo apt-get install tcl8.4-dev libicu-dev
109
110 cd src/third_party/sqlite/src
111 mkdir build 216 mkdir build
112 cd build 217 cd build
113 make -f ../Makefile.linux-gcc testfixture 218 make -f ../Makefile.linux-gcc testfixture sqlite3
219 # NOTE(shess): 64-bit builds under 3.7.6.3 show various warnings. AFAICT they
220 # don't impact test operation. Later versions are better so I'm not fixing it.
114 make -f ../Makefile.linux-gcc test > /tmp/test.log 221 make -f ../Makefile.linux-gcc test > /tmp/test.log
115 egrep -v 'Ok$' /tmp/test.log 222 egrep 'errors out of' /tmp/test.log
116 # For an ideal test run, you would see: 223 # Show broken tests:
117 # 0 errors out of 57887 tests 224 egrep 'Failures on these tests:' /tmp/test.log
118 # However, the current situation on my corp Linux Ubuntu 8.04 machine, with 225 # Broken tests will also show lines ending in "..." instead of "... Ok".
119 # test run on a locally mounted directory, is the failure of: 226
120 # "rollback-2.3", "tkt3457-1.4" 227 In version Right now on OSX, I see no failures:
121 # I do not know why, but it is not related to our fts2.c changes -- I backed 228 0 errors out of 77849 tests
122 # them out to check. 229
123 230 In version 3.7.6.3 on Ubuntu 14.04 I see some failures:
124 Chris Evans <cevans@google.com>, Oct 1, 2009 231 83 errors out of 78604 tests
125 232 - precision in formatting numbers in enc4.test.
126 -------------------------------------------- 233 - case sensitivity in nan.test.
127 234 - oserror-1.1.[1-3] fail because there are too many fds available. Fixed with
128 As of May 07, 2010, these are our changes from sqlite_vendor: 235 "ulimit -n 1024".
129 236
130 - A fix for a crash passing an integer expression to ATTACH / DETACH. See 237 --
131 attach-integer.patch 238
132 - A fix for a crash mis-calling the REGEXP() function of the ICU extension. 239 NOTE(shess): On Ubuntu it is possible to run the tests in a tmpfs something
133 See icu-regexp.patch 240 like:
134 - A large number of fts2 robustness fixes against corrupt data in its metadata 241
135 tables. 242 TMPFS=/dev/shm/sqlite_build
136 - fts2.c disables fts2_tokenizer(). 243 BUILD=$PWD
137 - fts3.c disables fts3_tokenizer(). 244 mkdir $TMPFS
138 - Tweak to SQLITE_EXTENSION_INIT* in sqlite3ext.h. 245 (cd $TMPFS ; $BUILD/testfixture $BUILD/../test/veryquick.test >/tmp/test.log)
139 - That implied a change in src/test_autoext.c for testing. 246
140 - Added fts.test in tests, modified quick.test. 247 This is faster, but it is plausible that different things are being tested than
141 - Modifications to Makefile.linux-gcc and main.mk for compiling 248 real-world use.
142 SQLite tests.
143 - Compile warning (cast to void* for sqlite3_free) fixed in func.c.
144 - Avoid using tolower() in fts code which causes problem in some locales, see:
145 safe-tolower.patch
146 http://crbug.com/15261
147 http://www.sqlite.org/src/tktview/991789d9f3136a0460dc83a33e815c1aa9757c26
148 - Check that the third argument to memset() is nonzero in expr.c to avoid
149 a linker warning when the compiler can optimize it to a constant zero
150 (e.g. see http://www.sqlite.org/cvstrac/tktview?tn=3765,39)
151
152 Changes from Chrome:
153 - I marked all changes I made with "evanm", so you can find them with
154 "grep evanm *".
155 - Most files include sqlite3ext.h with SQLITE_CORE #defined, but two don't:
156 fts2_tokenizer.c and icu.c. Without this #define, the calls in
157 fts2_tokenizer.c try to go through some pointer to the sqlite API instead
158 of calling the functions directly (to work as a loadable module), but then
159 crash (because the other files never initialize that loadable module
160 support). As a hack I #defined it in these files, but it'd be nice to
161 figure out what really ought to happen here (perhaps this file is new and
162 hasn't been tested to verify it works right). Update: Seems this is an
163 issue we get because we're using fts2 instead of fts3.
164 - shell_icu_win.c and shell_icu_linux.c are Chrome-specific files used to load
165 our ICU data. shell.c has been modifed to call into these files.
166 - fts2_icu.c and fts3_icu.c have a critical bug. U8_NEXT is used over
167 a UTF-16 string. It's rep$ by U16_NEXT (jungshik)
168 - Added a new function chromium_sqlite3_initialize_win_sqlite3_file()
169 at the end of os_win.c. It allows the Windows-specific Chromium VFS
170 to reuse most of the win32 SQLite VFS.
171 - Added a new function
172 chromium_sqlite3_initialize_unix_sqlite3_file() and made
173 fillInUnixFile() non-static in os_unix.c. It allows the
174 Linux-specific Chromium VFS to reuse most of the unix SQLite VFS.
175 - Exposed three functions that deal with unused file descriptors in
176 os_unix.c, to allow Chromium's Posix VFS implementation in
177 WebKit/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp
178 to correctly implement the "unused file descriptors" logic in the
179 xDlOpen() method. The new functions are
180 chromium_sqlite3_get_reusable_file_handle(),
181 chromium_sqlite3_update_reusable_file_handle() and
182 chromium_sqlite3_destroy_reusable_file_handle(). Also, added the
183 chromium_sqlite3_fill_in_unix_sqlite3_file() function that calls
184 fillInUnixFile(), which will be made static again as soon as a
185 WebKit patch using the new function lands.
186 - From mac_time_machine.patch:
187 When __APPLE__ and when creating a -journal file with any unix-type vfs,
188 determine if the database for which the journal is being created has been
189 excluded from being backed up using Apple's Time Machine and if so then also
190 exclude the journal. These changes were made in pager.c with includes of
191 Apple interfaces being made in sqliteInt.h. In order to eliminate a symbol
192 conflict with an Apple library after amalgamation it was also necessary to
193 rename fts3_porter.c's 'cType' to 'vOrCType'.
194 - fts3_85522.patch allows fts3 to work if PRAGMA is not authorized.
195 - src/recover.c file implements a virtual table which can read
196 through corruption.
197 - Enable the macro 'SQLITE_TEMP_STORE=3' for Android.
198 - memcmp.patch backports ASAN-related fixes from SQLite trunk.
OLDNEW
« no previous file with comments | « no previous file | third_party/sqlite/amalgamation/sqlite3.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698