summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/amalgamation
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 23:12:11 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 23:12:11 +0000
commit21799f4bffc69ec1b1ccd485a15e1ba08faccf1d (patch)
tree9ad3dd930b892c93b5ec4efb07c681a2fa3d0a3f /third_party/sqlite/amalgamation
parent29a6897f96acbc960cc0d4fd07657caa7969a5e5 (diff)
downloadchromium_src-21799f4bffc69ec1b1ccd485a15e1ba08faccf1d.zip
chromium_src-21799f4bffc69ec1b1ccd485a15e1ba08faccf1d.tar.gz
chromium_src-21799f4bffc69ec1b1ccd485a15e1ba08faccf1d.tar.bz2
Mac SQLite TimeMachine File Exclusions
When an SQLite database has been excluded from Time Machine backups also exclude its -journal. (In fts3_porter.c: had to rename the cType due to a conflict with an included Apple library.) BUG=74053 TEST=Manually: 1) Launch browser. 2) Run the following command: /usr/bin/xattr-2.6 ~/Library/Application\ Support/Chromium/Default/History-journal 3) Verify that the following is shown as one of the results of running the xattr-2.6 command: com.apple.metadata:com_apple_backup_excludeItem Review URL: http://codereview.chromium.org/6990066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87391 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/sqlite/amalgamation')
-rw-r--r--third_party/sqlite/amalgamation/sqlite3.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/third_party/sqlite/amalgamation/sqlite3.c b/third_party/sqlite/amalgamation/sqlite3.c
index cb4efb2..b1a6cc8 100644
--- a/third_party/sqlite/amalgamation/sqlite3.c
+++ b/third_party/sqlite/amalgamation/sqlite3.c
@@ -10871,6 +10871,16 @@ SQLITE_PRIVATE int sqlite3CantopenError(int);
#endif
/*
+** The CoreServices.h and CoreFoundation.h headers are needed for excluding a
+** -journal file from Time Machine backups when its associated database has
+** previously been excluded by the client code.
+*/
+#if defined(__APPLE__)
+#include <CoreServices/CoreServices.h>
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+/*
** The following macros mimic the standard library functions toupper(),
** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
** sqlite versions only work for ASCII characters, regardless of locale.
@@ -41551,6 +41561,20 @@ SQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){
}
}
+#if defined(__APPLE__)
+/*
+** Create and return a CFURLRef given a cstring containing the path to a file.
+*/
+static CFURLRef create_cfurl_from_cstring(const char* filePath){
+ CFStringRef urlString = CFStringCreateWithFileSystemRepresentation(
+ kCFAllocatorDefault, filePath);
+ CFURLRef urlRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
+ urlString, kCFURLPOSIXPathStyle, FALSE);
+ CFRelease(urlString);
+ return urlRef;
+}
+#endif
+
/*
** This function is called at the start of every write transaction.
** There must already be a RESERVED or EXCLUSIVE lock on the database
@@ -41610,6 +41634,21 @@ static int pager_open_journal(Pager *pPager){
#else
rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
#endif
+#if defined(__APPLE__)
+ /* Set the TimeMachine exclusion metadata for the journal if it has
+ ** been set for the database. */
+ if( rc==SQLITE_OK && pPager->zFilename!=NULL
+ && strlen(pPager->zFilename)>0 ){
+ CFURLRef database = create_cfurl_from_cstring(pPager->zFilename);
+ if( CSBackupIsItemExcluded(database, NULL) ){
+ CFURLRef journal = create_cfurl_from_cstring(pPager->zJournal);
+ /* Ignore errors from the following exclusion call. */
+ CSBackupSetItemExcluded(journal, TRUE, FALSE);
+ CFRelease(journal);
+ }
+ CFRelease(database);
+ }
+#endif
}
assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
}
@@ -116631,7 +116670,7 @@ static int porterClose(sqlite3_tokenizer_cursor *pCursor){
/*
** Vowel or consonant
*/
-static const char cType[] = {
+static const char vOrCType[] = {
0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
1, 1, 1, 2, 1
};
@@ -116655,7 +116694,7 @@ static int isConsonant(const char *z){
char x = *z;
if( x==0 ) return 0;
assert( x>='a' && x<='z' );
- j = cType[x-'a'];
+ j = vOrCType[x-'a'];
if( j<2 ) return j;
return z[1]==0 || isVowel(z + 1);
}
@@ -116664,7 +116703,7 @@ static int isVowel(const char *z){
char x = *z;
if( x==0 ) return 0;
assert( x>='a' && x<='z' );
- j = cType[x-'a'];
+ j = vOrCType[x-'a'];
if( j<2 ) return 1-j;
return isConsonant(z + 1);
}