Home | History | Annotate | Download | only in dist
      1 --- orig/shell.c	2018-02-20 10:41:05.477047088 +0000
      2 +++ shell.c	2019-03-15 19:21:22.193972160 +0000
      3 @@ -87,6 +87,12 @@
      4  #endif
      5  #include <ctype.h>
      6  #include <stdarg.h>
      7 +// Begin Android Add
      8 +#ifndef NO_ANDROID_FUNCS
      9 +#include <aicu/AIcu.h>
     10 +#include <sqlite3_android.h>
     11 +#endif
     12 +// End Android Add
     13  
     14  #if !defined(_WIN32) && !defined(WIN32)
     15  # include <signal.h>
     16 @@ -10389,6 +10395,23 @@
     17                              editFunc, 0, 0);
     18      sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
     19                              editFunc, 0, 0);
     20 +
     21 +    // Begin Android Add
     22 +    #ifndef NO_ANDROID_FUNCS
     23 +        AIcu_initializeIcuOrDie();
     24 +        int err = register_localized_collators(p->db, "en_US", 0);
     25 +        if (err != SQLITE_OK) {
     26 +          fprintf(stderr, "register_localized_collators() failed\n");
     27 +          exit(1);
     28 +        }
     29 +        err = register_android_functions(p->db, 0);
     30 +        if (err != SQLITE_OK) {
     31 +          fprintf(stderr, "register_android_functions() failed\n");
     32 +          exit(1);
     33 +        }
     34 +    #endif
     35 +    // End Android Add
     36 +
     37      if( p->openMode==SHELL_OPEN_ZIPFILE ){
     38        char *zSql = sqlite3_mprintf(
     39           "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
     40 --- orig/sqlite3.c	2019-01-14 19:10:21.799582821 +0000
     41 +++ sqlite3.c	2019-01-14 19:10:21.847582627 +0000
     42 @@ -30672,6 +30672,10 @@
     43  # include <sys/mount.h>
     44  #endif
     45  
     46 +#if defined(__BIONIC__)
     47 +# include <android/fdsan.h>
     48 +#endif
     49 +
     50  #ifdef HAVE_UTIME
     51  # include <utime.h>
     52  #endif
     53 @@ -31422,6 +31426,12 @@
     54  #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
     55      osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
     56  #endif
     57 +
     58 +#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
     59 +    uint64_t tag = android_fdsan_create_owner_tag(
     60 +        ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
     61 +    android_fdsan_exchange_owner_tag(fd, 0, tag);
     62 +#endif
     63    }
     64    return fd;
     65  }
     66 @@ -31954,7 +31964,13 @@
     67  ** and move on.
     68  */
     69  static void robust_close(unixFile *pFile, int h, int lineno){
     70 +#if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
     71 +  uint64_t tag = android_fdsan_create_owner_tag(
     72 +      ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
     73 +  if( android_fdsan_close_with_tag(h, tag) ){
     74 +#else
     75    if( osClose(h) ){
     76 +#endif
     77      unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
     78                         pFile ? pFile->zPath : 0, lineno);
     79    }
     80 @@ -34428,7 +34444,7 @@
     81    SimulateIOError( rc=1 );
     82    if( rc!=0 ){
     83      storeLastErrno((unixFile*)id, errno);
     84 -    return SQLITE_IOERR_FSTAT;
     85 +    return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
     86    }
     87    *pSize = buf.st_size;
     88  
     89 @@ -34464,7 +34480,7 @@
     90      struct stat buf;              /* Used to hold return values of fstat() */
     91     
     92      if( osFstat(pFile->h, &buf) ){
     93 -      return SQLITE_IOERR_FSTAT;
     94 +      return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
     95      }
     96  
     97      nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
     98 @@ -35139,7 +35155,7 @@
     99      ** with the same permissions.
    100      */
    101      if( osFstat(pDbFd->h, &sStat) ){
    102 -      rc = SQLITE_IOERR_FSTAT;
    103 +      rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
    104        goto shm_open_err;
    105      }
    106  
    107 @@ -118054,7 +118070,7 @@
    108    }
    109    if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
    110      sqlite3SetString(pzErrMsg, db, "unsupported file format");
    111 -    rc = SQLITE_ERROR;
    112 +    rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;";
    113      goto initone_error_out;
    114    }
    115  
    116 @@ -152769,13 +152785,25 @@
    117    ** module with sqlite.
    118    */
    119    if( SQLITE_OK==rc 
    120 +#ifndef ANDROID    /* fts3_tokenizer disabled for security reasons */
    121     && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
    122 +#endif
    123     && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
    124     && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
    125     && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
    126     && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
    127     && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
    128    ){
    129 +#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
    130 +    rc = sqlite3_create_module_v2(
    131 +        db, "fts1", &fts3Module, (void *)pHash, 0
    132 +        );
    133 +    if(rc) return rc;
    134 +    rc = sqlite3_create_module_v2(
    135 +        db, "fts2", &fts3Module, (void *)pHash, 0
    136 +        );
    137 +    if(rc) return rc;
    138 +#endif
    139      rc = sqlite3_create_module_v2(
    140          db, "fts3", &fts3Module, (void *)pHash, hashDestroy
    141      );
    142