Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: third_party/sqlite/patches/0003-Exclude-journal-file-from-Time-Machine-if-database-i.patch

Issue 2623083002: [sql] Move time-machine support from third_party/sqlite to sql/ (Closed)
Patch Set: scoped-ref in test, too, iwyu pass to remove leftover-from-prototype includes. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/amalgamation/sqlite3.c ('k') | third_party/sqlite/src/Makefile.linux-gcc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 From bacae540479e7dc84bfbd059a20afa2ef00e8cdb Mon Sep 17 00:00:00 2001
2 From: mrossetti <mrossetti@chromium.org>
3 Date: Tue, 31 May 2011 23:12:11 +0000
4 Subject: [PATCH 03/10] Exclude journal file from Time Machine if database is
5 excluded.
6
7 BUG=74053
8
9 Original review URL: http://codereview.chromium.org/6990066
10
11 TODO(shess): The fts3_porter.c change is due to a conflict with an included
12 Apple library. Perhaps move the operative code to a .c file, and firewall
13 SQLite from that include.
14
15 TODO(shess): Revisit this for -wal mode. http://crbug.com/78507
16 ---
17 third_party/sqlite/src/Makefile.linux-gcc | 4 ++++
18 third_party/sqlite/src/ext/fts3/fts3_porter.c | 6 ++---
19 third_party/sqlite/src/main.mk | 2 +-
20 third_party/sqlite/src/src/pager.c | 32 +++++++++++++++++++++++++++
21 third_party/sqlite/src/src/sqliteInt.h | 10 +++++++++
22 5 files changed, 50 insertions(+), 4 deletions(-)
23
24 diff --git a/third_party/sqlite/src/Makefile.linux-gcc b/third_party/sqlite/src/ Makefile.linux-gcc
25 index a1dec21..952e8d1 100644
26 --- a/third_party/sqlite/src/Makefile.linux-gcc
27 +++ b/third_party/sqlite/src/Makefile.linux-gcc
28 @@ -44,7 +44,11 @@ THREADLIB = -lpthread
29 #### Specify any extra libraries needed to access required functions.
30 #
31 #TLIBS = -lrt # fdatasync on Solaris 8
32 +ifeq ($(shell uname -s),Darwin)
33 +TLIBS = -framework CoreServices
34 +else
35 TLIBS = -ldl
36 +endif
37
38 #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1
39 # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all
40 diff --git a/third_party/sqlite/src/ext/fts3/fts3_porter.c b/third_party/sqlite/ src/ext/fts3/fts3_porter.c
41 index 8fb4c25d..b180ee2 100644
42 --- a/third_party/sqlite/src/ext/fts3/fts3_porter.c
43 +++ b/third_party/sqlite/src/ext/fts3/fts3_porter.c
44 @@ -128,7 +128,7 @@ static int porterClose(sqlite3_tokenizer_cursor *pCursor){
45 /*
46 ** Vowel or consonant
47 */
48 -static const char cType[] = {
49 +static const char vOrCType[] = {
50 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
51 1, 1, 1, 2, 1
52 };
53 @@ -152,7 +152,7 @@ static int isConsonant(const char *z){
54 char x = *z;
55 if( x==0 ) return 0;
56 assert( x>='a' && x<='z' );
57 - j = cType[x-'a'];
58 + j = vOrCType[x-'a'];
59 if( j<2 ) return j;
60 return z[1]==0 || isVowel(z + 1);
61 }
62 @@ -161,7 +161,7 @@ static int isVowel(const char *z){
63 char x = *z;
64 if( x==0 ) return 0;
65 assert( x>='a' && x<='z' );
66 - j = cType[x-'a'];
67 + j = vOrCType[x-'a'];
68 if( j<2 ) return 1-j;
69 return isConsonant(z + 1);
70 }
71 diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk
72 index fcc0270..6ff3bd4 100644
73 --- a/third_party/sqlite/src/main.mk
74 +++ b/third_party/sqlite/src/main.mk
75 @@ -724,7 +724,7 @@ TESTFIXTURE_FLAGS += -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" - DSQLITE_CORE
76 testfixture$(EXE): $(TESTSRC2) libsqlite3.a $(TESTSRC) $(TOP)/src/tclsqlite.c
77 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 $(TESTFIXTURE_FLAGS) \
78 $(TESTSRC) $(TESTSRC2) $(TOP)/src/tclsqlite.c \
79 - -o testfixture$(EXE) $(LIBTCL) libsqlite3.a $(THREADLIB)
80 + -o testfixture$(EXE) $(LIBTCL) libsqlite3.a $(THREADLIB) $(TLIBS )
81
82 amalgamation-testfixture$(EXE): sqlite3.c $(TESTSRC) $(TOP)/src/tclsqlite.c
83 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 $(TESTFIXTURE_FLAGS) \
84 diff --git a/third_party/sqlite/src/src/pager.c b/third_party/sqlite/src/src/pag er.c
85 index 2c904d2..74c76f37 100644
86 --- a/third_party/sqlite/src/src/pager.c
87 +++ b/third_party/sqlite/src/src/pager.c
88 @@ -5497,6 +5497,20 @@ void sqlite3PagerUnref(DbPage *pPg){
89 if( pPg ) sqlite3PagerUnrefNotNull(pPg);
90 }
91
92 +#if defined(__APPLE__)
93 +/*
94 +** Create and return a CFURLRef given a cstring containing the path to a file.
95 +*/
96 +static CFURLRef create_cfurl_from_cstring(const char* filePath){
97 + CFStringRef urlString = CFStringCreateWithFileSystemRepresentation(
98 + kCFAllocatorDefault, filePath);
99 + CFURLRef urlRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
100 + urlString, kCFURLPOSIXPathStyle, FALSE);
101 + CFRelease(urlString);
102 + return urlRef;
103 +}
104 +#endif
105 +
106 /*
107 ** This function is called at the start of every write transaction.
108 ** There must already be a RESERVED or EXCLUSIVE lock on the database
109 @@ -5561,6 +5575,24 @@ static int pager_open_journal(Pager *pPager){
110 #else
111 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
112 #endif
113 +#if defined(__APPLE__)
114 + /* Set the TimeMachine exclusion metadata for the journal if it has
115 + ** been set for the database. Only do this for unix-type vfs
116 + ** implementations. */
117 + if( rc==SQLITE_OK && pPager->zFilename!=NULL
118 + && strlen(pPager->zFilename)>0
119 + && strncmp(pVfs->zName, "unix", 4)==0
120 + && ( pVfs->zName[4]=='-' || pVfs->zName[4]=='\0' ) ){
121 + CFURLRef database = create_cfurl_from_cstring(pPager->zFilename);
122 + if( CSBackupIsItemExcluded(database, NULL) ){
123 + CFURLRef journal = create_cfurl_from_cstring(pPager->zJournal);
124 + /* Ignore errors from the following exclusion call. */
125 + CSBackupSetItemExcluded(journal, TRUE, FALSE);
126 + CFRelease(journal);
127 + }
128 + CFRelease(database);
129 + }
130 +#endif
131 }
132 }
133 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
134 diff --git a/third_party/sqlite/src/src/sqliteInt.h b/third_party/sqlite/src/src /sqliteInt.h
135 index c01bbc7..745b910 100644
136 --- a/third_party/sqlite/src/src/sqliteInt.h
137 +++ b/third_party/sqlite/src/src/sqliteInt.h
138 @@ -3168,6 +3168,16 @@ int sqlite3CantopenError(int);
139 #endif
140
141 /*
142 +** The CoreServices.h and CoreFoundation.h headers are needed for excluding a
143 +** -journal file from Time Machine backups when its associated database has
144 +** previously been excluded by the client code.
145 +*/
146 +#if defined(__APPLE__)
147 +#include <CoreServices/CoreServices.h>
148 +#include <CoreFoundation/CoreFoundation.h>
149 +#endif
150 +
151 +/*
152 ** The following macros mimic the standard library functions toupper(),
153 ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
154 ** sqlite versions only work for ASCII characters, regardless of locale.
155 --
156 2.7.0
157
OLDNEW
« no previous file with comments | « third_party/sqlite/amalgamation/sqlite3.c ('k') | third_party/sqlite/src/Makefile.linux-gcc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698