1--- orig/shell.c 2024-03-25 15:44:27.700300649 -0700 2+++ shell.c 2024-03-25 15:44:27.724300598 -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@@ -22266,6 +22271,21 @@ 16 editFunc, 0, 0); 17 #endif 18 19+// Begin Android Add 20+#ifndef NO_ANDROID_FUNCS 21+ int err = register_localized_collators(p->db, "en_US", 0); 22+ if (err != SQLITE_OK) { 23+ fprintf(stderr, "register_localized_collators() failed\n"); 24+ exit(1); 25+ } 26+ err = register_android_functions(p->db, 0); 27+ if (err != SQLITE_OK) { 28+ fprintf(stderr, "register_android_functions() failed\n"); 29+ exit(1); 30+ } 31+#endif 32+// End Android Add 33+ 34 if( p->openMode==SHELL_OPEN_ZIPFILE ){ 35 char *zSql = sqlite3_mprintf( 36 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename); 37--- orig/sqlite3.c 2024-03-25 15:44:27.708300632 -0700 38+++ sqlite3.c 2024-03-25 15:44:27.748300548 -0700 39@@ -38035,6 +38035,10 @@ 40 # include <sys/mount.h> 41 #endif 42 43+#if defined(__BIONIC__) 44+# include <android/fdsan.h> 45+#endif 46+ 47 #ifdef HAVE_UTIME 48 # include <utime.h> 49 #endif 50@@ -38643,6 +38647,12 @@ 51 #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0) 52 osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); 53 #endif 54+ 55+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__ 56+ uint64_t tag = android_fdsan_create_owner_tag( 57+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd); 58+ android_fdsan_exchange_owner_tag(fd, 0, tag); 59+#endif 60 } 61 return fd; 62 } 63@@ -39223,7 +39233,13 @@ 64 ** and move on. 65 */ 66 static void robust_close(unixFile *pFile, int h, int lineno){ 67+#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__ 68+ uint64_t tag = android_fdsan_create_owner_tag( 69+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h); 70+ if( android_fdsan_close_with_tag(h, tag) ){ 71+#else 72 if( osClose(h) ){ 73+#endif 74 unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close", 75 pFile ? pFile->zPath : 0, lineno); 76 } 77@@ -41763,7 +41779,7 @@ 78 SimulateIOError( rc=1 ); 79 if( rc!=0 ){ 80 storeLastErrno((unixFile*)id, errno); 81- return SQLITE_IOERR_FSTAT; 82+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath); 83 } 84 *pSize = buf.st_size; 85 86@@ -41799,7 +41815,7 @@ 87 struct stat buf; /* Used to hold return values of fstat() */ 88 89 if( osFstat(pFile->h, &buf) ){ 90- return SQLITE_IOERR_FSTAT; 91+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath); 92 } 93 94 nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; 95@@ -42541,7 +42557,7 @@ 96 ** with the same permissions. 97 */ 98 if( osFstat(pDbFd->h, &sStat) ){ 99- rc = SQLITE_IOERR_FSTAT; 100+ rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath); 101 goto shm_open_err; 102 } 103 104@@ -140715,7 +140731,7 @@ 105 } 106 if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ 107 sqlite3SetString(pzErrMsg, db, "unsupported file format"); 108- rc = SQLITE_ERROR; 109+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;"; 110 goto initone_error_out; 111 } 112 113@@ -188307,7 +188323,9 @@ 114 ** module with sqlite. 115 */ 116 if( SQLITE_OK==rc 117+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */ 118 && SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer")) 119+#endif 120 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) 121 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) 122 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1)) 123@@ -188318,6 +188336,20 @@ 124 rc = sqlite3_create_module_v2( 125 db, "fts3", &fts3Module, (void *)pHash, hashDestroy 126 ); 127+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS 128+ if( rc==SQLITE_OK ){ 129+ pHash->nRef++; 130+ rc = sqlite3_create_module_v2( 131+ db, "fts1", &fts3Module, (void *)pHash, hashDestroy 132+ ); 133+ } 134+ if( rc==SQLITE_OK ){ 135+ pHash->nRef++; 136+ rc = sqlite3_create_module_v2( 137+ db, "fts2", &fts3Module, (void *)pHash, hashDestroy 138+ ); 139+ } 140+#endif 141 if( rc==SQLITE_OK ){ 142 pHash->nRef++; 143 rc = sqlite3_create_module_v2( 144