OLD | NEW |
1 /* | 1 /* |
2 ** 2008 Jan 22 | 2 ** 2008 Jan 22 |
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 402 } |
403 | 403 |
404 /* Calculate and store a checksum for each page in the database file. */ | 404 /* Calculate and store a checksum for each page in the database file. */ |
405 if( rc==SQLITE_OK ){ | 405 if( rc==SQLITE_OK ){ |
406 int ii; | 406 int ii; |
407 for(ii=0; rc==SQLITE_OK && ii<(int)pMain->nPage; ii++){ | 407 for(ii=0; rc==SQLITE_OK && ii<(int)pMain->nPage; ii++){ |
408 i64 iOff = (i64)(pMain->nPagesize) * (i64)ii; | 408 i64 iOff = (i64)(pMain->nPagesize) * (i64)ii; |
409 if( iOff==PENDING_BYTE ) continue; | 409 if( iOff==PENDING_BYTE ) continue; |
410 rc = sqlite3OsRead(pMain->pReal, aData, pMain->nPagesize, iOff); | 410 rc = sqlite3OsRead(pMain->pReal, aData, pMain->nPagesize, iOff); |
411 pMain->aCksum[ii] = genCksum(aData, pMain->nPagesize); | 411 pMain->aCksum[ii] = genCksum(aData, pMain->nPagesize); |
412 if( ii+1==pMain->nPage && rc==SQLITE_IOERR_SHORT_READ ) rc = SQLITE_OK; | 412 if( ii+1==(int)pMain->nPage && rc==SQLITE_IOERR_SHORT_READ ){ |
| 413 rc = SQLITE_OK; |
| 414 } |
413 } | 415 } |
414 } | 416 } |
415 | 417 |
416 start_ioerr_simulation(iSave, iSave2); | 418 start_ioerr_simulation(iSave, iSave2); |
417 } | 419 } |
418 | 420 |
419 sqlite3_free(aData); | 421 sqlite3_free(aData); |
420 return rc; | 422 return rc; |
421 } | 423 } |
422 | 424 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 && iOfst>=(PENDING_BYTE+512) | 545 && iOfst>=(PENDING_BYTE+512) |
544 && iOfst+iAmt<=PENDING_BYTE+p->nPagesize | 546 && iOfst+iAmt<=PENDING_BYTE+p->nPagesize |
545 ){ | 547 ){ |
546 /* No-op. This special case is hit when the backup code is copying a | 548 /* No-op. This special case is hit when the backup code is copying a |
547 ** to a database with a larger page-size than the source database and | 549 ** to a database with a larger page-size than the source database and |
548 ** it needs to fill in the non-locking-region part of the original | 550 ** it needs to fill in the non-locking-region part of the original |
549 ** pending-byte page. | 551 ** pending-byte page. |
550 */ | 552 */ |
551 }else{ | 553 }else{ |
552 u32 pgno = (u32)(iOfst/p->nPagesize + 1); | 554 u32 pgno = (u32)(iOfst/p->nPagesize + 1); |
553 assert( (iAmt==1||iAmt==p->nPagesize) && ((iOfst+iAmt)%p->nPagesize)==0 ); | 555 assert( (iAmt==1||iAmt==(int)p->nPagesize) && |
| 556 ((iOfst+iAmt)%p->nPagesize)==0 ); |
554 assert( pgno<=p->nPage || p->nSync>0 ); | 557 assert( pgno<=p->nPage || p->nSync>0 ); |
555 assert( pgno>p->nPage || sqlite3BitvecTest(p->pWritable, pgno) ); | 558 assert( pgno>p->nPage || sqlite3BitvecTest(p->pWritable, pgno) ); |
556 } | 559 } |
557 } | 560 } |
558 | 561 |
559 rc = sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst); | 562 rc = sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst); |
560 if( (p->flags&SQLITE_OPEN_MAIN_JOURNAL) && iAmt==12 ){ | 563 if( (p->flags&SQLITE_OPEN_MAIN_JOURNAL) && iAmt==12 ){ |
561 jt_file *pMain = locateDatabaseHandle(p->zName); | 564 jt_file *pMain = locateDatabaseHandle(p->zName); |
562 int rc2 = readJournalFile(p, pMain); | 565 int rc2 = readJournalFile(p, pMain); |
563 if( rc==SQLITE_OK ) rc = rc2; | 566 if( rc==SQLITE_OK ) rc = rc2; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 } | 851 } |
849 | 852 |
850 /* | 853 /* |
851 ** Uninstall the jt VFS, if it is installed. | 854 ** Uninstall the jt VFS, if it is installed. |
852 */ | 855 */ |
853 void jt_unregister(void){ | 856 void jt_unregister(void){ |
854 sqlite3_vfs_unregister(&jt_vfs); | 857 sqlite3_vfs_unregister(&jt_vfs); |
855 } | 858 } |
856 | 859 |
857 #endif | 860 #endif |
OLD | NEW |