diff --git a/dist/Android.patch b/dist/Android.patch index 3647d10..b165277 100644 --- a/dist/Android.patch +++ b/dist/Android.patch @@ -1,6 +1,8 @@ ---- orig/shell.c 2022-09-01 12:39:01.340032408 +0100 -+++ shell.c 2022-09-01 12:39:01.528030292 +0100 -@@ -107,6 +107,11 @@ +diff --git a/dist/shell.c b/dist/shell.c +index 63f708c..5afd4a9 100644 +--- a/dist/shell.c ++++ b/dist/shell.c +@@ -126,6 +126,11 @@ typedef unsigned char u8; #endif #include #include @@ -12,7 +14,7 @@ #if !defined(_WIN32) && !defined(WIN32) # include -@@ -16177,6 +16182,22 @@ +@@ -19561,6 +19566,22 @@ static void open_db(ShellState *p, int openFlags){ sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0, editFunc, 0, 0); #endif @@ -35,9 +37,11 @@ if( p->openMode==SHELL_OPEN_ZIPFILE ){ char *zSql = sqlite3_mprintf( "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename); ---- orig/sqlite3.c 2022-09-01 12:39:01.356032228 +0100 -+++ sqlite3.c 2022-09-01 12:39:15.955867966 +0100 -@@ -35608,6 +35608,10 @@ +diff --git a/dist/sqlite3.c b/dist/sqlite3.c +index a290c82..a0e1ec3 100644 +--- a/dist/sqlite3.c ++++ b/dist/sqlite3.c +@@ -36808,6 +36808,10 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){ # include #endif @@ -48,7 +52,7 @@ #ifdef HAVE_UTIME # include #endif -@@ -36170,6 +36174,12 @@ +@@ -37373,6 +37377,12 @@ static int robust_open(const char *z, int f, mode_t m){ #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0) osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); #endif @@ -61,7 +65,7 @@ } return fd; } -@@ -36750,7 +36760,13 @@ +@@ -37953,7 +37963,13 @@ static int unixLogErrorAtLine( ** and move on. */ static void robust_close(unixFile *pFile, int h, int lineno){ @@ -75,7 +79,7 @@ unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close", pFile ? pFile->zPath : 0, lineno); } -@@ -39305,7 +39321,7 @@ +@@ -40508,7 +40524,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){ SimulateIOError( rc=1 ); if( rc!=0 ){ storeLastErrno((unixFile*)id, errno); @@ -84,7 +88,7 @@ } *pSize = buf.st_size; -@@ -39341,7 +39357,7 @@ +@@ -40544,7 +40560,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){ struct stat buf; /* Used to hold return values of fstat() */ if( osFstat(pFile->h, &buf) ){ @@ -93,7 +97,7 @@ } nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; -@@ -40083,7 +40099,7 @@ +@@ -41286,7 +41302,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ ** with the same permissions. */ if( osFstat(pDbFd->h, &sStat) ){ @@ -102,7 +106,7 @@ goto shm_open_err; } -@@ -134802,7 +134818,7 @@ +@@ -136618,7 +136634,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl } if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ sqlite3SetString(pzErrMsg, db, "unsupported file format"); @@ -111,7 +115,7 @@ goto initone_error_out; } -@@ -180855,7 +180871,9 @@ +@@ -182768,7 +182784,9 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ ** module with sqlite. */ if( SQLITE_OK==rc @@ -121,7 +125,7 @@ && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1)) -@@ -180866,6 +180884,20 @@ +@@ -182779,6 +182797,20 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ rc = sqlite3_create_module_v2( db, "fts3", &fts3Module, (void *)pHash, hashDestroy ); diff --git a/dist/shell.c b/dist/shell.c index 63f708c..5afd4a9 100644 --- a/dist/shell.c +++ b/dist/shell.c @@ -126,6 +126,11 @@ typedef unsigned char u8; #endif #include #include +// Begin Android Add +#ifndef NO_ANDROID_FUNCS +#include +#endif +// End Android Add #if !defined(_WIN32) && !defined(WIN32) # include @@ -19561,6 +19566,22 @@ static void open_db(ShellState *p, int openFlags){ sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0, editFunc, 0, 0); #endif + +// Begin Android Add +#ifndef NO_ANDROID_FUNCS + int err = register_localized_collators(p->db, "en_US", 0); + if (err != SQLITE_OK) { + fprintf(stderr, "register_localized_collators() failed\n"); + exit(1); + } + err = register_android_functions(p->db, 0); + if (err != SQLITE_OK) { + fprintf(stderr, "register_android_functions() failed\n"); + exit(1); + } +#endif +// End Android Add + if( p->openMode==SHELL_OPEN_ZIPFILE ){ char *zSql = sqlite3_mprintf( "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename); diff --git a/dist/sqlite3.c b/dist/sqlite3.c index a290c82..a0e1ec3 100644 --- a/dist/sqlite3.c +++ b/dist/sqlite3.c @@ -36808,6 +36808,10 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){ # include #endif +#if defined(__BIONIC__) +# include +#endif + #ifdef HAVE_UTIME # include #endif @@ -37373,6 +37377,12 @@ static int robust_open(const char *z, int f, mode_t m){ #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0) osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); #endif + +#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__ + uint64_t tag = android_fdsan_create_owner_tag( + ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd); + android_fdsan_exchange_owner_tag(fd, 0, tag); +#endif } return fd; } @@ -37953,7 +37963,13 @@ static int unixLogErrorAtLine( ** and move on. */ static void robust_close(unixFile *pFile, int h, int lineno){ +#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__ + uint64_t tag = android_fdsan_create_owner_tag( + ANDROID_FDSAN_OWNER_TYPE_SQLITE, h); + if( android_fdsan_close_with_tag(h, tag) ){ +#else if( osClose(h) ){ +#endif unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close", pFile ? pFile->zPath : 0, lineno); } @@ -40508,7 +40524,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){ SimulateIOError( rc=1 ); if( rc!=0 ){ storeLastErrno((unixFile*)id, errno); - return SQLITE_IOERR_FSTAT; + return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath); } *pSize = buf.st_size; @@ -40544,7 +40560,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){ struct stat buf; /* Used to hold return values of fstat() */ if( osFstat(pFile->h, &buf) ){ - return SQLITE_IOERR_FSTAT; + return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath); } nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; @@ -41286,7 +41302,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ ** with the same permissions. */ if( osFstat(pDbFd->h, &sStat) ){ - rc = SQLITE_IOERR_FSTAT; + rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath); goto shm_open_err; } @@ -136618,7 +136634,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl } if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ sqlite3SetString(pzErrMsg, db, "unsupported file format"); - rc = SQLITE_ERROR; + rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;"; goto initone_error_out; } @@ -182768,7 +182784,9 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ ** module with sqlite. */ if( SQLITE_OK==rc +#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */ && SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer")) +#endif && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1)) @@ -182779,6 +182797,20 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ rc = sqlite3_create_module_v2( db, "fts3", &fts3Module, (void *)pHash, hashDestroy ); +#ifdef SQLITE_ENABLE_FTS3_BACKWARDS + if( rc==SQLITE_OK ){ + pHash->nRef++; + rc = sqlite3_create_module_v2( + db, "fts1", &fts3Module, (void *)pHash, hashDestroy + ); + } + if( rc==SQLITE_OK ){ + pHash->nRef++; + rc = sqlite3_create_module_v2( + db, "fts2", &fts3Module, (void *)pHash, hashDestroy + ); + } +#endif if( rc==SQLITE_OK ){ pHash->nRef++; rc = sqlite3_create_module_v2(