OLD | NEW |
1 /* | 1 /* |
2 ** 2001 September 15 | 2 ** 2001 September 15 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 5075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5086 ** removed. | 5086 ** removed. |
5087 */ | 5087 */ |
5088 void sqlite3PagerUnref(DbPage *pPg){ | 5088 void sqlite3PagerUnref(DbPage *pPg){ |
5089 if( pPg ){ | 5089 if( pPg ){ |
5090 Pager *pPager = pPg->pPager; | 5090 Pager *pPager = pPg->pPager; |
5091 sqlite3PcacheRelease(pPg); | 5091 sqlite3PcacheRelease(pPg); |
5092 pagerUnlockIfUnused(pPager); | 5092 pagerUnlockIfUnused(pPager); |
5093 } | 5093 } |
5094 } | 5094 } |
5095 | 5095 |
5096 #if defined(__APPLE__) | |
5097 /* | |
5098 ** Create and return a CFURLRef given a cstring containing the path to a file. | |
5099 */ | |
5100 static CFURLRef create_cfurl_from_cstring(const char* filePath){ | |
5101 CFStringRef urlString = CFStringCreateWithFileSystemRepresentation( | |
5102 kCFAllocatorDefault, filePath); | |
5103 CFURLRef urlRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, | |
5104 urlString, kCFURLPOSIXPathStyle, FALSE); | |
5105 CFRelease(urlString); | |
5106 return urlRef; | |
5107 } | |
5108 #endif | |
5109 | |
5110 /* | 5096 /* |
5111 ** This function is called at the start of every write transaction. | 5097 ** This function is called at the start of every write transaction. |
5112 ** There must already be a RESERVED or EXCLUSIVE lock on the database | 5098 ** There must already be a RESERVED or EXCLUSIVE lock on the database |
5113 ** file when this routine is called. | 5099 ** file when this routine is called. |
5114 ** | 5100 ** |
5115 ** Open the journal file for pager pPager and write a journal header | 5101 ** Open the journal file for pager pPager and write a journal header |
5116 ** to the start of it. If there are active savepoints, open the sub-journal | 5102 ** to the start of it. If there are active savepoints, open the sub-journal |
5117 ** as well. This function is only used when the journal file is being | 5103 ** as well. This function is only used when the journal file is being |
5118 ** opened to write a rollback log for a transaction. It is not used | 5104 ** opened to write a rollback log for a transaction. It is not used |
5119 ** when opening a hot journal file to roll it back. | 5105 ** when opening a hot journal file to roll it back. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5159 (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL): | 5145 (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL): |
5160 (SQLITE_OPEN_MAIN_JOURNAL) | 5146 (SQLITE_OPEN_MAIN_JOURNAL) |
5161 ); | 5147 ); |
5162 #ifdef SQLITE_ENABLE_ATOMIC_WRITE | 5148 #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
5163 rc = sqlite3JournalOpen( | 5149 rc = sqlite3JournalOpen( |
5164 pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager) | 5150 pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager) |
5165 ); | 5151 ); |
5166 #else | 5152 #else |
5167 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0); | 5153 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0); |
5168 #endif | 5154 #endif |
5169 #if defined(__APPLE__) | |
5170 /* Set the TimeMachine exclusion metadata for the journal if it has | |
5171 ** been set for the database. Only do this for unix-type vfs | |
5172 ** implementations. */ | |
5173 if( rc==SQLITE_OK && pPager->zFilename!=NULL | |
5174 && strlen(pPager->zFilename)>0 | |
5175 && strncmp(pVfs->zName, "unix", 4)==0 | |
5176 && ( pVfs->zName[4]=='-' || pVfs->zName[4]=='\0' ) ){ | |
5177 CFURLRef database = create_cfurl_from_cstring(pPager->zFilename); | |
5178 if( CSBackupIsItemExcluded(database, NULL) ){ | |
5179 CFURLRef journal = create_cfurl_from_cstring(pPager->zJournal); | |
5180 /* Ignore errors from the following exclusion call. */ | |
5181 CSBackupSetItemExcluded(journal, TRUE, FALSE); | |
5182 CFRelease(journal); | |
5183 } | |
5184 CFRelease(database); | |
5185 } | |
5186 #endif | |
5187 } | 5155 } |
5188 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) ); | 5156 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) ); |
5189 } | 5157 } |
5190 | 5158 |
5191 | 5159 |
5192 /* Write the first journal header to the journal file and open | 5160 /* Write the first journal header to the journal file and open |
5193 ** the sub-journal if necessary. | 5161 ** the sub-journal if necessary. |
5194 */ | 5162 */ |
5195 if( rc==SQLITE_OK ){ | 5163 if( rc==SQLITE_OK ){ |
5196 /* TODO: Check if all of these are really required. */ | 5164 /* TODO: Check if all of these are really required. */ |
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6839 void *sqlite3PagerCodec(PgHdr *pPg){ | 6807 void *sqlite3PagerCodec(PgHdr *pPg){ |
6840 void *aData = 0; | 6808 void *aData = 0; |
6841 CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData); | 6809 CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData); |
6842 return aData; | 6810 return aData; |
6843 } | 6811 } |
6844 #endif /* SQLITE_HAS_CODEC */ | 6812 #endif /* SQLITE_HAS_CODEC */ |
6845 | 6813 |
6846 #endif /* !SQLITE_OMIT_WAL */ | 6814 #endif /* !SQLITE_OMIT_WAL */ |
6847 | 6815 |
6848 #endif /* SQLITE_OMIT_DISKIO */ | 6816 #endif /* SQLITE_OMIT_DISKIO */ |
OLD | NEW |