/ Check-in [306586c4]
Login

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

Overview
Comment:Remove the xLockState method for sqlite3_io_methods. Replace it with a defined call to xFileControl(). This simplifies the interface and also gives us coverage testing of sqlite3_file_control(). (CVS 4355)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 306586c412b87c6d12bac796641517afa3f9eb6a
User & Date: drh 2007-08-31 18:34:59
Context
2007-08-31
18:50
Get make doc working again. (CVS 4356) check-in: 8f73ebc6 user: drh tags: trunk
18:34
Remove the xLockState method for sqlite3_io_methods. Replace it with a defined call to xFileControl(). This simplifies the interface and also gives us coverage testing of sqlite3_file_control(). (CVS 4355) check-in: 306586c4 user: drh tags: trunk
17:42
Allow sqllimits1.test to be run from a regular build of testfixture. Add the 'amalgamation-testfixture' target to main.mk - to build testfixture via sqlite3.c. (CVS 4354) check-in: d1194273 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/journal.c.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
...
235
236
237
238
239
240
241
242
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** @(#) $Id: journal.c,v 1.3 2007/08/24 08:15:54 danielk1977 Exp $
*/

#ifdef SQLITE_ENABLE_ATOMIC_WRITE

/*
** This file implements a special kind of sqlite3_file object used
** by SQLite to create journal files if the atomic-write optimization
................................................................................
  jrnlWrite,     /* xWrite */
  jrnlTruncate,  /* xTruncate */
  jrnlSync,      /* xSync */
  jrnlFileSize,  /* xFileSize */
  0,             /* xLock */
  0,             /* xUnlock */
  0,             /* xCheckReservedLock */
  0,             /* xBreakLock */
  0,             /* xLockState */
  0,             /* xSectorSize */
  0              /* xDeviceCharacteristics */
};

/* 
** Open a journal file.
*/
................................................................................
** Return the number of bytes required to store a JournalFile that uses vfs
** pVfs to create the underlying on-disk files.
*/
int sqlite3JournalSize(sqlite3_vfs *pVfs){
  return (pVfs->szOsFile+sizeof(JournalFile));
}
#endif








|







 







|
<







 







<
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
182
183
184
185
186
187
188
189

190
191
192
193
194
195
196
...
234
235
236
237
238
239
240

**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** @(#) $Id: journal.c,v 1.4 2007/08/31 18:34:59 drh Exp $
*/

#ifdef SQLITE_ENABLE_ATOMIC_WRITE

/*
** This file implements a special kind of sqlite3_file object used
** by SQLite to create journal files if the atomic-write optimization
................................................................................
  jrnlWrite,     /* xWrite */
  jrnlTruncate,  /* xTruncate */
  jrnlSync,      /* xSync */
  jrnlFileSize,  /* xFileSize */
  0,             /* xLock */
  0,             /* xUnlock */
  0,             /* xCheckReservedLock */
  0,             /* xFileControl */

  0,             /* xSectorSize */
  0              /* xDeviceCharacteristics */
};

/* 
** Open a journal file.
*/
................................................................................
** Return the number of bytes required to store a JournalFile that uses vfs
** pVfs to create the underlying on-disk files.
*/
int sqlite3JournalSize(sqlite3_vfs *pVfs){
  return (pVfs->szOsFile+sizeof(JournalFile));
}
#endif

Changes to src/os.c.

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  int sqlite3OsSectorSize(sqlite3_file *id){
    int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
    return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
  }
  int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
    return id->pMethods->xDeviceCharacteristics(id);
  }
#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.
*/
int sqlite3OsOpen(







<
<
<
<
<
<
<
<
<
<
<







82
83
84
85
86
87
88











89
90
91
92
93
94
95
  int sqlite3OsSectorSize(sqlite3_file *id){
    int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
    return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
  }
  int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
    return id->pMethods->xDeviceCharacteristics(id);
  }











#endif

