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

Commit a575761

Browse files
committed
Applied Android changes to v3.36.0
1 parent 7b9d77b commit a575761

File tree

3 files changed

+73
-20
lines changed

3 files changed

+73
-20
lines changed

dist/Android.patch

Lines changed: 20 additions & 16 deletions
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 bf5be5c..bdde8b8 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+
@@ -15589,6 +15594,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 89faea5..71fdf1a 100644
42+
--- a/dist/sqlite3.c
43+
+++ b/dist/sqlite3.c
44+
@@ -34003,6 +34003,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+
@@ -34763,6 +34767,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+
@@ -35343,7 +35353,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+
@@ -37898,7 +37914,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+
@@ -37934,7 +37950,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+
@@ -38669,7 +38685,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+
@@ -131385,7 +131401,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+
@@ -175172,13 +175188,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

dist/shell.c

Lines changed: 21 additions & 0 deletions
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>
@@ -15589,6 +15594,22 @@ static void open_db(ShellState *p, int openFlags){
1558915594
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1559015595
editFunc, 0, 0);
1559115596
#endif
15597+
15598+
// Begin Android Add
15599+
#ifndef NO_ANDROID_FUNCS
15600+
int err = register_localized_collators(p->db, "en_US", 0);
15601+
if (err != SQLITE_OK) {
15602+
fprintf(stderr, "register_localized_collators() failed\n");
15603+
exit(1);
15604+
}
15605+
err = register_android_functions(p->db, 0);
15606+
if (err != SQLITE_OK) {
15607+
fprintf(stderr, "register_android_functions() failed\n");
15608+
exit(1);
15609+
}
15610+
#endif
15611+
// End Android Add
15612+
1559215613
if( p->openMode==SHELL_OPEN_ZIPFILE ){
1559315614
char *zSql = sqlite3_mprintf(
1559415615
"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
@@ -34003,6 +34003,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
3400334003
# include <sys/mount.h>
3400434004
#endif
3400534005

34006+
#if defined(__BIONIC__)
34007+
# include <android/fdsan.h>
34008+
#endif
34009+
3400634010
#ifdef HAVE_UTIME
3400734011
# include <utime.h>
3400834012
#endif
@@ -34763,6 +34767,12 @@ static int robust_open(const char *z, int f, mode_t m){
3476334767
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3476434768
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3476534769
#endif
34770+
34771+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34772+
uint64_t tag = android_fdsan_create_owner_tag(
34773+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
34774+
android_fdsan_exchange_owner_tag(fd, 0, tag);
34775+
#endif
3476634776
}
3476734777
return fd;
3476834778
}
@@ -35343,7 +35353,13 @@ static int unixLogErrorAtLine(
3534335353
** and move on.
3534435354
*/
3534535355
static void robust_close(unixFile *pFile, int h, int lineno){
35356+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
35357+
uint64_t tag = android_fdsan_create_owner_tag(
35358+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
35359+
if( android_fdsan_close_with_tag(h, tag) ){
35360+
#else
3534635361
if( osClose(h) ){
35362+
#endif
3534735363
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3534835364
pFile ? pFile->zPath : 0, lineno);
3534935365
}
@@ -37898,7 +37914,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3789837914
SimulateIOError( rc=1 );
3789937915
if( rc!=0 ){
3790037916
storeLastErrno((unixFile*)id, errno);
37901-
return SQLITE_IOERR_FSTAT;
37917+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
3790237918
}
3790337919
*pSize = buf.st_size;
3790437920

@@ -37934,7 +37950,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3793437950
struct stat buf; /* Used to hold return values of fstat() */
3793537951

3793637952
if( osFstat(pFile->h, &buf) ){
37937-
return SQLITE_IOERR_FSTAT;
37953+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
3793837954
}
3793937955

3794037956
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -38669,7 +38685,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3866938685
** with the same permissions.
3867038686
*/
3867138687
if( osFstat(pDbFd->h, &sStat) ){
38672-
rc = SQLITE_IOERR_FSTAT;
38688+
rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
3867338689
goto shm_open_err;
3867438690
}
3867538691

@@ -131385,7 +131401,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
131385131401
}
131386131402
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
131387131403
sqlite3SetString(pzErrMsg, db, "unsupported file format");
131388-
rc = SQLITE_ERROR;
131404+
rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
131389131405
goto initone_error_out;
131390131406
}
131391131407

@@ -175172,13 +175188,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
175172175188
** module with sqlite.
175173175189
*/
175174175190
if( SQLITE_OK==rc
175191+
#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
175175175192
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
175193+
#endif
175176175194
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
175177175195
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
175178175196
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
175179175197
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
175180175198
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
175181175199
){
175200+
#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
175201+
rc = sqlite3_create_module_v2(
175202+
db, "fts1", &fts3Module, (void *)pHash, 0
175203+
);
175204+
if(rc) return rc;
175205+
rc = sqlite3_create_module_v2(
175206+
db, "fts2", &fts3Module, (void *)pHash, 0
175207+
);
175208+
if(rc) return rc;
175209+
#endif
175182175210
rc = sqlite3_create_module_v2(
175183175211
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
175184175212
);

0 commit comments

Comments
 (0)