Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 1a3276b

Browse files
committed
Applied Android changes to 3.32.1
1 parent 29deb0f commit 1a3276b

File tree

3 files changed

+219
-18
lines changed

3 files changed

+219
-18
lines changed

dist/Android.patch

+164-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,154 @@
1-
--- orig/shell.c 2019-06-11 15:05:36.341739007 -0700
2-
+++ shell.c 2019-06-11 15:05:36.401739332 -0700
3-
@@ -87,6 +87,12 @@
1+
diff --git a/dist/Android.patch b/dist/Android.patch
2+
index 7ecbecb..e69de29 100644
3+
--- a/dist/Android.patch
4+
+++ b/dist/Android.patch
5+
@@ -1,141 +0,0 @@
6+
---- orig/shell.c 2019-06-11 15:05:36.341739007 -0700
7+
-+++ shell.c 2019-06-11 15:05:36.401739332 -0700
8+
-@@ -87,6 +87,12 @@
9+
- #endif
10+
- #include <ctype.h>
11+
- #include <stdarg.h>
12+
-+// Begin Android Add
13+
-+#ifndef NO_ANDROID_FUNCS
14+
-+#include <aicu/AIcu.h>
15+
-+#include <sqlite3_android.h>
16+
-+#endif
17+
-+// End Android Add
18+
-
19+
- #if !defined(_WIN32) && !defined(WIN32)
20+
- # include <signal.h>
21+
-@@ -11698,6 +11704,23 @@
22+
- sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
23+
- editFunc, 0, 0);
24+
- #endif
25+
-+
26+
-+// Begin Android Add
27+
-+#ifndef NO_ANDROID_FUNCS
28+
-+ AIcu_initializeIcuOrDie();
29+
-+ int err = register_localized_collators(p->db, "en_US", 0);
30+
-+ if (err != SQLITE_OK) {
31+
-+ fprintf(stderr, "register_localized_collators() failed\n");
32+
-+ exit(1);
33+
-+ }
34+
-+ err = register_android_functions(p->db, 0);
35+
-+ if (err != SQLITE_OK) {
36+
-+ fprintf(stderr, "register_android_functions() failed\n");
37+
-+ exit(1);
38+
-+ }
39+
-+#endif
40+
-+// End Android Add
41+
-+
42+
- if( p->openMode==SHELL_OPEN_ZIPFILE ){
43+
- char *zSql = sqlite3_mprintf(
44+
- "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
45+
---- orig/sqlite3.c 2019-06-11 15:05:36.393739289 -0700
46+
-+++ sqlite3.c 2019-06-11 15:05:36.449739593 -0700
47+
-@@ -32438,6 +32438,10 @@
48+
- # include <sys/mount.h>
49+
- #endif
50+
-
51+
-+#if defined(__BIONIC__)
52+
-+# include <android/fdsan.h>
53+
-+#endif
54+
-+
55+
- #ifdef HAVE_UTIME
56+
- # include <utime.h>
57+
- #endif
58+
-@@ -33197,6 +33201,12 @@
59+
- #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
60+
- osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
61+
- #endif
62+
-+
63+
-+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
64+
-+ uint64_t tag = android_fdsan_create_owner_tag(
65+
-+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
66+
-+ android_fdsan_exchange_owner_tag(fd, 0, tag);
67+
-+#endif
68+
- }
69+
- return fd;
70+
- }
71+
-@@ -33777,7 +33787,13 @@
72+
- ** and move on.
73+
- */
74+
- static void robust_close(unixFile *pFile, int h, int lineno){
75+
-+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
76+
-+ uint64_t tag = android_fdsan_create_owner_tag(
77+
-+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
78+
-+ if( android_fdsan_close_with_tag(h, tag) ){
79+
-+#else
80+
- if( osClose(h) ){
81+
-+#endif
82+
- unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
83+
- pFile ? pFile->zPath : 0, lineno);
84+
- }
85+
-@@ -36310,7 +36326,7 @@
86+
- SimulateIOError( rc=1 );
87+
- if( rc!=0 ){
88+
- storeLastErrno((unixFile*)id, errno);
89+
-- return SQLITE_IOERR_FSTAT;
90+
-+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
91+
- }
92+
- *pSize = buf.st_size;
93+
-
94+
-@@ -36346,7 +36362,7 @@
95+
- struct stat buf; /* Used to hold return values of fstat() */
96+
-
97+
- if( osFstat(pFile->h, &buf) ){
98+
-- return SQLITE_IOERR_FSTAT;
99+
-+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
100+
- }
101+
-
102+
- nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
103+
-@@ -37032,7 +37048,7 @@
104+
- ** with the same permissions.
105+
- */
106+
- if( osFstat(pDbFd->h, &sStat) ){
107+
-- rc = SQLITE_IOERR_FSTAT;
108+
-+ rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
109+
- goto shm_open_err;
110+
- }
111+
-
112+
-@@ -123984,7 +124000,7 @@
113+
- }
114+
- if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
115+
- sqlite3SetString(pzErrMsg, db, "unsupported file format");
116+
-- rc = SQLITE_ERROR;
117+
-+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
118+
- goto initone_error_out;
119+
- }
120+
-
121+
-@@ -164271,13 +164287,25 @@
122+
- ** module with sqlite.
123+
- */
124+
- if( SQLITE_OK==rc
125+
-+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
126+
- && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
127+
-+#endif
128+
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
129+
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
130+
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
131+
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
132+
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
133+
- ){
134+
-+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
135+
-+ rc = sqlite3_create_module_v2(
136+
-+ db, "fts1", &fts3Module, (void *)pHash, 0
137+
-+ );
138+
-+ if(rc) return rc;
139+
-+ rc = sqlite3_create_module_v2(
140+
-+ db, "fts2", &fts3Module, (void *)pHash, 0
141+
-+ );
142+
-+ if(rc) return rc;
143+
-+#endif
144+
- rc = sqlite3_create_module_v2(
145+
- db, "fts3", &fts3Module, (void *)pHash, hashDestroy
146+
- );
147+
diff --git a/dist/shell.c b/dist/shell.c
148+
index 974f57a..d0fe5d5 100644
149+
--- a/dist/shell.c
150+
+++ b/dist/shell.c
151+
@@ -95,6 +95,12 @@ typedef unsigned char u8;
4152
#endif
5153
#include <ctype.h>
6154
#include <stdarg.h>
@@ -13,7 +161,7 @@
13161

14162
#if !defined(_WIN32) && !defined(WIN32)
15163
# include <signal.h>
16-
@@ -11698,6 +11704,23 @@
164+
@@ -12957,6 +12963,23 @@ static void open_db(ShellState *p, int openFlags){
17165
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
18166
editFunc, 0, 0);
19167
#endif
@@ -37,9 +185,11 @@
37185
if( p->openMode==SHELL_OPEN_ZIPFILE ){
38186
char *zSql = sqlite3_mprintf(
39187
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
40-
--- orig/sqlite3.c 2019-06-11 15:05:36.393739289 -0700
41-
+++ sqlite3.c 2019-06-11 15:05:36.449739593 -0700
42-
@@ -32438,6 +32438,10 @@
188+
diff --git a/dist/sqlite3.c b/dist/sqlite3.c
189+
index 19c8768..9061f13 100644
190+
--- a/dist/sqlite3.c
191+
+++ b/dist/sqlite3.c
192+
@@ -33395,6 +33395,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
43193
# include <sys/mount.h>
44194
#endif
45195

@@ -50,7 +200,7 @@
50200
#ifdef HAVE_UTIME
51201
# include <utime.h>
52202
#endif
53-
@@ -33197,6 +33201,12 @@
203+
@@ -34155,6 +34159,12 @@ static int robust_open(const char *z, int f, mode_t m){
54204
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
55205
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
56206
#endif
@@ -63,7 +213,7 @@
63213
}
64214
return fd;
65215
}
66-
@@ -33777,7 +33787,13 @@
216+
@@ -34735,7 +34745,13 @@ static int unixLogErrorAtLine(
67217
** and move on.
68218
*/
69219
static void robust_close(unixFile *pFile, int h, int lineno){
@@ -77,7 +227,7 @@
77227
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
78228
pFile ? pFile->zPath : 0, lineno);
79229
}
80-
@@ -36310,7 +36326,7 @@
230+
@@ -37269,7 +37285,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
81231
SimulateIOError( rc=1 );
82232
if( rc!=0 ){
83233
storeLastErrno((unixFile*)id, errno);
@@ -86,7 +236,7 @@
86236
}
87237
*pSize = buf.st_size;
88238

89-
@@ -36346,7 +36362,7 @@
239+
@@ -37305,7 +37321,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
90240
struct stat buf; /* Used to hold return values of fstat() */
91241

92242
if( osFstat(pFile->h, &buf) ){
@@ -95,7 +245,7 @@
95245
}
96246

97247
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
98-
@@ -37032,7 +37048,7 @@
248+
@@ -38000,7 +38016,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
99249
** with the same permissions.
100250
*/
101251
if( osFstat(pDbFd->h, &sStat) ){
@@ -104,7 +254,7 @@
104254
goto shm_open_err;
105255
}
106256

107-
@@ -123984,7 +124000,7 @@
257+
@@ -128216,7 +128232,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
108258
}
109259
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
110260
sqlite3SetString(pzErrMsg, db, "unsupported file format");
@@ -113,7 +263,7 @@
113263
goto initone_error_out;
114264
}
115265

116-
@@ -164271,13 +164287,25 @@
266+
@@ -170126,13 +170142,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
117267
** module with sqlite.
118268
*/
119269
if( SQLITE_OK==rc

dist/shell.c

+23
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ typedef unsigned char u8;
9595
#endif
9696
#include <ctype.h>
9797
#include <stdarg.h>
98+
// Begin Android Add
99+
#ifndef NO_ANDROID_FUNCS
100+
#include <aicu/AIcu.h>
101+
#include <sqlite3_android.h>
102+
#endif
103+
// End Android Add
98104

99105
#if !defined(_WIN32) && !defined(WIN32)
100106
# include <signal.h>
@@ -12957,6 +12963,23 @@ static void open_db(ShellState *p, int openFlags){
1295712963
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1295812964
editFunc, 0, 0);
1295912965
#endif
12966+
12967+
// Begin Android Add
12968+
#ifndef NO_ANDROID_FUNCS
12969+
AIcu_initializeIcuOrDie();
12970+
int err = register_localized_collators(p->db, "en_US", 0);
12971+
if (err != SQLITE_OK) {
12972+
fprintf(stderr, "register_localized_collators() failed\n");
12973+
exit(1);
12974+
}
12975+
err = register_android_functions(p->db, 0);
12976+
if (err != SQLITE_OK) {
12977+
fprintf(stderr, "register_android_functions() failed\n");
12978+
exit(1);
12979+
}
12980+
#endif
12981+
// End Android Add
12982+
1296012983
if( p->openMode==SHELL_OPEN_ZIPFILE ){
1296112984
char *zSql = sqlite3_mprintf(
1296212985
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);

dist/sqlite3.c

+32-4
Original file line numberDiff line numberDiff line change
@@ -33395,6 +33395,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
3339533395
# include <sys/mount.h>
3339633396
#endif
3339733397

33398+
#if defined(__BIONIC__)
33399+
# include <android/fdsan.h>
33400+
#endif
33401+
3339833402
#ifdef HAVE_UTIME
3339933403
# include <utime.h>
3340033404
#endif
@@ -34155,6 +34159,12 @@ static int robust_open(const char *z, int f, mode_t m){
3415534159
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3415634160
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3415734161
#endif
34162+
34163+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34164+
uint64_t tag = android_fdsan_create_owner_tag(
34165+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
34166+
android_fdsan_exchange_owner_tag(fd, 0, tag);
34167+
#endif
3415834168
}
3415934169
return fd;
3416034170
}
@@ -34735,7 +34745,13 @@ static int unixLogErrorAtLine(
3473534745
** and move on.
3473634746
*/
3473734747
static void robust_close(unixFile *pFile, int h, int lineno){
34748+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34749+
uint64_t tag = android_fdsan_create_owner_tag(
34750+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
34751+
if( android_fdsan_close_with_tag(h, tag) ){
34752+
#else
3473834753
if( osClose(h) ){
34754+
#endif
3473934755
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3474034756
pFile ? pFile->zPath : 0, lineno);
3474134757
}
@@ -37269,7 +37285,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3726937285
SimulateIOError( rc=1 );
3727037286
if( rc!=0 ){
3727137287
storeLastErrno((unixFile*)id, errno);
37272-
return SQLITE_IOERR_FSTAT;
37288+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
3727337289
}
3727437290
*pSize = buf.st_size;
3727537291

@@ -37305,7 +37321,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3730537321
struct stat buf; /* Used to hold return values of fstat() */
3730637322

3730737323
if( osFstat(pFile->h, &buf) ){
37308-
return SQLITE_IOERR_FSTAT;
37324+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
3730937325
}
3731037326

3731137327
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -38000,7 +38016,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3800038016
** with the same permissions.
3800138017
*/
3800238018
if( osFstat(pDbFd->h, &sStat) ){
38003-
rc = SQLITE_IOERR_FSTAT;
38019+
rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
3800438020
goto shm_open_err;
3800538021
}
3800638022

@@ -128216,7 +128232,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
128216128232
}
128217128233
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
128218128234
sqlite3SetString(pzErrMsg, db, "unsupported file format");
128219-
rc = SQLITE_ERROR;
128235+
rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
128220128236
goto initone_error_out;
128221128237
}
128222128238

@@ -170126,13 +170142,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
170126170142
** module with sqlite.
170127170143
*/
170128170144
if( SQLITE_OK==rc
170145+
#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
170129170146
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
170147+
#endif
170130170148
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
170131170149
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
170132170150
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
170133170151
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
170134170152
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
170135170153
){
170154+
#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
170155+
rc = sqlite3_create_module_v2(
170156+
db, "fts1", &fts3Module, (void *)pHash, 0
170157+
);
170158+
if(rc) return rc;
170159+
rc = sqlite3_create_module_v2(
170160+
db, "fts2", &fts3Module, (void *)pHash, 0
170161+
);
170162+
if(rc) return rc;
170163+
#endif
170136170164
rc = sqlite3_create_module_v2(
170137170165
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
170138170166
);

0 commit comments

Comments
 (0)