blob: 2b315dc3cbd766651212a56f5014e181ae5d7f96 [file] [log] [blame]
Jeff Brown0bc48362012-04-19 19:17:00 -07001diff -r -u -d orig/shell.c ./shell.c
Nick Kralevich0c1333f2015-06-12 14:00:54 -07002--- orig/shell.c 2015-05-09 10:39:54.003128489 -0700
3+++ ./shell.c 2015-06-11 21:10:04.904360472 -0700
4@@ -52,6 +52,12 @@
Nick Kralevich3fcd43a2015-04-08 13:13:26 -07005 #endif
Jeff Brown0bc48362012-04-19 19:17:00 -07006 #include <ctype.h>
7 #include <stdarg.h>
8+// Begin Android Add
9+#ifndef NO_ANDROID_FUNCS
Nick Kralevich0c1333f2015-06-12 14:00:54 -070010+#include "IcuUtils.h"
Jeff Brown0bc48362012-04-19 19:17:00 -070011+#include <sqlite3_android.h>
12+#endif
13+// End Android Add
14
Nick Kralevich8fecf562014-05-29 16:56:33 -070015 #if !defined(_WIN32) && !defined(WIN32)
Jeff Brown0bc48362012-04-19 19:17:00 -070016 # include <signal.h>
Nick Kralevich0c1333f2015-06-12 14:00:54 -070017@@ -1938,6 +1944,22 @@
Jeff Brown9bee60b2014-08-20 16:41:25 -070018 readfileFunc, 0, 0);
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070019 sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
Jeff Brown9bee60b2014-08-20 16:41:25 -070020 writefileFunc, 0, 0);
21+
Jeff Brown0bc48362012-04-19 19:17:00 -070022+ // Begin Android Add
23+ #ifndef NO_ANDROID_FUNCS
Nick Kralevich0c1333f2015-06-12 14:00:54 -070024+ InitializeIcuOrDie();
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070025+ int err = register_localized_collators(p->db, "en_US", 0);
Jeff Brown0bc48362012-04-19 19:17:00 -070026+ if (err != SQLITE_OK) {
27+ fprintf(stderr, "register_localized_collators() failed\n");
28+ exit(1);
29+ }
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070030+ err = register_android_functions(p->db, 0);
Jeff Brown0bc48362012-04-19 19:17:00 -070031+ 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
Nick Kralevich0c1333f2015-06-12 14:00:54 -070041--- orig/sqlite3.c 2015-05-09 10:39:54.039128619 -0700
42+++ ./sqlite3.c 2015-05-09 10:39:54.075128751 -0700
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070043@@ -25289,6 +25289,13 @@
Nick Kralevich34084e22014-02-28 10:29:21 -080044 */
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:
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070057@@ -25843,7 +25850,12 @@
Jeff Brown0bc48362012-04-19 19:17:00 -070058 #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)
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070070@@ -25861,8 +25873,14 @@
Jeff Brown0bc48362012-04-19 19:17:00 -070071 #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
Jeff Brown0bc48362012-04-19 19:17:00 -070083 { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 },
Nick Kralevich8fecf562014-05-29 16:56:33 -070084 #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent)
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070085@@ -29112,7 +29130,7 @@
Nick Kralevich34084e22014-02-28 10:29:21 -080086 SimulateIOError( rc=1 );
87 if( rc!=0 ){
Nick Kralevich3fcd43a2015-04-08 13:13:26 -070088 storeLastErrno((unixFile*)id, errno);
Nick Kralevich34084e22014-02-28 10:29:21 -080089- return SQLITE_IOERR_FSTAT;
90+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
91 }
92 *pSize = buf.st_size;
93
Nick Kralevich3a6c79f2015-05-08 11:25:07 -070094@@ -29148,7 +29166,7 @@
Nick Kralevich34084e22014-02-28 10:29:21 -080095 struct stat buf; /* Used to hold return values of fstat() */
96
Nick Kralevich3fcd43a2015-04-08 13:13:26 -070097 if( osFstat(pFile->h, &buf) ){
98- return SQLITE_IOERR_FSTAT;
Nick Kralevich34084e22014-02-28 10:29:21 -080099+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
Nick Kralevich3fcd43a2015-04-08 13:13:26 -0700100 }
Nick Kralevich34084e22014-02-28 10:29:21 -0800101
102 nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
Nick Kralevich3a6c79f2015-05-08 11:25:07 -0700103@@ -29733,7 +29751,7 @@
Nick Kralevich34084e22014-02-28 10:29:21 -0800104 ** 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
Nick Kralevich3a6c79f2015-05-08 11:25:07 -0700112@@ -31079,7 +31097,7 @@
Nick Kralevich34084e22014-02-28 10:29:21 -0800113 *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;
Nick Kralevich3a6c79f2015-05-08 11:25:07 -0700121@@ -105873,7 +105891,7 @@
Jeff Brown0bc48362012-04-19 19:17:00 -0700122 }
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
Nick Kralevich3a6c79f2015-05-08 11:25:07 -0700130@@ -130846,9 +130864,9 @@
Jeff Brown0bc48362012-04-19 19:17:00 -0700131 #endif
132
133 #ifdef SQLITE_ENABLE_FTS3
134- if( !db->mallocFailed && rc==SQLITE_OK ){
135- rc = sqlite3Fts3Init(db);
136- }
Jeff Brown0bc48362012-04-19 19:17:00 -0700137+ if( !db->mallocFailed && rc==SQLITE_OK ){
Nick Kralevich34084e22014-02-28 10:29:21 -0800138+ rc = sqlite3Fts3Init(db);
Jeff Brown0bc48362012-04-19 19:17:00 -0700139+ }
Jeff Brown0bc48362012-04-19 19:17:00 -0700140 #endif
141
142 #ifdef SQLITE_ENABLE_ICU
Nick Kralevich3a6c79f2015-05-08 11:25:07 -0700143@@ -136906,16 +136924,28 @@
Nick Kralevich34084e22014-02-28 10:29:21 -0800144 ** module with sqlite.
145 */
146 if( SQLITE_OK==rc
147+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
148 && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
149+#endif
150 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
151 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
152 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
153 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
Jeff Brown0bc48362012-04-19 19:17:00 -0700154 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
155 ){
Nick Kralevich34084e22014-02-28 10:29:21 -0800156+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
157+ rc = sqlite3_create_module_v2(
158+ db, "fts1", &fts3Module, (void *)pHash, 0
159+ );
160+ if(rc) return rc;
161+ rc = sqlite3_create_module_v2(
162+ db, "fts2", &fts3Module, (void *)pHash, 0
163+ );
164+ if(rc) return rc;
165+#endif
Jeff Brown0bc48362012-04-19 19:17:00 -0700166 rc = sqlite3_create_module_v2(
Nick Kralevich34084e22014-02-28 10:29:21 -0800167 db, "fts3", &fts3Module, (void *)pHash, hashDestroy
168- );
169+ );
Jeff Brown0bc48362012-04-19 19:17:00 -0700170 if( rc==SQLITE_OK ){
171 rc = sqlite3_create_module_v2(
Nick Kralevich34084e22014-02-28 10:29:21 -0800172 db, "fts4", &fts3Module, (void *)pHash, 0