SQLite

Check-in [44b2dc18e2]
Login

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

Overview
Comment:When using a temporary file for a statement journal, store the first 64KiB in memory. If the file grows larger than that, flush it to disk and free the memory. Hardcoding to 64KiB is just an experiment to check that the memjournal.c code works.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | memjournal-exp
Files: files | file ages | folders
SHA1: 44b2dc18e200e87cf062cb8f1659727c53fa36e9
User & Date: dan 2016-02-29 20:18:21.986
Context
2016-03-03
21:29
Merge the latest updates from trunk. (check-in: 55c00f716d user: drh tags: memjournal-exp)
2016-02-29
20:18
When using a temporary file for a statement journal, store the first 64KiB in memory. If the file grows larger than that, flush it to disk and free the memory. Hardcoding to 64KiB is just an experiment to check that the memjournal.c code works. (check-in: 44b2dc18e2 user: dan tags: memjournal-exp)
20:00
Fix minor problems with new code in memjournal.c. (check-in: 9fd3f7b9c9 user: dan tags: memjournal-exp)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/memjournal.c.
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
){
  MemJournal *p = (MemJournal*)pJfd;

  /* Zero the file-handle object. If nBuf was passed zero, initialize
  ** it using the sqlite3OsOpen() function of the underlying VFS. In this
  ** case none of the code in this module is executed as a result of calls
  ** made on the journal file-handle.  */
  memset(p, 0, sizeof(MemJournal) + pVfs ? pVfs->szOsFile : 0);
  if( nBuf==0 ){
    return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);
  }

  if( nBuf>0 ){
    p->nChunkSize = nBuf;
  }else{







|







350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
){
  MemJournal *p = (MemJournal*)pJfd;

  /* Zero the file-handle object. If nBuf was passed zero, initialize
  ** it using the sqlite3OsOpen() function of the underlying VFS. In this
  ** case none of the code in this module is executed as a result of calls
  ** made on the journal file-handle.  */
  memset(p, 0, sizeof(MemJournal) + (pVfs ? pVfs->szOsFile : 0));
  if( nBuf==0 ){
    return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);
  }

  if( nBuf>0 ){
    p->nChunkSize = nBuf;
  }else{
Changes to src/pager.c.
4351
4352
4353
4354
4355
4356
4357




4358
4359
4360
4361

4362

4363
4364
4365
4366
4367
4368
4369
** SQLITE_OK is returned if everything goes according to plan. An 
** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() 
** fails.
*/
static int openSubJournal(Pager *pPager){
  int rc = SQLITE_OK;
  if( !isOpen(pPager->sjfd) ){




    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){
      sqlite3MemJournalOpen(pPager->sjfd);
    }else{
      rc = pagerOpentemp(pPager, pPager->sjfd, SQLITE_OPEN_SUBJOURNAL);

    }

  }
  return rc;
}

/*
** Append a record of the current state of page pPg to the sub-journal. 
**







>
>
>
>

<
<
<
>

>







4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362



4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
** SQLITE_OK is returned if everything goes according to plan. An 
** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() 
** fails.
*/
static int openSubJournal(Pager *pPager){
  int rc = SQLITE_OK;
  if( !isOpen(pPager->sjfd) ){
    const int flags =  SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_READWRITE 
      | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE 
      | SQLITE_OPEN_DELETEONCLOSE;
    int nBuf = 64*1024;
    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){



      nBuf = -1;
    }
    rc = sqlite3JournalOpen(pPager->pVfs, 0, pPager->sjfd, flags, nBuf);
  }
  return rc;
}

/*
** Append a record of the current state of page pPg to the sub-journal. 
**