SQLite4
Check-in [8132a601e8]
Not logged in

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

Overview
Comment:Change the name of "storage.h" to "kv.h". Other minor edits to comments and typedefs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8132a601e86a5d97869856204fa28240fe4f7e53
User & Date: drh 2012-10-20 12:57:54
Context
2012-10-20
13:01
Change the "TK_" macro prefix in lsm_tree.c to "TKV_" in order to avoid name collisions with "TK_" macros generated by the parser. check-in: b81bc323b9 user: drh tags: trunk
12:57
Change the name of "storage.h" to "kv.h". Other minor edits to comments and typedefs. check-in: 8132a601e8 user: drh tags: trunk
2012-10-19
16:39
Remove obsolete content from sqliteInt.h. check-in: d618b9b106 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to main.mk.

111
112
113
114
115
116
117

118
119
120
121
122
123
124
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
272
273
274
275
276
277
278

279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
  $(TOP)/src/fkey.c \
  $(TOP)/src/func.c \
  $(TOP)/src/global.c \
  $(TOP)/src/hash.c \
  $(TOP)/src/hash.h \
  $(TOP)/src/hwtime.h \
  $(TOP)/src/insert.c \

  $(TOP)/src/kvlsm.c \
  $(TOP)/src/kvmem.c \
  $(TOP)/src/legacy.c \
  $(TOP)/src/lsm.h \
  $(TOP)/src/lsmInt.h \
  $(TOP)/src/lsm_ckpt.c \
  $(TOP)/src/lsm_file.c \
................................................................................
  $(TOP)/src/select.c \
  $(TOP)/src/shell.c \
  $(TOP)/src/sqlite.h.in \
  $(TOP)/src/sqliteInt.h \
  $(TOP)/src/sqliteLimit.h \
  $(TOP)/src/status.c \
  $(TOP)/src/storage.c \
  $(TOP)/src/storage.h \
  $(TOP)/src/tclsqlite.c \
  $(TOP)/src/tokenize.c \
  $(TOP)/src/trigger.c \
  $(TOP)/src/utf.c \
  $(TOP)/src/update.c \
  $(TOP)/src/util.c \
  $(TOP)/src/varint.c \
................................................................................

# Header files used by all library source files.
#
HDR = \
   $(TOP)/src/hash.h \
   $(TOP)/src/hwtime.h \
   keywordhash.h \

   $(TOP)/src/lsm.h \
   $(TOP)/src/lsmInt.h \
   $(TOP)/src/mutex.h \
   opcodes.h \
   $(TOP)/src/os.h \
   parse.h  \
   sqlite4.h  \
   $(TOP)/src/sqliteInt.h  \
   $(TOP)/src/sqliteLimit.h \
   $(TOP)/src/storage.h \
   $(TOP)/src/vdbe.h \
   $(TOP)/src/vdbeInt.h

EXTHDR = \
  $(TOP)/ext/fts3/fts3.h \
  $(TOP)/ext/fts3/fts3Int.h \
  $(TOP)/ext/fts3/fts3_hash.h \







>







 







<







 







>









<







111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
158
159
160
161
162
163
164

165
166
167
168
169
170
171
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

289
290
291
292
293
294
295
  $(TOP)/src/fkey.c \
  $(TOP)/src/func.c \
  $(TOP)/src/global.c \
  $(TOP)/src/hash.c \
  $(TOP)/src/hash.h \
  $(TOP)/src/hwtime.h \
  $(TOP)/src/insert.c \
  $(TOP)/src/kv.h \
  $(TOP)/src/kvlsm.c \
  $(TOP)/src/kvmem.c \
  $(TOP)/src/legacy.c \
  $(TOP)/src/lsm.h \
  $(TOP)/src/lsmInt.h \
  $(TOP)/src/lsm_ckpt.c \
  $(TOP)/src/lsm_file.c \
