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

Commit daff8f4

Browse files
committed
Applied Android changes to v3.34.1
1 parent 3c24b8b commit daff8f4

File tree

3 files changed

+79
-26
lines changed

3 files changed

+79
-26
lines changed

dist/Android.patch

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
--- orig/shell.c 2020-07-09 13:55:18.598783417 +0100
2-
+++ shell.c 2020-10-06 00:01:10.631859326 +0100
3-
@@ -95,6 +95,11 @@
1+
diff --git a/dist/shell.c b/dist/shell.c
2+
index 6f4fee8..96ae749 100644
3+
--- a/dist/shell.c
4+
+++ b/dist/shell.c
5+
@@ -95,6 +95,11 @@ typedef unsigned char u8;
46
#endif
57
#include <ctype.h>
68
#include <stdarg.h>
@@ -12,7 +14,7 @@
1214

1315
#if !defined(_WIN32) && !defined(WIN32)
1416
# include <signal.h>
15-
@@ -12957,6 +12962,22 @@
17+
@@ -14673,6 +14678,22 @@ static void open_db(ShellState *p, int openFlags){
1618
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1719
editFunc, 0, 0);
1820
#endif
@@ -35,9 +37,11 @@
3537
if( p->openMode==SHELL_OPEN_ZIPFILE ){
3638
char *zSql = sqlite3_mprintf(
3739
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
38-
--- orig/sqlite3.c 2020-07-09 13:55:18.706784068 +0100
39-
+++ sqlite3.c 2020-07-09 13:55:18.814784719 +0100
40-
@@ -33395,6 +33395,10 @@
40+
diff --git a/dist/sqlite3.c b/dist/sqlite3.c
41+
index 38874ce..e68646c 100644
42+
--- a/dist/sqlite3.c
43+
+++ b/dist/sqlite3.c
44+
@@ -33579,6 +33579,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
4145
# include <sys/mount.h>
4246
#endif
4347

@@ -48,7 +52,7 @@
4852
#ifdef HAVE_UTIME
4953
# include <utime.h>
5054
#endif
51-
@@ -34155,6 +34159,12 @@
55+
@@ -34339,6 +34343,12 @@ static int robust_open(const char *z, int f, mode_t m){
5256
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
5357
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
5458
#endif
@@ -61,7 +65,7 @@
6165
}
6266
return fd;
6367
}
64-
@@ -34735,7 +34745,13 @@
68+
@@ -34919,7 +34929,13 @@ static int unixLogErrorAtLine(
6569
** and move on.
6670
*/
6771
static void robust_close(unixFile *pFile, int h, int lineno){
@@ -75,7 +79,7 @@
7579
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
7680
pFile ? pFile->zPath : 0, lineno);
7781
}
78-
@@ -37269,7 +37285,7 @@
82+
@@ -37474,7 +37490,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
7983
SimulateIOError( rc=1 );
8084
if( rc!=0 ){
8185
storeLastErrno((unixFile*)id, errno);
@@ -84,16 +88,16 @@
8488
}
8589
*pSize = buf.st_size;
8690

87-
@@ -37305,7 +37321,7 @@
91+
@@ -37510,7 +37526,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
8892
struct stat buf; /* Used to hold return values of fstat() */
89-
93+
9094
if( osFstat(pFile->h, &buf) ){
9195
- return SQLITE_IOERR_FSTAT;
9296
+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
9397
}
9498

9599
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
96-
@@ -38000,7 +38016,7 @@
100+
@@ -38206,7 +38222,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
97101
** with the same permissions.
98102
*/
99103
if( osFstat(pDbFd->h, &sStat) ){
@@ -102,7 +106,7 @@
102106
goto shm_open_err;
103107
}
104108

105-
@@ -128218,7 +128234,7 @@
109+
@@ -129165,7 +129181,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
106110
}
107111
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
108112
sqlite3SetString(pzErrMsg, db, "unsupported file format");
@@ -111,10 +115,10 @@
111115
goto initone_error_out;
112116
}
113117

