diff options
author | Bryan Ferris <bferris@google.com> | 2020-01-09 11:39:54 -0800 |
---|---|---|
committer | Bryan Ferris <bferris@google.com> | 2020-01-10 17:57:26 +0000 |
commit | 30846374cead7ba19f678e4a305207d6c94333e2 (patch) | |
tree | 54b0a5aabf617aa4c862b41e146344fdca36c4c2 | |
parent | 0f11c342886a8668da65d13cfb1e85596cf38e15 (diff) |
[RESTRICT AUTOMERGE] Apply Android.patch to dist directory
Test: atest SQLiteDatabaseTest
Bug: 140181188
Bug: 140180629
Bug: 140182003
Change-Id: I11031f94035f33dcee6bf4c6cf593277221aea29
-rw-r--r-- | dist/shell.c | 23 | ||||
-rw-r--r-- | dist/sqlite3.c | 20 |
2 files changed, 39 insertions, 4 deletions
diff --git a/dist/shell.c b/dist/shell.c index 41baf67..735aaff 100644 --- a/dist/shell.c +++ b/dist/shell.c @@ -87,6 +87,12 @@ typedef unsigned char u8; #endif #include <ctype.h> #include <stdarg.h> +// Begin Android Add +#ifndef NO_ANDROID_FUNCS +#include "IcuUtils.h" +#include <sqlite3_android.h> +#endif +// End Android Add #if !defined(_WIN32) && !defined(WIN32) # include <signal.h> @@ -10389,6 +10395,23 @@ static void open_db(ShellState *p, int keepAlive){ editFunc, 0, 0); sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0, editFunc, 0, 0); + + // Begin Android Add + #ifndef NO_ANDROID_FUNCS + InitializeIcuOrDie(); + int err = register_localized_collators(p->db, "en_US", 0); + if (err != SQLITE_OK) { + fprintf(stderr, "register_localized_collators() failed\n"); + exit(1); + } + err = register_android_functions(p->db, 0); + if (err != SQLITE_OK) { + fprintf(stderr, "register_android_functions() failed\n"); + exit(1); + } + #endif + // End Android Add + if( p->openMode==SHELL_OPEN_ZIPFILE ){ char *zSql = sqlite3_mprintf( "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename); diff --git a/dist/sqlite3.c b/dist/sqlite3.c index d14e246..c59f41c 100644 --- a/dist/sqlite3.c +++ b/dist/sqlite3.c @@ -34428,7 +34428,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){ SimulateIOError( rc=1 ); if( rc!=0 ){ storeLastErrno((unixFile*)id, errno); - return SQLITE_IOERR_FSTAT; + return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath); } *pSize = buf.st_size; @@ -34464,7 +34464,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){ struct stat buf; /* Used to hold return values of fstat() */ if( osFstat(pFile->h, &buf) ){ - return SQLITE_IOERR_FSTAT; + return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath); } nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; @@ -35139,7 +35139,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ ** with the same permissions. */ if( osFstat(pDbFd->h, &sStat) ){ - rc = SQLITE_IOERR_FSTAT; + rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath); goto shm_open_err; } @@ -118054,7 +118054,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ } if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ sqlite3SetString(pzErrMsg, db, "unsupported file format"); - rc = SQLITE_ERROR; + rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;"; goto initone_error_out; } @@ -152770,13 +152770,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ ** module with sqlite. */ if( SQLITE_OK==rc +#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */ && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer")) +#endif && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2)) && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1)) ){ +#ifdef SQLITE_ENABLE_FTS3_BACKWARDS + rc = sqlite3_create_module_v2( + db, "fts1", &fts3Module, (void *)pHash, 0 + ); + if(rc) return rc; + rc = sqlite3_create_module_v2( + db, "fts2", &fts3Module, (void *)pHash, 0 + ); + if(rc) return rc; +#endif rc = sqlite3_create_module_v2( db, "fts3", &fts3Module, (void *)pHash, hashDestroy ); |