................................................................................
  $(TOP)/src/select.c \
  $(TOP)/src/shell.c \
  $(TOP)/src/sqlite.h.in \
  $(TOP)/src/sqliteInt.h \
  $(TOP)/src/sqliteLimit.h \
  $(TOP)/src/status.c \
  $(TOP)/src/storage.c \

  $(TOP)/src/tclsqlite.c \
  $(TOP)/src/tokenize.c \
  $(TOP)/src/trigger.c \
  $(TOP)/src/utf.c \
  $(TOP)/src/update.c \
  $(TOP)/src/util.c \
  $(TOP)/src/varint.c \
................................................................................

# Header files used by all library source files.
#
HDR = \
   $(TOP)/src/hash.h \
   $(TOP)/src/hwtime.h \
   keywordhash.h \
   $(TOP)/src/kv.h \
   $(TOP)/src/lsm.h \
   $(TOP)/src/lsmInt.h \
   $(TOP)/src/mutex.h \
   opcodes.h \
   $(TOP)/src/os.h \
   parse.h  \
   sqlite4.h  \
   $(TOP)/src/sqliteInt.h  \
   $(TOP)/src/sqliteLimit.h \

   $(TOP)/src/vdbe.h \
   $(TOP)/src/vdbeInt.h

EXTHDR = \
  $(TOP)/ext/fts3/fts3.h \
  $(TOP)/ext/fts3/fts3Int.h \
  $(TOP)/ext/fts3/fts3_hash.h \

Name change from src/storage.h to src/kv.h.

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
** for content to be read.  The transaction level must be at least 2 for 
** content to be modified.
** 
** The xBegin method increases transaction level.  The increase may be no
** more than 1 unless the transaction level is initially 0 in which case
** it can be increased immediately to 2.  Increasing the transaction level
** to 1 or more makes a "snapshot" of the database file such that changes
** made by other connections are not visible.  An xBegin call may fail
** with SQLITE4_BUSY if the initial transaction level is 0 or 1.
** 
** A read-only database will fail an attempt to increase xBegin above 1.  An
** implementation that does not support nested transactions will fail any
** attempt to increase the transaction level above 2.
** 
** The xCommitPhaseOne and xCommitPhaseTwo methods implement a 2-phase
................................................................................
** to what it was immediately after the most recent xCommit(N).  Higher-level
** subtransactions are cancelled.  This call is equivalent to xRollback(N-1)
** followed by xBegin(N) but is atomic and might be more efficient.
** 
** The xReplace method replaces the value for an existing entry with the
** given key, or creates a new entry with the given key and value if no
** prior entry exists with the given key.  The key and value pointers passed
** into xReplace belong to the caller will likely be destroyed when the
** call to xReplace returns so the xReplace routine must make its own
** copy of that information.
** 
** A cursor is at all times pointing to ether an entry in the database or
** to EOF.  EOF means "no entry".  Cursor operations other than xCloseCursor 
** will fail if the transaction level is less than 1.
** 
** The xSeek method moves a cursor to an entry in the database that matches
** the supplied key as closely as possible.  If the dir argument is 0, then
................................................................................
** is found if it is available, otherwise the cursor is left pointing the
** the smallest entry that is larger than the search key, or to EOF if there
** are no entries larger than the search key.
**
** The return code from xSeek might be one of the following:
**
**    SQLITE4_OK        The cursor is left pointing to any entry that
**                     exactly matchings the probe key.
**
**    SQLITE4_INEXACT   The cursor is left pointing to the nearest entry
**                     to the probe it could find, either before or after
**                     the probe, according to the dir argument.
**
**    SQLITE4_NOTFOUND  No suitable entry could be found.  Either dir==0 and
**                     there was no exact match, or dir<0 and the probe is
**                     smaller than every entry in the database, or dir>0 and
**                     the probe is larger than every entry in the database.
**
** xSeek might also return some error code like SQLITE4_IOERR or
** SQLITE4_NOMEM.
** 
** The xNext method will only be called following an xSeek with a positive dir,
** or another xNext.  The xPrev method will only be called following an xSeek
** with a negative dir or another xPrev.  Both xNext and xPrev will return







|







 







|

|







 







|


|
|


