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

Commit 68c69d8

Browse files
committed
Applied Android changes to 3.40.1
1 parent 8af748f commit 68c69d8

File tree

3 files changed

+76
-19
lines changed

3 files changed

+76
-19
lines changed

dist/Android.patch

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
--- orig/shell.c 2022-09-01 12:39:01.340032408 +0100
2-
+++ shell.c 2022-09-01 12:39:01.528030292 +0100
3-
@@ -107,6 +107,11 @@
1+
diff --git a/dist/shell.c b/dist/shell.c
2+
index 63f708c..5afd4a9 100644
3+
--- a/dist/shell.c
4+
+++ b/dist/shell.c
5+
@@ -126,6 +126,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-
@@ -16177,6 +16182,22 @@
17+
@@ -19561,6 +19566,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);", zDbFilename);
38-
--- orig/sqlite3.c 2022-09-01 12:39:01.356032228 +0100
39-
+++ sqlite3.c 2022-09-01 12:39:15.955867966 +0100
40-
@@ -35608,6 +35608,10 @@
40+
diff --git a/dist/sqlite3.c b/dist/sqlite3.c
41+
index a290c82..a0e1ec3 100644
42+
--- a/dist/sqlite3.c
43+
+++ b/dist/sqlite3.c
44+
@@ -36808,6 +36808,10 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){
4145
# include <sys/mount.h>
4246
#endif
4347

@@ -48,7 +52,7 @@
4852
#ifdef HAVE_UTIME
4953
# include <utime.h>
5054
#endif
51-
@@ -36170,6 +36174,12 @@
55+
@@ -37373,6 +37377,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-
@@ -36750,7 +36760,13 @@
68+
@@ -37953,7 +37963,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-
@@ -39305,7 +39321,7 @@
82+
@@ -40508,7 +40524,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
7983
SimulateIOError( rc=1 );
8084
if( rc!=0 ){
8185
storeLastErrno((unixFile*)id, errno);
@@ -84,7 +88,7 @@
8488
}
8589
*pSize = buf.st_size;
8690

87-
@@ -39341,7 +39357,7 @@
91+
@@ -40544,7 +40560,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
8892
struct stat buf; /* Used to hold return values of fstat() */
8993

9094
if( osFstat(pFile->h, &buf) ){
@@ -93,7 +97,7 @@
9397
}
9498

9599
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
96-
@@ -40083,7 +40099,7 @@
100+
@@ -41286,7 +41302,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-
@@ -134802,7 +134818,7 @@
109+
@@ -136618,7 +136634,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,7 +115,7 @@
111115
goto initone_error_out;
112116
}
113117

