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

Commit 85460d3

Browse files
committed
Applied Android changes to v3.35.4
1 parent ff56d65 commit 85460d3

File tree

3 files changed

+82
-29
lines changed

3 files changed

+82
-29
lines changed

dist/Android.patch

+29-25
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 27de22a..374ae62 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+
@@ -14800,6 +14805,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 9fca48f..5e26429 100644
42+
--- a/dist/sqlite3.c
43+
+++ b/dist/sqlite3.c
44+
@@ -33806,6 +33806,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+
@@ -34566,6 +34570,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+
@@ -35146,7 +35156,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+
@@ -37701,7 +37717,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+
@@ -37737,7 +37753,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+
@@ -38433,7 +38449,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+
@@ -130467,7 +130483,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,11 +115,11 @@
111115
goto initone_error_out;
112116
}
113117

114-
@@ -170128,13 +170144,25 @@
118+
@@ -174092,13 +174108,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
115119
** module with sqlite.
116120
*/
117-
if( SQLITE_OK==rc
118-
+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
121+
if( SQLITE_OK==rc
122+
+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
119123
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
120124
+#endif
121125
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
@@ -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(
133-
+ db, "fts2", &fts3Module, (void *)pHash, 0
134-
+ );
135-
+ if(rc) return rc;
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(
137+
+ db, "fts2", &fts3Module, (void *)pHash, 0
138+
+ );
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>
@@ -14800,6 +14805,22 @@ static void open_db(ShellState *p, int openFlags){
1480014805
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1480114806
editFunc, 0, 0);
1480214807
#endif
14808+
14809+
// Begin Android Add
14810+
#ifndef NO_ANDROID_FUNCS
14811+
int err = register_localized_collators(p->db, "en_US", 0);
14812+
if (err != SQLITE_OK) {
14813+
fprintf(stderr, "register_localized_collators() failed\n");
14814+
exit(1);
14815+
}
14816+
err = register_android_functions(p->db, 0);
14817+
if (err != SQLITE_OK) {
14818+
fprintf(stderr, "register_android_functions() failed\n");
14819+
exit(1);
14820+
}
14821+
#endif
14822+
// End Android Add
14823+
1480314824
if( p->openMode==SHELL_OPEN_ZIPFILE ){
1480414825
char *zSql = sqlite3_mprintf(
1480514826
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);

dist/sqlite3.c

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

33809+
#if defined(__BIONIC__)
33810+
# include <android/fdsan.h>
33811+
#endif
33812+
3380933813
#ifdef HAVE_UTIME
3381033814
# include <utime.h>
3381133815
#endif
@@ -34566,6 +34570,12 @@ static int robust_open(const char *z, int f, mode_t m){
3456634570
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3456734571
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3456834572
#endif
34573+
34574+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34575+
uint64_t tag = android_fdsan_create_owner_tag(
34576+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
34577+
android_fdsan_exchange_owner_tag(fd, 0, tag);
34578+
#endif
3456934579
}
3457034580
return fd;
3457134581
}
@@ -35146,7 +35156,13 @@ static int unixLogErrorAtLine(
3514635156
** and move on.
3514735157
*/
3514835158
static void robust_close(unixFile *pFile, int h, int lineno){
35159+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
35160+
uint64_t tag = android_fdsan_create_owner_tag(
35161+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
35162+
if( android_fdsan_close_with_tag(h, tag) ){
35163+
#else
3514935164
if( osClose(h) ){
35165+
#endif
3515035166
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3515135167
pFile ? pFile->zPath : 0, lineno);
3515235168
}
@@ -37701,7 +37717,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3770137717
SimulateIOError( rc=1 );
3770237718
if( rc!=0 ){
3770337719
storeLastErrno((unixFile*)id, errno);
37704-
return SQLITE_IOERR_FSTAT;
37720+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
3770537721
}
3770637722
*pSize = buf.st_size;
3770737723

@@ -37737,7 +37753,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3773737753
struct stat buf; /* Used to hold return values of fstat() */
3773837754

3773937755
if( osFstat(pFile->h, &buf) ){
37740-
return SQLITE_IOERR_FSTAT;
37756+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
3774137757
}
3774237758

3774337759
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -38433,7 +38449,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3843338449
** with the same permissions.
3843438450
*/
3843538451
if( osFstat(pDbFd->h, &sStat) ){
38436-
rc = SQLITE_IOERR_FSTAT;
38452+
rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
3843738453
goto shm_open_err;
3843838454
}
3843938455

@@ -130467,7 +130483,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
130467130483
}
130468130484
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
130469130485
sqlite3SetString(pzErrMsg, db, "unsupported file format");
130470-
rc = SQLITE_ERROR;
130486+
rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
130471130487
goto initone_error_out;
130472130488
}
130473130489

@@ -174092,13 +174108,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
174092174108
** module with sqlite.
174093174109
*/
174094174110
if( SQLITE_OK==rc
174111+
#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
174095174112
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
174113+
#endif
174096174114
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
174097174115
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
174098174116
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
174099174117
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
174100174118
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
174101174119
){
174120+
#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
174121+
rc = sqlite3_create_module_v2(
174122+
db, "fts1", &fts3Module, (void *)pHash, 0
174123+
);
174124+
if(rc) return rc;
174125+
rc = sqlite3_create_module_v2(
174126+
db, "fts2", &fts3Module, (void *)pHash, 0
174127+
);
174128+
if(rc) return rc;
174129+
#endif
174102174130
rc = sqlite3_create_module_v2(
174103174131
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
174104174132
);

0 commit comments

Comments
 (0)