|
|
|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
** for content to be read.  The transaction level must be at least 2 for 
** content to be modified.
** 
** The xBegin method increases transaction level.  The increase may be no
** more than 1 unless the transaction level is initially 0 in which case
** it can be increased immediately to 2.  Increasing the transaction level
** to 1 or more makes a "snapshot" of the database file such that changes
** made by other connections are not visible.  Calls to xBegin may fail
** with SQLITE4_BUSY if the initial transaction level is 0 or 1.
** 
** A read-only database will fail an attempt to increase xBegin above 1.  An
** implementation that does not support nested transactions will fail any
** attempt to increase the transaction level above 2.
** 
** The xCommitPhaseOne and xCommitPhaseTwo methods implement a 2-phase
................................................................................
** to what it was immediately after the most recent xCommit(N).  Higher-level
** subtransactions are cancelled.  This call is equivalent to xRollback(N-1)
** followed by xBegin(N) but is atomic and might be more efficient.
** 
** The xReplace method replaces the value for an existing entry with the
** given key, or creates a new entry with the given key and value if no
** prior entry exists with the given key.  The key and value pointers passed
** into xReplace belong to the caller and will likely be destroyed when the
** call to xReplace returns so the xReplace routine must make its own
** copy of that information if it needs to retain it after returning.
** 
** A cursor is at all times pointing to ether an entry in the database or
** to EOF.  EOF means "no entry".  Cursor operations other than xCloseCursor 
** will fail if the transaction level is less than 1.
** 
** The xSeek method moves a cursor to an entry in the database that matches
** the supplied key as closely as possible.  If the dir argument is 0, then
................................................................................
** is found if it is available, otherwise the cursor is left pointing the
** the smallest entry that is larger than the search key, or to EOF if there
** are no entries larger than the search key.
**
** The return code from xSeek might be one of the following:
**
**    SQLITE4_OK        The cursor is left pointing to any entry that
**                      exactly matchings the probe key.
**
**    SQLITE4_INEXACT   The cursor is left pointing to the nearest entry
**                      to the probe it could find, either before or after
**                      the probe, according to the dir argument.
**
**    SQLITE4_NOTFOUND  No suitable entry could be found.  Either dir==0 and
**                      there was no exact match, or dir<0 and the probe is
**                      smaller than every entry in the database, or dir>0 and
**                      the probe is larger than every entry in the database.
**
** xSeek might also return some error code like SQLITE4_IOERR or
** SQLITE4_NOMEM.
** 
** The xNext method will only be called following an xSeek with a positive dir,
** or another xNext.  The xPrev method will only be called following an xSeek
** with a negative dir or another xPrev.  Both xNext and xPrev will return

Changes to src/kvlsm.c.

7
8
9
10
11
12
13
14
15
16
17
18

19
20
21



22
23
24
25
26
27




28
29
30
31
32
33
34
**    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.
**
*************************************************************************
**
** An in-memory key/value storage subsystem that presents the interfadce
** defined by storage.h
*/
#include "sqliteInt.h"
#include "lsm.h"


typedef struct KVLsm KVLsm;
typedef struct KVLsmCsr KVLsmCsr;




struct KVLsm {
  KVStore base;                   /* Base class, must be first */
  lsm_db *pDb;                    /* LSM database handle */
  lsm_cursor *pCsr;               /* LSM cursor holding read-trans open */
};





struct KVLsmCsr {
  KVCursor base;                  /* Base class. Must be first */
  lsm_cursor *pCsr;               /* LSM cursor handle */
};
  
/*
** Begin a transaction or subtransaction.







|




>



>
>
>






>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
**    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.
**
*************************************************************************
**
** An in-memory key/value storage subsystem that presents the interfadce
** defined by kv.h
*/
#include "sqliteInt.h"
#include "lsm.h"

/* Forward declarations of objects */
typedef struct KVLsm KVLsm;
typedef struct KVLsmCsr KVLsmCsr;

/*
** An instance of an open connection to an LSM store.  A subclass of KVStore.
*/
struct KVLsm {
  KVStore base;                   /* Base class, must be first */
  lsm_db *pDb;                    /* LSM database handle */
  lsm_cursor *pCsr;               /* LSM cursor holding read-trans open */
};

