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

Commit 325e91a

Browse files
committed
Applied Android patch
1 parent c932458 commit 325e91a

File tree

3 files changed

+70
-19
lines changed

3 files changed

+70
-19
lines changed

dist/Android.patch

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
--- orig/shell.c 2018-02-18 23:53:25.407627650 -0800
2-
+++ shell.c 2018-02-18 23:53:25.467627374 -0800
1+
--- orig/shell.c 2018-12-01 14:38:00.000000000 +0100
2+
+++ shell.c 2019-01-02 18:02:45.146309610 +0100
33
@@ -87,6 +87,12 @@
44
#endif
55
#include <ctype.h>
@@ -13,10 +13,10 @@
1313

1414
#if !defined(_WIN32) && !defined(WIN32)
1515
# include <signal.h>
16-
@@ -10389,6 +10395,23 @@
17-
editFunc, 0, 0);
16+
@@ -11328,6 +11334,23 @@
1817
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1918
editFunc, 0, 0);
19+
#endif
2020
+
2121
+ // Begin Android Add
2222
+ #ifndef NO_ANDROID_FUNCS
@@ -37,20 +37,20 @@
3737
if( p->openMode==SHELL_OPEN_ZIPFILE ){
3838
char *zSql = sqlite3_mprintf(
3939
"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 @@
40+
--- orig/sqlite3.c 2018-12-01 14:38:00.000000000 +0100
41+
+++ sqlite3.c 2019-01-02 18:36:11.811626272 +0100
42+
@@ -32262,6 +32262,10 @@
4343
# include <sys/mount.h>
4444
#endif
4545

46-
+#if defined(__BIONIC__)
46+
+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
4747
+# include <android/fdsan.h>
4848
+#endif
4949
+
5050
#ifdef HAVE_UTIME
5151
# include <utime.h>
5252
#endif
53-
@@ -31422,6 +31426,12 @@
53+
@@ -33021,6 +33025,12 @@
5454
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
5555
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
5656
#endif
@@ -63,7 +63,7 @@
6363
}
6464
return fd;
6565
}
66-
@@ -31954,7 +31964,13 @@
66+
@@ -33601,7 +33611,13 @@
6767
** and move on.
6868
*/
6969
static void robust_close(unixFile *pFile, int h, int lineno){
@@ -77,7 +77,7 @@
7777
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
7878
pFile ? pFile->zPath : 0, lineno);
7979
}
80-
@@ -34428,7 +34444,7 @@
80+
@@ -36134,7 +36150,7 @@
8181
SimulateIOError( rc=1 );
8282
if( rc!=0 ){
8383
storeLastErrno((unixFile*)id, errno);
@@ -86,7 +86,7 @@
8686
}
8787
*pSize = buf.st_size;
8888

89-
@@ -34464,7 +34480,7 @@
89+
@@ -36170,7 +36186,7 @@
9090
struct stat buf; /* Used to hold return values of fstat() */
9191

9292
if( osFstat(pFile->h, &buf) ){
@@ -95,7 +95,7 @@
9595
}
9696

9797
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
98-
@@ -35139,7 +35155,7 @@
98+
@@ -36856,7 +36872,7 @@
9999
** with the same permissions.
100100
*/
101101
if( osFstat(pDbFd->h, &sStat) ){
@@ -104,7 +104,7 @@
104104
goto shm_open_err;
105105
}
106106

107-
@@ -118054,7 +118070,7 @@
107+
@@ -122984,7 +123000,7 @@
108108
}
109109
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
110110
sqlite3SetString(pzErrMsg, db, "unsupported file format");
@@ -113,7 +113,7 @@
113113
goto initone_error_out;
114114
}
115115