/*
** The next group of routines are convenience wrappers around the
** VFS methods.
*/
int sqlite3OsOpen(

Changes to src/os.h.

236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset);
int sqlite3OsTruncate(sqlite3_file*, i64 size);
int sqlite3OsSync(sqlite3_file*, int);
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);

/* 
** Functions for accessing sqlite3_vfs methods 
*/
................................................................................
/*
** Convenience functions for opening and closing files using 
** sqlite3_malloc() to obtain space for the file-handle structure.
*/
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
** is defined (meaning that the application-defined OS interface layer
** is used) then there is no default VFS.   The application must
** register one or more VFS structures using sqlite3_vfs_register()
** before attempting to use SQLite.







<







 







<
<
<
<
<







236
237
238
239
240
241
242

243
244
245
246
247
248
249
...
263
264
265
266
267
268
269





270
271
272
273
274
275
276
int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset);
int sqlite3OsTruncate(sqlite3_file*, i64 size);
int sqlite3OsSync(sqlite3_file*, int);
int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);
int sqlite3OsLock(sqlite3_file*, int);
int sqlite3OsUnlock(sqlite3_file*, int);
int sqlite3OsCheckReservedLock(sqlite3_file *id);

int sqlite3OsFileControl(sqlite3_file*,int,void*);
int sqlite3OsSectorSize(sqlite3_file *id);
int sqlite3OsDeviceCharacteristics(sqlite3_file *id);

/* 
** Functions for accessing sqlite3_vfs methods 
*/
................................................................................
/*
** Convenience functions for opening and closing files using 
** sqlite3_malloc() to obtain space for the file-handle structure.
*/
int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);
int sqlite3OsCloseFree(sqlite3_file *);






/*
** Each OS-specific backend defines an instance of the following
** structure for returning a pointer to its sqlite3_vfs.  If OS_OTHER
** is defined (meaning that the application-defined OS interface layer
** is used) then there is no default VFS.   The application must
** register one or more VFS structures using sqlite3_vfs_register()
** before attempting to use SQLite.

Changes to src/os_unix.c.

2012
2013
2014
2015
2016
2017
2018
2019
2020
2021






2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
....
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
....
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
....
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
....
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
....
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
  return SQLITE_OK;
}

#endif /* SQLITE_ENABLE_LOCKING_STYLE */


