xref: /aosp_15_r20/external/sqlite/README-upgrade.md (revision a3141fd39888aecc864dfb08485df64ff6c387f9)
1*a3141fd3SAndroid Build Coastguard Worker## Upgrading SQLite
2*a3141fd3SAndroid Build Coastguard Worker
3*a3141fd3SAndroid Build Coastguard WorkerThis document lists the steps needed to upgrade the sources in this repository
4*a3141fd3SAndroid Build Coastguard Workerwith the latest revision from upstream.
5*a3141fd3SAndroid Build Coastguard Worker
6*a3141fd3SAndroid Build Coastguard Worker## Source Directory
7*a3141fd3SAndroid Build Coastguard Worker
8*a3141fd3SAndroid Build Coastguard WorkerThe upgrade takes place on `aosp-main`. The primary directory is below.
9*a3141fd3SAndroid Build Coastguard Worker
10*a3141fd3SAndroid Build Coastguard Worker```text
11*a3141fd3SAndroid Build Coastguard Workerexternal/sqlite
12*a3141fd3SAndroid Build Coastguard Worker```
13*a3141fd3SAndroid Build Coastguard Worker
14*a3141fd3SAndroid Build Coastguard WorkerThe upgrade steps are:
15*a3141fd3SAndroid Build Coastguard Worker
16*a3141fd3SAndroid Build Coastguard Worker*   Select a version for the upgrade.  Note the year it was released by sqlite.org.
17*a3141fd3SAndroid Build Coastguard Worker*   Find the autoconf amalgamation tarball. For release 3.42.0, the URL is
18*a3141fd3SAndroid Build Coastguard Worker    [sqlite-autoconf-3420000.tar.gz](https://sqlite.org/2023/sqlite-autoconf-3420000.tar.gz).
19*a3141fd3SAndroid Build Coastguard Worker*   Change to the directory `external/sqlite` in the workspace.
20*a3141fd3SAndroid Build Coastguard Worker*   Run the script `UPDATE-SOURCE.bash`. This script is executable. The
21*a3141fd3SAndroid Build Coastguard Worker    arguments are the sqlite release year and the version. Invoke the script without
22*a3141fd3SAndroid Build Coastguard Worker    arguments for an example.
23*a3141fd3SAndroid Build Coastguard Worker
24*a3141fd3SAndroid Build Coastguard Worker`UPDATE-SOURCE.bash` may fail if the Android patch cannot be applied cleanly. If
25*a3141fd3SAndroid Build Coastguard Workerthis happens, correct the patch failures by hand and rebuild the Android patch
26*a3141fd3SAndroid Build Coastguard Workerfile. Use the script `REBUILD-ANDROID-PATCH.bash` to rebuild the patch file.
27*a3141fd3SAndroid Build Coastguard WorkerThis script takes a single argument which is the same version number that was
28*a3141fd3SAndroid Build Coastguard Workergiven to `UPDATE-SOURCE.bash`.  Then rerun `UPDATE-SOURCE.bash`. It is important
29*a3141fd3SAndroid Build Coastguard Workerthat `UPDATE-SOURCE.bash` run without errors.
30*a3141fd3SAndroid Build Coastguard Worker
31*a3141fd3SAndroid Build Coastguard WorkerOnce the scripts have completed, there will be a directory containing the new
32*a3141fd3SAndroid Build Coastguard Workersource files.  The directory is named after the sqlite release and exists in
33*a3141fd3SAndroid Build Coastguard Workerparallel with other sqlite release directories.  For release 3.42.0, the
34*a3141fd3SAndroid Build Coastguard Workerdirectory name is `external/sqlite/dist/sqlite-autoconf-3420000`.
35*a3141fd3SAndroid Build Coastguard Worker
36*a3141fd3SAndroid Build Coastguard Worker## Flagging
37*a3141fd3SAndroid Build Coastguard Worker
38*a3141fd3SAndroid Build Coastguard WorkerThe release of sqlite can be controlled by trunk-stable build flags.  The flag
39*a3141fd3SAndroid Build Coastguard Workeris `RELEASE_PACKAGE_LIBSQLITE3`.  The value of that flag is the 7-digit sqlite
40*a3141fd3SAndroid Build Coastguard Workerrelease number (e.g., 3420000).  Any target that respects trunk-stable flags
41*a3141fd3SAndroid Build Coastguard Workerwill use the source in `external/sqlite/dist/sqlite-autoconf-FLAG`.  Not all
42*a3141fd3SAndroid Build Coastguard Workertargets respect the trunk-stable flags, however.  Such targets use the directory
43*a3141fd3SAndroid Build Coastguard Worker`external/sqlite/dist/sqlite-default`.
44*a3141fd3SAndroid Build Coastguard Worker
45*a3141fd3SAndroid Build Coastguard WorkerA new release of sqlite can be promoted to `trunk` by setting the flag to the
46*a3141fd3SAndroid Build Coastguard Workerproper release string.  Once a new release of sqlite has been promoted to
47*a3141fd3SAndroid Build Coastguard Worker`next`, it is best practice to change the symbolic link `sqlite-default` to
48*a3141fd3SAndroid Build Coastguard Workerpoint to the new release.  This ensures that any target that does not honor
49*a3141fd3SAndroid Build Coastguard Workerbuild flags will use the newly promoted release.
50*a3141fd3SAndroid Build Coastguard Worker
51*a3141fd3SAndroid Build Coastguard WorkerFinally, after the new sqlite release has been delivered in an Android update,
52*a3141fd3SAndroid Build Coastguard Workerold sqlite release directories can be deleted.
53*a3141fd3SAndroid Build Coastguard Worker
54*a3141fd3SAndroid Build Coastguard Worker## LICENSE
55*a3141fd3SAndroid Build Coastguard Worker
56*a3141fd3SAndroid Build Coastguard WorkerThis file contains the license that allows Android to use the third-party
57*a3141fd3SAndroid Build Coastguard Workersoftware. SQLite is unusual because it has no license: it is in the public
58*a3141fd3SAndroid Build Coastguard Workerdomain. The current file content is below.
59*a3141fd3SAndroid Build Coastguard Worker
60*a3141fd3SAndroid Build Coastguard Worker```text
61*a3141fd3SAndroid Build Coastguard WorkerThe author disclaims copyright to this source code.  In place of
62*a3141fd3SAndroid Build Coastguard Workera legal notice, here is a blessing:
63*a3141fd3SAndroid Build Coastguard Worker
64*a3141fd3SAndroid Build Coastguard Worker   May you do good and not evil.
65*a3141fd3SAndroid Build Coastguard Worker   May you find forgiveness for yourself and forgive others.
66*a3141fd3SAndroid Build Coastguard Worker   May you share freely, never taking more than you give.
67*a3141fd3SAndroid Build Coastguard Worker```
68*a3141fd3SAndroid Build Coastguard Worker
69*a3141fd3SAndroid Build Coastguard Worker## CTS Version Test
70*a3141fd3SAndroid Build Coastguard Worker
71*a3141fd3SAndroid Build Coastguard WorkerThere is a CTS test that verifies the SQLite version. This must be updated as
72*a3141fd3SAndroid Build Coastguard Workerwell and it must be updated within `aosp-main` at the same time as the source.
73*a3141fd3SAndroid Build Coastguard Worker
74*a3141fd3SAndroid Build Coastguard Worker```text
75*a3141fd3SAndroid Build Coastguard Workercts/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
76*a3141fd3SAndroid Build Coastguard Worker```
77*a3141fd3SAndroid Build Coastguard Worker
78*a3141fd3SAndroid Build Coastguard WorkerFind and update the function `testSqliteLibraryVersion()`.  This function must
79*a3141fd3SAndroid Build Coastguard Workerbe updated as soon as a new sqlite release is installed in `trunk_staging`, and
80*a3141fd3SAndroid Build Coastguard Workerthe function must accept old and new sqlite releases. Once a new release has
81*a3141fd3SAndroid Build Coastguard Workerbeen committed to `next`, old releases can be rejected by this function.
82*a3141fd3SAndroid Build Coastguard Worker
83*a3141fd3SAndroid Build Coastguard WorkerNote that the CTS test is sometimes propagated to branches for older Android
84*a3141fd3SAndroid Build Coastguard Workerreleases, which do not use the latest sqlite release.  If that happens, the CTS
85*a3141fd3SAndroid Build Coastguard Workertest will have to accept both the old and new sqlite releases.
86*a3141fd3SAndroid Build Coastguard Worker
87*a3141fd3SAndroid Build Coastguard Worker## package.html
88*a3141fd3SAndroid Build Coastguard Worker
89*a3141fd3SAndroid Build Coastguard Worker```text
90*a3141fd3SAndroid Build Coastguard Workerframeworks/base/core/java/android/database/sqlite/package.html
91*a3141fd3SAndroid Build Coastguard Worker```
92*a3141fd3SAndroid Build Coastguard Worker
93*a3141fd3SAndroid Build Coastguard WorkerThis is a documentation file that, among other things, maps SQLite versions to
94*a3141fd3SAndroid Build Coastguard WorkerAndroid API levels. It should be updated every time SQLite is upgraded and on
95*a3141fd3SAndroid Build Coastguard Workerevery Android API bump. There is a small problem with API names: Android usually
96*a3141fd3SAndroid Build Coastguard Workerprefers not to publicize the new API level until it is official, so care must be
97*a3141fd3SAndroid Build Coastguard Workertaken not to expose unofficial API levels through this file.
98*a3141fd3SAndroid Build Coastguard Worker
99*a3141fd3SAndroid Build Coastguard WorkerThe current plan for modifying this file when SQLite is upgraded is to add a new
100*a3141fd3SAndroid Build Coastguard Workerrow, using "latest" as the API level. The file should also be updated
101*a3141fd3SAndroid Build Coastguard Workerappropriately when a new API level is formally announced.
102*a3141fd3SAndroid Build Coastguard Worker
103*a3141fd3SAndroid Build Coastguard WorkerThis file probably should be modified in an Android branch (not AOSP). That way
104*a3141fd3SAndroid Build Coastguard Workerit enters public view with the official release process.
105*a3141fd3SAndroid Build Coastguard Worker
106*a3141fd3SAndroid Build Coastguard Worker## Recommended Tests
107*a3141fd3SAndroid Build Coastguard Worker
108*a3141fd3SAndroid Build Coastguard WorkerThe following tests are recommended before committing an update:
109*a3141fd3SAndroid Build Coastguard Worker
110*a3141fd3SAndroid Build Coastguard Worker```text
111*a3141fd3SAndroid Build Coastguard WorkerCtsScopedStorageDeviceOnlyTest
112*a3141fd3SAndroid Build Coastguard WorkerCtsScopedStorageBypassDatabaseOperationsTest
113*a3141fd3SAndroid Build Coastguard WorkerCtsScopedStorageGeneralTest
114*a3141fd3SAndroid Build Coastguard WorkerCtsScopedStorageRedactUriTest
115*a3141fd3SAndroid Build Coastguard WorkerCtsDatabaseTestCases
116*a3141fd3SAndroid Build Coastguard WorkerFrameworksCoreTests:android.database
117*a3141fd3SAndroid Build Coastguard Worker```
118*a3141fd3SAndroid Build Coastguard Worker
119*a3141fd3SAndroid Build Coastguard WorkerAt the time of writing, there are no test failures in the baseline code.
120