1--- orig/shell.c 2023-06-13 13:30:22.470500137 -0700 2+++ shell.c 2023-06-13 13:30:22.546500365 -0700 3@@ -127,6 +127,11 @@ 4 #endif 5 #include <ctype.h> 6 #include <stdarg.h> 7+// Begin Android Add 8+#ifndef NO_ANDROID_FUNCS 9+#include <sqlite3_android.h> 10+#endif 11+// End Android Add 12 13 #if !defined(_WIN32) && !defined(WIN32) 14 # include <signal.h> 15@@ -246,7 +251,9 @@ 16 #if SQLITE_OS_WINRT 17 #include <intrin.h> 18 #endif 19+#ifndef WIN32_LEAN_AND_MEAN 20 #define WIN32_LEAN_AND_MEAN 21+#endif 22 #include <windows.h> 23 24 /* string conversion routines only needed on Win32 */ 25@@ -20793,6 +20800,21 @@ 26 editFunc, 0, 0); 27 #endif 28 29+// Begin Android Add 30+#ifndef NO_ANDROID_FUNCS 31+ int err = register_localized_collators(p->db, "en_US", 0); 32+ if (err != SQLITE_OK) { 33+ fprintf(stderr, "register_localized_collators() failed\n"); 34+ exit(1); 35+ } 36+ err = register_android_functions(p->db, 0); 37+ if (err != SQLITE_OK) { 38+ fprintf(stderr, "register_android_functions() failed\n"); 39+ exit(1); 40+ } 41+#endif 42+// End Android Add 43+ 44 if( p->openMode==SHELL_OPEN_ZIPFILE ){ 45 char *zSql = sqlite3_mprintf( 46 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename); 47--- orig/sqlite3.c 2023-06-13 13:30:22.494500209 -0700 48+++ sqlite3.c 2023-06-13 13:30:22.590500496 -0700 49@@ -37314,6 +37314,10 @@ 50 # include <sys/mount.h> 51 #endif 52 53+#if defined(__BIONIC__) 54+# include <android/fdsan.h> 55+#endif 56+ 57 #ifdef HAVE_UTIME 58 # include <utime.h> 59 #endif 60@@ -37922,6 +37926,12 @@ 61 #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0) 62 osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); 63 #endif 64+ 65+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__ 66+ uint64_t tag = android_fdsan_create_owner_tag( 67+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd); 68+ android_fdsan_exchange_owner_tag(fd, 0, tag); 69+#endif 70 } 71 return fd; 72 } 73@@ -38502,7 +38512,13 @@ 74 ** and move on. 75 */ 76 static void robust_close(unixFile *pFile, int h, int lineno){ 77+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__ 78+ uint64_t tag = android_fdsan_create_owner_tag( 79+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h); 80+ if( android_fdsan_close_with_tag(h, tag) ){ 81+#else 82 if( osClose(h) ){ 83+#endif 84 unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close", 85 pFile ? pFile->zPath : 0, lineno); 86 } 87@@ -41051,7 +41067,7 @@ 88 SimulateIOError( rc=1 ); 89 if( rc!=0 ){ 90 storeLastErrno((unixFile*)id, errno); 91- return SQLITE_IOERR_FSTAT; 92+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath); 93 } 94 *pSize = buf.st_size; 95 96@@ -41087,7 +41103,7 @@ 97 struct stat buf; /* Used to hold return values of fstat() */ 98 99 if( osFstat(pFile->h, &buf) ){ 100- return SQLITE_IOERR_FSTAT; 101+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath); 102 } 103 104 nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; 105@@ -41829,7 +41845,7 @@ 106 ** with the same permissions. 107 */ 108 if( osFstat(pDbFd->h, &sStat) ){ 109- rc = SQLITE_IOERR_FSTAT; 110+ rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath); 111 goto shm_open_err; 112 } 113 114@@ -138266,7 +138282,7 @@ 115 } 116 if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ 117 sqlite3SetString(pzErrMsg, db, "unsupported file format"); 118- rc = SQLITE_ERROR; 119+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;"; 120 goto initone_error_out; 121 } 122 123@@ -185208,7 +185224,9 @@ 124 ** module with sqlite. 125 */ 126 if( SQLITE_OK==rc 127+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */ 128 && SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer")) 129+#endif 130 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) 131 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) 132 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1)) 133@@ -185219,6 +185237,20 @@ 134 rc = sqlite3_create_module_v2( 135 db, "fts3", &fts3Module, (void *)pHash, hashDestroy 136 ); 137+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS 138+ if( rc==SQLITE_OK ){ 139+ pHash->nRef++; 140+ rc = sqlite3_create_module_v2( 141+ db, "fts1", &fts3Module, (void *)pHash, hashDestroy 142+ ); 143+ } 144+ if( rc==SQLITE_OK ){ 145+ pHash->nRef++; 146+ rc = sqlite3_create_module_v2( 147+ db, "fts2", &fts3Module, (void *)pHash, hashDestroy 148+ ); 149+ } 150+#endif 151 if( rc==SQLITE_OK ){ 152 pHash->nRef++; 153 rc = sqlite3_create_module_v2( 154