/*
** No xFileControl opcodes are implemented by this VFS.
*/
static int unixFileControl(sqlite3_file *id, int op, void *pArg){






  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.
**
** SQLite code assumes this function cannot fail. It also assumes that
** if two files are created in the same file-system directory (i.e.
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  unixLock,
  unixUnlock,
  unixCheckReservedLock,
  unixLockState,
  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

#ifdef SQLITE_ENABLE_LOCKING_STYLE
/*
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  afpUnixLock,
  afpUnixUnlock,
  afpUnixCheckReservedLock,
  unixLockState,
  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

/*
** This vector defines all the methods that can operate on an sqlite3_file
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  flockUnixLock,
  flockUnixUnlock,
  flockUnixCheckReservedLock,
  unixLockState,
  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

/*
** This vector defines all the methods that can operate on an sqlite3_file
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  dotlockUnixLock,
  dotlockUnixUnlock,
  dotlockUnixCheckReservedLock,
  unixLockState,
  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

/*
** This vector defines all the methods that can operate on an sqlite3_file
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  nolockUnixLock,
  nolockUnixUnlock,
  nolockUnixCheckReservedLock,
  unixLockState,
  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

#endif /* SQLITE_ENABLE_LOCKING_STYLE */








|


>
>
>
>
>
>



<
<
<
<
<
<
<
<







 







<







 







<







 







<







 







<







 







<







2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030








2031
2032
2033
2034
2035
2036
2037
....
2060
2061
2062
2063
2064
2065
2066

2067
2068
2069
2070
2071
2072
2073
....
2081
2082
2083
2084
2085
2086
2087

2088
2089
2090
2091
2092
2093
2094
....
2101
2102
2103
2104
2105
2106
2107

2108
2109
2110
2111
2112
2113
2114
....
2121
2122
2123
2124
2125
2126
2127

2128
2129
2130
2131
2132
2133
2134
....
2141
2142
2143
2144
2145
2146
2147

2148
2149
2150
2151
2152
2153
2154
  return SQLITE_OK;
}

#endif /* SQLITE_ENABLE_LOCKING_STYLE */


/*
** 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 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.
**
** SQLite code assumes this function cannot fail. It also assumes that
** if two files are created in the same file-system directory (i.e.
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  unixLock,
  unixUnlock,
  unixCheckReservedLock,

  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

#ifdef SQLITE_ENABLE_LOCKING_STYLE
/*
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  afpUnixLock,
  afpUnixUnlock,
  afpUnixCheckReservedLock,

  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

/*
** This vector defines all the methods that can operate on an sqlite3_file
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  flockUnixLock,
  flockUnixUnlock,
  flockUnixCheckReservedLock,

  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

/*
** This vector defines all the methods that can operate on an sqlite3_file
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  dotlockUnixLock,
  dotlockUnixUnlock,
  dotlockUnixCheckReservedLock,

  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

/*
** This vector defines all the methods that can operate on an sqlite3_file
................................................................................
  unixWrite,
  unixTruncate,
  unixSync,
  unixFileSize,
  nolockUnixLock,
  nolockUnixUnlock,
  nolockUnixCheckReservedLock,

  unixFileControl,
  unixSectorSize,
  unixDeviceCharacteristics
};

#endif /* SQLITE_ENABLE_LOCKING_STYLE */

Changes to src/os_win.c.

973
974
975
976
977
978
979
980
981
982






983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
....
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
    UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0);
  }
  pFile->locktype = locktype;
  return rc;
}

