-C Select\sthe\sdefault\spage\ssize\sfor\snew\sdatabases\sbased\son\sthe\ssector-size\sand\sIOCAP\sflags.\s(CVS\s4286)
-D 2007-08-24T11:52:29
+C Remove\snRef\sand\svfsMutex\sfrom\sthe\ssqlite3_vfs\sstructure.\s\sOmit\sthe\nsqlite3_vfs_release()\sinterface.\s\sLess\smemory\sallocated\sfor\sa\spager\nin\sthe\scommon\scase\swhere\sthe\ssize\sof\sthe\spathname\sis\sless\sthan\sMAX_PATH.\s(CVS\s4287)
+D 2007-08-24T16:08:29
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/legacy.c 7e1b1c57694e49cbadf561e2a7d9cd984dc743b5
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
F src/loadext.c 8b31e2e0e961918fa045515459aee1c122d8c266
-F src/main.c 795ec066ce38908b5c35ca4353bb601d022e2275
+F src/main.c 58f71f9b0c583fbe74d13b6d3fdb509cac5871f3
F src/malloc.c d4282f50964ab1ca31f504c97b7cf2fdb4d4195d
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c afe2fbf6d7e8247c6c9f69c1481358b1cad60c08
F src/mem2.c 1a2ca756a285b5365d667841508cc1f98938b8d8
F src/mutex.c 9cf641f556a4119ef90ed41b82f2d5647f81686e
-F src/os.c 3b0d37208ea3ec9e1f913fbdeaf88841ed443b9d
+F src/os.c a8ed3c495161475dbce255f7003144144fb425f1
F src/os.h 2bfbbad126a775e4d8c7d59eb4d9585a5fd7dfb5
F src/os_common.h a5c446d3b93f09f369d13bf217de4bed3437dd1c
F src/os_os2.c 8769301bff502de642ad2634cedcb77d967ce199
F src/os_os2.h c3f7d0af7e3453d1d7aa81b06c0a56f5a226530b
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
-F src/os_unix.c c45b20f868fab1178710ea2f1c8043ce706d3a99
+F src/os_unix.c 27b1fad58587bc949013a5a4df9fc20fce395648
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
-F src/os_win.c 1cb94dd33d38e01de82d77bef107c7f3323463ec
+F src/os_win.c e2598a18dbcb70cba888cebd37fb46d1eaee82b1
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 6c9622a14f9778efb575072737c7f68c1ab95fe2
+F src/pager.c f5c2a4e85b632faa7cd891c214f1cfd021c1ffa9
F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8
F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590
F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5
F src/select.c 98c367bce3f38c5adfcc97de9ab5c79b0e5dc2b2
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c ac29402b538515fa4697282387be9c1205e6e9eb
-F src/sqlite.h.in 09a5256ee80dfc7cb4353739f78e4267be323574
+F src/sqlite.h.in 22397464e1026437a755489c3eeb459346ae8749
F src/sqlite3ext.h 9a26028378c288af500d8b94ed079666fed5806b
F src/sqliteInt.h ea7a14a33c0a03479d2d98ce9ac83fe5e7f4bb55
F src/sqliteLimit.h 1bcbbdfa856f8b71b561abb31edb864b0eca1d12
F src/tclsqlite.c d76af53f45c9e9f7f7d39531fa4c7bee7d0adad6
F src/test1.c 8b20d1f05777ac480d3caf8d5f79ab7a543513fc
F src/test2.c 4f742e99ed1bea5c14692f627bdb59a146f30504
-F src/test3.c a7d011c51d6b2e2a73c43983d5c2b731d69c74d7
+F src/test3.c 637824fa560f9a4ffcec6b262febb0f57f400487
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
-F src/test6.c 37caea087882ecce1cbc6c83f9f1d457bd42b731
+F src/test6.c 7007b3941ade02f51242ae898b5b9646d2164773
F src/test7.c a9d509d0e9ad214b4772696f49f6e61be26213d1
F src/test8.c e6a543c8b248efe120ae33a6859fcd55dcf46a96
F src/test9.c b46c8fe02ac7cca1a7316436d8d38d50c66f4b2f
F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33
F test/notnull.test 44d600f916b770def8b095a9962dbe3be5a70d82
F test/null.test 9503e1f63e959544c006d9f01709c5b5eab67d54
-F test/pager.test 6c644725db2a79528f67a6f3472b9c9ddee17f05
+F test/pager.test f07c06fef8e3b4964a9b337b751b56825a44d326
F test/pager2.test c025f91b75fe65e85febda64d9416428b8a5cab5
F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
F test/pageropt.test 51e3c091bc2992f5098f7576e3594e1908988939
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P eb6c98fc1097b327453d7e8ec8877101ea8187c3
-R 33f9af4f9be6e647c8b59a027b74b510
-U danielk1977
-Z ea44b5abf05f45dd9f144b230dd5f4ae
+P 13dda2e8e879835c21e539ba3ff8f96face1af4c
+R 9943ec857d44edaed5e279e84f17aaa5
+U drh
+Z a0440ce84e84a78d112a7ad4d7f13668
-13dda2e8e879835c21e539ba3ff8f96face1af4c
\ No newline at end of file
+b8451da378179d43f25d9a014480c0f13dd1dc37
\ No newline at end of file
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.397 2007/08/24 03:51:34 drh Exp $
+** $Id: main.c,v 1.398 2007/08/24 16:08:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
** structure?
*/
sqlite3_free(db->aDb[1].pSchema);
- sqlite3_vfs_release(db->pVfs);
sqlite3_mutex_leave(db->mutex);
sqlite3_mutex_free(db->mutex);
sqlite3_free(db);
** API uses microseconds. Hence the 1000's.
*/
rc = (sqlite3OsSleep(pVfs, 1000*ms)/1000);
- sqlite3_vfs_release(pVfs);
return rc;
}
if( zVfs==0 ) break;
if( strcmp(zVfs, pVfs->zName)==0 ) break;
}
- if( pVfs ){
- pVfs->nRef++;
- assert( pVfs->nRef==1 || pVfs->vfsMutex!=0 );
- assert( pVfs->nRef>1 || pVfs->vfsMutex==0 );
- if( pVfs->vfsMutex==0 ){
- pVfs->vfsMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
- }
- }
sqlite3_mutex_leave(mutex);
return pVfs;
}
-/*
-** Release a VFS once it is no longer needed.
-*/
-int sqlite3_vfs_release(sqlite3_vfs *pVfs){
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
- sqlite3_mutex_enter(mutex);
- assert( pVfs->nRef>0 );
- pVfs->nRef--;
- if( pVfs->nRef==0 && pVfs->vfsMutex ){
- sqlite3_mutex_free(pVfs->vfsMutex);
- pVfs->vfsMutex = 0;
- }
- sqlite3_mutex_leave(mutex);
- return SQLITE_OK;
-}
-
/*
** Unlink a VFS from the linked list
*/
1, /* iVersion */
sizeof(unixFile), /* szOsFile */
MAX_PATHNAME, /* mxPathname */
- 0, /* nRef */
- 0, /* vfsMutex */
0, /* pNext */
"unix", /* zName */
0, /* pAppData */
1, /* iVersion */
sizeof(winFile), /* szOsFile */
MAX_PATH, /* mxPathname */
- 0, /* nRef */
- 0, /* vfsMutex */
0, /* pNext */
"win32", /* zName */
0, /* pAppData */
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.374 2007/08/24 11:52:29 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.375 2007/08/24 16:08:29 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
** last page is released using sqlite3PagerUnref().
**
** If zFilename is NULL then a randomly-named temporary file is created
-** and
+** and used as the file to be cached. The file will be deleted
** automatically when it is closed.
**
** If zFilename is ":memory:" then all information is held in cache.
int useJournal = (flags & PAGER_OMIT_JOURNAL)==0;
int noReadlock = (flags & PAGER_NO_READLOCK)!=0;
int journalFileSize = sqlite3JournalSize(pVfs);
- int nDefaultPage = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size. */
+ int nDefaultPage = SQLITE_DEFAULT_PAGE_SIZE;
+ char *zPathname;
+ int nPathname;
/* The default return is a NULL pointer */
*ppPager = 0;
+ /* Compute the full pathname */
+ zPathname = sqlite3_malloc(pVfs->mxPathname+1);
+ if( zPathname==0 ){
+ return SQLITE_NOMEM;
+ }
+ if( zFilename && zFilename[0] ){
+#ifndef SQLITE_OMIT_MEMORYDB
+ if( strcmp(zFilename,":memory:")==0 ){
+ memDb = 1;
+ zPathname[0] = 0;
+ }else
+#endif
+ {
+ rc = sqlite3OsFullPathname(pVfs, zFilename, zPathname);
+ if( rc!=SQLITE_OK ){
+ sqlite3_free(zPathname);
+ return rc;
+ }
+ }
+ }else{
+ zPathname[0] = 0;
+ }
+ nPathname = strlen(zPathname);
+
/* Allocate memory for the pager structure */
pPager = sqlite3MallocZero(
sizeof(*pPager) + /* Pager structure */
journalFileSize + /* The journal file structure */
pVfs->szOsFile * 2 + /* The db and stmt journal files */
- pVfs->mxPathname * 3 + 30 /* zFilename, zDirectory, zJournal */
+ nPathname * 3 + 30 /* zFilename, zDirectory, zJournal */
);
if( !pPager ){
+ sqlite3_free(zPathname);
return SQLITE_NOMEM;
}
pPtr = (u8 *)&pPager[1];
pPager->stfd = (sqlite3_file*)&pPtr[pVfs->szOsFile*1];
pPager->jfd = (sqlite3_file*)&pPtr[pVfs->szOsFile*2];
pPager->zFilename = (char*)&pPtr[pVfs->szOsFile*2+journalFileSize];
- pPager->zDirectory = &pPager->zFilename[pVfs->mxPathname];
- pPager->zJournal = &pPager->zDirectory[pVfs->mxPathname];
+ pPager->zDirectory = &pPager->zFilename[nPathname+1];
+ pPager->zJournal = &pPager->zDirectory[nPathname+1];
pPager->pVfs = pVfs;
+ memcpy(pPager->zFilename, zPathname, nPathname+1);
+ sqlite3_free(zPathname);
/* Open the pager file.
*/
- if( zFilename && zFilename[0] ){
-#ifndef SQLITE_OMIT_MEMORYDB
- if( strcmp(zFilename,":memory:")==0 ){
- memDb = 1;
- pPager->zFilename[0] = '\0';
- }else
-#endif
- {
- rc = sqlite3OsFullPathname(pVfs, zFilename, pPager->zFilename);
- if( rc==SQLITE_OK ){
- if( strlen(pPager->zFilename)>(pVfs->mxPathname - strlen("-journal")) ){
- rc = SQLITE_CANTOPEN;
- }else{
- int oflag =
- (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_DB);
- int fout = 0;
- rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, oflag, &fout);
- readOnly = (fout&SQLITE_OPEN_READONLY);
-
- /* If the file was successfully opened for read/write access,
- ** choose a default page size in case we have to create the
- ** database file. The default page size is the maximum of:
- **
- ** + SQLITE_DEFAULT_PAGE_SIZE,
- ** + The value returned by sqlite3OsSectorSize()
- ** + The largest page size that can be written atomically.
- */
- if( rc==SQLITE_OK && !readOnly ){
- int iSectorSize = sqlite3OsSectorSize(pPager->fd);
- if( nDefaultPage<iSectorSize ){
- nDefaultPage = iSectorSize;
- }
+ if( pPager->zFilename[0] ){
+ if( nPathname>(pVfs->mxPathname - sizeof("-journal")) ){
+ rc = SQLITE_CANTOPEN;
+ }else{
+/*** FIXME: Might need to be SQLITE_OPEN_TEMP_DB. Need to pass in
+**** a flag from higher up.
+****/
+ int oflag =
+ (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_DB);
+ int fout = 0;
+ rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, oflag, &fout);
+ readOnly = (fout&SQLITE_OPEN_READONLY);
+
+ /* If the file was successfully opened for read/write access,
+ ** choose a default page size in case we have to create the
+ ** database file. The default page size is the maximum of:
+ **
+ ** + SQLITE_DEFAULT_PAGE_SIZE,
+ ** + The value returned by sqlite3OsSectorSize()
+ ** + The largest page size that can be written atomically.
+ */
+ if( rc==SQLITE_OK && !readOnly ){
+ int iSectorSize = sqlite3OsSectorSize(pPager->fd);
+ if( nDefaultPage<iSectorSize ){
+ nDefaultPage = iSectorSize;
+ }
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
- {
- int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);
- int ii;
- assert(SQLITE_IOCAP_ATOMIC512==(512>>8));
- assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));
- assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);
- for(ii=nDefaultPage; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){
- if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ) nDefaultPage = ii;
- }
- }
-#endif
- if( nDefaultPage>SQLITE_MAX_DEFAULT_PAGE_SIZE ){
- nDefaultPage = SQLITE_MAX_DEFAULT_PAGE_SIZE;
- }
+ {
+ int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);
+ int ii;
+ assert(SQLITE_IOCAP_ATOMIC512==(512>>8));
+ assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));
+ assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);
+ for(ii=nDefaultPage; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){
+ if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ) nDefaultPage = ii;
}
}
+#endif
+ if( nDefaultPage>SQLITE_MAX_DEFAULT_PAGE_SIZE ){
+ nDefaultPage = SQLITE_MAX_DEFAULT_PAGE_SIZE;
+ }
}
}
- }else{
+ }else if( !memDb ){
/* If a temporary file is requested, it is not opened immediately.
** In this case we accept the default page size and delay actually
** opening the file until the first call to OsWrite().
IOTRACE(("OPEN %p %s\n", pPager, pPager->zFilename))
/* Fill in Pager.zDirectory[] */
- memcpy(pPager->zDirectory, pPager->zFilename, pVfs->mxPathname);
+ memcpy(pPager->zDirectory, pPager->zFilename, nPathname+1);
for(i=strlen(pPager->zDirectory); i>0 && pPager->zDirectory[i-1]!='/'; i--){}
if( i>0 ) pPager->zDirectory[i-1] = 0;
/* Fill in Pager.zJournal[] */
- memcpy(pPager->zJournal, pPager->zFilename, pVfs->mxPathname);
- memcpy(&pPager->zJournal[strlen(pPager->zJournal)], "-journal", 9);
+ memcpy(pPager->zJournal, pPager->zFilename, nPathname);
+ memcpy(&pPager->zJournal[nPathname], "-journal", 9);
/* pPager->journalOpen = 0; */
pPager->useJournal = useJournal && !memDb;
/* pPager->nPage = 0; */
pPager->mxPage = 100;
pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;
- assert( PAGER_UNLOCK==0 );
/* pPager->state = PAGER_UNLOCK; */
+ assert( pPager->state == (tempFile ? PAGER_EXCLUSIVE : PAGER_UNLOCK) );
/* pPager->errMask = 0; */
pPager->tempFile = tempFile;
assert( tempFile==PAGER_LOCKINGMODE_NORMAL
pPager->pDirty = 0;
/* Sync the database file. */
- if( !pPager->noSync ){
+ if( !pPager->noSync ){
rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
}
IOTRACE(("DBSYNC %p\n", pPager))
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
-** @(#) $Id: sqlite.h.in,v 1.239 2007/08/24 03:51:34 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.240 2007/08/24 16:08:29 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
** structure used by this VFS. mxPathname is the maximum length of
** a pathname in this VFS.
**
-** The nRef field is incremented and decremented by SQLite to keep
-** count of the number of users of the VFS. This field and
-** vfsMutex, pNext, and pPrev are the only fields in the sqlite3_vfs
-** structure that SQLite will ever modify. SQLite will only access
-** or modify these fields while holding a particular static mutex.
-** The application should never modify any fields of the sqlite3_vfs
-** object once the object has been registered.
-**
-** The sqlite3_vfs.vfsMutex is a mutex used by the OS interface.
-** It should initially be NULL. SQLite will initialize this field
-** using sqlite3_mutex_alloc() upon first use of the adaptor
-** by sqlite3_open_v2() and will deallocate the mutex when the
-** last user closes. In other words, vfsMutex will be allocated
-** when nRef transitions from 0 to 1 and will be deallocated when
-** nRef transitions from 1 to 0.
-**
** Registered vfs modules are kept on a linked list formed by
** the pNext pointer. The [sqlite3_register_vfs()]
** and [sqlite3_unregister_vfs()] interfaces manage this list
** in a thread-safe way. The [sqlite3_find_vfs()] interface
** searches the list.
**
+** The pNext field is the only fields in the sqlite3_vfs
+** structure that SQLite will ever modify. SQLite will only access
+** or modify this field while holding a particular static mutex.
+** The application should never modify anything within the sqlite3_vfs
+** object once the object has been registered.
+**
** The zName field holds the name of the VFS module. The name must
** be unique across all VFS modules.
**
int iVersion; /* Structure version number */
int szOsFile; /* Size of subclassed sqlite3_file */
int mxPathname; /* Maximum file pathname length */
- int nRef; /* Number of references to this structure */
- sqlite3_mutex *vfsMutex; /* A mutex for this VFS */
sqlite3_vfs *pNext; /* Next registered VFS */
const char *zName; /* Name of this virtual file system */
- void *pAppData; /* Application context */
+ void *pAppData; /* Pointer to application-specific data */
int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
int flags, int *pOutFlags);
int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
** The sqlite3_vfs_find() interface returns a pointer to a VFS given its
** name. Names are case sensitive. If there is no match, a NULL
** pointer is returned. If zVfsName is NULL then the default
-** VFS is returned. If a valid VFS pointer is returned, its
-** vfsMutex field will have been initialized and nRef will be
-** greater than zero. The sqlite3_vfs_release() function should
-** be used to release the VFS when it is no longer needed.
+** VFS is returned.
**
** New VFSes are registered with sqlite3_vfs_register(). Each
** new VFS becomes the default VFS if the makeDflt flag is set.
** the default. The choice for the new VFS is arbitrary.
*/
sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
-int sqlite3_vfs_release(sqlite3_vfs*);
int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
int sqlite3_vfs_unregister(sqlite3_vfs*);
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test3.c,v 1.81 2007/08/22 02:56:44 drh Exp $
+** $Id: test3.c,v 1.82 2007/08/24 16:08:29 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
sqlite3_mutex_leave(sDb.mutex);
sqlite3_mutex_free(sDb.mutex);
sDb.mutex = 0;
- sqlite3_vfs_release(sDb.pVfs);
sDb.pVfs = 0;
}
return TCL_OK;
1, /* iVersion */
0, /* szOsFile */
0, /* mxPathname */
- 0, /* nRef */
- 0, /* vfsMutex */
0, /* pNext */
"crash", /* zName */
0, /* pAppData */
crashVfs.mxPathname = pOriginalVfs->mxPathname;
crashVfs.pAppData = (void *)pOriginalVfs;
crashVfs.szOsFile = sizeof(CrashFile) + pOriginalVfs->szOsFile;
- sqlite3_vfs_release(pOriginalVfs);
/* sqlite3_vfs_unregister(pOriginalVfs); */
sqlite3_vfs_register(&crashVfs, 1);
}
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
-# $Id: pager.test,v 1.28 2007/04/05 17:15:53 danielk1977 Exp $
+# $Id: pager.test,v 1.29 2007/08/24 16:08:29 drh Exp $
set testdir [file dirname $argv0]
# Test truncate on an in-memory database is Ok.
ifcapable memorydb {
do_test pager-4.6.2 {
+btree_breakpoint
set ::p2 [pager_open :memory: 10]
pager_truncate $::p2 5
} {}
} {}
}
finish_test
-
-
-