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

Commit 4ea4c69

Browse files
committed
Applied the Android patch
1 parent 2977f92 commit 4ea4c69

File tree

3 files changed

+87
-34
lines changed

3 files changed

+87
-34
lines changed

dist/Android.patch

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
--- orig/shell.c 2018-02-18 23:53:25.407627650 -0800
2-
+++ shell.c 2018-02-18 23:53:25.467627374 -0800
3-
@@ -87,6 +87,12 @@
1+
diff --git a/dist/shell.c b/dist/shell.c
2+
index fb3ac9f..94bf2e9 100644
3+
--- a/dist/shell.c
4+
+++ b/dist/shell.c
5+
@@ -87,6 +87,12 @@ typedef unsigned char u8;
46
#endif
57
#include <ctype.h>
68
#include <stdarg.h>
@@ -13,44 +15,45 @@
1315

1416
#if !defined(_WIN32) && !defined(WIN32)
1517
# include <signal.h>
16-
@@ -10389,6 +10395,23 @@
17-
editFunc, 0, 0);
18+
@@ -11170,6 +11176,22 @@ static void open_db(ShellState *p, int openFlags){
1819
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1920
editFunc, 0, 0);
20-
+
21+
#endif
2122
+ // Begin Android Add
22-
+ #ifndef NO_ANDROID_FUNCS
23-
+ InitializeIcuOrDie();
24-
+ int err = register_localized_collators(p->db, "en_US", 0);
25-
+ if (err != SQLITE_OK) {
26-
+ fprintf(stderr, "register_localized_collators() failed\n");
27-
+ exit(1);
28-
+ }
29-
+ err = register_android_functions(p->db, 0);
30-
+ if (err != SQLITE_OK) {
31-
+ fprintf(stderr, "register_android_functions() failed\n");
32-
+ exit(1);
33-
+ }
34-
+ #endif
23+
+#ifndef NO_ANDROID_FUNCS
24+
+ InitializeIcuOrDie();
25+
+ int err = register_localized_collators(p->db, "en_US", 0);
26+
+ if (err != SQLITE_OK) {
27+
+ fprintf(stderr, "register_localized_collators() failed\n");
28+
+ exit(1);
29+
+ }
30+
+ err = register_android_functions(p->db, 0);
31+
+ if (err != SQLITE_OK) {
32+
+ fprintf(stderr, "register_android_functions() failed\n");
33+
+ exit(1);
34+
+ }
35+
+#endif
3536
+ // End Android Add
3637
+
3738
if( p->openMode==SHELL_OPEN_ZIPFILE ){
3839
char *zSql = sqlite3_mprintf(
3940
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
40-
--- orig/sqlite3.c 2018-02-18 23:53:25.459627411 -0800
41-
+++ sqlite3.c 2018-08-22 15:28:04.016188846 -0700
42-
@@ -30672,6 +30672,10 @@
41+
diff --git a/dist/sqlite3.c b/dist/sqlite3.c
42+
index 7b525c3..b9591b3 100644
43+
--- a/dist/sqlite3.c
44+
+++ b/dist/sqlite3.c
45+
@@ -32027,6 +32027,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
4346
# include <sys/mount.h>
4447
#endif
4548

46-
+#if defined(__BIONIC__)
49+
+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
4750
+# include <android/fdsan.h>
4851
+#endif
4952
+
5053
#ifdef HAVE_UTIME
5154
# include <utime.h>
5255
#endif
53-
@@ -31422,6 +31426,12 @@
56+
@@ -32788,6 +32792,12 @@ static int robust_open(const char *z, int f, mode_t m){
5457
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
5558
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
5659
#endif
@@ -63,7 +66,7 @@
6366
}
6467
return fd;
6568
}
66-
@@ -31954,7 +31964,13 @@
69+
@@ -33366,7 +33376,13 @@ static int unixLogErrorAtLine(
6770
** and move on.
6871
*/
6972
static void robust_close(unixFile *pFile, int h, int lineno){
@@ -77,7 +80,7 @@
7780
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
7881
pFile ? pFile->zPath : 0, lineno);
7982
}
80-
@@ -34428,7 +34444,7 @@
83+
@@ -35898,7 +35914,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
8184
SimulateIOError( rc=1 );
8285
if( rc!=0 ){
8386
storeLastErrno((unixFile*)id, errno);
@@ -86,7 +89,7 @@
8689
}
8790
*pSize = buf.st_size;
8891

89-
@@ -34464,7 +34480,7 @@
92+
@@ -35934,7 +35950,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
9093
struct stat buf; /* Used to hold return values of fstat() */
9194

9295
if( osFstat(pFile->h, &buf) ){
@@ -95,7 +98,7 @@
9598
}
9699

97100
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
98-
@@ -35139,7 +35155,7 @@
101+
@@ -36614,7 +36630,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
99102
** with the same permissions.
100103
*/
101104
if( osFstat(pDbFd->h, &sStat) ){
@@ -104,7 +107,7 @@
104107
goto shm_open_err;
105108
}
106109

107-
@@ -118054,7 +118070,7 @@
110+
@@ -122488,7 +122504,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
108111
}
109112
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
110113
sqlite3SetString(pzErrMsg, db, "unsupported file format");
@@ -113,7 +116,7 @@
113116
goto initone_error_out;
114117
}
115118

