1diff -r -u -d orig/shell.c ./shell.c 2--- orig/shell.c 2015-11-03 01:44:04.000000000 -0800 3+++ ./shell.c 2015-12-23 09:50:51.081951250 -0800 4@@ -52,6 +52,12 @@ 5 #endif 6 #include <ctype.h> 7 #include <stdarg.h> 8+// Begin Android Add 9+#ifndef NO_ANDROID_FUNCS 10+#include "IcuUtils.h" 11+#include <sqlite3_android.h> 12+#endif 13+// End Android Add 14 15 #if !defined(_WIN32) && !defined(WIN32) 16 # include <signal.h> 17@@ -1943,6 +1949,22 @@ 18 readfileFunc, 0, 0); 19 sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0, 20 writefileFunc, 0, 0); 21+ 22+ // Begin Android Add 23+ #ifndef NO_ANDROID_FUNCS 24+ InitializeIcuOrDie(); 25+ int err = register_localized_collators(p->db, "en_US", 0); 26+ if (err != SQLITE_OK) { 27+ fprintf(stderr, "register_localized_collators() failed\n"); 28+ exit(1); 29+ } 30+ err = register_android_functions(p->db, 0); 31+ if (err != SQLITE_OK) { 32+ fprintf(stderr, "register_android_functions() failed\n"); 33+ exit(1); 34+ } 35+ #endif 36+ // End Android Add 37 } 38 } 39 40diff -r -u -d orig/sqlite3.c ./sqlite3.c 41--- orig/sqlite3.c 2015-11-03 01:44:04.000000000 -0800 42+++ ./sqlite3.c 2015-12-23 09:50:51.113951381 -0800 43@@ -26470,6 +26470,13 @@ 44 /* #include "sqliteInt.h" */ 45 #if SQLITE_OS_UNIX /* This file is used on unix only */ 46 47+/* Use posix_fallocate() if it is available 48+*/ 49+#if !defined(HAVE_POSIX_FALLOCATE) \ 50+ && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) 51+# define HAVE_POSIX_FALLOCATE 1 52+#endif 53+ 54 /* 55 ** There are various methods for file locking used for concurrency 56 ** control: 57@@ -27024,7 +27031,12 @@ 58 #else 59 { "pread64", (sqlite3_syscall_ptr)0, 0 }, 60 #endif 61+#ifdef ANDROID 62+// Bionic defines pread64 using off64_t rather than off_t. 63+#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent) 64+#else 65 #define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent) 66+#endif 67 68 { "write", (sqlite3_syscall_ptr)write, 0 }, 69 #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent) 70@@ -27042,8 +27054,14 @@ 71 #else 72 { "pwrite64", (sqlite3_syscall_ptr)0, 0 }, 73 #endif 74+#ifdef ANDROID 75+// Bionic defines pwrite64 using off64_t rather than off_t. 76+#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\ 77+ aSyscall[13].pCurrent) 78+#else 79 #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\ 80 aSyscall[13].pCurrent) 81+#endif 82 83 { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 }, 84 #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent) 85@@ -30292,7 +30310,7 @@ 86 SimulateIOError( rc=1 ); 87 if( rc!=0 ){ 88 storeLastErrno((unixFile*)id, errno); 89- return SQLITE_IOERR_FSTAT; 90+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath); 91 } 92 *pSize = buf.st_size; 93 94@@ -30328,7 +30346,7 @@ 95 struct stat buf; /* Used to hold return values of fstat() */ 96 97 if( osFstat(pFile->h, &buf) ){ 98- return SQLITE_IOERR_FSTAT; 99+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath); 100 } 101 102 nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; 103@@ -30913,7 +30931,7 @@ 104 ** with the same permissions. 105 */ 106 if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){ 107- rc = SQLITE_IOERR_FSTAT; 108+ rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath); 109 goto shm_open_err; 110 } 111 112@@ -32260,7 +32278,7 @@ 113 *pUid = sStat.st_uid; 114 *pGid = sStat.st_gid; 115 }else{ 116- rc = SQLITE_IOERR_FSTAT; 117+ rc = unixLogError(SQLITE_IOERR_FSTAT, "stat", zDb); 118 } 119 }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ 120 *pMode = 0600; 121@@ -108046,7 +108064,7 @@ 122 } 123 if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ 124 sqlite3SetString(pzErrMsg, db, "unsupported file format"); 125- rc = SQLITE_ERROR; 126+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;" 127 goto initone_error_out; 128 } 129 130@@ -139786,16 +139804,28 @@ 131 ** module with sqlite. 132 */ 133 if( SQLITE_OK==rc 134+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */ 135 && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer")) 136+#endif 137 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) 138 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) 139 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1)) 140 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2)) 141 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1)) 142 ){ 143+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS 144+ rc = sqlite3_create_module_v2( 145+ db, "fts1", &fts3Module, (void *)pHash, 0 146+ ); 147+ if(rc) return rc; 148+ rc = sqlite3_create_module_v2( 149+ db, "fts2", &fts3Module, (void *)pHash, 0 150+ ); 151+ if(rc) return rc; 152+#endif 153 rc = sqlite3_create_module_v2( 154 db, "fts3", &fts3Module, (void *)pHash, hashDestroy 155- ); 156+ ); 157 if( rc==SQLITE_OK ){ 158 rc = sqlite3_create_module_v2( 159 db, "fts4", &fts3Module, (void *)pHash, 0 160