/*
** No xFileControl operations are currently implemented.
*/
static int winFileControl(sqlite3_file *id){






  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.
**
** SQLite code assumes this function cannot fail. It also assumes that
** if two files are created in the same file-system directory (i.e.
................................................................................
  winWrite,
  winTruncate,
  winSync,
  winFileSize,
  winLock,
  winUnlock,
  winCheckReservedLock,
  winLockState,
  winFileControl,
  winSectorSize,
  winDeviceCharacteristics
};

/***************************************************************************
** Here ends the I/O methods that form the sqlite3_io_methods object.







|

|
>
>
>
>
>
>



<
<
<
<
<
<
<
<
<







 







<







973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991









992
993
994
995
996
997
998
....
1021
1022
1023
1024
1025
1026
1027

1028
1029
1030
1031
1032
1033
1034
    UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0);
  }
  pFile->locktype = locktype;
  return rc;
}

/*
** Control and query of the open file handle.
*/
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 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.
**
** SQLite code assumes this function cannot fail. It also assumes that
** if two files are created in the same file-system directory (i.e.
................................................................................
  winWrite,
  winTruncate,
  winSync,
  winFileSize,
  winLock,
  winUnlock,
  winCheckReservedLock,

  winFileControl,
  winSectorSize,
  winDeviceCharacteristics
};

/***************************************************************************
** Here ends the I/O methods that form the sqlite3_io_methods object.

Changes to src/pager.c.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
....
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** 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 $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include <assert.h>
#include <string.h>

/*
................................................................................
  assert( PAGER_LOCKINGMODE_NORMAL>=0 && PAGER_LOCKINGMODE_EXCLUSIVE>=0 );
  if( eMode>=0 && !pPager->tempFile ){
    pPager->exclusiveMode = 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.
*/
void sqlite3PagerRefdump(Pager *pPager){
  PgHdr *pPg;
  for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){







|







 







<
<
<
<
<
<
<
<
<
<
<







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
....
5006
5007
5008
5009
5010
5011
5012











5013
5014
5015
5016
5017
5018
5019
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.383 2007/08/31 18:34:59 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include <assert.h>
#include <string.h>

/*
................................................................................
  assert( PAGER_LOCKINGMODE_NORMAL>=0 && PAGER_LOCKINGMODE_EXCLUSIVE>=0 );
  if( eMode>=0 && !pPager->tempFile ){
    pPager->exclusiveMode = eMode;
  }
  return (int)pPager->exclusiveMode;
}












#ifdef SQLITE_DEBUG
/*
** Print a listing of all referenced pages and their ref count.
*/
void sqlite3PagerRefdump(Pager *pPager){
  PgHdr *pPg;
  for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){

Changes to src/pager.h.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the interface that the sqlite page cache
** 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 $
*/

#ifndef _PAGER_H_
#define _PAGER_H_

/*
** The type used to represent a page number.  The first page in a file
................................................................................
#endif

#if !defined(NDEBUG) || defined(SQLITE_TEST)
  Pgno sqlite3PagerPagenumber(DbPage*);
  int sqlite3PagerIswriteable(DbPage*);
#endif

#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  int sqlite3PagerLockstate(Pager*);
#endif

#ifdef SQLITE_TEST
  int *sqlite3PagerStats(Pager*);
  void sqlite3PagerRefdump(Pager*);
  int pager3_refinfo_enable;
#endif

#ifdef SQLITE_TEST







|







 







<
<
<
<







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
104
105
106
107
108
109
110




111
112
113
114
115
116
117
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the interface that the sqlite page cache
** 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.66 2007/08/31 18:34:59 drh Exp $
*/

#ifndef _PAGER_H_
#define _PAGER_H_

/*
** The type used to represent a page number.  The first page in a file
................................................................................
#endif

#if !defined(NDEBUG) || defined(SQLITE_TEST)
  Pgno sqlite3PagerPagenumber(DbPage*);
  int sqlite3PagerIswriteable(DbPage*);
#endif





#ifdef SQLITE_TEST
  int *sqlite3PagerStats(Pager*);
  void sqlite3PagerRefdump(Pager*);
  int pager3_refinfo_enable;
#endif

#ifdef SQLITE_TEST

Changes to src/pragma.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
1104
1105
1106
1107
1108
1109
1110


1111
1112
1113
1114
1115
1116
1117
1118
1119
1120

1121
1122
1123
1124
1125
1126
1127
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.148 2007/08/30 10:07:39 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/* Ignore this whole file if pragmas are disabled
*/
#if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
................................................................................
    Vdbe *v = sqlite3GetVdbe(pParse);
    sqlite3VdbeSetNumCols(v, 2);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", P3_STATIC);
    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", P3_STATIC);
    for(i=0; i<db->nDb; i++){
      Btree *pBt;
      Pager *pPager;


      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);
      }

      sqlite3VdbeAddOp(v, OP_Callback, 2, 0);
    }
  }else
#endif

#ifdef SQLITE_SSE
  /*







|







 







>
>




|
|
|
|
<

>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120

1121
1122
1123
1124
1125
1126
1127
1128
1129
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.149 2007/08/31 18:34:59 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/* Ignore this whole file if pragmas are disabled
*/
#if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
................................................................................
    Vdbe *v = sqlite3GetVdbe(pParse);
    sqlite3VdbeSetNumCols(v, 2);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", P3_STATIC);
    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", P3_STATIC);
    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 ){
        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
#endif

#ifdef SQLITE_SSE
  /*

Changes to src/sqlite.h.in.

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
...
527
528
529
530
531
532
533
534
535
536
537
538
539
540

















541
542
543
544
545
546
547
** on how SQLite interfaces are suppose to operate.
**
** The name of this file under configuration management is "sqlite.h.in".
** The makefile makes some minor changes to this file (such as inserting
** 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 $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
#include <stdarg.h>     /* Needed for the definition of va_list */

/*
** Make sure we can call this stuff from C++.
................................................................................
** [sqlite3_file_control()] interface.  The second argument (the
** "op" argument) is intended to be an integer opcode.  The third
** argument is a generic pointer which is intended to be a pointer
** to a structure that may contain arguments or space in which to
** 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.
**
** The xSectorSize() method returns the sector size of the
** device that underlies the file.  The sector size is the
** minimum write that can be performed without disturbing
** other bytes in the file.  The xDeviceCharacteristics()
** method returns a bit vector describing behaviors of the
** underlying device:
................................................................................
  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite_int64 iOfst);
  int (*xTruncate)(sqlite3_file*, sqlite_int64 size);
  int (*xSync)(sqlite3_file*, int flags);
  int (*xFileSize)(sqlite3_file*, sqlite_int64 *pSize);
  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*);
  /* Additional methods may be added in future releases */
};


















