SQLite

Check-in [5896ae3d68]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Always sync the journal file after zeroing out the header. (CVS 5036)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5896ae3d68d29dc172c027c72aa2a98ced2b7eb8
User & Date: drh 2008-04-22 17:15:18.000
Context
2008-04-23
23:03
We should better not pass open file handles to child processes, so add respective flag for DosOpen(). (CVS 5037) (check-in: 1518e8542c user: pweilbacher tags: trunk)
2008-04-22
17:15
Always sync the journal file after zeroing out the header. (CVS 5036) (check-in: 5896ae3d68 user: drh tags: trunk)
14:31
Avoid non-contiguous writes when creating a journal header. (CVS 5035) (check-in: dfacddbb50 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.432 2008/04/22 14:31:48 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include <assert.h>
#include <string.h>

/*







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.433 2008/04/22 17:15:18 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include <assert.h>
#include <string.h>

/*
968
969
970
971
972
973
974



975
976
977
978
979
980
981
*/
static int zeroJournalHdr(Pager *pPager){
  int rc;
  static const char zeroHdr[28];

  IOTRACE(("JZEROHDR %p\n", pPager))
  rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);



  return rc;
}

/*
** The journal file must be open when this routine is called. A journal
** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the
** current location.







>
>
>







968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
*/
static int zeroJournalHdr(Pager *pPager){
  int rc;
  static const char zeroHdr[28];

  IOTRACE(("JZEROHDR %p\n", pPager))
  rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);
  if( rc==SQLITE_OK ){
    rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY | pPager->sync_flags);
  }
  return rc;
}

/*
** The journal file must be open when this routine is called. A journal
** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the
** current location.