1 diff -r -u -d orig/shell.c ./shell.c 2 --- orig/shell.c 2012-04-19 19:18:38.000000000 -0700 3 +++ ./shell.c 2012-04-19 19:26:02.000000000 -0700 4 @@ -35,6 +35,11 @@ 5 #include "sqlite3.h" 6 #include <ctype.h> 7 #include <stdarg.h> 8 +// Begin Android Add 9 +#ifndef NO_ANDROID_FUNCS 10 +#include <sqlite3_android.h> 11 +#endif 12 +// End Android Add 13 14 #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) 15 # include <signal.h> 16 @@ -1463,6 +1468,20 @@ 17 #ifndef SQLITE_OMIT_LOAD_EXTENSION 18 sqlite3_enable_load_extension(p->db, 1); 19 #endif 20 + // Begin Android Add 21 + #ifndef NO_ANDROID_FUNCS 22 + int err = register_localized_collators(db, "en_US", 0); 23 + if (err != SQLITE_OK) { 24 + fprintf(stderr, "register_localized_collators() failed\n"); 25 + exit(1); 26 + } 27 + err = register_android_functions(db, 0); 28 + if (err != SQLITE_OK) { 29 + fprintf(stderr, "register_android_functions() failed\n"); 30 + exit(1); 31 + } 32 + #endif 33 + // End Android Add 34 } 35 } 36 37 diff -r -u -d orig/sqlite3.c ./sqlite3.c 38 --- orig/sqlite3.c 2012-04-19 19:18:38.000000000 -0700 39 +++ ./sqlite3.c 2012-04-19 19:26:02.000000000 -0700 40 @@ -25387,7 +25387,12 @@ 41 #else 42 { "pread64", (sqlite3_syscall_ptr)0, 0 }, 43 #endif 44 +#ifdef ANDROID 45 +// Bionic defines pread64 using off64_t rather than off_t. 46 +#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent) 47 +#else 48 #define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent) 49 +#endif 50 51 { "write", (sqlite3_syscall_ptr)write, 0 }, 52 #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent) 53 @@ -25405,8 +25410,14 @@ 54 #else 55 { "pwrite64", (sqlite3_syscall_ptr)0, 0 }, 56 #endif 57 +#ifdef ANDROID 58 +// Bionic defines pwrite64 using off64_t rather than off_t. 59 +#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\ 60 + aSyscall[13].pCurrent) 61 +#else 62 #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\ 63 aSyscall[13].pCurrent) 64 +#endif 65 66 #if SQLITE_ENABLE_LOCKING_STYLE 67 { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 }, 68 @@ -93937,7 +93948,7 @@ 69 } 70 if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ 71 sqlite3SetString(pzErrMsg, db, "unsupported file format"); 72 - rc = SQLITE_ERROR; 73 + rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;" 74 goto initone_error_out; 75 } 76 77 @@ -112387,7 +112398,7 @@ 78 extern "C" { 79 #endif /* __cplusplus */ 80 81 -SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db); 82 +SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db, const char* registerAs); // Android Change 83 84 #if 0 85 } /* extern "C" */ 86 @@ -114717,9 +114728,24 @@ 87 #endif 88 89 #ifdef SQLITE_ENABLE_FTS3 90 - if( !db->mallocFailed && rc==SQLITE_OK ){ 91 - rc = sqlite3Fts3Init(db); 92 - } 93 + // Begin Android change 94 + #ifdef SQLITE_ENABLE_FTS3_BACKWARDS 95 + /* Also register as fts1 and fts2, for backwards compatability on 96 + ** systems known to have never seen a pre-fts3 database. 97 + */ 98 + if( !db->mallocFailed && rc==SQLITE_OK ){ 99 + rc = sqlite3Fts3Init(db, "fts1"); 100 + } 101 + 102 + if( !db->mallocFailed && rc==SQLITE_OK ){ 103 + rc = sqlite3Fts3Init(db, "fts2"); 104 + } 105 + #endif 106 + 107 + if( !db->mallocFailed && rc==SQLITE_OK ){ 108 + rc = sqlite3Fts3Init(db, "fts3"); 109 + } 110 + // End Android change 111 #endif 112 113 #ifdef SQLITE_ENABLE_ICU 114 @@ -120143,7 +120169,7 @@ 115 ** SQLite. If fts3 is built as a dynamically loadable extension, this 116 ** function is called by the sqlite3_extension_init() entry point. 117 */ 118 -SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ 119 +SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db, const char* registerAs){ // Android Change 120 int rc = SQLITE_OK; 121 Fts3Hash *pHash = 0; 122 const sqlite3_tokenizer_module *pSimple = 0; 123 @@ -120204,7 +120230,10 @@ 124 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1)) 125 ){ 126 rc = sqlite3_create_module_v2( 127 - db, "fts3", &fts3Module, (void *)pHash, hashDestroy 128 + // Begin Android change 129 + // Also register as fts1 and fts2 130 + db, registerAs, &fts3Module, (void *)pHash, hashDestroy 131 + // End Android change 132 ); 133 if( rc==SQLITE_OK ){ 134 rc = sqlite3_create_module_v2( 135