aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/journal.c6
-rw-r--r--src/os.c11
-rw-r--r--src/os.h6
-rw-r--r--src/os_unix.c21
-rw-r--r--src/os_win.c20
-rw-r--r--src/pager.c13
-rw-r--r--src/pager.h6
-rw-r--r--src/pragma.c14
-rw-r--r--src/sqlite.h.in29
-rw-r--r--src/test6.c4
-rw-r--r--src/test_async.c14
11 files changed, 52 insertions, 92 deletions
diff --git a/src/journal.c b/src/journal.c
index 0006f56c4..d894b81cf 100644
--- a/src/journal.c
+++ b/src/journal.c
@@ -10,7 +10,7 @@
**
*************************************************************************
**
-** @(#) $Id: journal.c,v 1.3 2007/08/24 08:15:54 danielk1977 Exp $
+** @(#) $Id: journal.c,v 1.4 2007/08/31 18:34:59 drh Exp $
*/
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
@@ -186,8 +186,7 @@ static struct sqlite3_io_methods JournalFileMethods = {
0, /* xLock */
0, /* xUnlock */
0, /* xCheckReservedLock */
- 0, /* xBreakLock */
- 0, /* xLockState */
+ 0, /* xFileControl */
0, /* xSectorSize */
0 /* xDeviceCharacteristics */
};
@@ -239,4 +238,3 @@ int sqlite3JournalSize(sqlite3_vfs *pVfs){
return (pVfs->szOsFile+sizeof(JournalFile));
}
#endif
-
diff --git a/src/os.c b/src/os.c
index 8ca0185d9..c1b551097 100644
--- a/src/os.c
+++ b/src/os.c
@@ -88,17 +88,6 @@ int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
}
#endif
-#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
- /* These methods are currently only used for testing and debugging. */
- int sqlite3OsFileHandle(sqlite3_file *id){
- /* return id->pMethods->xFileHandle(id); */
- return 0;
- }
- int sqlite3OsLockState(sqlite3_file *id){
- return id->pMethods->xLockState(id);
- }
-#endif
-
/*
** The next group of routines are convenience wrappers around the
** VFS methods.
diff --git a/src/os.h b/src/os.h
index 1570aecc9..86da032d1 100644
--- a/src/os.h
+++ b/src/os.h
@@ -240,7 +240,6 @@ int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);
int sqlite3OsLock(sqlite3_file*, int);
int sqlite3OsUnlock(sqlite3_file*, int);
int sqlite3OsCheckReservedLock(sqlite3_file *id);
-int sqlite3OsLockState(sqlite3_file *id);
int sqlite3OsFileControl(sqlite3_file*,int,void*);
int sqlite3OsSectorSize(sqlite3_file *id);
int sqlite3OsDeviceCharacteristics(sqlite3_file *id);
@@ -268,11 +267,6 @@ int sqlite3OsCurrentTime(sqlite3_vfs *, double*);
int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);
int sqlite3OsCloseFree(sqlite3_file *);
-#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
- int sqlite3OsFileHandle(sqlite3_file *id);
- int sqlite3OsLockState(sqlite3_file *id);
-#endif
-
/*
** Each OS-specific backend defines an instance of the following
** structure for returning a pointer to its sqlite3_vfs. If OS_OTHER
diff --git a/src/os_unix.c b/src/os_unix.c
index 54674f7c7..b74e9f1d6 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2016,21 +2016,19 @@ static int nolockUnixClose(sqlite3_file *id) {
/*
-** No xFileControl opcodes are implemented by this VFS.
+** Information and control of an open file handle.
*/
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
+ switch( op ){
+ case SQLITE_FCNTL_LOCKSTATE: {
+ *(int*)pArg = ((unixFile*)id)->locktype;
+ return SQLITE_OK;
+ }
+ }
return SQLITE_ERROR;
}
/*
-** Return an integer that indices the type of lock currently held
-** by this handle. (Used for testing and analysis only.)
-*/
-static int unixLockState(sqlite3_file *id){
- return ((unixFile*)id)->locktype;
-}
-
-/*
** Return the sector size in bytes of the underlying block device for
** the specified file. This is almost always 512 bytes, but may be
** larger for some devices.
@@ -2066,7 +2064,6 @@ static const sqlite3_io_methods sqlite3UnixIoMethod = {
unixLock,
unixUnlock,
unixCheckReservedLock,
- unixLockState,
unixFileControl,
unixSectorSize,
unixDeviceCharacteristics
@@ -2088,7 +2085,6 @@ static const sqlite3_io_methods sqlite3AFPLockingUnixIoMethod = {
afpUnixLock,
afpUnixUnlock,
afpUnixCheckReservedLock,
- unixLockState,
unixFileControl,
unixSectorSize,
unixDeviceCharacteristics
@@ -2109,7 +2105,6 @@ static const sqlite3_io_methods sqlite3FlockLockingUnixIoMethod = {
flockUnixLock,
flockUnixUnlock,
flockUnixCheckReservedLock,
- unixLockState,
unixFileControl,
unixSectorSize,
unixDeviceCharacteristics
@@ -2130,7 +2125,6 @@ static const sqlite3_io_methods sqlite3DotlockLockingUnixIoMethod = {
dotlockUnixLock,
dotlockUnixUnlock,
dotlockUnixCheckReservedLock,
- unixLockState,
unixFileControl,
unixSectorSize,
unixDeviceCharacteristics
@@ -2151,7 +2145,6 @@ static const sqlite3_io_methods sqlite3NolockLockingUnixIoMethod = {
nolockUnixLock,
nolockUnixUnlock,
nolockUnixCheckReservedLock,
- unixLockState,
unixFileControl,
unixSectorSize,
unixDeviceCharacteristics
diff --git a/src/os_win.c b/src/os_win.c
index 233195f0f..0e2e488ee 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -977,22 +977,19 @@ static int winUnlock(sqlite3_file *id, int locktype){
}
/*
-** No xFileControl operations are currently implemented.
+** Control and query of the open file handle.
*/
-static int winFileControl(sqlite3_file *id){
+static int winFileControl(sqlite3_file *id, int op, void *pArg){
+ switch( op ){
+ case SQLITE_FCNTL_LOCKSTATE: {
+ *(int*)pArg = ((winFile*)id)->locktype;
+ return SQLITE_OK;
+ }
+ }
return SQLITE_ERROR;
}
/*
-** Return an integer that indices the type of lock currently held
-** by this handle. (Used for testing and analysis only.)
-*/
-static int winLockState(sqlite3_file *id){
- winFile *pFile = (winFile*)id;
- return pFile->locktype;
-}
-
-/*
** Return the sector size in bytes of the underlying block device for
** the specified file. This is almost always 512 bytes, but may be
** larger for some devices.
@@ -1028,7 +1025,6 @@ static const sqlite3_io_methods winIoMethod = {
winLock,
winUnlock,
winCheckReservedLock,
- winLockState,
winFileControl,
winSectorSize,
winDeviceCharacteristics
diff --git a/src/pager.c b/src/pager.c
index 59ef3e804..2559a4cdd 100644
--- a/src/pager.c
+++ b/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.382 2007/08/31 16:11:36 drh Exp $
+** @(#) $Id: pager.c,v 1.383 2007/08/31 18:34:59 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -5010,17 +5010,6 @@ int sqlite3PagerLockingMode(Pager *pPager, int eMode){
return (int)pPager->exclusiveMode;
}
-#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
-/*
-** Return the current state of the file lock for the given pager.
-** The return value is one of NO_LOCK, SHARED_LOCK, RESERVED_LOCK,
-** PENDING_LOCK, or EXCLUSIVE_LOCK.
-*/
-int sqlite3PagerLockstate(Pager *pPager){
- return sqlite3OsLockState(pPager->fd);
-}
-#endif
-
#ifdef SQLITE_DEBUG
/*
** Print a listing of all referenced pages and their ref count.
diff --git a/src/pager.h b/src/pager.h
index 4933d0069..72fc84f42 100644
--- a/src/pager.h
+++ b/src/pager.h
@@ -13,7 +13,7 @@
** 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.65 2007/08/31 16:11:36 drh Exp $
+** @(#) $Id: pager.h,v 1.66 2007/08/31 18:34:59 drh Exp $
*/
#ifndef _PAGER_H_
@@ -108,10 +108,6 @@ int sqlite3PagerLockingMode(Pager *, int);
int sqlite3PagerIswriteable(DbPage*);
#endif
-#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
- int sqlite3PagerLockstate(Pager*);
-#endif
-
#ifdef SQLITE_TEST
int *sqlite3PagerStats(Pager*);
void sqlite3PagerRefdump(Pager*);
diff --git a/src/pragma.c b/src/pragma.c
index 6db457bbc..b4d9774c1 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.148 2007/08/30 10:07:39 danielk1977 Exp $
+** $Id: pragma.c,v 1.149 2007/08/31 18:34:59 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1108,16 +1108,18 @@ void sqlite3Pragma(
for(i=0; i<db->nDb; i++){
Btree *pBt;
Pager *pPager;
+ const char *zState = "unknown";
+ int j;
if( db->aDb[i].zName==0 ) continue;
sqlite3VdbeOp3(v, OP_String8, 0, 0, db->aDb[i].zName, P3_STATIC);
pBt = db->aDb[i].pBt;
if( pBt==0 || (pPager = sqlite3BtreePager(pBt))==0 ){
- sqlite3VdbeOp3(v, OP_String8, 0, 0, "closed", P3_STATIC);
- }else{
- int j = sqlite3PagerLockstate(pPager);
- sqlite3VdbeOp3(v, OP_String8, 0, 0,
- (j>=0 && j<=4) ? azLockName[j] : "unknown", P3_STATIC);
+ zState = "closed";
+ }else if( sqlite3_file_control(db, db->aDb[i].zName,
+ SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
+ zState = azLockName[j];
}
+ sqlite3VdbeOp3(v, OP_String8, 0, 0, zState, P3_STATIC);
sqlite3VdbeAddOp(v, OP_Callback, 2, 0);
}
}else
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index 4ec7226da..b481679ae 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -30,7 +30,7 @@
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
-** @(#) $Id: sqlite.h.in,v 1.252 2007/08/31 16:11:36 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.253 2007/08/31 18:34:59 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@@ -481,11 +481,10 @@ struct sqlite3_file {
** write return values. Potential uses for xFileControl() might be
** functions to enable blocking locks with timeouts, to change the
** locking strategy (for example to use dot-file locks), to inquire
-** about the status of a lock, or to break stale locks. No standard
-** xFileControl opcodes are currently defined, but this may change in
-** future releases. Applications that define a custom xFileControl
-** method should use opcodes greater than 100 to avoid conflicts
-** with future official opcodes which will be less than that value.
+** about the status of a lock, or to break stale locks. The SQLite
+** core reserves opcodes less than 100 for its own use. Applications
+** that define a custom xFileControl method should use opcodes
+** greater than 100 to avoid conflicts.
**
** The xSectorSize() method returns the sector size of the
** device that underlies the file. The sector size is the
@@ -531,7 +530,6 @@ struct sqlite3_io_methods {
int (*xLock)(sqlite3_file*, int);
int (*xUnlock)(sqlite3_file*, int);
int (*xCheckReservedLock)(sqlite3_file*);
- int (*xLockState)(sqlite3_file *);
int (*xFileControl)(sqlite3_file*, int op, void *pArg);
int (*xSectorSize)(sqlite3_file*);
int (*xDeviceCharacteristics)(sqlite3_file*);
@@ -539,6 +537,23 @@ struct sqlite3_io_methods {
};
/*
+** CAPI3REF: Standard File Control Opcodes
+**
+** These integer constants are opcodes for the xFileControl method
+** of the [sqlite3_io_methods] object and to the [sqlite3_file_control()]
+** interface.
+**
+** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
+** opcode cases the xFileControl method to write the current state of
+** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
+** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
+** into an integer that the pArg argument points to. This capability
+** is used during testing and only needs to be supported when SQLITE_TEST
+** is defined.
+*/
+#define SQLITE_FCNTL_LOCKSTATE 1
+
+/*
** CAPI3REF: Mutex Handle
**
** The mutex module within SQLite defines [sqlite3_mutex] to be an
diff --git a/src/test6.c b/src/test6.c
index 5d47cc79c..f4b98a5fc 100644
--- a/src/test6.c
+++ b/src/test6.c
@@ -473,9 +473,6 @@ static int cfUnlock(sqlite3_file *pFile, int eLock){
static int cfCheckReservedLock(sqlite3_file *pFile){
return sqlite3OsCheckReservedLock(((CrashFile *)pFile)->pRealFile);
}
-static int cfLockState(sqlite3_file *pFile){
- return sqlite3OsLockState(((CrashFile *)pFile)->pRealFile);
-}
static int cfFileControl(sqlite3_file *pFile, int op, void *pArg){
return sqlite3OsFileControl(((CrashFile *)pFile)->pRealFile, op, pArg);
}
@@ -503,7 +500,6 @@ static const sqlite3_io_methods CrashFileVtab = {
cfLock, /* xLock */
cfUnlock, /* xUnlock */
cfCheckReservedLock, /* xCheckReservedLock */
- cfLockState, /* xLockState */
cfFileControl, /* xFileControl */
cfSectorSize, /* xSectorSize */
cfDeviceCharacteristics /* xDeviceCharacteristics */
diff --git a/src/test_async.c b/src/test_async.c
index 1627f912f..74147f149 100644
--- a/src/test_async.c
+++ b/src/test_async.c
@@ -612,15 +612,8 @@ static int asyncCheckReservedLock(sqlite3_file *pFile){
/*
** This is a no-op, as the asynchronous backend does not support locking.
*/
-static int asyncBreakLock(sqlite3_file *id){
- return SQLITE_OK;
-}
-
-/*
-** This is broken. But sqlite3OsLockState() is only used for testing anyway.
-*/
-static int asyncLockState(sqlite3_file *id){
- return SQLITE_OK;
+static int asyncFileControl(sqlite3_file *id, int op, void *pArg){
+ return SQLITE_ERROR;
}
/*
@@ -656,8 +649,7 @@ static int asyncOpen(
asyncLock, /* xLock */
asyncUnlock, /* xUnlock */
asyncCheckReservedLock, /* xCheckReservedLock */
- asyncBreakLock, /* xBreakLock */
- asyncLockState, /* xLockState */
+ asyncFileControl, /* xFileControl */
asyncSectorSize, /* xSectorSize */
asyncDeviceCharacteristics /* xDeviceCharacteristics */
};