/*
** An instance of an open cursor pointing into an LSM store.  A subclass
** of KVCursor.
*/
struct KVLsmCsr {
  KVCursor base;                  /* Base class. Must be first */
  lsm_cursor *pCsr;               /* LSM cursor handle */
};
  
/*
** Begin a transaction or subtransaction.

Changes to src/kvmem.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
**    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.
**
*************************************************************************
**
** An in-memory key/value storage subsystem that presents the interfadce
** defined by storage.h
*/
#include "sqliteInt.h"

/* Forward declarations of object names */
typedef struct KVMemNode KVMemNode;
typedef struct KVMemChng KVMemChng;
typedef struct KVMem KVMem;







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
**    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.
**
*************************************************************************
**
** An in-memory key/value storage subsystem that presents the interfadce
** defined by kv.h
*/
#include "sqliteInt.h"

/* Forward declarations of object names */
typedef struct KVMemNode KVMemNode;
typedef struct KVMemChng KVMemChng;
typedef struct KVMem KVMem;

Changes to src/shell.c.

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
    FILETIME ftCreation, ftExit;
    getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin);
  }
}

/* Return the difference of two FILETIME structs in seconds */
static double timeDiff(FILETIME *pStart, FILETIME *pEnd){
  sqlite_int64 i64Start = *((sqlite_int64 *) pStart);
  sqlite_int64 i64End = *((sqlite_int64 *) pEnd);
  return (double) ((i64End - i64Start) / 10000000.0);
}

/*
** Print the timing results.
*/
static void endTimer(void){







|
|







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
    FILETIME ftCreation, ftExit;
    getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin);
  }
}

/* Return the difference of two FILETIME structs in seconds */
static double timeDiff(FILETIME *pStart, FILETIME *pEnd){
  sqlite4_int64 i64Start = *((sqlite4_int64 *) pStart);
  sqlite4_int64 i64End = *((sqlite4_int64 *) pEnd);
  return (double) ((i64End - i64Start) / 10000000.0);
}

/*
** Print the timing results.
*/
static void endTimer(void){

Changes to src/sqlite.h.in.

252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
** [sqlite4_busy_timeout()] to name but three) that are methods on an
** sqlite4 object.
*/
typedef struct sqlite4 sqlite4;

/*
** CAPIREF: 64-Bit Integer Types
** KEYWORDS: sqlite_int64 sqlite_uint64
**
** Because there is no cross-platform way to specify 64-bit integer types
** SQLite includes typedefs for 64-bit signed and unsigned integers.
**
** The sqlite4_int64 and sqlite4_uint64 are the preferred type definitions.
** The sqlite_int64 and sqlite_uint64 types are supported for backwards
** compatibility only.
**
** ^The sqlite4_int64 and sqlite_int64 types can store integer values
** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
** sqlite4_uint64 and sqlite_uint64 types can store integer values 
** between 0 and +18446744073709551615 inclusive.
*/
#ifdef SQLITE4_INT64_TYPE
  typedef SQLITE4_INT64_TYPE sqlite4_int64_t;







|




<
<
<
<







252
253
254
255
256
257
258
259
260
261
262
263




264
265
266
267
268
269
270
** [sqlite4_busy_timeout()] to name but three) that are methods on an
** sqlite4 object.
*/
typedef struct sqlite4 sqlite4;

/*
** CAPIREF: 64-Bit Integer Types
** KEYWORDS: sqlite4_int64 sqlite4_uint64
**
** Because there is no cross-platform way to specify 64-bit integer types
** SQLite includes typedefs for 64-bit signed and unsigned integers.
**




** ^The sqlite4_int64 and sqlite_int64 types can store integer values
** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
** sqlite4_uint64 and sqlite_uint64 types can store integer values 
** between 0 and +18446744073709551615 inclusive.
*/
#ifdef SQLITE4_INT64_TYPE
  typedef SQLITE4_INT64_TYPE sqlite4_int64_t;

Changes to src/sqliteInt.h.

300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
...
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#include <stddef.h>

