mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Save the full pathname of the database file so that journalling still works
even if the user changes working directories after opening the databae. Ticket #200. (CVS 798) FossilOrigin-Name: 1c58b4fc032c5975dcce9b8ae844c0e516254a17
This commit is contained in:
19
src/pager.c
19
src/pager.c
@@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.60 2002/12/02 04:25:21 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.61 2002/12/07 21:45:14 drh Exp $
|
||||
*/
|
||||
#include "os.h" /* Must be first to enable large file support */
|
||||
#include "sqliteInt.h"
|
||||
@@ -626,6 +626,7 @@ int sqlitepager_open(
|
||||
int useJournal /* TRUE to use a rollback journal on this file */
|
||||
){
|
||||
Pager *pPager;
|
||||
char *zFullPathname;
|
||||
int nameLen;
|
||||
OsFile fd;
|
||||
int rc;
|
||||
@@ -638,26 +639,34 @@ int sqlitepager_open(
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
if( zFilename ){
|
||||
rc = sqliteOsOpenReadWrite(zFilename, &fd, &readOnly);
|
||||
zFullPathname = sqliteOsFullPathname(zFilename);
|
||||
rc = sqliteOsOpenReadWrite(zFullPathname, &fd, &readOnly);
|
||||
tempFile = 0;
|
||||
}else{
|
||||
rc = sqlitepager_opentemp(zTemp, &fd);
|
||||
zFilename = zTemp;
|
||||
zFullPathname = sqliteOsFullPathname(zFilename);
|
||||
tempFile = 1;
|
||||
}
|
||||
if( sqlite_malloc_failed ){
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqliteFree(zFullPathname);
|
||||
return SQLITE_CANTOPEN;
|
||||
}
|
||||
nameLen = strlen(zFilename);
|
||||
nameLen = strlen(zFullPathname);
|
||||
pPager = sqliteMalloc( sizeof(*pPager) + nameLen*2 + 30 );
|
||||
if( pPager==0 ){
|
||||
sqliteOsClose(&fd);
|
||||
sqliteFree(zFullPathname);
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
pPager->zFilename = (char*)&pPager[1];
|
||||
pPager->zJournal = &pPager->zFilename[nameLen+1];
|
||||
strcpy(pPager->zFilename, zFilename);
|
||||
strcpy(pPager->zJournal, zFilename);
|
||||
strcpy(pPager->zFilename, zFullPathname);
|
||||
strcpy(pPager->zJournal, zFullPathname);
|
||||
sqliteFree(zFullPathname);
|
||||
strcpy(&pPager->zJournal[nameLen], "-journal");
|
||||
pPager->fd = fd;
|
||||
pPager->journalOpen = 0;
|
||||
|
Reference in New Issue
Block a user