/*
** CAPI3REF: Mutex Handle
**
** The mutex module within SQLite defines [sqlite3_mutex] to be an
** abstract type for a mutex object.  The SQLite core never looks
** at the internal representation of an [sqlite3_mutex].  It only
** deals with pointers to the [sqlite3_mutex] object.







|







 







|
|
|
|
<







 







<






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
...
477
478
479
480
481
482
483
484
485
486
487

488
489
490
491
492
493
494
...
526
527
528
529
530
531
532

533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
** on how SQLite interfaces are suppose to operate.
**
** The name of this file under configuration management is "sqlite.h.in".
** The makefile makes some minor changes to this file (such as inserting
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
** @(#) $Id: sqlite.h.in,v 1.253 2007/08/31 18:34:59 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
#include <stdarg.h>     /* Needed for the definition of va_list */

/*
** Make sure we can call this stuff from C++.
................................................................................
** [sqlite3_file_control()] interface.  The second argument (the
** "op" argument) is intended to be an integer opcode.  The third
** argument is a generic pointer which is intended to be a pointer
** to a structure that may contain arguments or space in which to
** 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.  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
** minimum write that can be performed without disturbing
** other bytes in the file.  The xDeviceCharacteristics()
** method returns a bit vector describing behaviors of the
** underlying device:
................................................................................
  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite_int64 iOfst);
  int (*xTruncate)(sqlite3_file*, sqlite_int64 size);
  int (*xSync)(sqlite3_file*, int flags);
  int (*xFileSize)(sqlite3_file*, sqlite_int64 *pSize);
  int (*xLock)(sqlite3_file*, int);
  int (*xUnlock)(sqlite3_file*, int);
  int (*xCheckReservedLock)(sqlite3_file*);

  int (*xFileControl)(sqlite3_file*, int op, void *pArg);
  int (*xSectorSize)(sqlite3_file*);
  int (*xDeviceCharacteristics)(sqlite3_file*);
  /* Additional methods may be added in future releases */
};

/*
** 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
** abstract type for a mutex object.  The SQLite core never looks
** at the internal representation of an [sqlite3_mutex].  It only
** deals with pointers to the [sqlite3_mutex] object.

Changes to src/test6.c.

469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
}
static int cfUnlock(sqlite3_file *pFile, int eLock){
  return sqlite3OsUnlock(((CrashFile *)pFile)->pRealFile, 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);
}

/*
** The xSectorSize() and xDeviceCharacteristics() functions return
** the global values configured by the [sqlite_crashparams] tcl
................................................................................
  cfWrite,                      /* xWrite */
  cfTruncate,                   /* xTruncate */
  cfSync,                       /* xSync */
  cfFileSize,                   /* xFileSize */
  cfLock,                       /* xLock */
  cfUnlock,                     /* xUnlock */
  cfCheckReservedLock,          /* xCheckReservedLock */
  cfLockState,                  /* xLockState */
  cfFileControl,                /* xFileControl */
  cfSectorSize,                 /* xSectorSize */
  cfDeviceCharacteristics       /* xDeviceCharacteristics */
};

