[Clean-up] Remove NetworkStats code, which has been dead code since July 2014.
[chromium-blink-merge.git] / third_party / sqlite / README.chromium
blob39e085e2c803b6aa7dfb8107d8e6f66a61ac2156
1 Name: sqlite
2 URL: http://sqlite.org/
3 Version: 3.8.7.4
4 Included In Release: Yes
5 Security Critical: Yes
6 License: Public domain
8 1) Managing differences between SQLite core and Chromium's version.
9 2) Making changes to Chromium SQLite.
10 3) Import new release of SQLite.
11 4) Running SQLite's test suite within the Chromium checkout.
13 ---
15 1) Managing differences between SQLite core and Chromium's version.
17 Chromium maintains some differences WRT SQLite, for reasons beyond this
18 document's remit.  Some differences are bugs we have found and fixed (and
19 hopefully upstreamed), some are fixes we've backported from a later version of
20 SQLite, and some our local changes unlikely to ever be upstreamed.  New versions
21 of SQLite are imported every year or two, at which point the changes need to be
22 reviewed for continued applicability, and sometimes adjusted to reflect upstream
23 code changes.
25 To this end, the repository contains a reference copy of the SQLite source code
26 as of the last import, plus a series of patches which can be applied to
27 re-create the current trunk code.  These patches are generated and processed by
28 git, with the intention of re-creating a changelist series so that importers can
29 use their regular revision-control knowledge to manage import merges.
31 ---
33 2) Making changes to Chromium SQLite.
35 third_party/sqlite/src is the patched source from SQLite.  This is used to
36 generate the amalgamation, a concatenation of all of the files into a giant
37 sqlite3.c.  To prototype, edit in src/, then call
38   ./google_generate_amalgamation.sh
39 to regenerate sqlite3.c.  The code in src/ is much easier to edit, and the
40 SQLite test framework can easily be run.  During development it may be
41 convenient to modify sqlite.gyp (or BUILD.gn) based on src/main.mk to just pull
42 in the src/ files rather than sqlite3.c.
44 Once your patch is complete, squash it down into a reasonable CL, then
45 re-generate the patches.  This is a truncated version of the import flow.  The
46 following is written like a shell script to allow copy/paste to a shell, ignore
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).
50 # Everything based in sqlite subdir.
51 cd third_party/sqlite
53 BASE=3080704
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.
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.
72 #### Cherry-pick your change.
73 git cherry-pick <your change>
74 # This branch should be identical to your development branch, except
75 # amalgamation.
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}"
83 # Re-generate the amalgamation.
84 ./google_generate_amalgamation.sh
85 git commit -m 'google_generate_amalgamation.sh' amalgamation/
86 # At this point everything should build and work.
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?
95 # Find a sucker.  Send review.
97 ---
99 3) Import new release of SQLite.
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.
111 # Everything based in sqlite subdir.
112 cd third_party/sqlite
114 BASE=3070603
115 VERSION=3080704
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.
126 #### Convert patches into CLs.
127 git checkout -b sqlite_${BASE}_patched master
128 git rebase sqlite_${BASE}
129 git am --keep-non-patch patches/*.patch
130 git diff master
131 # This branch should be identical to master.
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 # Sometimes DOS line endings sneak into the source code.  This command works on
145 # OSX and Linux and fixes those files, but double-check the results before
146 # committing:
147 egrep --exclude="*.eps" --exclude="*.ico" --exclude="*.jpg" \
148       --exclude="*.gif" --exclude="*.tiff" --exclude="*.vsix" -URl '\r' . | \
149     LANG=C xargs sed -i~ -e $'s/\r$//'
150 git commit -m "Begin import of sqlite-src-${VERSION}" sqlite-src-${VERSION}
151 rm -rf src
152 cp -a sqlite-src-${VERSION} src
153 # -f includes ignored files, of which there are a couple.
154 git add -f src/
155 git commit -m "Update src to sqlite-src-${VERSION}" src/
156 # This branch is unlikely to build.
158 #### Create a branch for merging the CLs to the new SQLite.
159 git checkout -b sqlite_${VERSION}_patched master
160 git rebase sqlite_${VERSION}
162 # Replay the  patches onto this branch.   There will be merge  conflicts to fix.
163 # My approach is  generally to just accept them prefering  the patch's change in
164 # case of conflicts, and then resolve the conflicts as a second pass.
165 git rebase --onto zsqlite_${VERSION}_patched zsqlite_${BASE} zsqlite_${BASE}_patched
166 # Once everything is resolved, re-generate the amalgamation.
167 ./google_generate_amalgamation.sh
168 git commit -a -m "google_generate_amalgamation.sh"
170 # The goal is to have a set of reasonably-independent CLs which can be
171 # understood separately, so that future importers can sensibly determine how to
172 # handle conflicts.  So use git-rebase and slipstream fixups back into their
173 # original CL until things are relatively clean.
175 # Rebuild the patch set.
176 git rm patches/*
177 # This assumes that HEAD is still the google_generate_amalgamation.sh checkin.
178 git format-patch --output-directory=patches sqlite_${VERSION}..HEAD^
179 git add patches/*.patch
180 git commit -m "Rebuild patches for sqlite_${VERSION}"
182 # Drop the old version of SQLite.
183 git rm -r sqlite_${BASE}
184 git commit -m 'Remove sqlite_${BASE}' -- sqlite_${BASE}
186 # Do a squash upload.  Edit the commit message appropriately to reflect anything
187 # from <http://www.sqlite.org/changes.html> which might be deemed important.
188 # Don't enumerate all of the patch messages, those are assumed, but do reference
189 # any material changes made.
190 # TODO(shess) Describe an appropriate comment style.  Seems like it should at
191 # least include the SQLite version number.  Meanwhile, look in the logs for past
192 # commits to model things on.
194 Find a sucker.  Send review.
196 TODO(shess): It is basically impossible to trybot the entire change, it takes
197 forever to upload and sqlite3.c breaks things because it's too large.  I have a
198 nasty Perl script to break up sqlite3.c into pieces which are then included by a
199 single .c file, but there must be a better way.  Perhaps just have sqlite.gyp
200 include all the .c files directly?
202 Note that things can be broken down differently, if you prefer.  For instance,
203 adding the new version of the SQLite distro and removing the old one can be
204 distinct CLs.
206 --------------------------------------------
208 4) Running SQLite's test suite within the Chromium checkout.
210 Prerequisites: The test suite requires tcl-dev and libicu-dev.  Install those on
211 Ubuntu like:
212   sudo apt-get install tcl8.5-dev libicu-dev
213 On OSX, I use Homebrew:
214   sudo port install tcl
215 TODO(shess): OSX works fine with either tcl8.5 or tcl8.6, but on Ubuntu 14.04.1
216 with tcl8.6, I see crashes in some of the WAL tests.  Revisit using tcl8.6 on
217 next import of SQLite.
218 TODO(shess): That Homebrew command has installed tcl8.6 for a few years, so the
219 above may require some adaptation of the build files.
221 cd third_party/sqlite/src
222 mkdir build
223 cd build
224 make -j -f ../Makefile.linux-gcc testfixture sqlite3
225 make -f ../Makefile.linux-gcc test > /tmp/test.log
226 egrep 'errors out of' /tmp/test.log 
227 # Show broken tests:
228 egrep 'Failures on these tests:' /tmp/test.log
229 # Broken tests will also show lines ending in "..." instead of "... Ok".
231 In version 3.8.7.4 on OSX 10.9.5, I see:
232    6 errors out of 138390 tests
233 The failed tests are:
234    pager4-1.3 pager4-1.4 pager4-1.5 pager4-1.9 pager4-1.10 pager4-1.11
235 This is due to the change in os_unix.c fileHasMoved() to support WebDatabase.
236 Commenting out the early return allows them to succeed.
238 In version 3.8.7.4 on Ubuntu 14.04 I see:
239    9 errors out of 138920 tests
240 The failed tests are:
241    oserror-1.1.1 oserror-1.1.2 oserror-1.1.3
242    pager4-1.3 pager4-1.4 pager4-1.5 pager4-1.9 pager4-1.10 pager4-1.11
243 The oserror tests fail because there are too many fds available, and can be
244 fixed by running "ulimit -n 1024" before the test.  The pager4 tests are failing
245 for the same reason as above.
249 NOTE(shess): On Ubuntu it is possible to run the tests in a tmpfs something
250 like:
252 TMPFS=/dev/shm/sqlite_build
253 BUILD=$PWD
254 mkdir $TMPFS
255 (cd $TMPFS ; $BUILD/testfixture $BUILD/../test/veryquick.test >/tmp/test.log)
257 This is faster, but it is plausible that different things are being tested than
258 real-world use.