116-
@@ -152769,13 +152785,25 @@
116+
@@ -162306,13 +162322,25 @@
117117
** module with sqlite.
118118
*/
119119
if( SQLITE_OK==rc

dist/shell.c

Lines changed: 23 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>
@@ -11328,6 +11334,23 @@ static void open_db(ShellState *p, int openFlags){
1132811334
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1132911335
editFunc, 0, 0);
1133011336
#endif
11337+
11338+
// Begin Android Add
11339+
#ifndef NO_ANDROID_FUNCS
11340+
InitializeIcuOrDie();
11341+
int err = register_localized_collators(p->db, "en_US", 0);
11342+
if (err != SQLITE_OK) {
11343+
fprintf(stderr, "register_localized_collators() failed\n");
11344+
exit(1);
11345+
}
11346+
err = register_android_functions(p->db, 0);
11347+
if (err != SQLITE_OK) {
11348+
fprintf(stderr, "register_android_functions() failed\n");
11349+
exit(1);
11350+
}
11351+
#endif
11352+
// End Android Add
11353+
1133111354
if( p->openMode==SHELL_OPEN_ZIPFILE ){
1133211355
char *zSql = sqlite3_mprintf(
1133311356
"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
@@ -32262,6 +32262,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
3226232262
# include <sys/mount.h>
3226332263
#endif
3226432264

32265+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
32266+
# include <android/fdsan.h>
32267+
#endif
32268+
3226532269
#ifdef HAVE_UTIME
3226632270
# include <utime.h>
3226732271
#endif
@@ -33021,6 +33025,12 @@ static int robust_open(const char *z, int f, mode_t m){
3302133025
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3302233026
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3302333027
#endif
33028+
33029+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
33030+
uint64_t tag = android_fdsan_create_owner_tag(
33031+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
33032+
android_fdsan_exchange_owner_tag(fd, 0, tag);
33033+
#endif
3302433034
}
3302533035
return fd;
3302633036
}
@@ -33601,7 +33611,13 @@ static int unixLogErrorAtLine(
3360133611
** and move on.
3360233612
*/
3360333613
static void robust_close(unixFile *pFile, int h, int lineno){
33614+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
33615+
uint64_t tag = android_fdsan_create_owner_tag(
33616+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
33617+
if( android_fdsan_close_with_tag(h, tag) ){
33618+
#else
3360433619
if( osClose(h) ){
33620+
#endif
3360533621
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3360633622
pFile ? pFile->zPath : 0, lineno);
3360733623
}
@@ -36134,7 +36150,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3613436150
SimulateIOError( rc=1 );
3613536151
if( rc!=0 ){
3613636152
storeLastErrno((unixFile*)id, errno);
36137-
return SQLITE_IOERR_FSTAT;
36153+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
3613836154
}
3613936155
*pSize = buf.st_size;
3614036156

@@ -36170,7 +36186,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3617036186
struct stat buf; /* Used to hold return values of fstat() */
3617136187

3617236188
if( osFstat(pFile->h, &buf) ){
36173-
return SQLITE_IOERR_FSTAT;
36189+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
3617436190
}
3617536191

3617636192
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -36856,7 +36872,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3685636872
** with the same permissions.
3685736873
*/
3685836874
if( osFstat(pDbFd->h, &sStat) ){
36859-
rc = SQLITE_IOERR_FSTAT;
36875+
rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
3686036876
goto shm_open_err;
3686136877
}
3686236878

@@ -122984,7 +123000,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
122984123000
}
122985123001
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
122986123002
sqlite3SetString(pzErrMsg, db, "unsupported file format");
122987-
rc = SQLITE_ERROR;
123003+
rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
122988123004
goto initone_error_out;
122989123005
}
122990123006

@@ -162306,13 +162322,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
162306162322
** module with sqlite.
162307162323
*/
162308162324
if( SQLITE_OK==rc
162325+
#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
162309162326
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
162327+
#endif
162310162328
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
162311162329
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
162312162330
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
162313162331
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
162314162332
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
162315162333
){
162334+
#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
162335+
rc = sqlite3_create_module_v2(
162336+
db, "fts1", &fts3Module, (void *)pHash, 0
162337+
);
162338+
if(rc) return rc;
162339+
rc = sqlite3_create_module_v2(
162340+
db, "fts2", &fts3Module, (void *)pHash, 0
162341+
);
162342+
if(rc) return rc;
162343+
#endif
162316162344
rc = sqlite3_create_module_v2(
162317162345
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
162318162346
);

0 commit comments

Comments
 (0)