/*
** Application data for the crash VFS







<
<
<







 







<







469
470
471
472
473
474
475



476
477
478
479
480
481
482
...
496
497
498
499
500
501
502

503
504
505
506
507
508
509
}
static int cfUnlock(sqlite3_file *pFile, int eLock){
  return sqlite3OsUnlock(((CrashFile *)pFile)->pRealFile, eLock);
}
static int cfCheckReservedLock(sqlite3_file *pFile){
  return sqlite3OsCheckReservedLock(((CrashFile *)pFile)->pRealFile);
}



static int cfFileControl(sqlite3_file *pFile, int op, void *pArg){
  return sqlite3OsFileControl(((CrashFile *)pFile)->pRealFile, op, pArg);
}

/*
** The xSectorSize() and xDeviceCharacteristics() functions return
** the global values configured by the [sqlite_crashparams] tcl
................................................................................
  cfWrite,                      /* xWrite */
  cfTruncate,                   /* xTruncate */
  cfSync,                       /* xSync */
  cfFileSize,                   /* xFileSize */
  cfLock,                       /* xLock */
  cfUnlock,                     /* xUnlock */
  cfCheckReservedLock,          /* xCheckReservedLock */

  cfFileControl,                /* xFileControl */
  cfSectorSize,                 /* xSectorSize */
  cfDeviceCharacteristics       /* xDeviceCharacteristics */
};

/*
** Application data for the crash VFS

Changes to src/test_async.c.

608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
...
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
  ASYNC_TRACE(("CHECK-LOCK %d (%s)\n", rc, p->zName));
  return rc>SHARED_LOCK;
}

/* 
** 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;
}

/* 
** Return the device characteristics and sector-size of the device. It
** is not tricky to implement these correctly, as this backend might 
** not have an open file handle at this point.
*/
................................................................................
    asyncWrite,                      /* xWrite */
    asyncTruncate,                   /* xTruncate */
    asyncSync,                       /* xSync */
    asyncFileSize,                   /* xFileSize */
    asyncLock,                       /* xLock */
    asyncUnlock,                     /* xUnlock */
    asyncCheckReservedLock,          /* xCheckReservedLock */
    asyncBreakLock,                  /* xBreakLock */
    asyncLockState,                  /* xLockState */
    asyncSectorSize,                 /* xSectorSize */
    asyncDeviceCharacteristics       /* xDeviceCharacteristics */
  };

  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;
  AsyncFile *p = (AsyncFile *)pFile;
  int nName = strlen(zName);;







|
|
<
<
<
<
<
<
<







 







|
<







608
609
610
611
612
613
614
615
616







617
618
619
620
621
622
623
...
645
646
647
648
649
650
651
652

653
654
655
656
657
658
659
  ASYNC_TRACE(("CHECK-LOCK %d (%s)\n", rc, p->zName));
  return rc>SHARED_LOCK;
}

/* 
** This is a no-op, as the asynchronous backend does not support locking.
*/
static int asyncFileControl(sqlite3_file *id, int op, void *pArg){
  return SQLITE_ERROR;







}

/* 
** Return the device characteristics and sector-size of the device. It
** is not tricky to implement these correctly, as this backend might 
** not have an open file handle at this point.
*/
................................................................................
    asyncWrite,                      /* xWrite */
    asyncTruncate,                   /* xTruncate */
    asyncSync,                       /* xSync */
    asyncFileSize,                   /* xFileSize */
    asyncLock,                       /* xLock */
    asyncUnlock,                     /* xUnlock */
    asyncCheckReservedLock,          /* xCheckReservedLock */
    asyncFileControl,                /* xFileControl */

    asyncSectorSize,                 /* xSectorSize */
    asyncDeviceCharacteristics       /* xDeviceCharacteristics */
  };

  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;
  AsyncFile *p = (AsyncFile *)pFile;
  int nName = strlen(zName);;