116-
@@ -152769,13 +152785,25 @@
119+
@@ -161312,13 +161328,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
117120
** module with sqlite.
118121
*/
119122
if( SQLITE_OK==rc

dist/shell.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ typedef unsigned char u8;
8787
#endif
8888
#include <ctype.h>
8989
#include <stdarg.h>
90+
// Begin Android Add
91+
#ifndef NO_ANDROID_FUNCS
92+
#include "IcuUtils.h"
93+
#include <sqlite3_android.h>
94+
#endif
95+
// End Android Add
9096

9197
#if !defined(_WIN32) && !defined(WIN32)
9298
# include <signal.h>
@@ -11170,6 +11176,22 @@ static void open_db(ShellState *p, int openFlags){
1117011176
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1117111177
editFunc, 0, 0);
1117211178
#endif
11179+
// Begin Android Add
11180+
#ifndef NO_ANDROID_FUNCS
11181+
InitializeIcuOrDie();
11182+
int err = register_localized_collators(p->db, "en_US", 0);
11183+
if (err != SQLITE_OK) {
11184+
fprintf(stderr, "register_localized_collators() failed\n");
11185+
exit(1);
11186+
}
11187+
err = register_android_functions(p->db, 0);
11188+
if (err != SQLITE_OK) {
11189+
fprintf(stderr, "register_android_functions() failed\n");
11190+
exit(1);
11191+
}
11192+
#endif
11193+
// End Android Add
11194+
1117311195
if( p->openMode==SHELL_OPEN_ZIPFILE ){
1117411196
char *zSql = sqlite3_mprintf(
1117511197
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);

dist/sqlite3.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32027,6 +32027,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
3202732027
# include <sys/mount.h>
3202832028
#endif
3202932029

32030+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
32031+
# include <android/fdsan.h>
32032+
#endif
32033+
3203032034
#ifdef HAVE_UTIME
3203132035
# include <utime.h>
3203232036
#endif
@@ -32788,6 +32792,12 @@ static int robust_open(const char *z, int f, mode_t m){
3278832792
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3278932793
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3279032794
#endif
32795+
32796+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
32797+
uint64_t tag = android_fdsan_create_owner_tag(
32798+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
32799+
android_fdsan_exchange_owner_tag(fd, 0, tag);
32800+
#endif
3279132801
}
3279232802
return fd;
3279332803
}
@@ -33366,7 +33376,13 @@ static int unixLogErrorAtLine(
3336633376
** and move on.
3336733377
*/
3336833378
static void robust_close(unixFile *pFile, int h, int lineno){
33379+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
33380+
uint64_t tag = android_fdsan_create_owner_tag(
33381+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
33382+
if( android_fdsan_close_with_tag(h, tag) ){
33383+
#else
3336933384
if( osClose(h) ){
33385+
#endif
3337033386
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3337133387
pFile ? pFile->zPath : 0, lineno);
3337233388
}
@@ -35898,7 +35914,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3589835914
SimulateIOError( rc=1 );
3589935915
if( rc!=0 ){
3590035916
storeLastErrno((unixFile*)id, errno);
35901-
return SQLITE_IOERR_FSTAT;
35917+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
3590235918
}
3590335919
*pSize = buf.st_size;
3590435920

@@ -35934,7 +35950,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3593435950
struct stat buf; /* Used to hold return values of fstat() */
3593535951

3593635952
if( osFstat(pFile->h, &buf) ){
35937-
return SQLITE_IOERR_FSTAT;
35953+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
3593835954
}
3593935955

3594035956
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -36614,7 +36630,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3661436630
** with the same permissions.
3661536631
*/
3661636632
if( osFstat(pDbFd->h, &sStat) ){
36617-
rc = SQLITE_IOERR_FSTAT;
36633+
rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
3661836634
goto shm_open_err;
3661936635
}
3662036636

@@ -122488,7 +122504,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
122488122504
}
122489122505
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
122490122506
sqlite3SetString(pzErrMsg, db, "unsupported file format");
122491-
rc = SQLITE_ERROR;
122507+
rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
122492122508
goto initone_error_out;
122493122509
}
122494122510

@@ -161312,13 +161328,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
161312161328
** module with sqlite.
161313161329
*/
161314161330
if( SQLITE_OK==rc
161331+
#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
161315161332
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
161333+
#endif
161316161334
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
161317161335
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
161318161336
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
161319161337
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
161320161338
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
161321161339
){
161340+
#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
161341+
rc = sqlite3_create_module_v2(
161342+
db, "fts1", &fts3Module, (void *)pHash, 0
161343+
);
161344+
if(rc) return rc;
161345+
rc = sqlite3_create_module_v2(
161346+
db, "fts2", &fts3Module, (void *)pHash, 0
161347+
);
161348+
if(rc) return rc;
161349+
#endif
161322161350
rc = sqlite3_create_module_v2(
161323161351
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
161324161352
);

0 commit comments

Comments
 (0)