114-
@@ -170128,13 +170144,25 @@
118+
@@ -171835,13 +171851,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
115119
** module with sqlite.
116120
*/
117-
if( SQLITE_OK==rc
121+
if( SQLITE_OK==rc
118122
+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
119123
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
120124
+#endif
@@ -125,14 +129,14 @@
125129
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
126130
){
127131
+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
128-
+ rc = sqlite3_create_module_v2(
129-
+ db, "fts1", &fts3Module, (void *)pHash, 0
130-
+ );
131-
+ if(rc) return rc;
132-
+ rc = sqlite3_create_module_v2(
132+
+ rc = sqlite3_create_module_v2(
133+
+ db, "fts1", &fts3Module, (void *)pHash, 0
134+
+ );
135+
+ if(rc) return rc;
136+
+ rc = sqlite3_create_module_v2(
133137
+ db, "fts2", &fts3Module, (void *)pHash, 0
134138
+ );
135-
+ if(rc) return rc;
139+
+ if(rc) return rc;
136140
+#endif
137141
rc = sqlite3_create_module_v2(
138142
db, "fts3", &fts3Module, (void *)pHash, hashDestroy

dist/shell.c

+21
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ 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 <sqlite3_android.h>
101+
#endif
102+
// End Android Add
98103

99104
#if !defined(_WIN32) && !defined(WIN32)
100105
# include <signal.h>
@@ -14673,6 +14678,22 @@ static void open_db(ShellState *p, int openFlags){
1467314678
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1467414679
editFunc, 0, 0);
1467514680
#endif
14681+
14682+
// Begin Android Add
14683+
#ifndef NO_ANDROID_FUNCS
14684+
int err = register_localized_collators(p->db, "en_US", 0);
14685+
if (err != SQLITE_OK) {
14686+
fprintf(stderr, "register_localized_collators() failed\n");
14687+
exit(1);
14688+
}
14689+
err = register_android_functions(p->db, 0);
14690+
if (err != SQLITE_OK) {
14691+
fprintf(stderr, "register_android_functions() failed\n");
14692+
exit(1);
14693+
}
14694+
#endif
14695+
// End Android Add
14696+
1467614697
if( p->openMode==SHELL_OPEN_ZIPFILE ){
1467714698
char *zSql = sqlite3_mprintf(
1467814699
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);

dist/sqlite3.c

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

33582+
#if defined(__BIONIC__)
33583+
# include <android/fdsan.h>
33584+
#endif
33585+
3358233586
#ifdef HAVE_UTIME
3358333587
# include <utime.h>
3358433588
#endif
@@ -34339,6 +34343,12 @@ static int robust_open(const char *z, int f, mode_t m){
3433934343
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3434034344
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3434134345
#endif
34346+
34347+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34348+
uint64_t tag = android_fdsan_create_owner_tag(
34349+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
34350+
android_fdsan_exchange_owner_tag(fd, 0, tag);
34351+
#endif
3434234352
}
3434334353
return fd;
3434434354
}
@@ -34919,7 +34929,13 @@ static int unixLogErrorAtLine(
3491934929
** and move on.
3492034930
*/
3492134931
static void robust_close(unixFile *pFile, int h, int lineno){
34932+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34933+
uint64_t tag = android_fdsan_create_owner_tag(
34934+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
34935+
if( android_fdsan_close_with_tag(h, tag) ){
34936+
#else
3492234937
if( osClose(h) ){
34938+
#endif
3492334939
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3492434940
pFile ? pFile->zPath : 0, lineno);
3492534941
}
@@ -37474,7 +37490,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3747437490
SimulateIOError( rc=1 );
3747537491
if( rc!=0 ){
3747637492
storeLastErrno((unixFile*)id, errno);
37477-
return SQLITE_IOERR_FSTAT;
37493+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
3747837494
}
3747937495
*pSize = buf.st_size;
3748037496

@@ -37510,7 +37526,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3751037526
struct stat buf; /* Used to hold return values of fstat() */
3751137527

3751237528
if( osFstat(pFile->h, &buf) ){
37513-
return SQLITE_IOERR_FSTAT;
37529+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
3751437530
}
3751537531

3751637532
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -38206,7 +38222,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3820638222
** with the same permissions.
3820738223
*/
3820838224
if( osFstat(pDbFd->h, &sStat) ){
38209-
rc = SQLITE_IOERR_FSTAT;
38225+
rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
3821038226
goto shm_open_err;
3821138227
}
3821238228

@@ -129165,7 +129181,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
129165129181
}
129166129182
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
129167129183
sqlite3SetString(pzErrMsg, db, "unsupported file format");
129168-
rc = SQLITE_ERROR;
129184+
rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
129169129185
goto initone_error_out;
129170129186
}
129171129187

@@ -171835,13 +171851,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
171835171851
** module with sqlite.
171836171852
*/
171837171853
if( SQLITE_OK==rc
171854+
#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
171838171855
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
171856+
#endif
171839171857
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
171840171858
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
171841171859
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
171842171860
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
171843171861
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
171844171862
){
171863+
#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
171864+
rc = sqlite3_create_module_v2(
171865+
db, "fts1", &fts3Module, (void *)pHash, 0
171866+
);
171867+
if(rc) return rc;
171868+
rc = sqlite3_create_module_v2(
171869+
db, "fts2", &fts3Module, (void *)pHash, 0
171870+
);
171871+
if(rc) return rc;
171872+
#endif
171845171873
rc = sqlite3_create_module_v2(
171846171874
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
171847171875
);

0 commit comments

Comments
 (0)