/ Check-in [5896ae3d]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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 | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5896ae3d68d29dc172c027c72aa2a98ced2b7eb8
User & Date: drh 2008-04-22 17:15:18
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: 1518e854 user: pweilbacher tags: trunk
2008-04-22
17:15
Always sync the journal file after zeroing out the header. (CVS 5036) check-in: 5896ae3d user: drh tags: trunk
14:31
Avoid non-contiguous writes when creating a journal header. (CVS 5035) check-in: dfacddbb user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/pager.c.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
968
969
970
971
972
973
974



975
976
977
978
979
980
981
** 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>

/*
................................................................................
*/
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.







|







 







>
>
>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
** 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>

/*
................................................................................
*/
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.