summarylogtreecommitdiffstats
path: root/5022efe33088.patch
blob: 9c12394f94727e71c56157f1fb1998012a7067ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
diff -r 8753b16d88a2 browser/installer/package-manifest.in
--- a/browser/installer/package-manifest.in	Sat Mar 05 00:24:48 2022 +0000
+++ b/browser/installer/package-manifest.in	Sun Mar 06 15:04:56 2022 +0200
@@ -139,9 +139,11 @@
 @RESPATH@/update-settings.ini
 #endif
 @RESPATH@/platform.ini
+#ifndef MOZ_SYSTEM_SQLITE
 #ifndef MOZ_FOLD_LIBS
 @BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@
 #endif
+#endif
 @BINPATH@/@DLL_PREFIX@lgpllibs@DLL_SUFFIX@
 #ifdef MOZ_FFVPX
 @BINPATH@/@DLL_PREFIX@mozavutil@DLL_SUFFIX@
diff -r 8753b16d88a2 config/external/sqlite/moz.build
--- a/config/external/sqlite/moz.build	Sat Mar 05 00:24:48 2022 +0000
+++ b/config/external/sqlite/moz.build	Sun Mar 06 15:04:56 2022 +0200
@@ -4,15 +4,18 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-DIRS += ["../../../third_party/sqlite3/src"]
-if CONFIG["MOZ_FOLD_LIBS"]:
-    Library("sqlite")
-    # When folding libraries, sqlite is actually in the nss library.
-    USE_LIBS += [
-        "nss",
-    ]
+if CONFIG['MOZ_SYSTEM_SQLITE']:
+    Library('sqlite')
+    OS_LIBS += CONFIG['SQLITE_LIBS']
 else:
-    SharedLibrary("sqlite")
-    SHARED_LIBRARY_NAME = "mozsqlite3"
-
-    SYMBOLS_FILE = "/third_party/sqlite3/src/sqlite.symbols"
+    if CONFIG['MOZ_FOLD_LIBS']:
+        Library('sqlite')
+        # When folding libraries, sqlite is actually in the nss library.
+        USE_LIBS += [
+            'nss',
+        ]
+    else:
+        SharedLibrary('sqlite')
+        SHARED_LIBRARY_NAME = 'mozsqlite3'
+        SYMBOLS_FILE = '/third_party/sqlite3/src/sqlite.symbols'
+

diff -r 0f0ba6e8029d toolkit/moz.configure
--- a/toolkit/moz.configure     Sat Feb 05 20:57:50 2022 +0000
+++ b/toolkit/moz.configure     Sun Mar 06 17:23:39 2022 +0200
@@ -237,6 +237,21 @@
 set_config("MOZ_AUDIOUNIT_RUST", True, when=enable_audiounit_rust)
 set_define("MOZ_AUDIOUNIT_RUST", True, when=enable_audiounit_rust)
 
+
+# SQLite
+# ==============================================================
+option('--with-system-sqlite', help="Use system sqlite (located with pkgconfig")
+
+@depends('--with-system-sqlite')
+def check_for_sqlite(value):
+    return bool(value)
+
+system_sqlite = pkg_check_modules('SQLITE', 'sqlite3',
+                                     when=check_for_sqlite)
+
+set_config('MOZ_SYSTEM_SQLITE', depends_if(system_sqlite)(lambda _: True))
+set_define('MOZ_SYSTEM_SQLITE', depends_if(system_sqlite)(lambda _: True))
+
 # Javascript engine
 # ==============================================================
 include("../js/moz.configure")
diff -r 8753b16d88a2 storage/SQLiteMutex.h
--- a/storage/SQLiteMutex.h	Sat Mar 05 00:24:48 2022 +0000
+++ b/storage/SQLiteMutex.h	Sun Mar 06 15:04:56 2022 +0200
@@ -56,7 +56,7 @@
    */
   void lock() {
     MOZ_ASSERT(mMutex, "No mutex associated with this wrapper!");
-#if defined(DEBUG)
+#if defined(DEBUG) && !defined(MOZ_SYSTEM_SQLITE)
     // While SQLite Mutexes may be recursive, in our own code we do not want to
     // treat them as such.
     CheckAcquire();
@@ -64,7 +64,7 @@
 
     ::sqlite3_mutex_enter(mMutex);
 
-#if defined(DEBUG)
+#if defined(DEBUG) && !defined(MOZ_SYSTEM_SQLITE)
     Acquire();  // Call is protected by us holding the mutex.
 #endif
   }
