-C Update\sthe\sfile\schange\scounter\sjust\sbefore\seach\stransaction\sis\scommitted.\s(CVS\s1582)
-D 2004-06-14T05:10:43
+C Ensure\sthe\smaster\sjournal\sdirectory\sis\ssynced.\sAlso,\schange\sthe\smaster\sjournal\nformat\sto\sstore\sjournal\sfile\snames.\s(CVS\s1583)
+D 2004-06-14T06:03:57
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
F src/attach.c 93b8ecec4a8d7b4e9f2479e2327d90c9d01765e8
F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79
-F src/btree.c 5591068c5ed0e5d65938d41ac9e3fe6f461fdb07
-F src/btree.h 589427ac13bb544d298cd99726e2572a6fe4bdaa
+F src/btree.c 1bed18993e54483de8ff869142e82c48847e1d50
+F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
F src/build.c 916a84fa5f8bfd44dbe14c3d7c923dd07ee7373f
F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
F src/delete.c 911221aadb35d610c84fadb32e71c52990827e58
F src/os_unix.h 1cd6133cf66dea704b8646b70b2dfdcbdd9b3738
F src/os_win.c d4009586dfd0543ca8956ff0be30f9d23e2cbbdd
F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c
-F src/pager.c feb44bd0279f77319079c1fddf9be927b052d028
-F src/pager.h ca8f293e1d623a7c628a1c5e0c6cf43d5bbb80bf
+F src/pager.c d42af374b23b50805b42c08cbba5bd70dd73964f
+F src/pager.h bc58d32a9dee464f7268fb68652c130a4216e438
F src/parse.y 097438674976355a10cf177bd97326c548820b86
F src/pragma.c e288bd122d3ca41ec2032475abde1ff5fa3095f4
F src/printf.c 63b15f1ea9fe3daa066bb7430fd20d4a2d717dc8
F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde
F src/vdbeInt.h ffc7b8ed911c5bf804796a768fdb6f0568010fa2
F src/vdbeapi.c ee350b552fc4c1c695b760f914f69e9c5556e829
-F src/vdbeaux.c 7b45d4934cddcf0fb79feac13c3399165774d35c
+F src/vdbeaux.c d792de3b042ffc49c344e147543af6cf2a3dc5de
F src/vdbemem.c 34f59988831ea032b7f526c2c73175f9f4c0f3ad
F src/where.c dda77afaa593cd54e5955ec433076de18faf62f6
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 77c5eaa10a9d2e2bb8f89b7434d6e6efbacf35e9
-R 728fa94fee79e66b965ca32e2cd56d1b
+P 4649abcbfd032836b196b5d690ef66e4aa494c45
+R b61789483f3e3746f567ebdec2a394da
U danielk1977
-Z 982942d9d284a3b9c20e3e9aaf713011
+Z cb4dbe83de3608a128ac6ced61032939
-4649abcbfd032836b196b5d690ef66e4aa494c45
\ No newline at end of file
+73cd0aabb24f7b663c8b55cf5e8fcb34fd48c032
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.165 2004/06/13 23:07:04 drh Exp $
+** $Id: btree.c,v 1.166 2004/06/14 06:03:57 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
return sqlite3pager_filename(pBt->pPager);
}
+/*
+** Return the pathname of the directory that contains the database file.
+*/
+const char *sqlite3BtreeGetDirname(Btree *pBt){
+ assert( pBt->pPager!=0 );
+ return sqlite3pager_dirname(pBt->pPager);
+}
+
+/*
+** Return the pathname of the journal file for this database. The return
+** value of this routine is the same regardless of whether the journal file
+** has been created or not.
+*/
+const char *sqlite3BtreeGetJournalname(Btree *pBt){
+ assert( pBt->pPager!=0 );
+ return sqlite3pager_journalname(pBt->pPager);
+}
+
/*
** Copy the complete content of pBtFrom into pBtTo. A transaction
** must be active for both files.
** subsystem. See comments in the source code for a detailed description
** of what each interface routine does.
**
-** @(#) $Id: btree.h,v 1.53 2004/06/04 06:22:01 danielk1977 Exp $
+** @(#) $Id: btree.h,v 1.54 2004/06/14 06:03:57 danielk1977 Exp $
*/
#ifndef _BTREE_H_
#define _BTREE_H_
int sqlite3BtreeSync(Btree*, const char *zMaster);
const char *sqlite3BtreeGetFilename(Btree *);
+const char *sqlite3BtreeGetDirname(Btree *);
+const char *sqlite3BtreeGetJournalname(Btree *);
int sqlite3BtreeCopyFile(Btree *, Btree *);
/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.125 2004/06/14 05:10:43 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.126 2004/06/14 06:03:57 danielk1977 Exp $
*/
#include "os.h" /* Must be first to enable large file support */
#include "sqliteInt.h"
rc = sqlite3OsOpenExclusive(zMaster, &master, 0);
if( rc!=SQLITE_OK ) goto delmaster_out;
master_open = 1;
-
rc = sqlite3OsFileSize(&master, &nMasterJournal);
if( rc!=SQLITE_OK ) goto delmaster_out;
if( nMasterJournal>0 ){
- char *zDb;
- zMasterJournal = (char *)sqliteMalloc(nMasterJournal);
+ char *zJournal;
+ char *zMasterPtr;
+ int nMasterPtr; /* Number of bytes allocated at zMasterPtr */
+
+ /* Load the entire master journal file into space obtained from
+ ** sqliteMalloc() and pointed to by zMasterJournal.
+ **
+ ** Also allocate an extra (strlen(zMaster)+1) bytes. This space is used
+ ** to load a master-journal filename from some other journal file to
+ ** check if it points at this master journal file.
+ */
+ nMasterPtr = strlen(zMaster) + 1;
+ zMasterJournal = (char *)sqliteMalloc(nMasterJournal) + nMasterPtr;
if( !zMasterJournal ){
rc = SQLITE_NOMEM;
goto delmaster_out;
}
+ zMasterPtr = &zMasterJournal[nMasterJournal];
rc = sqlite3OsRead(&master, zMasterJournal, nMasterJournal);
if( rc!=SQLITE_OK ) goto delmaster_out;
- zDb = zMasterJournal;
- while( (zDb-zMasterJournal)<nMasterJournal ){
- char *zJournal = 0;
- /*** FIX ME: Store the full journal name in the master journal,
- **** not just the base database name. ***/
- sqlite3SetString(&zJournal, zDb, "-journal", 0);
- if( !zJournal ){
- rc = SQLITE_NOMEM;
- goto delmaster_out;
- }
+ zJournal = zMasterJournal;
+ while( (zJournal-zMasterJournal)<nMasterJournal ){
if( sqlite3OsFileExists(zJournal) ){
/* One of the journals pointed to by the master journal exists.
** Open it and check if it points at the master journal. If
off_t jsz;
rc = sqlite3OsOpenReadOnly(zJournal, &journal);
- sqliteFree(zJournal);
if( rc!=SQLITE_OK ){
sqlite3OsClose(&journal);
goto delmaster_out;
if( rc!=SQLITE_OK ) goto delmaster_out;
rc = read32bits(&journal, (u32*)&nMaster);
if( rc!=SQLITE_OK ) goto delmaster_out;
- if( nMaster>0 && nMaster>=strlen(zMaster)+1 ){
- /*** FIX ME: Consider allocating this space at the same time
- **** space is allocated for holding the text of the master journal */
- char *zMasterPtr = (char *)sqliteMalloc(nMaster);
- if( !zMasterPtr ){
- rc = SQLITE_NOMEM;
- }
- rc = sqlite3OsRead(&journal, zMasterPtr, nMaster);
+ if( nMaster>=nMasterPtr ){
+ rc = sqlite3OsRead(&journal, zMasterPtr, nMasterPtr);
if( rc!=SQLITE_OK ){
- sqliteFree(zMasterPtr);
goto delmaster_out;
}
- if( 0==strncmp(zMasterPtr, zMaster, nMaster) ){
+ if( zMasterPtr[nMasterPtr-1]=='\0' && !strcmp(zMasterPtr, zMaster) ){
/* We have a match. Do not delete the master journal file. */
- sqliteFree(zMasterPtr);
goto delmaster_out;
}
}
}
- zDb += (strlen(zDb)+1);
+ zJournal += (strlen(zJournal)+1);
}
}
return pPager->zFilename;
}
+/*
+** Return the directory of the database file.
+*/
+const char *sqlite3pager_dirname(Pager *pPager){
+ return pPager->zDirectory;
+}
+
+/*
+** Return the full pathname of the journal file.
+*/
+const char *sqlite3pager_journalname(Pager *pPager){
+ return pPager->zJournal;
+}
+
/*
** Set the codec for this pager
*/
** subsystem. The page cache subsystem reads and writes a file a page
** at a time and provides a journal for rollback.
**
-** @(#) $Id: pager.h,v 1.33 2004/06/09 17:37:28 drh Exp $
+** @(#) $Id: pager.h,v 1.34 2004/06/14 06:03:57 danielk1977 Exp $
*/
/*
int *sqlite3pager_stats(Pager*);
void sqlite3pager_set_safety_level(Pager*,int);
const char *sqlite3pager_filename(Pager*);
+const char *sqlite3pager_dirname(Pager*);
+const char *sqlite3pager_journalname(Pager*);
int sqlite3pager_rename(Pager*, const char *zNewName);
void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
Btree *pBt = db->aDb[i].pBt;
if( i==1 ) continue; /* Ignore the TEMP database */
if( pBt && sqlite3BtreeIsInTrans(pBt) ){
- char const *zFile = sqlite3BtreeGetFilename(pBt);
+ char const *zFile = sqlite3BtreeGetJournalname(pBt);
if( zFile[0]==0 ) continue; /* Ignore :memory: databases */
rc = sqlite3OsWrite(&master, zFile, strlen(zFile)+1);
if( rc!=SQLITE_OK ){
}
}
- /* Sync the master journal file */
+
+ /* Sync the master journal file. Before doing this, open the directory
+ ** the master journal file is store in so that it gets synced too.
+ */
+ zMainFile = sqlite3BtreeGetDirname(db->aDb[0].pBt);
+ rc = sqlite3OsOpenDirectory(zMainFile, &master);
+ if( rc!=SQLITE_OK ){
+ sqlite3OsClose(&master);
+ sqlite3OsDelete(zMaster);
+ sqliteFree(zMaster);
+ return rc;
+ }
rc = sqlite3OsSync(&master);
+ if( rc!=SQLITE_OK ){
+ sqliteFree(zMaster);
+ return rc;
+ }
sqlite3OsClose(&master);
- /* FIXME: Sync the directory that contains the master journal to
- ** make sure the i-node is up to date. */
-
/* Sync all the db files involved in the transaction. The same call
** sets the master journal pointer in each individual journal. If
** an error occurs here, do not delete the master journal file.