114-
@@ -180855,7 +180871,9 @@
118+
@@ -182768,7 +182784,9 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
115119
** module with sqlite.
116120
*/
117121
if( SQLITE_OK==rc
@@ -121,7 +125,7 @@
121125
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
122126
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
123127
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
124-
@@ -180866,6 +180884,20 @@
128+
@@ -182779,6 +182797,20 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
125129
rc = sqlite3_create_module_v2(
126130
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
127131
);

dist/shell.c

+21
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ typedef unsigned char u8;
126126
#endif
127127
#include <ctype.h>
128128
#include <stdarg.h>
129+
// Begin Android Add
130+
#ifndef NO_ANDROID_FUNCS
131+
#include <sqlite3_android.h>
132+
#endif
133+
// End Android Add
129134

130135
#if !defined(_WIN32) && !defined(WIN32)
131136
# include <signal.h>
@@ -19561,6 +19566,22 @@ static void open_db(ShellState *p, int openFlags){
1956119566
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1956219567
editFunc, 0, 0);
1956319568
#endif
19569+
19570+
// Begin Android Add
19571+
#ifndef NO_ANDROID_FUNCS
19572+
int err = register_localized_collators(p->db, "en_US", 0);
19573+
if (err != SQLITE_OK) {
19574+
fprintf(stderr, "register_localized_collators() failed\n");
19575+
exit(1);
19576+
}
19577+
err = register_android_functions(p->db, 0);
19578+
if (err != SQLITE_OK) {
19579+
fprintf(stderr, "register_android_functions() failed\n");
19580+
exit(1);
19581+
}
19582+
#endif
19583+
// End Android Add
19584+
1956419585
if( p->openMode==SHELL_OPEN_ZIPFILE ){
1956519586
char *zSql = sqlite3_mprintf(
1956619587
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);

dist/sqlite3.c

+36-4
Original file line numberDiff line numberDiff line change
@@ -36808,6 +36808,10 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){
3680836808
# include <sys/mount.h>
3680936809
#endif
3681036810

36811+
#if defined(__BIONIC__)
36812+
# include <android/fdsan.h>
36813+
#endif
36814+
3681136815
#ifdef HAVE_UTIME
3681236816
# include <utime.h>
3681336817
#endif
@@ -37373,6 +37377,12 @@ static int robust_open(const char *z, int f, mode_t m){
3737337377
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3737437378
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3737537379
#endif
37380+
37381+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
37382+
uint64_t tag = android_fdsan_create_owner_tag(
37383+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
37384+
android_fdsan_exchange_owner_tag(fd, 0, tag);
37385+
#endif
3737637386
}
3737737387
return fd;
3737837388
}
@@ -37953,7 +37963,13 @@ static int unixLogErrorAtLine(
3795337963
** and move on.
3795437964
*/
3795537965
static void robust_close(unixFile *pFile, int h, int lineno){
37966+
#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
37967+
uint64_t tag = android_fdsan_create_owner_tag(
37968+
ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
37969+
if( android_fdsan_close_with_tag(h, tag) ){
37970+
#else
3795637971
if( osClose(h) ){
37972+
#endif
3795737973
unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3795837974
pFile ? pFile->zPath : 0, lineno);
3795937975
}
@@ -40508,7 +40524,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
4050840524
SimulateIOError( rc=1 );
4050940525
if( rc!=0 ){
4051040526
storeLastErrno((unixFile*)id, errno);
40511-
return SQLITE_IOERR_FSTAT;
40527+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
4051240528
}
4051340529
*pSize = buf.st_size;
4051440530

@@ -40544,7 +40560,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
4054440560
struct stat buf; /* Used to hold return values of fstat() */
4054540561

4054640562
if( osFstat(pFile->h, &buf) ){
40547-
return SQLITE_IOERR_FSTAT;
40563+
return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
4054840564
}
4054940565

4055040566
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -41286,7 +41302,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
4128641302
** with the same permissions.
4128741303
*/
4128841304
if( osFstat(pDbFd->h, &sStat) ){
41289-
rc = SQLITE_IOERR_FSTAT;
41305+
rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
4129041306
goto shm_open_err;
4129141307
}
4129241308

@@ -136618,7 +136634,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
136618136634
}
136619136635
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
136620136636
sqlite3SetString(pzErrMsg, db, "unsupported file format");
136621-
rc = SQLITE_ERROR;
136637+
rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
136622136638
goto initone_error_out;
136623136639
}
136624136640

@@ -182768,7 +182784,9 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
182768182784
** module with sqlite.
182769182785
*/
182770182786
if( SQLITE_OK==rc
182787+
#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
182771182788
&& SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer"))
182789+
#endif
182772182790
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
182773182791
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
182774182792
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
@@ -182779,6 +182797,20 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
182779182797
rc = sqlite3_create_module_v2(
182780182798
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
182781182799
);
182800+
#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
182801+
if( rc==SQLITE_OK ){
182802+
pHash->nRef++;
182803+
rc = sqlite3_create_module_v2(
182804+
db, "fts1", &fts3Module, (void *)pHash, hashDestroy
182805+
);
182806+
}
182807+
if( rc==SQLITE_OK ){
182808+
pHash->nRef++;
182809+
rc = sqlite3_create_module_v2(
182810+
db, "fts2", &fts3Module, (void *)pHash, hashDestroy
182811+
);
182812+
}
182813+
#endif
182782182814
if( rc==SQLITE_OK ){
182783182815
pHash->nRef++;
182784182816
rc = sqlite3_create_module_v2(

0 commit comments

Comments
 (0)