@@ -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*/
3795537965static 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