Chromium Code Reviews| Index: third_party/sqlite/src/src/pager.c |
| =================================================================== |
| --- third_party/sqlite/src/src/pager.c (revision 86429) |
| +++ third_party/sqlite/src/src/pager.c (working copy) |
| @@ -122,6 +122,11 @@ |
| #define MAX_SECTOR_SIZE 0x10000 |
| /* |
| +** The string appended to the database file name giving the journal file name. |
| +*/ |
| +const char kPagerJournalSuffix[] = "-journal\0"; |
|
Mark Mentovai
2011/05/25 01:14:35
Why have you included a \0 here? C (including deri
Mark Mentovai
2011/05/25 01:14:35
However, here’s an area where C++ differs from str
mrossetti
2011/05/26 21:02:40
Done.
mrossetti
2011/05/26 21:02:40
Done.
|
| + |
| +/* |
| ** An instance of the following structure is allocated for each active |
| ** savepoint and statement transaction in the system. All such structures |
| ** are stored in the Pager.aSavepoint[] array, which is allocated and |
| @@ -3222,7 +3227,8 @@ |
| pPager->zJournal = (char*)(pPtr += nPathname + 1); |
| memcpy(pPager->zFilename, zPathname, nPathname); |
| memcpy(pPager->zJournal, zPathname, nPathname); |
| - memcpy(&pPager->zJournal[nPathname], "-journal", 8); |
| + memcpy(&pPager->zJournal[nPathname], kPagerJournalSuffix, |
| + strlen(kPagerJournalSuffix)); |
| if( pPager->zFilename[0]==0 ) pPager->zJournal[0] = 0; |
| sqlite3_free(zPathname); |
| } |
| @@ -3990,6 +3996,11 @@ |
| return rc; |
| } |
| +#if defined(__APPLE__) |
|
Mark Mentovai
2011/05/25 01:14:35
I’m not sure what the sqlite tradition is, but it
mrossetti
2011/05/26 21:02:40
Done.
|
| +#include <CoreServices/CoreServices.h> |
| +#include <CoreFoundation/CoreFoundation.h> |
| +#endif |
| + |
| /* |
| ** This function is called at the start of every write transaction. |
| ** There must already be a RESERVED or EXCLUSIVE lock on the database |
| @@ -4055,6 +4066,38 @@ |
| #else |
| rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0); |
| #endif |
| +#if defined(__APPLE__) |
| + if( rc == SQLITE_OK && pPager->zJournal ) { |
|
Mark Mentovai
2011/05/25 01:14:35
sqlite style seems to not put any spaces around th
mrossetti
2011/05/26 21:02:40
Done.
|
| + // Set the TimeMachine exclusion metadata for the journal if it has |
| + // been set for the database. |
| + int database_path_len = |
|
Mark Mentovai
2011/05/25 01:14:35
Unless there’s sqlite precedent to do otherwise…
mrossetti
2011/05/26 21:02:40
Done.
|
| + strlen(pPager->zJournal) - strlen(kPagerJournalSuffix) + 1; |
| + char *database_path = sqlite3Malloc(database_path_len); |
| + strlcpy(database_path, pPager->zJournal, database_path_len); |
| + CFURLRef database_url = |
|
Mark Mentovai
2011/05/25 01:14:35
sqlite seems to adhere to the rules for strict ANS
mrossetti
2011/05/26 21:02:40
Done.
|
| + CFURLCreateWithFileSystemPath(kCFAllocatorDefault, |
| + CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, |
|
Mark Mentovai
2011/05/25 01:14:35
1. Don’t use CFStringCreateWithCStringNoCopy with
mrossetti
2011/05/26 21:02:40
Done.
|
| + database_path, kCFStringEncodingMacRoman, kCFAllocatorNull), |
| + kCFURLPOSIXPathStyle, false); |
|
Mark Mentovai
2011/05/25 01:14:35
Technically you should use FALSE and not false her
mrossetti
2011/05/26 21:02:40
Done.
|
| + sqlite3_free(database_path); |
|
Avi (use Gerrit)
2011/05/25 14:22:16
Drive-by: Use of the NoCopy functions from CF lead
mrossetti
2011/05/26 21:02:40
Done.
|
| + if( CSBackupIsItemExcluded(database_url, NULL) ){ |
|
Mark Mentovai
2011/05/25 01:14:35
I suggest checking excludeByPath here and only pro
mrossetti
2011/05/26 21:02:40
Done.
|
| + CFURLRef journal_url = |
| + CFURLCreateWithFileSystemPath(kCFAllocatorDefault, |
| + CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, |
|
Mark Mentovai
2011/05/25 01:14:35
The same comments I made at line 4079 above apply
mrossetti
2011/05/26 21:02:40
Done.
|
| + pPager->zJournal, kCFStringEncodingMacRoman, |
| + kCFAllocatorNull), |
| + kCFURLPOSIXPathStyle, false); |
| + OSStatus err = CSBackupSetItemExcluded(journal_url, TRUE, FALSE); |
| + CFRelease(journal_url); |
| + if( err != noErr ){ |
| + fprintf(stderr, "CSBackupSetItemExcluded(\"%s\", TRUE, FALSE): %d", |
|
Mark Mentovai
2011/05/25 01:14:35
It doesn’t look like sqlite actually does any sort
mrossetti
2011/05/26 21:02:40
Done.
|
| + pPager->zJournal, (int)err); |
| + // DO NOT set rc to an error code -- ignore exclusion errors. |
| + } |
| + } |
| + CFRelease(database_url); |
| + } |
| +#endif |
| } |
| assert( rc!=SQLITE_OK || isOpen(pPager->jfd) ); |
| } |