@@ -74,7 +74,7 @@
    */
   void unlock() {
     MOZ_ASSERT(mMutex, "No mutex associated with this wrapper!");
-#if defined(DEBUG)
+#if defined(DEBUG) && !defined(MOZ_SYSTEM_SQLITE)
     // While SQLite Mutexes may be recursive, in our own code we do not want to
     // treat them as such.
     Release();  // Call is protected by us holding the mutex.
diff -r 8753b16d88a2 storage/moz.build
--- a/storage/moz.build	Sat Mar 05 00:24:48 2022 +0000
+++ b/storage/moz.build	Sun Mar 06 15:04:56 2022 +0200
@@ -99,6 +99,12 @@
 # will need to change it here as well.
 DEFINES["SQLITE_MAX_LIKE_PATTERN_LENGTH"] = 50000
 
+# See Sqlite moz.build for reasoning about TEMP_STORE.
+# For system sqlite we cannot use the compile time option, so we use a pragma.
+if CONFIG['MOZ_SYSTEM_SQLITE'] and (CONFIG['OS_TARGET'] == 'Android'
+                                    or CONFIG['HAVE_64BIT_BUILD']):
+    DEFINES['MOZ_MEMORY_TEMP_STORE_PRAGMA'] = True
+
 LOCAL_INCLUDES += [
     "/dom/base",
     "/third_party/sqlite3/src",
diff -r 8753b16d88a2 storage/mozStorageConnection.cpp
--- a/storage/mozStorageConnection.cpp	Sat Mar 05 00:24:48 2022 +0000
+++ b/storage/mozStorageConnection.cpp	Sun Mar 06 15:04:56 2022 +0200
@@ -877,6 +877,10 @@
     return convertResultCode(srv);
   }
 
+#if defined(MOZ_MEMORY_TEMP_STORE_PRAGMA)
+  (void)ExecuteSimpleSQL("PRAGMA temp_store = 2;"_ns);
+#endif
+
   // Register our built-in SQL functions.
   srv = registerFunctions(mDBConn);
   if (srv != SQLITE_OK) {
diff -r 8753b16d88a2 storage/mozStorageService.cpp
--- a/storage/mozStorageService.cpp	Sat Mar 05 00:24:48 2022 +0000
+++ b/storage/mozStorageService.cpp	Sun Mar 06 15:04:56 2022 +0200
@@ -35,6 +35,20 @@
 
 using mozilla::intl::Collator;
 
+#include "nsIPromptService.h"
+
+////////////////////////////////////////////////////////////////////////////////
+//// Defines
+
+#define PREF_TS_SYNCHRONOUS "toolkit.storage.synchronous"
+#define PREF_TS_SYNCHRONOUS_DEFAULT 1
+
+#define PREF_TS_PAGESIZE "toolkit.storage.pageSize"
+
+// This value must be kept in sync with the value of SQLITE_DEFAULT_PAGE_SIZE in
+// third_party/sqlite3/src/Makefile.in.
+#define PREF_TS_PAGESIZE_DEFAULT 32768
+
 namespace mozilla {
 namespace storage {
 
@@ -167,6 +181,31 @@
     return do_AddRef(gService);
   }
 
+  // Ensure that we are using the same version of SQLite that we compiled with
+  // or newer.  Our configure check ensures we are using a new enough version
+  // at compile time.
+  if (SQLITE_VERSION_NUMBER > ::sqlite3_libversion_number() ||
+      !::sqlite3_compileoption_used("SQLITE_SECURE_DELETE") ||
+      !::sqlite3_compileoption_used("SQLITE_THREADSAFE=1") ||
+      !::sqlite3_compileoption_used("SQLITE_ENABLE_FTS3") ||
+      !::sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY") ||
+      !::sqlite3_compileoption_used("SQLITE_ENABLE_DBSTAT_VTAB")) {
+    nsCOMPtr<nsIPromptService> ps(do_GetService(NS_PROMPTSERVICE_CONTRACTID));
+    if (ps) {
+      nsAutoString title, message;
+      title.AppendLiteral("SQLite Version Error");
+      message.AppendLiteral(
+          "The application has been updated, but the SQLite "
+          "library wasn't updated properly and the application "
+          "cannot run. Please try to launch the application again. "
+          "If that should still fail, please try reinstalling "
+          "it, or contact the support of where you got the "
+          "application from.");
+      (void)ps->Alert(nullptr, title.get(), message.get());
+    }
+    MOZ_CRASH("SQLite Version Error");
+  }
+
   // The first reference to the storage service must be obtained on the
   // main thread.
   NS_ENSURE_TRUE(NS_IsMainThread(), nullptr);
diff -r 8753b16d88a2 third_party/sqlite3/src/moz.build
--- a/third_party/sqlite3/src/moz.build	Sat Mar 05 00:24:48 2022 +0000
+++ b/third_party/sqlite3/src/moz.build	Sun Mar 06 15:04:56 2022 +0200
@@ -79,6 +79,7 @@
 # Try to use a MEMORY temp store when possible. That allows for better
 # performance and doesn't suffer from a full separate tmp partition.
 # Exclude 32bit platforms due to address space fragmentation issues.
+# System Sqlite is managed through a PRAGMA instead.
 if CONFIG['OS_TARGET'] == 'Android':
     # On Android there's no tmp partition, so always use a MEMORY temp store.
     DEFINES['SQLITE_TEMP_STORE'] = 3
@@ -88,6 +89,7 @@
 
 # Change the default temp files prefix, to easily distinguish files we created
 # vs files created by other Sqlite instances in the system.
+# This has obviously no effect in case of System Sqlite.
 DEFINES['SQLITE_TEMP_FILE_PREFIX'] = '"mz_etilqs_"'
 
 # Enabling sqlite math functions
diff -r 8753b16d88a2 third_party/sqlite3/src/sqlite.symbols
--- a/third_party/sqlite3/src/sqlite.symbols	Sat Mar 05 00:24:48 2022 +0000
+++ b/third_party/sqlite3/src/sqlite.symbols	Sun Mar 06 15:04:56 2022 +0200
@@ -38,6 +38,7 @@
 sqlite3_column_type
 sqlite3_column_value
 sqlite3_commit_hook
+sqlite3_compileoption_used
 sqlite3_complete
 sqlite3_complete16
 sqlite3_config