/*
** If compiling for a processor that lacks floating point support,
** substitute integer for floating-point
*/
#ifdef SQLITE4_OMIT_FLOATING_POINT
# define double sqlite_int64
# define float sqlite_int64
# define LONGDOUBLE_TYPE sqlite_int64
# ifndef SQLITE4_BIG_DBL
#   define SQLITE4_BIG_DBL (((sqlite4_int64)1)<<50)
# endif
# define SQLITE4_OMIT_DATETIME_FUNCS 1
# define SQLITE4_OMIT_TRACE 1
# undef SQLITE4_MIXED_ENDIAN_64BIT_FLOAT
# undef SQLITE4_HAVE_ISNAN
................................................................................
typedef struct Walker Walker;
typedef struct WherePlan WherePlan;
typedef struct WhereInfo WhereInfo;
typedef struct WhereLevel WhereLevel;


#include "vdbe.h"
#include "storage.h"

#include "os.h"
#include "mutex.h"


/*
** Each database file to be accessed by the system is an instance







|
|
|







 







|







300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
...
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#include <stddef.h>

/*
** If compiling for a processor that lacks floating point support,
** substitute integer for floating-point
*/
#ifdef SQLITE4_OMIT_FLOATING_POINT
# define double sqlite4_int64
# define float sqlite4_int64
# define LONGDOUBLE_TYPE sqlite4_int64
# ifndef SQLITE4_BIG_DBL
#   define SQLITE4_BIG_DBL (((sqlite4_int64)1)<<50)
# endif
# define SQLITE4_OMIT_DATETIME_FUNCS 1
# define SQLITE4_OMIT_TRACE 1
# undef SQLITE4_MIXED_ENDIAN_64BIT_FLOAT
# undef SQLITE4_HAVE_ISNAN
................................................................................
typedef struct Walker Walker;
typedef struct WherePlan WherePlan;
typedef struct WhereInfo WhereInfo;
typedef struct WhereLevel WhereLevel;


#include "vdbe.h"
#include "kv.h"

#include "os.h"
#include "mutex.h"


/*
** Each database file to be accessed by the system is an instance

Changes to src/vdbe.c.

4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
** is set to the value of the rowid for the row just inserted.
*/
case OP_VUpdate: {
  sqlite4_vtab *pVtab;
  sqlite4_module *pModule;
  int nArg;
  int i;
  sqlite_int64 rowid;
  Mem **apArg;
  Mem *pX;

  assert( pOp->p2==1        || pOp->p5==OE_Fail   || pOp->p5==OE_Rollback 
       || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
  );
  pVtab = pOp->p4.pVtab->pVtab;







|







4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
** is set to the value of the rowid for the row just inserted.
*/
case OP_VUpdate: {
  sqlite4_vtab *pVtab;
  sqlite4_module *pModule;
  int nArg;
  int i;
  sqlite4_int64 rowid;
  Mem **apArg;
  Mem *pX;

  assert( pOp->p2==1        || pOp->p5==OE_Fail   || pOp->p5==OE_Rollback 
       || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
  );
  pVtab = pOp->p4.pVtab->pVtab;

Changes to tool/mksqlite4c.tcl.

90
91
92
93
94
95
96

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# files are seen in a #include statement in the C code, include the complete
# text of the file in-line.  The file only needs to be included once.
#
foreach hdr {
   hash.h
   hwtime.h
   keywordhash.h

   lsm.h
   lsmInt.h
   mutex.h
   opcodes.h
   os.h
   parse.h
   sqlite4.h
   sqliteInt.h
   sqliteLimit.h
   storage.h
   vdbe.h
   vdbeInt.h
} {
  set available_hdr($hdr) 1
}
set available_hdr(sqliteInt.h) 0








>









<







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
# files are seen in a #include statement in the C code, include the complete
# text of the file in-line.  The file only needs to be included once.
#
foreach hdr {
   hash.h
   hwtime.h
   keywordhash.h
   kv.h
   lsm.h
   lsmInt.h
   mutex.h
   opcodes.h
   os.h
   parse.h
   sqlite4.h
   sqliteInt.h
   sqliteLimit.h

   vdbe.h
   vdbeInt.h
} {
  set available_hdr($hdr) 1
}
set available_hdr(sqliteInt.h) 0