wasCSharpSQLite – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #define SQLITE_MAX_EXPR_DEPTH |
2 | |||
3 | using System; |
||
4 | using System.Diagnostics; |
||
5 | using System.Runtime.InteropServices; |
||
6 | using System.Text; |
||
7 | |||
8 | using Bitmask = System.UInt64; |
||
9 | using i16 = System.Int16; |
||
10 | using i64 = System.Int64; |
||
11 | using sqlite3_int64 = System.Int64; |
||
12 | |||
13 | using u8 = System.Byte; |
||
14 | using u16 = System.UInt16; |
||
15 | using u32 = System.UInt32; |
||
16 | using u64 = System.UInt64; |
||
17 | using unsigned = System.UInt64; |
||
18 | |||
19 | using Pgno = System.UInt32; |
||
20 | |||
21 | #if !SQLITE_MAX_VARIABLE_NUMBER |
||
22 | using ynVar = System.Int16; |
||
23 | #else |
||
24 | using ynVar = System.Int32; |
||
25 | #endif |
||
26 | |||
27 | /* |
||
28 | ** The yDbMask datatype for the bitmask of all attached databases. |
||
29 | */ |
||
30 | #if SQLITE_MAX_ATTACHED//>30 |
||
31 | // typedef sqlite3_uint64 yDbMask; |
||
32 | using yDbMask = System.Int64; |
||
33 | #else |
||
34 | // typedef unsigned int yDbMask; |
||
35 | using yDbMask = System.Int32; |
||
36 | #endif |
||
37 | |||
38 | namespace Community.CsharpSqlite |
||
39 | { |
||
40 | using sqlite3_value = Sqlite3.Mem; |
||
41 | |||
42 | public partial class Sqlite3 |
||
43 | { |
||
44 | /* |
||
45 | ** 2001 September 15 |
||
46 | ** |
||
47 | ** The author disclaims copyright to this source code. In place of |
||
48 | ** a legal notice, here is a blessing: |
||
49 | ** |
||
50 | ** May you do good and not evil. |
||
51 | ** May you find forgiveness for yourself and forgive others. |
||
52 | ** May you share freely, never taking more than you give. |
||
53 | ** |
||
54 | ************************************************************************* |
||
55 | ** Internal interface definitions for SQLite. |
||
56 | ** |
||
57 | ************************************************************************* |
||
58 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart |
||
59 | ** C#-SQLite is an independent reimplementation of the SQLite software library |
||
60 | ** |
||
61 | ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2 |
||
62 | ** |
||
63 | ************************************************************************* |
||
64 | */ |
||
65 | //#if !_SQLITEINT_H_ |
||
66 | //#define _SQLITEINT_H_ |
||
67 | |||
68 | /* |
||
69 | ** These #defines should enable >2GB file support on POSIX if the |
||
70 | ** underlying operating system supports it. If the OS lacks |
||
71 | ** large file support, or if the OS is windows, these should be no-ops. |
||
72 | ** |
||
73 | ** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any |
||
74 | ** system #includes. Hence, this block of code must be the very first |
||
75 | ** code in all source files. |
||
76 | ** |
||
77 | ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch |
||
78 | ** on the compiler command line. This is necessary if you are compiling |
||
79 | ** on a recent machine (ex: Red Hat 7.2) but you want your code to work |
||
80 | ** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2 |
||
81 | ** without this option, LFS is enable. But LFS does not exist in the kernel |
||
82 | ** in Red Hat 6.0, so the code won't work. Hence, for maximum binary |
||
83 | ** portability you should omit LFS. |
||
84 | ** |
||
85 | ** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later. |
||
86 | */ |
||
87 | //#if !SQLITE_DISABLE_LFS |
||
88 | //# define _LARGE_FILE 1 |
||
89 | //# ifndef _FILE_OFFSET_BITS |
||
90 | //# define _FILE_OFFSET_BITS 64 |
||
91 | //# endif |
||
92 | //# define _LARGEFILE_SOURCE 1 |
||
93 | //#endif |
||
94 | |||
95 | /* |
||
96 | ** Include the configuration header output by 'configure' if we're using the |
||
97 | ** autoconf-based build |
||
98 | */ |
||
99 | #if _HAVE_SQLITE_CONFIG_H |
||
100 | //#include "config.h" |
||
101 | #endif |
||
102 | //#include "sqliteLimit.h" |
||
103 | |||
104 | /* Disable nuisance warnings on Borland compilers */ |
||
105 | //#if (__BORLANDC__) |
||
106 | //#pragma warn -rch /* unreachable code */ |
||
107 | //#pragma warn -ccc /* Condition is always true or false */ |
||
108 | //#pragma warn -aus /* Assigned value is never used */ |
||
109 | //#pragma warn -csu /* Comparing signed and unsigned */ |
||
110 | //#pragma warn -spa /* Suspicious pointer arithmetic */ |
||
111 | //#endif |
||
112 | |||
113 | /* Needed for various definitions... */ |
||
114 | //#if !_GNU_SOURCE |
||
115 | //#define _GNU_SOURCE |
||
116 | //#endif |
||
117 | /* |
||
118 | ** Include standard header files as necessary |
||
119 | */ |
||
120 | #if HAVE_STDINT_H |
||
121 | //#include <stdint.h> |
||
122 | #endif |
||
123 | #if HAVE_INTTYPES_H |
||
124 | //#include <inttypes.h> |
||
125 | #endif |
||
126 | |||
127 | /* |
||
128 | ** The number of samples of an index that SQLite takes in order to |
||
129 | ** construct a histogram of the table content when running ANALYZE |
||
130 | ** and with SQLITE_ENABLE_STAT2 |
||
131 | */ |
||
132 | //#define SQLITE_INDEX_SAMPLES 10 |
||
133 | public const int SQLITE_INDEX_SAMPLES = 10; |
||
134 | |||
135 | /* |
||
136 | ** The following macros are used to cast pointers to integers and |
||
137 | ** integers to pointers. The way you do this varies from one compiler |
||
138 | ** to the next, so we have developed the following set of #if statements |
||
139 | ** to generate appropriate macros for a wide range of compilers. |
||
140 | ** |
||
141 | ** The correct "ANSI" way to do this is to use the intptr_t type. |
||
142 | ** Unfortunately, that typedef is not available on all compilers, or |
||
143 | ** if it is available, it requires an #include of specific headers |
||
144 | ** that vary from one machine to the next. |
||
145 | ** |
||
146 | ** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on |
||
147 | ** the ((void)&((char)0)[X]) construct. But MSVC chokes on ((void)(X)). |
||
148 | ** So we have to define the macros in different ways depending on the |
||
149 | ** compiler. |
||
150 | */ |
||
151 | //#if (__PTRDIFF_TYPE__) /* This case should work for GCC */ |
||
152 | //# define SQLITE_INT_TO_PTR(X) ((void)(__PTRDIFF_TYPE__)(X)) |
||
153 | //# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X)) |
||
154 | //#elif !defined(__GNUC__) /* Works for compilers other than LLVM */ |
||
155 | //# define SQLITE_INT_TO_PTR(X) ((void)&((char)0)[X]) |
||
156 | //# define SQLITE_PTR_TO_INT(X) ((int)(((char)X)-(char)0)) |
||
157 | //#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */ |
||
158 | //# define SQLITE_INT_TO_PTR(X) ((void)(intptr_t)(X)) |
||
159 | //# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X)) |
||
160 | //#else /* Generates a warning - but it always works */ |
||
161 | //# define SQLITE_INT_TO_PTR(X) ((void)(X)) |
||
162 | //# define SQLITE_PTR_TO_INT(X) ((int)(X)) |
||
163 | //#endif |
||
164 | |||
165 | /* |
||
166 | ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. |
||
167 | ** 0 means mutexes are permanently disable and the library is never |
||
168 | ** threadsafe. 1 means the library is serialized which is the highest |
||
169 | ** level of threadsafety. 2 means the libary is multithreaded - multiple |
||
170 | ** threads can use SQLite as long as no two threads try to use the same |
||
171 | ** database connection at the same time. |
||
172 | ** |
||
173 | ** Older versions of SQLite used an optional THREADSAFE macro. |
||
174 | ** We support that for legacy. |
||
175 | */ |
||
176 | |||
177 | #if !SQLITE_THREADSAFE |
||
178 | //# define SQLITE_THREADSAFE 2 |
||
179 | const int SQLITE_THREADSAFE = 2; |
||
180 | #else |
||
181 | const int SQLITE_THREADSAFE = 2; /* IMP: R-07272-22309 */ |
||
182 | #endif |
||
183 | |||
184 | /* |
||
185 | ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1. |
||
186 | ** It determines whether or not the features related to |
||
187 | ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can |
||
188 | ** be overridden at runtime using the sqlite3_config() API. |
||
189 | */ |
||
190 | #if !(SQLITE_DEFAULT_MEMSTATUS) |
||
191 | //# define SQLITE_DEFAULT_MEMSTATUS 1 |
||
192 | const int SQLITE_DEFAULT_MEMSTATUS = 0; |
||
193 | #else |
||
194 | const int SQLITE_DEFAULT_MEMSTATUS = 1; |
||
195 | #endif |
||
196 | |||
197 | /* |
||
198 | ** Exactly one of the following macros must be defined in order to |
||
199 | ** specify which memory allocation subsystem to use. |
||
200 | ** |
||
201 | ** SQLITE_SYSTEM_MALLOC // Use normal system malloc() |
||
202 | ** SQLITE_MEMDEBUG // Debugging version of system malloc() |
||
203 | ** |
||
204 | ** (Historical note: There used to be several other options, but we've |
||
205 | ** pared it down to just these two.) |
||
206 | ** |
||
207 | ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as |
||
208 | ** the default. |
||
209 | */ |
||
210 | //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ |
||
211 | //# error "At most one of the following compile-time configuration options\ |
||
212 | // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG" |
||
213 | //#endif |
||
214 | //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ |
||
215 | //# define SQLITE_SYSTEM_MALLOC 1 |
||
216 | //#endif |
||
217 | |||
218 | /* |
||
219 | ** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the |
||
220 | ** sizes of memory allocations below this value where possible. |
||
221 | */ |
||
222 | #if !(SQLITE_MALLOC_SOFT_LIMIT) |
||
223 | const int SQLITE_MALLOC_SOFT_LIMIT = 1024; |
||
224 | #endif |
||
225 | |||
226 | /* |
||
227 | ** We need to define _XOPEN_SOURCE as follows in order to enable |
||
228 | ** recursive mutexes on most Unix systems. But Mac OS X is different. |
||
229 | ** The _XOPEN_SOURCE define causes problems for Mac OS X we are told, |
||
230 | ** so it is omitted there. See ticket #2673. |
||
231 | ** |
||
232 | ** Later we learn that _XOPEN_SOURCE is poorly or incorrectly |
||
233 | ** implemented on some systems. So we avoid defining it at all |
||
234 | ** if it is already defined or if it is unneeded because we are |
||
235 | ** not doing a threadsafe build. Ticket #2681. |
||
236 | ** |
||
237 | ** See also ticket #2741. |
||
238 | */ |
||
239 | #if !_XOPEN_SOURCE && !__DARWIN__ && !__APPLE__ && SQLITE_THREADSAFE |
||
240 | const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ |
||
241 | #endif |
||
242 | |||
243 | /* |
||
244 | ** The TCL headers are only needed when compiling the TCL bindings. |
||
245 | */ |
||
246 | #if SQLITE_TCL || TCLSH |
||
247 | //# include <tcl.h> |
||
248 | #endif |
||
249 | |||
250 | /* |
||
251 | ** Many people are failing to set -DNDEBUG=1 when compiling SQLite. |
||
252 | ** Setting NDEBUG makes the code smaller and run faster. So the following |
||
253 | ** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 |
||
254 | ** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out |
||
255 | ** feature. |
||
256 | */ |
||
257 | #if !NDEBUG && !SQLITE_DEBUG |
||
258 | const int NDEBUG = 1;//# define NDEBUG 1 |
||
259 | #endif |
||
260 | |||
261 | /* |
||
262 | ** The testcase() macro is used to aid in coverage testing. When |
||
263 | ** doing coverage testing, the condition inside the argument to |
||
264 | ** testcase() must be evaluated both true and false in order to |
||
265 | ** get full branch coverage. The testcase() macro is inserted |
||
266 | ** to help ensure adequate test coverage in places where simple |
||
267 | ** condition/decision coverage is inadequate. For example, testcase() |
||
268 | ** can be used to make sure boundary values are tested. For |
||
269 | ** bitmask tests, testcase() can be used to make sure each bit |
||
270 | ** is significant and used at least once. On switch statements |
||
271 | ** where multiple cases go to the same block of code, testcase() |
||
272 | ** can insure that all cases are evaluated. |
||
273 | ** |
||
274 | */ |
||
275 | #if SQLITE_COVERAGE_TEST |
||
276 | void sqlite3Coverage(int); |
||
277 | //# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); } |
||
278 | #else |
||
279 | //# define testcase(X) |
||
280 | static void testcase<T>( T X ) |
||
281 | { |
||
282 | } |
||
283 | #endif |
||
284 | |||
285 | /* |
||
286 | ** The TESTONLY macro is used to enclose variable declarations or |
||
287 | ** other bits of code that are needed to support the arguments |
||
288 | ** within testcase() and Debug.Assert() macros. |
||
289 | */ |
||
290 | #if !NDEBUG || SQLITE_COVERAGE_TEST |
||
291 | //# define TESTONLY(X) X |
||
292 | // -- Need workaround for C#, since inline macros don't exist |
||
293 | #else |
||
294 | //# define TESTONLY(X) |
||
295 | #endif |
||
296 | |||
297 | /* |
||
298 | ** Sometimes we need a small amount of code such as a variable initialization |
||
299 | ** to setup for a later Debug.Assert() statement. We do not want this code to |
||
300 | ** appear when Debug.Assert() is disabled. The following macro is therefore |
||
301 | ** used to contain that setup code. The "VVA" acronym stands for |
||
302 | ** "Verification, Validation, and Accreditation". In other words, the |
||
303 | ** code within VVA_ONLY() will only run during verification processes. |
||
304 | */ |
||
305 | #if !NDEBUG |
||
306 | //# define VVA_ONLY(X) X |
||
307 | #else |
||
308 | //# define VVA_ONLY(X) |
||
309 | #endif |
||
310 | |||
311 | /* |
||
312 | ** The ALWAYS and NEVER macros surround boolean expressions which |
||
313 | ** are intended to always be true or false, respectively. Such |
||
314 | ** expressions could be omitted from the code completely. But they |
||
315 | ** are included in a few cases in order to enhance the resilience |
||
316 | ** of SQLite to unexpected behavior - to make the code "self-healing" |
||
317 | ** or "ductile" rather than being "brittle" and crashing at the first |
||
318 | ** hint of unplanned behavior. |
||
319 | ** |
||
320 | ** In other words, ALWAYS and NEVER are added for defensive code. |
||
321 | ** |
||
322 | ** When doing coverage testing ALWAYS and NEVER are hard-coded to |
||
323 | ** be true and false so that the unreachable code then specify will |
||
324 | ** not be counted as untested code. |
||
325 | */ |
||
326 | #if SQLITE_COVERAGE_TEST |
||
327 | //# define ALWAYS(X) (1) |
||
328 | //# define NEVER(X) (0) |
||
329 | #elif !NDEBUG |
||
330 | //# define ALWAYS(X) ((X)?1:(Debug.Assert(0),0)) |
||
331 | static bool ALWAYS( bool X ) |
||
332 | { |
||
333 | if ( X != true ) |
||
334 | Debug.Assert( false ); |
||
335 | return true; |
||
336 | } |
||
337 | static int ALWAYS( int X ) |
||
338 | { |
||
339 | if ( X == 0 ) |
||
340 | Debug.Assert( false ); |
||
341 | return 1; |
||
342 | } |
||
343 | static bool ALWAYS<T>( T X ) |
||
344 | { |
||
345 | if ( X == null ) |
||
346 | Debug.Assert( false ); |
||
347 | return true; |
||
348 | } |
||
349 | |||
350 | //# define NEVER(X) ((X)?(Debug.Assert(0),1):0) |
||
351 | static bool NEVER( bool X ) |
||
352 | { |
||
353 | if ( X == true ) |
||
354 | Debug.Assert( false ); |
||
355 | return false; |
||
356 | } |
||
357 | static byte NEVER( byte X ) |
||
358 | { |
||
359 | if ( X != 0 ) |
||
360 | Debug.Assert( false ); |
||
361 | return 0; |
||
362 | } |
||
363 | static int NEVER( int X ) |
||
364 | { |
||
365 | if ( X != 0 ) |
||
366 | Debug.Assert( false ); |
||
367 | return 0; |
||
368 | } |
||
369 | static bool NEVER<T>( T X ) |
||
370 | { |
||
371 | if ( X != null ) |
||
372 | Debug.Assert( false ); |
||
373 | return false; |
||
374 | } |
||
375 | #else |
||
376 | //# define ALWAYS(X) (X) |
||
377 | static bool ALWAYS(bool X) { return X; } |
||
378 | static byte ALWAYS(byte X) { return X; } |
||
379 | static int ALWAYS(int X) { return X; } |
||
380 | static bool ALWAYS<T>( T X ) { return true; } |
||
381 | |||
382 | //# define NEVER(X) (X) |
||
383 | static bool NEVER(bool X) { return X; } |
||
384 | static byte NEVER(byte X) { return X; } |
||
385 | static int NEVER(int X) { return X; } |
||
386 | static bool NEVER<T>(T X) { return false; } |
||
387 | #endif |
||
388 | |||
389 | /* |
||
390 | ** Return true (non-zero) if the input is a integer that is too large |
||
391 | ** to fit in 32-bits. This macro is used inside of various testcase() |
||
392 | ** macros to verify that we have tested SQLite for large-file support. |
||
393 | */ |
||
394 | static bool IS_BIG_INT( i64 X ) |
||
395 | { |
||
396 | return ( ( ( X ) & ~(i64)0xffffffff ) != 0 ); |
||
397 | }//#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0) |
||
398 | |||
399 | /* |
||
400 | ** The macro unlikely() is a hint that surrounds a boolean |
||
401 | ** expression that is usually false. Macro likely() surrounds |
||
402 | ** a boolean expression that is usually true. GCC is able to |
||
403 | ** use these hints to generate better code, sometimes. |
||
404 | */ |
||
405 | #if (__GNUC__) && FALSE |
||
406 | //# define likely(X) __builtin_expect((X),1) |
||
407 | //# define unlikely(X) __builtin_expect((X),0) |
||
408 | #else |
||
409 | //# define likely(X) !!(X) |
||
410 | static bool likely( bool X ) |
||
411 | { |
||
412 | return !!X; |
||
413 | } |
||
414 | //# define unlikely(X) !!(X) |
||
415 | static bool unlikely( bool X ) |
||
416 | { |
||
417 | return !!X; |
||
418 | } |
||
419 | #endif |
||
420 | |||
421 | //#include "sqlite3.h" |
||
422 | //#include "hash.h" |
||
423 | //#include "parse.h" |
||
424 | //#include <stdio.h> |
||
425 | //#include <stdlib.h> |
||
426 | //#include <string.h> |
||
427 | //#include <assert.h> |
||
428 | //#include <stddef.h> |
||
429 | |||
430 | /* |
||
431 | ** If compiling for a processor that lacks floating point support, |
||
432 | ** substitute integer for floating-point |
||
433 | */ |
||
434 | #if SQLITE_OMIT_FLOATING_POINT |
||
435 | //# define double sqlite_int64 |
||
436 | //# define float sqlite_int64 |
||
437 | //# define LONGDOUBLE_TYPE sqlite_int64 |
||
438 | //#if !SQLITE_BIG_DBL |
||
439 | //# define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50) |
||
440 | //# endif |
||
441 | //# define SQLITE_OMIT_DATETIME_FUNCS 1 |
||
442 | //# define SQLITE_OMIT_TRACE 1 |
||
443 | //# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT |
||
444 | //# undef SQLITE_HAVE_ISNAN |
||
445 | #endif |
||
446 | #if !SQLITE_BIG_DBL |
||
447 | const double SQLITE_BIG_DBL = ( ( (sqlite3_int64)1 ) << 60 );//# define SQLITE_BIG_DBL (1e99) |
||
448 | #endif |
||
449 | |||
450 | /* |
||
451 | ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 |
||
452 | ** afterward. Having this macro allows us to cause the C compiler |
||
453 | ** to omit code used by TEMP tables without messy #if !statements. |
||
454 | */ |
||
455 | #if SQLITE_OMIT_TEMPDB |
||
456 | //#define OMIT_TEMPDB 1 |
||
457 | #else |
||
458 | static int OMIT_TEMPDB = 0; |
||
459 | #endif |
||
460 | |||
461 | |||
462 | /* |
||
463 | ** The "file format" number is an integer that is incremented whenever |
||
464 | ** the VDBE-level file format changes. The following macros define the |
||
465 | ** the default file format for new databases and the maximum file format |
||
466 | ** that the library can read. |
||
467 | */ |
||
468 | static public int SQLITE_MAX_FILE_FORMAT = 4;//#define SQLITE_MAX_FILE_FORMAT 4 |
||
469 | //#if !SQLITE_DEFAULT_FILE_FORMAT |
||
470 | static int SQLITE_DEFAULT_FILE_FORMAT = 1;//# define SQLITE_DEFAULT_FILE_FORMAT 1 |
||
471 | //#endif |
||
472 | |||
473 | /* |
||
474 | ** Determine whether triggers are recursive by default. This can be |
||
475 | ** changed at run-time using a pragma. |
||
476 | */ |
||
477 | #if !SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
||
478 | //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0 |
||
479 | static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = false; |
||
480 | #else |
||
481 | static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = true; |
||
482 | #endif |
||
483 | |||
484 | |||
485 | /* |
||
486 | ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified |
||
487 | ** on the command-line |
||
488 | */ |
||
489 | //#if !SQLITE_TEMP_STORE |
||
490 | static int SQLITE_TEMP_STORE = 1;//#define SQLITE_TEMP_STORE 1 |
||
491 | //#endif |
||
492 | |||
493 | /* |
||
494 | ** GCC does not define the offsetof() macro so we'll have to do it |
||
495 | ** ourselves. |
||
496 | */ |
||
497 | #if !offsetof |
||
498 | //#define offsetof(STRUCTURE,FIELD) ((int)((char)&((STRUCTURE)0)->FIELD)) |
||
499 | #endif |
||
500 | |||
501 | /* |
||
502 | ** Check to see if this machine uses EBCDIC. (Yes, believe it or |
||
503 | ** not, there are still machines out there that use EBCDIC.) |
||
504 | */ |
||
505 | #if FALSE //'A' == '\301' |
||
506 | //# define SQLITE_EBCDIC 1 |
||
507 | #else |
||
508 | const int SQLITE_ASCII = 1;//#define SQLITE_ASCII 1 |
||
509 | #endif |
||
510 | |||
511 | /* |
||
512 | ** Integers of known sizes. These typedefs might change for architectures |
||
513 | ** where the sizes very. Preprocessor macros are available so that the |
||
514 | ** types can be conveniently redefined at compile-type. Like this: |
||
515 | ** |
||
516 | ** cc '-Du32PTR_TYPE=long long int' ... |
||
517 | */ |
||
518 | //#if !u32_TYPE |
||
519 | //# ifdef HAVE_u32_T |
||
520 | //# define u32_TYPE u32_t |
||
521 | //# else |
||
522 | //# define u32_TYPE unsigned int |
||
523 | //# endif |
||
524 | //#endif |
||
525 | //#if !u3216_TYPE |
||
526 | //# ifdef HAVE_u3216_T |
||
527 | //# define u3216_TYPE u3216_t |
||
528 | //# else |
||
529 | //# define u3216_TYPE unsigned short int |
||
530 | //# endif |
||
531 | //#endif |
||
532 | //#if !INT16_TYPE |
||
533 | //# ifdef HAVE_INT16_T |
||
534 | //# define INT16_TYPE int16_t |
||
535 | //# else |
||
536 | //# define INT16_TYPE short int |
||
537 | //# endif |
||
538 | //#endif |
||
539 | //#if !u328_TYPE |
||
540 | //# ifdef HAVE_u328_T |
||
541 | //# define u328_TYPE u328_t |
||
542 | //# else |
||
543 | //# define u328_TYPE unsigned char |
||
544 | //# endif |
||
545 | //#endif |
||
546 | //#if !INT8_TYPE |
||
547 | //# ifdef HAVE_INT8_T |
||
548 | //# define INT8_TYPE int8_t |
||
549 | //# else |
||
550 | //# define INT8_TYPE signed char |
||
551 | //# endif |
||
552 | //#endif |
||
553 | //#if !LONGDOUBLE_TYPE |
||
554 | //# define LONGDOUBLE_TYPE long double |
||
555 | //#endif |
||
556 | //typedef sqlite_int64 i64; /* 8-byte signed integer */ |
||
557 | //typedef sqlite_u3264 u64; /* 8-byte unsigned integer */ |
||
558 | //typedef u32_TYPE u32; /* 4-byte unsigned integer */ |
||
559 | //typedef u3216_TYPE u16; /* 2-byte unsigned integer */ |
||
560 | //typedef INT16_TYPE i16; /* 2-byte signed integer */ |
||
561 | //typedef u328_TYPE u8; /* 1-byte unsigned integer */ |
||
562 | //typedef INT8_TYPE i8; /* 1-byte signed integer */ |
||
563 | |||
564 | /* |
||
565 | ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value |
||
566 | ** that can be stored in a u32 without loss of data. The value |
||
567 | ** is 0x00000000ffffffff. But because of quirks of some compilers, we |
||
568 | ** have to specify the value in the less intuitive manner shown: |
||
569 | */ |
||
570 | //#define SQLITE_MAX_U32 ((((u64)1)<<32)-1) |
||
571 | const u32 SQLITE_MAX_U32 = (u32)( ( ( (u64)1 ) << 32 ) - 1 ); |
||
572 | |||
573 | |||
574 | /* |
||
575 | ** Macros to determine whether the machine is big or little endian, |
||
576 | ** evaluated at runtime. |
||
577 | */ |
||
578 | #if SQLITE_AMALGAMATION |
||
579 | //const int sqlite3one = 1; |
||
580 | #else |
||
581 | const bool sqlite3one = true; |
||
582 | #endif |
||
583 | #if i386 || __i386__ || _M_IX86 |
||
584 | const int ;//#define SQLITE_BIGENDIAN 0 |
||
585 | const int ;//#define SQLITE_LITTLEENDIAN 1 |
||
586 | const int ;//#define SQLITE_UTF16NATIVE SQLITE_UTF16LE |
||
587 | #else |
||
588 | static u8 SQLITE_BIGENDIAN = 0;//#define SQLITE_BIGENDIAN (*(char )(&sqlite3one)==0) |
||
589 | static u8 SQLITE_LITTLEENDIAN = 1;//#define SQLITE_LITTLEENDIAN (*(char )(&sqlite3one)==1) |
||
590 | static u8 SQLITE_UTF16NATIVE = ( SQLITE_BIGENDIAN != 0 ? SQLITE_UTF16BE : SQLITE_UTF16LE );//#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) |
||
591 | #endif |
||
592 | |||
593 | /* |
||
594 | ** Constants for the largest and smallest possible 64-bit signed integers. |
||
595 | ** These macros are designed to work correctly on both 32-bit and 64-bit |
||
596 | ** compilers. |
||
597 | */ |
||
598 | //#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
||
599 | //#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
||
600 | const i64 LARGEST_INT64 = i64.MaxValue;//( 0xffffffff | ( ( (i64)0x7fffffff ) << 32 ) ); |
||
601 | const i64 SMALLEST_INT64 = i64.MinValue;//( ( ( i64 ) - 1 ) - LARGEST_INT64 ); |
||
602 | |||
603 | /* |
||
604 | ** Round up a number to the next larger multiple of 8. This is used |
||
605 | ** to force 8-byte alignment on 64-bit architectures. |
||
606 | */ |
||
607 | //#define ROUND8(x) (((x)+7)&~7) |
||
608 | static int ROUND8( int x ) |
||
609 | { |
||
610 | return ( x + 7 ) & ~7; |
||
611 | } |
||
612 | |||
613 | /* |
||
614 | ** Round down to the nearest multiple of 8 |
||
615 | */ |
||
616 | //#define ROUNDDOWN8(x) ((x)&~7) |
||
617 | static int ROUNDDOWN8( int x ) |
||
618 | { |
||
619 | return x & ~7; |
||
620 | } |
||
621 | |||
622 | /* |
||
623 | ** Assert that the pointer X is aligned to an 8-byte boundary. This |
||
624 | ** macro is used only within Debug.Assert() to verify that the code gets |
||
625 | ** all alignment restrictions correct. |
||
626 | ** |
||
627 | ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the |
||
628 | ** underlying malloc() implemention might return us 4-byte aligned |
||
629 | ** pointers. In that case, only verify 4-byte alignment. |
||
630 | */ |
||
631 | //#if SQLITE_4_BYTE_ALIGNED_MALLOC |
||
632 | //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&3)==0) |
||
633 | //#else |
||
634 | //# define EIGHT_BYTE_ALIGNMENT(X) ((((char)(X) - (char)0)&7)==0) |
||
635 | //#endif |
||
636 | |||
637 | /* |
||
638 | ** An instance of the following structure is used to store the busy-handler |
||
639 | ** callback for a given sqlite handle. |
||
640 | ** |
||
641 | ** The sqlite.busyHandler member of the sqlite struct contains the busy |
||
642 | ** callback for the database handle. Each pager opened via the sqlite |
||
643 | ** handle is passed a pointer to sqlite.busyHandler. The busy-handler |
||
644 | ** callback is currently invoked only from within pager.c. |
||
645 | */ |
||
646 | //typedef struct BusyHandler BusyHandler; |
||
647 | public class BusyHandler |
||
648 | { |
||
649 | public dxBusy xFunc;//)(void *,int); /* The busy callback */ |
||
650 | public object pArg; /* First arg to busy callback */ |
||
651 | public int nBusy; /* Incremented with each busy call */ |
||
652 | }; |
||
653 | |||
654 | /* |
||
655 | ** Name of the master database table. The master database table |
||
656 | ** is a special table that holds the names and attributes of all |
||
657 | ** user tables and indices. |
||
658 | */ |
||
659 | const string MASTER_NAME = "sqlite_master";//#define MASTER_NAME "sqlite_master" |
||
660 | const string TEMP_MASTER_NAME = "sqlite_temp_master";//#define TEMP_MASTER_NAME "sqlite_temp_master" |
||
661 | |||
662 | /* |
||
663 | ** The root-page of the master database table. |
||
664 | */ |
||
665 | const int MASTER_ROOT = 1;//#define MASTER_ROOT 1 |
||
666 | |||
667 | /* |
||
668 | ** The name of the schema table. |
||
669 | */ |
||
670 | static string SCHEMA_TABLE( int x ) //#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME) |
||
671 | { |
||
672 | return ( ( OMIT_TEMPDB == 0 ) && ( x == 1 ) ? TEMP_MASTER_NAME : MASTER_NAME ); |
||
673 | } |
||
674 | |||
675 | /* |
||
676 | ** A convenience macro that returns the number of elements in |
||
677 | ** an array. |
||
678 | */ |
||
679 | //#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) |
||
680 | static int ArraySize<T>( T[] x ) |
||
681 | { |
||
682 | return x.Length; |
||
683 | } |
||
684 | |||
685 | /* |
||
686 | ** The following value as a destructor means to use sqlite3DbFree(). |
||
687 | ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. |
||
688 | */ |
||
689 | //#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) |
||
690 | static dxDel SQLITE_DYNAMIC; |
||
691 | |||
692 | /* |
||
693 | ** When SQLITE_OMIT_WSD is defined, it means that the target platform does |
||
694 | ** not support Writable Static Data (WSD) such as global and static variables. |
||
695 | ** All variables must either be on the stack or dynamically allocated from |
||
696 | ** the heap. When WSD is unsupported, the variable declarations scattered |
||
697 | ** throughout the SQLite code must become constants instead. The SQLITE_WSD |
||
698 | ** macro is used for this purpose. And instead of referencing the variable |
||
699 | ** directly, we use its constant as a key to lookup the run-time allocated |
||
700 | ** buffer that holds real variable. The constant is also the initializer |
||
701 | ** for the run-time allocated buffer. |
||
702 | ** |
||
703 | ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL |
||
704 | ** macros become no-ops and have zero performance impact. |
||
705 | */ |
||
706 | #if SQLITE_OMIT_WSD |
||
707 | //#define SQLITE_WSD const |
||
708 | //#define GLOBAL(t,v) (*(t)sqlite3_wsd_find((void)&(v), sizeof(v))) |
||
709 | //#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config) |
||
710 | int sqlite3_wsd_init(int N, int J); |
||
711 | void *sqlite3_wsd_find(void *K, int L); |
||
712 | #else |
||
713 | //#define SQLITE_WSD |
||
714 | //#define GLOBAL(t,v) v |
||
715 | //#define sqlite3GlobalConfig sqlite3Config |
||
716 | static Sqlite3Config sqlite3GlobalConfig; |
||
717 | #endif |
||
718 | |||
719 | /* |
||
720 | ** The following macros are used to suppress compiler warnings and to |
||
721 | ** make it clear to human readers when a function parameter is deliberately |
||
722 | ** left unused within the body of a function. This usually happens when |
||
723 | ** a function is called via a function pointer. For example the |
||
724 | ** implementation of an SQL aggregate step callback may not use the |
||
725 | ** parameter indicating the number of arguments passed to the aggregate, |
||
726 | ** if it knows that this is enforced elsewhere. |
||
727 | ** |
||
728 | ** When a function parameter is not used at all within the body of a function, |
||
729 | ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. |
||
730 | ** However, these macros may also be used to suppress warnings related to |
||
731 | ** parameters that may or may not be used depending on compilation options. |
||
732 | ** For example those parameters only used in Debug.Assert() statements. In these |
||
733 | ** cases the parameters are named as per the usual conventions. |
||
734 | */ |
||
735 | //#define UNUSED_PARAMETER(x) (void)(x) |
||
736 | static void UNUSED_PARAMETER<T>( T x ) |
||
737 | { |
||
738 | } |
||
739 | |||
740 | //#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y) |
||
741 | static void UNUSED_PARAMETER2<T1, T2>( T1 x, T2 y ) |
||
742 | { |
||
743 | UNUSED_PARAMETER( x ); |
||
744 | UNUSED_PARAMETER( y ); |
||
745 | } |
||
746 | |||
747 | /* |
||
748 | ** Forward references to structures |
||
749 | */ |
||
750 | //typedef struct AggInfo AggInfo; |
||
751 | //typedef struct AuthContext AuthContext; |
||
752 | //typedef struct AutoincInfo AutoincInfo; |
||
753 | //typedef struct Bitvec Bitvec; |
||
754 | //typedef struct CollSeq CollSeq; |
||
755 | //typedef struct Column Column; |
||
756 | //typedef struct Db Db; |
||
757 | //typedef struct Schema Schema; |
||
758 | //typedef struct Expr Expr; |
||
759 | //typedef struct ExprList ExprList; |
||
760 | //typedef struct ExprSpan ExprSpan; |
||
761 | //typedef struct FKey FKey; |
||
762 | //typedef struct FuncDestructor FuncDestructor; |
||
763 | //typedef struct FuncDef FuncDef; |
||
764 | //typedef struct IdList IdList; |
||
765 | //typedef struct Index Index; |
||
766 | //typedef struct IndexSample IndexSample; |
||
767 | //typedef struct KeyClass KeyClass; |
||
768 | //typedef struct KeyInfo KeyInfo; |
||
769 | //typedef struct Lookaside Lookaside; |
||
770 | //typedef struct LookasideSlot LookasideSlot; |
||
771 | //typedef struct Module Module; |
||
772 | //typedef struct NameContext NameContext; |
||
773 | //typedef struct Parse Parse; |
||
774 | //typedef struct RowSet RowSet; |
||
775 | //typedef struct Savepoint Savepoint; |
||
776 | //typedef struct Select Select; |
||
777 | //typedef struct SrcList SrcList; |
||
778 | //typedef struct StrAccum StrAccum; |
||
779 | //typedef struct Table Table; |
||
780 | //typedef struct TableLock TableLock; |
||
781 | //typedef struct Token Token; |
||
782 | //typedef struct Trigger Trigger; |
||
783 | //typedef struct TriggerPrg TriggerPrg; |
||
784 | //typedef struct TriggerStep TriggerStep; |
||
785 | //typedef struct UnpackedRecord UnpackedRecord; |
||
786 | //typedef struct VTable VTable; |
||
787 | //typedef struct VtabCtx VtabCtx; |
||
788 | //typedef struct Walker Walker; |
||
789 | //typedef struct WherePlan WherePlan; |
||
790 | //typedef struct WhereInfo WhereInfo; |
||
791 | //typedef struct WhereLevel WhereLevel; |
||
792 | |||
793 | /* |
||
794 | ** Defer sourcing vdbe.h and btree.h until after the "u8" and |
||
795 | ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque |
||
796 | ** pointer types (i.e. FuncDef) defined above. |
||
797 | */ |
||
798 | //#include "btree.h" |
||
799 | //#include "vdbe.h" |
||
800 | //#include "pager.h" |
||
801 | //#include "pcache_g.h" |
||
802 | |||
803 | //#include "os.h" |
||
804 | //#include "mutex.h" |
||
805 | |||
806 | /* |
||
807 | ** Each database file to be accessed by the system is an instance |
||
808 | ** of the following structure. There are normally two of these structures |
||
809 | ** in the sqlite.aDb[] array. aDb[0] is the main database file and |
||
810 | ** aDb[1] is the database file used to hold temporary tables. Additional |
||
811 | ** databases may be attached. |
||
812 | */ |
||
813 | public class Db |
||
814 | { |
||
815 | public string zName; /* Name of this database */ |
||
816 | public Btree pBt; /* The B Tree structure for this database file */ |
||
817 | public u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ |
||
818 | public u8 safety_level; /* How aggressive at syncing data to disk */ |
||
819 | public Schema pSchema; /* Pointer to database schema (possibly shared) */ |
||
820 | }; |
||
821 | |||
822 | /* |
||
823 | ** An instance of the following structure stores a database schema. |
||
824 | ** |
||
825 | ** Most Schema objects are associated with a Btree. The exception is |
||
826 | ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing. |
||
827 | ** In shared cache mode, a single Schema object can be shared by multiple |
||
828 | ** Btrees that refer to the same underlying BtShared object. |
||
829 | ** |
||
830 | ** Schema objects are automatically deallocated when the last Btree that |
||
831 | ** references them is destroyed. The TEMP Schema is manually freed by |
||
832 | ** sqlite3_close(). |
||
833 | * |
||
834 | ** A thread must be holding a mutex on the corresponding Btree in order |
||
835 | ** to access Schema content. This implies that the thread must also be |
||
836 | ** holding a mutex on the sqlite3 connection pointer that owns the Btree. |
||
837 | ** For a TEMP Schema, only the connection mutex is required. |
||
838 | */ |
||
839 | public class Schema |
||
840 | { |
||
841 | public int schema_cookie; /* Database schema version number for this file */ |
||
842 | public u32 iGeneration; /* Generation counter. Incremented with each change */ |
||
843 | public Hash tblHash = new Hash(); /* All tables indexed by name */ |
||
844 | public Hash idxHash = new Hash(); /* All (named) indices indexed by name */ |
||
845 | public Hash trigHash = new Hash();/* All triggers indexed by name */ |
||
846 | public Hash fkeyHash = new Hash();/* All foreign keys by referenced table name */ |
||
847 | public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ |
||
848 | public u8 file_format; /* Schema format version for this file */ |
||
849 | public u8 enc; /* Text encoding used by this database */ |
||
850 | public u16 flags; /* Flags associated with this schema */ |
||
851 | public int cache_size; /* Number of pages to use in the cache */ |
||
852 | public Schema Copy() |
||
853 | { |
||
854 | if ( this == null ) |
||
855 | return null; |
||
856 | else |
||
857 | { |
||
858 | Schema cp = (Schema)MemberwiseClone(); |
||
859 | return cp; |
||
860 | } |
||
861 | } |
||
862 | |||
863 | public void Clear() |
||
864 | { |
||
865 | if ( this != null ) |
||
866 | { |
||
867 | schema_cookie = 0; |
||
868 | tblHash = new Hash(); |
||
869 | idxHash = new Hash(); |
||
870 | trigHash = new Hash(); |
||
871 | fkeyHash = new Hash(); |
||
872 | pSeqTab = null; |
||
873 | } |
||
874 | } |
||
875 | }; |
||
876 | |||
877 | /* |
||
878 | ** These macros can be used to test, set, or clear bits in the |
||
879 | ** Db.pSchema->flags field. |
||
880 | */ |
||
881 | //#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P)) |
||
882 | static bool DbHasProperty( sqlite3 D, int I, ushort P ) |
||
883 | { |
||
884 | return ( D.aDb[I].pSchema.flags & P ) == P; |
||
885 | } |
||
886 | //#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0) |
||
887 | //#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P) |
||
888 | static void DbSetProperty( sqlite3 D, int I, ushort P ) |
||
889 | { |
||
890 | D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags | P ); |
||
891 | } |
||
892 | //#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P) |
||
893 | static void DbClearProperty( sqlite3 D, int I, ushort P ) |
||
894 | { |
||
895 | D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags & ~P ); |
||
896 | } |
||
897 | /* |
||
898 | ** Allowed values for the DB.pSchema->flags field. |
||
899 | ** |
||
900 | ** The DB_SchemaLoaded flag is set after the database schema has been |
||
901 | ** read into internal hash tables. |
||
902 | ** |
||
903 | ** DB_UnresetViews means that one or more views have column names that |
||
904 | ** have been filled out. If the schema changes, these column names might |
||
905 | ** changes and so the view will need to be reset. |
||
906 | */ |
||
907 | //#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */ |
||
908 | //#define DB_UnresetViews 0x0002 /* Some views have defined column names */ |
||
909 | //#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */ |
||
910 | const u16 DB_SchemaLoaded = 0x0001; |
||
911 | const u16 DB_UnresetViews = 0x0002; |
||
912 | const u16 DB_Empty = 0x0004; |
||
913 | |||
914 | /* |
||
915 | ** The number of different kinds of things that can be limited |
||
916 | ** using the sqlite3_limit() interface. |
||
917 | */ |
||
918 | //#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1) |
||
919 | const int SQLITE_N_LIMIT = SQLITE_LIMIT_TRIGGER_DEPTH + 1; |
||
920 | |||
921 | /* |
||
922 | ** Lookaside malloc is a set of fixed-size buffers that can be used |
||
923 | ** to satisfy small transient memory allocation requests for objects |
||
924 | ** associated with a particular database connection. The use of |
||
925 | ** lookaside malloc provides a significant performance enhancement |
||
926 | ** (approx 10%) by avoiding numerous malloc/free requests while parsing |
||
927 | ** SQL statements. |
||
928 | ** |
||
929 | ** The Lookaside structure holds configuration information about the |
||
930 | ** lookaside malloc subsystem. Each available memory allocation in |
||
931 | ** the lookaside subsystem is stored on a linked list of LookasideSlot |
||
932 | ** objects. |
||
933 | ** |
||
934 | ** Lookaside allocations are only allowed for objects that are associated |
||
935 | ** with a particular database connection. Hence, schema information cannot |
||
936 | ** be stored in lookaside because in shared cache mode the schema information |
||
937 | ** is shared by multiple database connections. Therefore, while parsing |
||
938 | ** schema information, the Lookaside.bEnabled flag is cleared so that |
||
939 | ** lookaside allocations are not used to construct the schema objects. |
||
940 | */ |
||
941 | public class Lookaside |
||
942 | { |
||
943 | public int sz; /* Size of each buffer in bytes */ |
||
944 | public u8 bEnabled; /* False to disable new lookaside allocations */ |
||
945 | public bool bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
||
946 | public int nOut; /* Number of buffers currently checked out */ |
||
947 | public int mxOut; /* Highwater mark for nOut */ |
||
948 | public int[] anStat = new int[3]; /* 0: hits. 1: size misses. 2: full misses */ |
||
949 | public LookasideSlot pFree; /* List of available buffers */ |
||
950 | public int pStart; /* First byte of available memory space */ |
||
951 | public int pEnd; /* First byte past end of available space */ |
||
952 | }; |
||
953 | public class LookasideSlot |
||
954 | { |
||
955 | public LookasideSlot pNext; /* Next buffer in the list of free buffers */ |
||
956 | }; |
||
957 | |||
958 | /* |
||
959 | ** A hash table for function definitions. |
||
960 | ** |
||
961 | ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. |
||
962 | ** Collisions are on the FuncDef.pHash chain. |
||
963 | */ |
||
964 | public class FuncDefHash |
||
965 | { |
||
966 | public FuncDef[] a = new FuncDef[23]; /* Hash table for functions */ |
||
967 | }; |
||
968 | |||
969 | /* |
||
970 | ** Each database connection is an instance of the following structure. |
||
971 | ** |
||
972 | ** The sqlite.lastRowid records the last insert rowid generated by an |
||
973 | ** insert statement. Inserts on views do not affect its value. Each |
||
974 | ** trigger has its own context, so that lastRowid can be updated inside |
||
975 | ** triggers as usual. The previous value will be restored once the trigger |
||
976 | ** exits. Upon entering a before or instead of trigger, lastRowid is no |
||
977 | ** longer (since after version 2.8.12) reset to -1. |
||
978 | ** |
||
979 | ** The sqlite.nChange does not count changes within triggers and keeps no |
||
980 | ** context. It is reset at start of sqlite3_exec. |
||
981 | ** The sqlite.lsChange represents the number of changes made by the last |
||
982 | ** insert, update, or delete statement. It remains constant throughout the |
||
983 | ** length of a statement and is then updated by OP_SetCounts. It keeps a |
||
984 | ** context stack just like lastRowid so that the count of changes |
||
985 | ** within a trigger is not seen outside the trigger. Changes to views do not |
||
986 | ** affect the value of lsChange. |
||
987 | ** The sqlite.csChange keeps track of the number of current changes (since |
||
988 | ** the last statement) and is used to update sqlite_lsChange. |
||
989 | ** |
||
990 | ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16 |
||
991 | ** store the most recent error code and, if applicable, string. The |
||
992 | ** internal function sqlite3Error() is used to set these variables |
||
993 | ** consistently. |
||
994 | */ |
||
995 | public class sqlite3 |
||
996 | { |
||
997 | public sqlite3_vfs pVfs; /* OS Interface */ |
||
998 | public int nDb; /* Number of backends currently in use */ |
||
999 | public Db[] aDb = new Db[SQLITE_MAX_ATTACHED]; /* All backends */ |
||
1000 | public int flags; /* Miscellaneous flags. See below */ |
||
1001 | public int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ |
||
1002 | public int errCode; /* Most recent error code (SQLITE_) */ |
||
1003 | public int errMask; /* & result codes with this before returning */ |
||
1004 | public u8 autoCommit; /* The auto-commit flag. */ |
||
1005 | public u8 temp_store; /* 1: file 2: memory 0: default */ |
||
1006 | // Cannot happen under C# |
||
1007 | // public u8 mallocFailed; /* True if we have seen a malloc failure */ |
||
1008 | public u8 dfltLockMode; /* Default locking-mode for attached dbs */ |
||
1009 | public int nextAutovac; /* Autovac setting after VACUUM if >=0 */ |
||
1010 | public u8 suppressErr; /* Do not issue error messages if true */ |
||
1011 | public u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ |
||
1012 | public int nextPagesize; /* Pagesize after VACUUM if >0 */ |
||
1013 | public int nTable; /* Number of tables in the database */ |
||
1014 | public CollSeq pDfltColl; /* The default collating sequence (BINARY) */ |
||
1015 | public i64 lastRowid; /* ROWID of most recent insert (see above) */ |
||
1016 | public u32 magic; /* Magic number for detect library misuse */ |
||
1017 | public int nChange; /* Value returned by sqlite3_changes() */ |
||
1018 | public int nTotalChange; /* Value returned by sqlite3_total_changes() */ |
||
1019 | public sqlite3_mutex mutex; /* Connection mutex */ |
||
1020 | public int[] aLimit = new int[SQLITE_N_LIMIT]; /* Limits */ |
||
1021 | public class sqlite3InitInfo |
||
1022 | { /* Information used during initialization */ |
||
1023 | public int iDb; /* When back is being initialized */ |
||
1024 | public int newTnum; /* Rootpage of table being initialized */ |
||
1025 | public u8 busy; /* TRUE if currently initializing */ |
||
1026 | public u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ |
||
1027 | }; |
||
1028 | public sqlite3InitInfo init = new sqlite3InitInfo(); |
||
1029 | public int nExtension; /* Number of loaded extensions */ |
||
1030 | public object[] aExtension; /* Array of shared library handles */ |
||
1031 | public Vdbe pVdbe; /* List of active virtual machines */ |
||
1032 | public int activeVdbeCnt; /* Number of VDBEs currently executing */ |
||
1033 | public int writeVdbeCnt; /* Number of active VDBEs that are writing */ |
||
1034 | public int vdbeExecCnt; /* Number of nested calls to VdbeExec() */ |
||
1035 | public dxTrace xTrace;//)(void*,const char); /* Trace function */ |
||
1036 | public object pTraceArg; /* Argument to the trace function */ |
||
1037 | public dxProfile xProfile;//)(void*,const char*,u64); /* Profiling function */ |
||
1038 | public object pProfileArg; /* Argument to profile function */ |
||
1039 | public object pCommitArg; /* Argument to xCommitCallback() */ |
||
1040 | public dxCommitCallback xCommitCallback;//)(void); /* Invoked at every commit. */ |
||
1041 | public object pRollbackArg; /* Argument to xRollbackCallback() */ |
||
1042 | public dxRollbackCallback xRollbackCallback;//)(void); /* Invoked at every commit. */ |
||
1043 | public object pUpdateArg; |
||
1044 | public dxUpdateCallback xUpdateCallback;//)(void*,int, const char*,const char*,sqlite_int64); |
||
1045 | #if !SQLITE_OMIT_WAL |
||
1046 | //int (*xWalCallback)(void *, sqlite3 *, string , int); |
||
1047 | //void *pWalArg; |
||
1048 | #endif |
||
1049 | public dxCollNeeded xCollNeeded;//)(void*,sqlite3*,int eTextRep,const char); |
||
1050 | public dxCollNeeded xCollNeeded16;//)(void*,sqlite3*,int eTextRep,const void); |
||
1051 | public object pCollNeededArg; |
||
1052 | public sqlite3_value pErr; /* Most recent error message */ |
||
1053 | public string zErrMsg; /* Most recent error message (UTF-8 encoded) */ |
||
1054 | public string zErrMsg16; /* Most recent error message (UTF-16 encoded) */ |
||
1055 | public struct _u1 |
||
1056 | { |
||
1057 | public bool isInterrupted; /* True if sqlite3_interrupt has been called */ |
||
1058 | public double notUsed1; /* Spacer */ |
||
1059 | } |
||
1060 | public _u1 u1; |
||
1061 | public Lookaside lookaside = new Lookaside(); /* Lookaside malloc configuration */ |
||
1062 | #if !SQLITE_OMIT_AUTHORIZATION |
||
1063 | public dxAuth xAuth;//)(void*,int,const char*,const char*,const char*,const char); |
||
1064 | /* Access authorization function */ |
||
1065 | public object pAuthArg; /* 1st argument to the access auth function */ |
||
1066 | #endif |
||
1067 | #if !SQLITE_OMIT_PROGRESS_CALLBACK |
||
1068 | public dxProgress xProgress;//)(void ); /* The progress callback */ |
||
1069 | public object pProgressArg; /* Argument to the progress callback */ |
||
1070 | public int nProgressOps; /* Number of opcodes for progress callback */ |
||
1071 | #endif |
||
1072 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
1073 | public Hash aModule; /* populated by sqlite3_create_module() */ |
||
1074 | public VtabCtx pVtabCtx; /* Context for active vtab connect/create */ |
||
1075 | public VTable[] aVTrans; /* Virtual tables with open transactions */ |
||
1076 | public int nVTrans; /* Allocated size of aVTrans */ |
||
1077 | public VTable pDisconnect; /* Disconnect these in next sqlite3_prepare() */ |
||
1078 | #endif |
||
1079 | public FuncDefHash aFunc = new FuncDefHash(); /* Hash table of connection functions */ |
||
1080 | public Hash aCollSeq = new Hash(); /* All collating sequences */ |
||
1081 | public BusyHandler busyHandler = new BusyHandler(); /* Busy callback */ |
||
1082 | public int busyTimeout; /* Busy handler timeout, in msec */ |
||
1083 | public Db[] aDbStatic = new Db[] { new Db(), new Db() }; /* Static space for the 2 default backends */ |
||
1084 | public Savepoint pSavepoint; /* List of active savepoints */ |
||
1085 | public int nSavepoint; /* Number of non-transaction savepoints */ |
||
1086 | public int nStatement; /* Number of nested statement-transactions */ |
||
1087 | public u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ |
||
1088 | public i64 nDeferredCons; /* Net deferred constraints this transaction. */ |
||
1089 | public int pnBytesFreed; /* If not NULL, increment this in DbFree() */ |
||
1090 | #if SQLITE_ENABLE_UNLOCK_NOTIFY |
||
1091 | /* The following variables are all protected by the STATIC_MASTER |
||
1092 | ** mutex, not by sqlite3.mutex. They are used by code in notify.c. |
||
1093 | ** |
||
1094 | ** When X.pUnlockConnection==Y, that means that X is waiting for Y to |
||
1095 | ** unlock so that it can proceed. |
||
1096 | ** |
||
1097 | ** When X.pBlockingConnection==Y, that means that something that X tried |
||
1098 | ** tried to do recently failed with an SQLITE_LOCKED error due to locks |
||
1099 | ** held by Y. |
||
1100 | */ |
||
1101 | sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */ |
||
1102 | sqlite3 *pUnlockConnection; /* Connection to watch for unlock */ |
||
1103 | void *pUnlockArg; /* Argument to xUnlockNotify */ |
||
1104 | void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ |
||
1105 | sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ |
||
1106 | #endif |
||
1107 | }; |
||
1108 | |||
1109 | /* |
||
1110 | ** A macro to discover the encoding of a database. |
||
1111 | */ |
||
1112 | //#define ENC(db) ((db)->aDb[0].pSchema->enc) |
||
1113 | static u8 ENC( sqlite3 db ) |
||
1114 | { |
||
1115 | return db.aDb[0].pSchema.enc; |
||
1116 | } |
||
1117 | |||
1118 | /* |
||
1119 | ** Possible values for the sqlite3.flags. |
||
1120 | */ |
||
1121 | //#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ |
||
1122 | //#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ |
||
1123 | //#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */ |
||
1124 | //#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */ |
||
1125 | //#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ |
||
1126 | // /* DELETE, or UPDATE and return */ |
||
1127 | // /* the count using a callback. */ |
||
1128 | //#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */ |
||
1129 | // /* result set is empty */ |
||
1130 | //#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ |
||
1131 | //#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ |
||
1132 | //#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ |
||
1133 | //#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when |
||
1134 | // ** accessing read-only databases */ |
||
1135 | //#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ |
||
1136 | //#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ |
||
1137 | //#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ |
||
1138 | //#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */ |
||
1139 | //#define SQLITE_CkptFullFSync 0x00400000 /* Use full fsync for checkpoint */ |
||
1140 | //#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ |
||
1141 | //#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ |
||
1142 | //#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ |
||
1143 | //#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ |
||
1144 | //#define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ |
||
1145 | //#define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ |
||
1146 | //#define SQLITE_LoadExtension 0x20000000 /* Enable load_extension */ |
||
1147 | //define SQLITE_EnableTrigger 0x40000000 /* True to enable triggers */ |
||
1148 | const int SQLITE_VdbeTrace = 0x00000100; |
||
1149 | const int SQLITE_InternChanges = 0x00000200; |
||
1150 | const int SQLITE_FullColNames = 0x00000400; |
||
1151 | const int SQLITE_ShortColNames = 0x00000800; |
||
1152 | const int SQLITE_CountRows = 0x00001000; |
||
1153 | const int SQLITE_NullCallback = 0x00002000; |
||
1154 | const int SQLITE_SqlTrace = 0x00004000; |
||
1155 | const int SQLITE_VdbeListing = 0x00008000; |
||
1156 | const int SQLITE_WriteSchema = 0x00010000; |
||
1157 | const int SQLITE_NoReadlock = 0x00020000; |
||
1158 | const int SQLITE_IgnoreChecks = 0x00040000; |
||
1159 | const int SQLITE_ReadUncommitted = 0x0080000; |
||
1160 | const int SQLITE_LegacyFileFmt = 0x00100000; |
||
1161 | const int SQLITE_FullFSync = 0x00200000; |
||
1162 | const int SQLITE_CkptFullFSync = 0x00400000; |
||
1163 | const int SQLITE_RecoveryMode = 0x00800000; |
||
1164 | const int SQLITE_ReverseOrder = 0x01000000; |
||
1165 | const int SQLITE_RecTriggers = 0x02000000; |
||
1166 | const int SQLITE_ForeignKeys = 0x04000000; |
||
1167 | const int SQLITE_AutoIndex = 0x08000000; |
||
1168 | const int SQLITE_PreferBuiltin = 0x10000000; |
||
1169 | const int SQLITE_LoadExtension = 0x20000000; |
||
1170 | const int SQLITE_EnableTrigger = 0x40000000; |
||
1171 | |||
1172 | /* |
||
1173 | ** Bits of the sqlite3.flags field that are used by the |
||
1174 | ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. |
||
1175 | ** These must be the low-order bits of the flags field. |
||
1176 | */ |
||
1177 | //#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ |
||
1178 | //#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ |
||
1179 | //#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ |
||
1180 | //#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ |
||
1181 | //#define SQLITE_IndexCover 0x10 /* Disable index covering table */ |
||
1182 | //#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ |
||
1183 | //#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ |
||
1184 | //#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ |
||
1185 | //#define SQLITE_OptMask 0xff /* Mask of all disablable opts */ |
||
1186 | const int SQLITE_QueryFlattener = 0x01; |
||
1187 | const int SQLITE_ColumnCache = 0x02; |
||
1188 | const int SQLITE_IndexSort = 0x04; |
||
1189 | const int SQLITE_IndexSearch = 0x08; |
||
1190 | const int SQLITE_IndexCover = 0x10; |
||
1191 | const int SQLITE_GroupByOrder = 0x20; |
||
1192 | const int SQLITE_FactorOutConst = 0x40; |
||
1193 | const int SQLITE_IdxRealAsInt = 0x80; |
||
1194 | const int SQLITE_OptMask = 0xff; |
||
1195 | |||
1196 | /* |
||
1197 | ** Possible values for the sqlite.magic field. |
||
1198 | ** The numbers are obtained at random and have no special meaning, other |
||
1199 | ** than being distinct from one another. |
||
1200 | */ |
||
1201 | const int SQLITE_MAGIC_OPEN = 0x1029a697; //#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ |
||
1202 | const int SQLITE_MAGIC_CLOSED = 0x2f3c2d33; //#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ |
||
1203 | const int SQLITE_MAGIC_SICK = 0x3b771290; //#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ |
||
1204 | const int SQLITE_MAGIC_BUSY = 0x403b7906; //#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ |
||
1205 | const int SQLITE_MAGIC_ERROR = 0x55357930; //#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ |
||
1206 | |||
1207 | /* |
||
1208 | ** Each SQL function is defined by an instance of the following |
||
1209 | ** structure. A pointer to this structure is stored in the sqlite.aFunc |
||
1210 | ** hash table. When multiple functions have the same name, the hash table |
||
1211 | ** points to a linked list of these structures. |
||
1212 | */ |
||
1213 | public class FuncDef |
||
1214 | { |
||
1215 | public i16 nArg; /* Number of arguments. -1 means unlimited */ |
||
1216 | public u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ |
||
1217 | public u8 flags; /* Some combination of SQLITE_FUNC_* */ |
||
1218 | public object pUserData; /* User data parameter */ |
||
1219 | public FuncDef pNext; /* Next function with same name */ |
||
1220 | public dxFunc xFunc;//)(sqlite3_context*,int,sqlite3_value*); /* Regular function */ |
||
1221 | public dxStep xStep;//)(sqlite3_context*,int,sqlite3_value*); /* Aggregate step */ |
||
1222 | public dxFinal xFinalize;//)(sqlite3_context); /* Aggregate finalizer */ |
||
1223 | public string zName; /* SQL name of the function. */ |
||
1224 | public FuncDef pHash; /* Next with a different name but the same hash */ |
||
1225 | public FuncDestructor pDestructor; /* Reference counted destructor function */ |
||
1226 | |||
1227 | public FuncDef() |
||
1228 | { |
||
1229 | } |
||
1230 | |||
1231 | public FuncDef( i16 nArg, u8 iPrefEnc, u8 iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor ) |
||
1232 | { |
||
1233 | this.nArg = nArg; |
||
1234 | this.iPrefEnc = iPrefEnc; |
||
1235 | this.flags = iflags; |
||
1236 | this.pUserData = pUserData; |
||
1237 | this.pNext = pNext; |
||
1238 | this.xFunc = xFunc; |
||
1239 | this.xStep = xStep; |
||
1240 | this.xFinalize = xFinalize; |
||
1241 | this.zName = zName; |
||
1242 | this.pHash = pHash; |
||
1243 | this.pDestructor = pDestructor; |
||
1244 | } |
||
1245 | public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxFunc xFunc ) |
||
1246 | { |
||
1247 | this.nArg = nArg; |
||
1248 | this.iPrefEnc = iPrefEnc; |
||
1249 | this.flags = iflags; |
||
1250 | this.pUserData = iArg; |
||
1251 | this.pNext = null; |
||
1252 | this.xFunc = xFunc; |
||
1253 | this.xStep = null; |
||
1254 | this.xFinalize = null; |
||
1255 | this.zName = zName; |
||
1256 | } |
||
1257 | |||
1258 | public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxStep xStep, dxFinal xFinal ) |
||
1259 | { |
||
1260 | this.nArg = nArg; |
||
1261 | this.iPrefEnc = iPrefEnc; |
||
1262 | this.flags = iflags; |
||
1263 | this.pUserData = iArg; |
||
1264 | this.pNext = null; |
||
1265 | this.xFunc = null; |
||
1266 | this.xStep = xStep; |
||
1267 | this.xFinalize = xFinal; |
||
1268 | this.zName = zName; |
||
1269 | } |
||
1270 | |||
1271 | public FuncDef( string zName, u8 iPrefEnc, i16 nArg, object arg, dxFunc xFunc, u8 flags ) |
||
1272 | { |
||
1273 | this.nArg = nArg; |
||
1274 | this.iPrefEnc = iPrefEnc; |
||
1275 | this.flags = flags; |
||
1276 | this.pUserData = arg; |
||
1277 | this.pNext = null; |
||
1278 | this.xFunc = xFunc; |
||
1279 | this.xStep = null; |
||
1280 | this.xFinalize = null; |
||
1281 | this.zName = zName; |
||
1282 | } |
||
1283 | |||
1284 | public FuncDef Copy() |
||
1285 | { |
||
1286 | FuncDef c = new FuncDef(); |
||
1287 | c.nArg = nArg; |
||
1288 | c.iPrefEnc = iPrefEnc; |
||
1289 | c.flags = flags; |
||
1290 | c.pUserData = pUserData; |
||
1291 | c.pNext = pNext; |
||
1292 | c.xFunc = xFunc; |
||
1293 | c.xStep = xStep; |
||
1294 | c.xFinalize = xFinalize; |
||
1295 | c.zName = zName; |
||
1296 | c.pHash = pHash; |
||
1297 | c.pDestructor = pDestructor; |
||
1298 | return c; |
||
1299 | } |
||
1300 | }; |
||
1301 | |||
1302 | /* |
||
1303 | ** This structure encapsulates a user-function destructor callback (as |
||
1304 | ** configured using create_function_v2()) and a reference counter. When |
||
1305 | ** create_function_v2() is called to create a function with a destructor, |
||
1306 | ** a single object of this type is allocated. FuncDestructor.nRef is set to |
||
1307 | ** the number of FuncDef objects created (either 1 or 3, depending on whether |
||
1308 | ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor |
||
1309 | ** member of each of the new FuncDef objects is set to point to the allocated |
||
1310 | ** FuncDestructor. |
||
1311 | ** |
||
1312 | ** Thereafter, when one of the FuncDef objects is deleted, the reference |
||
1313 | ** count on this object is decremented. When it reaches 0, the destructor |
||
1314 | ** is invoked and the FuncDestructor structure freed. |
||
1315 | */ |
||
1316 | //struct FuncDestructor { |
||
1317 | // int nRef; |
||
1318 | // void (*xDestroy)(void ); |
||
1319 | // void *pUserData; |
||
1320 | //}; |
||
1321 | public class FuncDestructor |
||
1322 | { |
||
1323 | public int nRef; |
||
1324 | public dxFDestroy xDestroy;// (*xDestroy)(void ); |
||
1325 | public object pUserData; |
||
1326 | }; |
||
1327 | |||
1328 | |||
1329 | /* |
||
1330 | ** Possible values for FuncDef.flags |
||
1331 | */ |
||
1332 | //#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ |
||
1333 | //#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ |
||
1334 | //#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ |
||
1335 | //#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ |
||
1336 | //#define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ |
||
1337 | //#define SQLITE_FUNC_COUNT 0x20 /* Built-in count() aggregate */ |
||
1338 | //#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ |
||
1339 | const int SQLITE_FUNC_LIKE = 0x01; /* Candidate for the LIKE optimization */ |
||
1340 | const int SQLITE_FUNC_CASE = 0x02; /* Case-sensitive LIKE-type function */ |
||
1341 | const int SQLITE_FUNC_EPHEM = 0x04; /* Ephermeral. Delete with VDBE */ |
||
1342 | const int SQLITE_FUNC_NEEDCOLL = 0x08;/* sqlite3GetFuncCollSeq() might be called */ |
||
1343 | const int SQLITE_FUNC_PRIVATE = 0x10; /* Allowed for internal use only */ |
||
1344 | const int SQLITE_FUNC_COUNT = 0x20; /* Built-in count() aggregate */ |
||
1345 | const int SQLITE_FUNC_COALESCE = 0x40;/* Built-in coalesce() or ifnull() function */ |
||
1346 | |||
1347 | |||
1348 | /* |
||
1349 | ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are |
||
1350 | ** used to create the initializers for the FuncDef structures. |
||
1351 | ** |
||
1352 | ** FUNCTION(zName, nArg, iArg, bNC, xFunc) |
||
1353 | ** Used to create a scalar function definition of a function zName |
||
1354 | ** implemented by C function xFunc that accepts nArg arguments. The |
||
1355 | ** value passed as iArg is cast to a (void) and made available |
||
1356 | ** as the user-data (sqlite3_user_data()) for the function. If |
||
1357 | ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. |
||
1358 | ** |
||
1359 | ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) |
||
1360 | ** Used to create an aggregate function definition implemented by |
||
1361 | ** the C functions xStep and xFinal. The first four parameters |
||
1362 | ** are interpreted in the same way as the first 4 parameters to |
||
1363 | ** FUNCTION(). |
||
1364 | ** |
||
1365 | ** LIKEFUNC(zName, nArg, pArg, flags) |
||
1366 | ** Used to create a scalar function definition of a function zName |
||
1367 | ** that accepts nArg arguments and is implemented by a call to C |
||
1368 | ** function likeFunc. Argument pArg is cast to a (void ) and made |
||
1369 | ** available as the function user-data (sqlite3_user_data()). The |
||
1370 | ** FuncDef.flags variable is set to the value passed as the flags |
||
1371 | ** parameter. |
||
1372 | */ |
||
1373 | //#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
||
1374 | // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ |
||
1375 | //SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
||
1376 | |||
1377 | static FuncDef FUNCTION( string zName, i16 nArg, int iArg, u8 bNC, dxFunc xFunc ) |
||
1378 | { |
||
1379 | return new FuncDef( zName, SQLITE_UTF8, nArg, iArg, (u8)( bNC * SQLITE_FUNC_NEEDCOLL ), xFunc ); |
||
1380 | } |
||
1381 | |||
1382 | //#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
||
1383 | // {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ |
||
1384 | //pArg, 0, xFunc, 0, 0, #zName, 0, 0} |
||
1385 | |||
1386 | //#define LIKEFUNC(zName, nArg, arg, flags) \ |
||
1387 | // {nArg, SQLITE_UTF8, flags, (void )arg, 0, likeFunc, 0, 0, #zName, 0, 0} |
||
1388 | static FuncDef LIKEFUNC( string zName, i16 nArg, object arg, u8 flags ) |
||
1389 | { |
||
1390 | return new FuncDef( zName, SQLITE_UTF8, nArg, arg, likeFunc, flags ); |
||
1391 | } |
||
1392 | |||
1393 | //#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ |
||
1394 | // {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \ |
||
1395 | //SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} |
||
1396 | |||
1397 | static FuncDef AGGREGATE( string zName, i16 nArg, int arg, u8 nc, dxStep xStep, dxFinal xFinal ) |
||
1398 | { |
||
1399 | return new FuncDef( zName, SQLITE_UTF8, nArg, arg, (u8)( nc * SQLITE_FUNC_NEEDCOLL ), xStep, xFinal ); |
||
1400 | } |
||
1401 | |||
1402 | /* |
||
1403 | ** All current savepoints are stored in a linked list starting at |
||
1404 | ** sqlite3.pSavepoint. The first element in the list is the most recently |
||
1405 | ** opened savepoint. Savepoints are added to the list by the vdbe |
||
1406 | ** OP_Savepoint instruction. |
||
1407 | */ |
||
1408 | //struct Savepoint { |
||
1409 | // string zName; /* Savepoint name (nul-terminated) */ |
||
1410 | // i64 nDeferredCons; /* Number of deferred fk violations */ |
||
1411 | // Savepoint *pNext; /* Parent savepoint (if any) */ |
||
1412 | //}; |
||
1413 | public class Savepoint |
||
1414 | { |
||
1415 | public string zName; /* Savepoint name (nul-terminated) */ |
||
1416 | public i64 nDeferredCons; /* Number of deferred fk violations */ |
||
1417 | public Savepoint pNext; /* Parent savepoint (if any) */ |
||
1418 | }; |
||
1419 | /* |
||
1420 | ** The following are used as the second parameter to sqlite3Savepoint(), |
||
1421 | ** and as the P1 argument to the OP_Savepoint instruction. |
||
1422 | */ |
||
1423 | const int SAVEPOINT_BEGIN = 0; //#define SAVEPOINT_BEGIN 0 |
||
1424 | const int SAVEPOINT_RELEASE = 1; //#define SAVEPOINT_RELEASE 1 |
||
1425 | const int SAVEPOINT_ROLLBACK = 2; //#define SAVEPOINT_ROLLBACK 2 |
||
1426 | |||
1427 | /* |
||
1428 | ** Each SQLite module (virtual table definition) is defined by an |
||
1429 | ** instance of the following structure, stored in the sqlite3.aModule |
||
1430 | ** hash table. |
||
1431 | */ |
||
1432 | public class Module |
||
1433 | { |
||
1434 | public sqlite3_module pModule; /* Callback pointers */ |
||
1435 | public string zName; /* Name passed to create_module() */ |
||
1436 | public object pAux; /* pAux passed to create_module() */ |
||
1437 | public smdxDestroy xDestroy;//)(void );/* Module destructor function */ |
||
1438 | }; |
||
1439 | |||
1440 | /* |
||
1441 | ** information about each column of an SQL table is held in an instance |
||
1442 | ** of this structure. |
||
1443 | */ |
||
1444 | public class Column |
||
1445 | { |
||
1446 | public string zName; /* Name of this column */ |
||
1447 | public Expr pDflt; /* Default value of this column */ |
||
1448 | public string zDflt; /* Original text of the default value */ |
||
1449 | public string zType; /* Data type for this column */ |
||
1450 | public string zColl; /* Collating sequence. If NULL, use the default */ |
||
1451 | public u8 notNull; /* True if there is a NOT NULL constraint */ |
||
1452 | public u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ |
||
1453 | public char affinity; /* One of the SQLITE_AFF_... values */ |
||
1454 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
1455 | public u8 isHidden; /* True if this column is 'hidden' */ |
||
1456 | #endif |
||
1457 | public Column Copy() |
||
1458 | { |
||
1459 | Column cp = (Column)MemberwiseClone(); |
||
1460 | if ( cp.pDflt != null ) |
||
1461 | cp.pDflt = pDflt.Copy(); |
||
1462 | return cp; |
||
1463 | } |
||
1464 | }; |
||
1465 | |||
1466 | /* |
||
1467 | ** A "Collating Sequence" is defined by an instance of the following |
||
1468 | ** structure. Conceptually, a collating sequence consists of a name and |
||
1469 | ** a comparison routine that defines the order of that sequence. |
||
1470 | ** |
||
1471 | ** There may two separate implementations of the collation function, one |
||
1472 | ** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that |
||
1473 | ** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine |
||
1474 | ** native byte order. When a collation sequence is invoked, SQLite selects |
||
1475 | ** the version that will require the least expensive encoding |
||
1476 | ** translations, if any. |
||
1477 | ** |
||
1478 | ** The CollSeq.pUser member variable is an extra parameter that passed in |
||
1479 | ** as the first argument to the UTF-8 comparison function, xCmp. |
||
1480 | ** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, |
||
1481 | ** xCmp16. |
||
1482 | ** |
||
1483 | ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the |
||
1484 | ** collating sequence is undefined. Indices built on an undefined |
||
1485 | ** collating sequence may not be read or written. |
||
1486 | */ |
||
1487 | public class CollSeq |
||
1488 | { |
||
1489 | public string zName; /* Name of the collating sequence, UTF-8 encoded */ |
||
1490 | public u8 enc; /* Text encoding handled by xCmp() */ |
||
1491 | public u8 type; /* One of the SQLITE_COLL_... values below */ |
||
1492 | public object pUser; /* First argument to xCmp() */ |
||
1493 | public dxCompare xCmp;//)(void*,int, const void*, int, const void); |
||
1494 | public dxDelCollSeq xDel;//)(void); /* Destructor for pUser */ |
||
1495 | |||
1496 | public CollSeq Copy() |
||
1497 | { |
||
1498 | if ( this == null ) |
||
1499 | return null; |
||
1500 | else |
||
1501 | { |
||
1502 | CollSeq cp = (CollSeq)MemberwiseClone(); |
||
1503 | return cp; |
||
1504 | } |
||
1505 | } |
||
1506 | }; |
||
1507 | |||
1508 | /* |
||
1509 | ** Allowed values of CollSeq.type: |
||
1510 | */ |
||
1511 | const int SQLITE_COLL_BINARY = 1;//#define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */ |
||
1512 | const int SQLITE_COLL_NOCASE = 2;//#define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */ |
||
1513 | const int SQLITE_COLL_REVERSE = 3;//#define SQLITE_COLL_REVERSE 3 /* The built-in REVERSE collating sequence */ |
||
1514 | const int SQLITE_COLL_USER = 0;//#define SQLITE_COLL_USER 0 /* Any other user-defined collating sequence */ |
||
1515 | |||
1516 | /* |
||
1517 | ** A sort order can be either ASC or DESC. |
||
1518 | */ |
||
1519 | const int SQLITE_SO_ASC = 0;//#define SQLITE_SO_ASC 0 /* Sort in ascending order */ |
||
1520 | const int SQLITE_SO_DESC = 1;//#define SQLITE_SO_DESC 1 /* Sort in ascending order */ |
||
1521 | |||
1522 | /* |
||
1523 | ** Column affinity types. |
||
1524 | ** |
||
1525 | ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and |
||
1526 | ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve |
||
1527 | ** the speed a little by numbering the values consecutively. |
||
1528 | ** |
||
1529 | ** But rather than start with 0 or 1, we begin with 'a'. That way, |
||
1530 | ** when multiple affinity types are concatenated into a string and |
||
1531 | ** used as the P4 operand, they will be more readable. |
||
1532 | ** |
||
1533 | ** Note also that the numeric types are grouped together so that testing |
||
1534 | ** for a numeric type is a single comparison. |
||
1535 | */ |
||
1536 | const char SQLITE_AFF_TEXT = 'a';//#define SQLITE_AFF_TEXT 'a' |
||
1537 | const char SQLITE_AFF_NONE = 'b';//#define SQLITE_AFF_NONE 'b' |
||
1538 | const char SQLITE_AFF_NUMERIC = 'c';//#define SQLITE_AFF_NUMERIC 'c' |
||
1539 | const char SQLITE_AFF_INTEGER = 'd';//#define SQLITE_AFF_INTEGER 'd' |
||
1540 | const char SQLITE_AFF_REAL = 'e';//#define SQLITE_AFF_REAL 'e' |
||
1541 | |||
1542 | //#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) |
||
1543 | |||
1544 | /* |
||
1545 | ** The SQLITE_AFF_MASK values masks off the significant bits of an |
||
1546 | ** affinity value. |
||
1547 | */ |
||
1548 | const int SQLITE_AFF_MASK = 0x67;//#define SQLITE_AFF_MASK 0x67 |
||
1549 | |||
1550 | /* |
||
1551 | ** Additional bit values that can be ORed with an affinity without |
||
1552 | ** changing the affinity. |
||
1553 | */ |
||
1554 | const int SQLITE_JUMPIFNULL = 0x08; //#define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */ |
||
1555 | const int SQLITE_STOREP2 = 0x10; //#define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */ |
||
1556 | const int SQLITE_NULLEQ = 0x80; //#define SQLITE_NULLEQ 0x80 /* NULL=NULL */ |
||
1557 | |||
1558 | /* |
||
1559 | ** An object of this type is created for each virtual table present in |
||
1560 | ** the database schema. |
||
1561 | ** |
||
1562 | ** If the database schema is shared, then there is one instance of this |
||
1563 | ** structure for each database connection (sqlite3) that uses the shared |
||
1564 | ** schema. This is because each database connection requires its own unique |
||
1565 | ** instance of the sqlite3_vtab* handle used to access the virtual table |
||
1566 | ** implementation. sqlite3_vtab* handles can not be shared between |
||
1567 | ** database connections, even when the rest of the in-memory database |
||
1568 | ** schema is shared, as the implementation often stores the database |
||
1569 | ** connection handle passed to it via the xConnect() or xCreate() method |
||
1570 | ** during initialization internally. This database connection handle may |
||
1571 | ** then be used by the virtual table implementation to access real tables |
||
1572 | ** within the database. So that they appear as part of the callers |
||
1573 | ** transaction, these accesses need to be made via the same database |
||
1574 | ** connection as that used to execute SQL operations on the virtual table. |
||
1575 | ** |
||
1576 | ** All VTable objects that correspond to a single table in a shared |
||
1577 | ** database schema are initially stored in a linked-list pointed to by |
||
1578 | ** the Table.pVTable member variable of the corresponding Table object. |
||
1579 | ** When an sqlite3_prepare() operation is required to access the virtual |
||
1580 | ** table, it searches the list for the VTable that corresponds to the |
||
1581 | ** database connection doing the preparing so as to use the correct |
||
1582 | ** sqlite3_vtab* handle in the compiled query. |
||
1583 | ** |
||
1584 | ** When an in-memory Table object is deleted (for example when the |
||
1585 | ** schema is being reloaded for some reason), the VTable objects are not |
||
1586 | ** deleted and the sqlite3_vtab* handles are not xDisconnect()ed |
||
1587 | ** immediately. Instead, they are moved from the Table.pVTable list to |
||
1588 | ** another linked list headed by the sqlite3.pDisconnect member of the |
||
1589 | ** corresponding sqlite3 structure. They are then deleted/xDisconnected |
||
1590 | ** next time a statement is prepared using said sqlite3*. This is done |
||
1591 | ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes. |
||
1592 | ** Refer to comments above function sqlite3VtabUnlockList() for an |
||
1593 | ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect |
||
1594 | ** list without holding the corresponding sqlite3.mutex mutex. |
||
1595 | ** |
||
1596 | ** The memory for objects of this type is always allocated by |
||
1597 | ** sqlite3DbMalloc(), using the connection handle stored in VTable.db as |
||
1598 | ** the first argument. |
||
1599 | */ |
||
1600 | public class VTable |
||
1601 | { |
||
1602 | public sqlite3 db; /* Database connection associated with this table */ |
||
1603 | public Module pMod; /* Pointer to module implementation */ |
||
1604 | public sqlite3_vtab pVtab; /* Pointer to vtab instance */ |
||
1605 | public int nRef; /* Number of pointers to this structure */ |
||
1606 | public u8 bConstraint; /* True if constraints are supported */ |
||
1607 | public int iSavepoint; /* Depth of the SAVEPOINT stack */ |
||
1608 | public VTable pNext; /* Next in linked list (see above) */ |
||
1609 | }; |
||
1610 | |||
1611 | /* |
||
1612 | ** Each SQL table is represented in memory by an instance of the |
||
1613 | ** following structure. |
||
1614 | ** |
||
1615 | ** Table.zName is the name of the table. The case of the original |
||
1616 | ** CREATE TABLE statement is stored, but case is not significant for |
||
1617 | ** comparisons. |
||
1618 | ** |
||
1619 | ** Table.nCol is the number of columns in this table. Table.aCol is a |
||
1620 | ** pointer to an array of Column structures, one for each column. |
||
1621 | ** |
||
1622 | ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of |
||
1623 | ** the column that is that key. Otherwise Table.iPKey is negative. Note |
||
1624 | ** that the datatype of the PRIMARY KEY must be INTEGER for this field to |
||
1625 | ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of |
||
1626 | ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid |
||
1627 | ** is generated for each row of the table. TF_HasPrimaryKey is set if |
||
1628 | ** the table has any PRIMARY KEY, INTEGER or otherwise. |
||
1629 | ** |
||
1630 | ** Table.tnum is the page number for the root BTree page of the table in the |
||
1631 | ** database file. If Table.iDb is the index of the database table backend |
||
1632 | ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that |
||
1633 | ** holds temporary tables and indices. If TF_Ephemeral is set |
||
1634 | ** then the table is stored in a file that is automatically deleted |
||
1635 | ** when the VDBE cursor to the table is closed. In this case Table.tnum |
||
1636 | ** refers VDBE cursor number that holds the table open, not to the root |
||
1637 | ** page number. Transient tables are used to hold the results of a |
||
1638 | ** sub-query that appears instead of a real table name in the FROM clause |
||
1639 | ** of a SELECT statement. |
||
1640 | */ |
||
1641 | public class Table |
||
1642 | { |
||
1643 | public string zName; /* Name of the table or view */ |
||
1644 | public int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ |
||
1645 | public int nCol; /* Number of columns in this table */ |
||
1646 | public Column[] aCol; /* Information about each column */ |
||
1647 | public Index pIndex; /* List of SQL indexes on this table. */ |
||
1648 | public int tnum; /* Root BTree node for this table (see note above) */ |
||
1649 | public u32 nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ |
||
1650 | public Select pSelect; /* NULL for tables. Points to definition if a view. */ |
||
1651 | public u16 nRef; /* Number of pointers to this Table */ |
||
1652 | public u8 tabFlags; /* Mask of TF_* values */ |
||
1653 | public u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
||
1654 | public FKey pFKey; /* Linked list of all foreign keys in this table */ |
||
1655 | public string zColAff; /* String defining the affinity of each column */ |
||
1656 | #if !SQLITE_OMIT_CHECK |
||
1657 | public Expr pCheck; /* The AND of all CHECK constraints */ |
||
1658 | #endif |
||
1659 | #if !SQLITE_OMIT_ALTERTABLE |
||
1660 | public int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ |
||
1661 | #endif |
||
1662 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
1663 | public VTable pVTable; /* List of VTable objects. */ |
||
1664 | public int nModuleArg; /* Number of arguments to the module */ |
||
1665 | public string[] azModuleArg;/* Text of all module args. [0] is module name */ |
||
1666 | #endif |
||
1667 | public Trigger pTrigger; /* List of SQL triggers on this table */ |
||
1668 | public Schema pSchema; /* Schema that contains this table */ |
||
1669 | public Table pNextZombie; /* Next on the Parse.pZombieTab list */ |
||
1670 | |||
1671 | public Table Copy() |
||
1672 | { |
||
1673 | if ( this == null ) |
||
1674 | return null; |
||
1675 | else |
||
1676 | { |
||
1677 | Table cp = (Table)MemberwiseClone(); |
||
1678 | if ( pIndex != null ) |
||
1679 | cp.pIndex = pIndex.Copy(); |
||
1680 | if ( pSelect != null ) |
||
1681 | cp.pSelect = pSelect.Copy(); |
||
1682 | if ( pTrigger != null ) |
||
1683 | cp.pTrigger = pTrigger.Copy(); |
||
1684 | if ( pFKey != null ) |
||
1685 | cp.pFKey = pFKey.Copy(); |
||
1686 | #if !SQLITE_OMIT_CHECK |
||
1687 | // Don't Clone Checks, only copy reference via Memberwise Clone above -- |
||
1688 | //if ( pCheck != null ) cp.pCheck = pCheck.Copy(); |
||
1689 | #endif |
||
1690 | // Don't Clone Schema, only copy reference via Memberwise Clone above -- |
||
1691 | // if ( pSchema != null ) cp.pSchema=pSchema.Copy(); |
||
1692 | // Don't Clone pNextZombie, only copy reference via Memberwise Clone above -- |
||
1693 | // if ( pNextZombie != null ) cp.pNextZombie=pNextZombie.Copy(); |
||
1694 | return cp; |
||
1695 | } |
||
1696 | } |
||
1697 | }; |
||
1698 | |||
1699 | /* |
||
1700 | ** Allowed values for Tabe.tabFlags. |
||
1701 | */ |
||
1702 | //#define TF_Readonly 0x01 /* Read-only system table */ |
||
1703 | //#define TF_Ephemeral 0x02 /* An ephemeral table */ |
||
1704 | //#define TF_HasPrimaryKey 0x04 /* Table has a primary key */ |
||
1705 | //#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ |
||
1706 | //#define TF_Virtual 0x10 /* Is a virtual table */ |
||
1707 | //#define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */ |
||
1708 | /* |
||
1709 | ** Allowed values for Tabe.tabFlags. |
||
1710 | */ |
||
1711 | const int TF_Readonly = 0x01; /* Read-only system table */ |
||
1712 | const int TF_Ephemeral = 0x02; /* An ephemeral table */ |
||
1713 | const int TF_HasPrimaryKey = 0x04; /* Table has a primary key */ |
||
1714 | const int TF_Autoincrement = 0x08; /* Integer primary key is autoincrement */ |
||
1715 | const int TF_Virtual = 0x10; /* Is a virtual table */ |
||
1716 | const int TF_NeedMetadata = 0x20; /* aCol[].zType and aCol[].pColl missing */ |
||
1717 | |||
1718 | /* |
||
1719 | ** Test to see whether or not a table is a virtual table. This is |
||
1720 | ** done as a macro so that it will be optimized out when virtual |
||
1721 | ** table support is omitted from the build. |
||
1722 | */ |
||
1723 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
1724 | //# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) |
||
1725 | static bool IsVirtual( Table X ) |
||
1726 | { |
||
1727 | return ( X.tabFlags & TF_Virtual ) != 0; |
||
1728 | } |
||
1729 | //# define IsHiddenColumn(X) ((X)->isHidden) |
||
1730 | static bool IsHiddenColumn( Column X ) |
||
1731 | { |
||
1732 | return X.isHidden != 0; |
||
1733 | } |
||
1734 | #else |
||
1735 | //# define IsVirtual(X) 0 |
||
1736 | static bool IsVirtual( Table T ) |
||
1737 | { |
||
1738 | return false; |
||
1739 | } |
||
1740 | //# define IsHiddenColumn(X) 0 |
||
1741 | static bool IsHiddenColumn( Column C ) |
||
1742 | { |
||
1743 | return false; |
||
1744 | } |
||
1745 | #endif |
||
1746 | |||
1747 | /* |
||
1748 | ** Each foreign key constraint is an instance of the following structure. |
||
1749 | ** |
||
1750 | ** A foreign key is associated with two tables. The "from" table is |
||
1751 | ** the table that contains the REFERENCES clause that creates the foreign |
||
1752 | ** key. The "to" table is the table that is named in the REFERENCES clause. |
||
1753 | ** Consider this example: |
||
1754 | ** |
||
1755 | ** CREATE TABLE ex1( |
||
1756 | ** a INTEGER PRIMARY KEY, |
||
1757 | ** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) |
||
1758 | ** ); |
||
1759 | ** |
||
1760 | ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". |
||
1761 | ** |
||
1762 | ** Each REFERENCES clause generates an instance of the following structure |
||
1763 | ** which is attached to the from-table. The to-table need not exist when |
||
1764 | ** the from-table is created. The existence of the to-table is not checked. |
||
1765 | */ |
||
1766 | public class FKey |
||
1767 | { |
||
1768 | public Table pFrom; /* Table containing the REFERENCES clause (aka: Child) */ |
||
1769 | public FKey pNextFrom; /* Next foreign key in pFrom */ |
||
1770 | public string zTo; /* Name of table that the key points to (aka: Parent) */ |
||
1771 | public FKey pNextTo; /* Next foreign key on table named zTo */ |
||
1772 | public FKey pPrevTo; /* Previous foreign key on table named zTo */ |
||
1773 | public int nCol; /* Number of columns in this key */ |
||
1774 | /* EV: R-30323-21917 */ |
||
1775 | public u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ |
||
1776 | public u8[] aAction = new u8[2]; /* ON DELETE and ON UPDATE actions, respectively */ |
||
1777 | public Trigger[] apTrigger = new Trigger[2];/* Triggers for aAction[] actions */ |
||
1778 | |||
1779 | public class sColMap |
||
1780 | { /* Mapping of columns in pFrom to columns in zTo */ |
||
1781 | public int iFrom; /* Index of column in pFrom */ |
||
1782 | public string zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ |
||
1783 | }; |
||
1784 | public sColMap[] aCol; /* One entry for each of nCol column s */ |
||
1785 | |||
1786 | public FKey Copy() |
||
1787 | { |
||
1788 | if ( this == null ) |
||
1789 | return null; |
||
1790 | else |
||
1791 | { |
||
1792 | FKey cp = (FKey)MemberwiseClone(); |
||
1793 | return cp; |
||
1794 | } |
||
1795 | } |
||
1796 | |||
1797 | }; |
||
1798 | |||
1799 | /* |
||
1800 | ** SQLite supports many different ways to resolve a constraint |
||
1801 | ** error. ROLLBACK processing means that a constraint violation |
||
1802 | ** causes the operation in process to fail and for the current transaction |
||
1803 | ** to be rolled back. ABORT processing means the operation in process |
||
1804 | ** fails and any prior changes from that one operation are backed out, |
||
1805 | ** but the transaction is not rolled back. FAIL processing means that |
||
1806 | ** the operation in progress stops and returns an error code. But prior |
||
1807 | ** changes due to the same operation are not backed out and no rollback |
||
1808 | ** occurs. IGNORE means that the particular row that caused the constraint |
||
1809 | ** error is not inserted or updated. Processing continues and no error |
||
1810 | ** is returned. REPLACE means that preexisting database rows that caused |
||
1811 | ** a UNIQUE constraint violation are removed so that the new insert or |
||
1812 | ** update can proceed. Processing continues and no error is reported. |
||
1813 | ** |
||
1814 | ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. |
||
1815 | ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the |
||
1816 | ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign |
||
1817 | ** key is set to NULL. CASCADE means that a DELETE or UPDATE of the |
||
1818 | ** referenced table row is propagated into the row that holds the |
||
1819 | ** foreign key. |
||
1820 | ** |
||
1821 | ** The following symbolic values are used to record which type |
||
1822 | ** of action to take. |
||
1823 | */ |
||
1824 | const int OE_None = 0;//#define OE_None 0 /* There is no constraint to check */ |
||
1825 | const int OE_Rollback = 1;//#define OE_Rollback 1 /* Fail the operation and rollback the transaction */ |
||
1826 | const int OE_Abort = 2;//#define OE_Abort 2 /* Back out changes but do no rollback transaction */ |
||
1827 | const int OE_Fail = 3;//#define OE_Fail 3 /* Stop the operation but leave all prior changes */ |
||
1828 | const int OE_Ignore = 4;//#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ |
||
1829 | const int OE_Replace = 5;//#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ |
||
1830 | |||
1831 | const int OE_Restrict = 6;//#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ |
||
1832 | const int OE_SetNull = 7;//#define OE_SetNull 7 /* Set the foreign key value to NULL */ |
||
1833 | const int OE_SetDflt = 8;//#define OE_SetDflt 8 /* Set the foreign key value to its default */ |
||
1834 | const int OE_Cascade = 9;//#define OE_Cascade 9 /* Cascade the changes */ |
||
1835 | |||
1836 | const int OE_Default = 99;//#define OE_Default 99 /* Do whatever the default action is */ |
||
1837 | |||
1838 | |||
1839 | /* |
||
1840 | ** An instance of the following structure is passed as the first |
||
1841 | ** argument to sqlite3VdbeKeyCompare and is used to control the |
||
1842 | ** comparison of the two index keys. |
||
1843 | */ |
||
1844 | public class KeyInfo |
||
1845 | { |
||
1846 | public sqlite3 db; /* The database connection */ |
||
1847 | public u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ |
||
1848 | public u16 nField; /* Number of entries in aColl[] */ |
||
1849 | public u8[] aSortOrder; /* Sort order for each column. May be NULL */ |
||
1850 | public CollSeq[] aColl = new CollSeq[1]; /* Collating sequence for each term of the key */ |
||
1851 | public KeyInfo Copy() |
||
1852 | { |
||
1853 | return (KeyInfo)MemberwiseClone(); |
||
1854 | } |
||
1855 | }; |
||
1856 | |||
1857 | /* |
||
1858 | ** An instance of the following structure holds information about a |
||
1859 | ** single index record that has already been parsed out into individual |
||
1860 | ** values. |
||
1861 | ** |
||
1862 | ** A record is an object that contains one or more fields of data. |
||
1863 | ** Records are used to store the content of a table row and to store |
||
1864 | ** the key of an index. A blob encoding of a record is created by |
||
1865 | ** the OP_MakeRecord opcode of the VDBE and is disassembled by the |
||
1866 | ** OP_Column opcode. |
||
1867 | ** |
||
1868 | ** This structure holds a record that has already been disassembled |
||
1869 | ** into its constituent fields. |
||
1870 | */ |
||
1871 | public class UnpackedRecord |
||
1872 | { |
||
1873 | public KeyInfo pKeyInfo; /* Collation and sort-order information */ |
||
1874 | public u16 nField; /* Number of entries in apMem[] */ |
||
1875 | public u16 flags; /* Boolean settings. UNPACKED_... below */ |
||
1876 | public i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ |
||
1877 | public Mem[] aMem; /* Values */ |
||
1878 | }; |
||
1879 | |||
1880 | /* |
||
1881 | ** Allowed values of UnpackedRecord.flags |
||
1882 | */ |
||
1883 | //#define UNPACKED_NEED_FREE 0x0001 /* Memory is from sqlite3Malloc() */ |
||
1884 | //#define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */ |
||
1885 | //#define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */ |
||
1886 | //#define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */ |
||
1887 | //#define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */ |
||
1888 | //#define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */ |
||
1889 | const int UNPACKED_NEED_FREE = 0x0001; /* Memory is from sqlite3Malloc() */ |
||
1890 | const int UNPACKED_NEED_DESTROY = 0x0002; /* apMem[]s should all be destroyed */ |
||
1891 | const int UNPACKED_IGNORE_ROWID = 0x0004; /* Ignore trailing rowid on key1 */ |
||
1892 | const int UNPACKED_INCRKEY = 0x0008; /* Make this key an epsilon larger */ |
||
1893 | const int UNPACKED_PREFIX_MATCH = 0x0010; /* A prefix match is considered OK */ |
||
1894 | const int UNPACKED_PREFIX_SEARCH = 0x0020; /* A prefix match is considered OK */ |
||
1895 | |||
1896 | /* |
||
1897 | ** Each SQL index is represented in memory by an |
||
1898 | ** instance of the following structure. |
||
1899 | ** |
||
1900 | ** The columns of the table that are to be indexed are described |
||
1901 | ** by the aiColumn[] field of this structure. For example, suppose |
||
1902 | ** we have the following table and index: |
||
1903 | ** |
||
1904 | ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); |
||
1905 | ** CREATE INDEX Ex2 ON Ex1(c3,c1); |
||
1906 | ** |
||
1907 | ** In the Table structure describing Ex1, nCol==3 because there are |
||
1908 | ** three columns in the table. In the Index structure describing |
||
1909 | ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. |
||
1910 | ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the |
||
1911 | ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. |
||
1912 | ** The second column to be indexed (c1) has an index of 0 in |
||
1913 | ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. |
||
1914 | ** |
||
1915 | ** The Index.onError field determines whether or not the indexed columns |
||
1916 | ** must be unique and what to do if they are not. When Index.onError=OE_None, |
||
1917 | ** it means this is not a unique index. Otherwise it is a unique index |
||
1918 | ** and the value of Index.onError indicate the which conflict resolution |
||
1919 | ** algorithm to employ whenever an attempt is made to insert a non-unique |
||
1920 | ** element. |
||
1921 | */ |
||
1922 | public class Index |
||
1923 | { |
||
1924 | public string zName; /* Name of this index */ |
||
1925 | public int nColumn; /* Number of columns in the table used by this index */ |
||
1926 | public int[] aiColumn; /* Which columns are used by this index. 1st is 0 */ |
||
1927 | public int[] aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ |
||
1928 | public Table pTable; /* The SQL table being indexed */ |
||
1929 | public int tnum; /* Page containing root of this index in database file */ |
||
1930 | public u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
||
1931 | public u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ |
||
1932 | public u8 bUnordered; /* Use this index for == or IN queries only */ |
||
1933 | public string zColAff; /* String defining the affinity of each column */ |
||
1934 | public Index pNext; /* The next index associated with the same table */ |
||
1935 | public Schema pSchema; /* Schema containing this index */ |
||
1936 | public u8[] aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ |
||
1937 | public string[] azColl; /* Array of collation sequence names for index */ |
||
1938 | public IndexSample[] aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ |
||
1939 | |||
1940 | public Index Copy() |
||
1941 | { |
||
1942 | if ( this == null ) |
||
1943 | return null; |
||
1944 | else |
||
1945 | { |
||
1946 | Index cp = (Index)MemberwiseClone(); |
||
1947 | return cp; |
||
1948 | } |
||
1949 | } |
||
1950 | }; |
||
1951 | /* |
||
1952 | ** Each sample stored in the sqlite_stat2 table is represented in memory |
||
1953 | ** using a structure of this type. |
||
1954 | */ |
||
1955 | public class IndexSample |
||
1956 | { |
||
1957 | public struct _u |
||
1958 | { //union { |
||
1959 | public string z; /* Value if eType is SQLITE_TEXT */ |
||
1960 | public byte[] zBLOB; /* Value if eType is SQLITE_BLOB */ |
||
1961 | public double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ |
||
1962 | } |
||
1963 | public _u u; |
||
1964 | public u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ |
||
1965 | public u8 nByte; /* Size in byte of text or blob. */ |
||
1966 | }; |
||
1967 | |||
1968 | /* |
||
1969 | ** Each token coming out of the lexer is an instance of |
||
1970 | ** this structure. Tokens are also used as part of an expression. |
||
1971 | ** |
||
1972 | ** Note if Token.z==0 then Token.dyn and Token.n are undefined and |
||
1973 | ** may contain random values. Do not make any assumptions about Token.dyn |
||
1974 | ** and Token.n when Token.z==0. |
||
1975 | */ |
||
1976 | public class Token |
||
1977 | { |
||
1978 | #if DEBUG_CLASS_TOKEN || DEBUG_CLASS_ALL |
||
1979 | public string _z; /* Text of the token. Not NULL-terminated! */ |
||
1980 | public bool dyn;// : 1; /* True for malloced memory, false for static */ |
||
1981 | public Int32 _n;// : 31; /* Number of characters in this token */ |
||
1982 | |||
1983 | public string z |
||
1984 | { |
||
1985 | get { return _z; } |
||
1986 | set { _z = value; } |
||
1987 | } |
||
1988 | |||
1989 | public Int32 n |
||
1990 | { |
||
1991 | get { return _n; } |
||
1992 | set { _n = value; } |
||
1993 | } |
||
1994 | #else |
||
1995 | public string z; /* Text of the token. Not NULL-terminated! */ |
||
1996 | public Int32 n; /* Number of characters in this token */ |
||
1997 | #endif |
||
1998 | public Token() |
||
1999 | { |
||
2000 | this.z = null; |
||
2001 | this.n = 0; |
||
2002 | } |
||
2003 | public Token( string z, Int32 n ) |
||
2004 | { |
||
2005 | this.z = z; |
||
2006 | this.n = n; |
||
2007 | } |
||
2008 | public Token Copy() |
||
2009 | { |
||
2010 | if ( this == null ) |
||
2011 | return null; |
||
2012 | else |
||
2013 | { |
||
2014 | Token cp = (Token)MemberwiseClone(); |
||
2015 | if ( z == null || z.Length == 0 ) |
||
2016 | cp.n = 0; |
||
2017 | else |
||
2018 | if ( n > z.Length ) |
||
2019 | cp.n = z.Length; |
||
2020 | return cp; |
||
2021 | } |
||
2022 | } |
||
2023 | } |
||
2024 | |||
2025 | /* |
||
2026 | ** An instance of this structure contains information needed to generate |
||
2027 | ** code for a SELECT that contains aggregate functions. |
||
2028 | ** |
||
2029 | ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a |
||
2030 | ** pointer to this structure. The Expr.iColumn field is the index in |
||
2031 | ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate |
||
2032 | ** code for that node. |
||
2033 | ** |
||
2034 | ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the |
||
2035 | ** original Select structure that describes the SELECT statement. These |
||
2036 | ** fields do not need to be freed when deallocating the AggInfo structure. |
||
2037 | */ |
||
2038 | public class AggInfo_col |
||
2039 | { /* For each column used in source tables */ |
||
2040 | public Table pTab; /* Source table */ |
||
2041 | public int iTable; /* VdbeCursor number of the source table */ |
||
2042 | public int iColumn; /* Column number within the source table */ |
||
2043 | public int iSorterColumn; /* Column number in the sorting index */ |
||
2044 | public int iMem; /* Memory location that acts as accumulator */ |
||
2045 | public Expr pExpr; /* The original expression */ |
||
2046 | }; |
||
2047 | public class AggInfo_func |
||
2048 | { /* For each aggregate function */ |
||
2049 | public Expr pExpr; /* Expression encoding the function */ |
||
2050 | public FuncDef pFunc; /* The aggregate function implementation */ |
||
2051 | public int iMem; /* Memory location that acts as accumulator */ |
||
2052 | public int iDistinct; /* Ephemeral table used to enforce DISTINCT */ |
||
2053 | } |
||
2054 | public class AggInfo |
||
2055 | { |
||
2056 | public u8 directMode; /* Direct rendering mode means take data directly |
||
2057 | ** from source tables rather than from accumulators */ |
||
2058 | public u8 useSortingIdx; /* In direct mode, reference the sorting index rather |
||
2059 | ** than the source table */ |
||
2060 | public int sortingIdx; /* VdbeCursor number of the sorting index */ |
||
2061 | public ExprList pGroupBy; /* The group by clause */ |
||
2062 | public int nSortingColumn; /* Number of columns in the sorting index */ |
||
2063 | public AggInfo_col[] aCol; |
||
2064 | public int nColumn; /* Number of used entries in aCol[] */ |
||
2065 | public int nColumnAlloc; /* Number of slots allocated for aCol[] */ |
||
2066 | public int nAccumulator; /* Number of columns that show through to the output. |
||
2067 | ** Additional columns are used only as parameters to |
||
2068 | ** aggregate functions */ |
||
2069 | public AggInfo_func[] aFunc; |
||
2070 | public int nFunc; /* Number of entries in aFunc[] */ |
||
2071 | public int nFuncAlloc; /* Number of slots allocated for aFunc[] */ |
||
2072 | |||
2073 | public AggInfo Copy() |
||
2074 | { |
||
2075 | if ( this == null ) |
||
2076 | return null; |
||
2077 | else |
||
2078 | { |
||
2079 | AggInfo cp = (AggInfo)MemberwiseClone(); |
||
2080 | if ( pGroupBy != null ) |
||
2081 | cp.pGroupBy = pGroupBy.Copy(); |
||
2082 | return cp; |
||
2083 | } |
||
2084 | } |
||
2085 | }; |
||
2086 | |||
2087 | /* |
||
2088 | ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. |
||
2089 | ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater |
||
2090 | ** than 32767 we have to make it 32-bit. 16-bit is preferred because |
||
2091 | ** it uses less memory in the Expr object, which is a big memory user |
||
2092 | ** in systems with lots of prepared statements. And few applications |
||
2093 | ** need more than about 10 or 20 variables. But some extreme users want |
||
2094 | ** to have prepared statements with over 32767 variables, and for them |
||
2095 | ** the option is available (at compile-time). |
||
2096 | */ |
||
2097 | //#if SQLITE_MAX_VARIABLE_NUMBER<=32767 |
||
2098 | //typedef i16 ynVar; |
||
2099 | //#else |
||
2100 | //typedef int ynVar; |
||
2101 | //#endif |
||
2102 | |||
2103 | /* |
||
2104 | ** Each node of an expression in the parse tree is an instance |
||
2105 | ** of this structure. |
||
2106 | ** |
||
2107 | ** Expr.op is the opcode. The integer parser token codes are reused |
||
2108 | ** as opcodes here. For example, the parser defines TK_GE to be an integer |
||
2109 | ** code representing the ">=" operator. This same integer code is reused |
||
2110 | ** to represent the greater-than-or-equal-to operator in the expression |
||
2111 | ** tree. |
||
2112 | ** |
||
2113 | ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, |
||
2114 | ** or TK_STRING), then Expr.token contains the text of the SQL literal. If |
||
2115 | ** the expression is a variable (TK_VARIABLE), then Expr.token contains the |
||
2116 | ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), |
||
2117 | ** then Expr.token contains the name of the function. |
||
2118 | ** |
||
2119 | ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a |
||
2120 | ** binary operator. Either or both may be NULL. |
||
2121 | ** |
||
2122 | ** Expr.x.pList is a list of arguments if the expression is an SQL function, |
||
2123 | ** a CASE expression or an IN expression of the form "<lhs> IN (<y>, <z>...)". |
||
2124 | ** Expr.x.pSelect is used if the expression is a sub-select or an expression of |
||
2125 | ** the form "<lhs> IN (SELECT ...)". If the EP_xIsSelect bit is set in the |
||
2126 | ** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is |
||
2127 | ** valid. |
||
2128 | ** |
||
2129 | ** An expression of the form ID or ID.ID refers to a column in a table. |
||
2130 | ** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is |
||
2131 | ** the integer cursor number of a VDBE cursor pointing to that table and |
||
2132 | ** Expr.iColumn is the column number for the specific column. If the |
||
2133 | ** expression is used as a result in an aggregate SELECT, then the |
||
2134 | ** value is also stored in the Expr.iAgg column in the aggregate so that |
||
2135 | ** it can be accessed after all aggregates are computed. |
||
2136 | ** |
||
2137 | ** If the expression is an unbound variable marker (a question mark |
||
2138 | ** character '?' in the original SQL) then the Expr.iTable holds the index |
||
2139 | ** number for that variable. |
||
2140 | ** |
||
2141 | ** If the expression is a subquery then Expr.iColumn holds an integer |
||
2142 | ** register number containing the result of the subquery. If the |
||
2143 | ** subquery gives a constant result, then iTable is -1. If the subquery |
||
2144 | ** gives a different answer at different times during statement processing |
||
2145 | ** then iTable is the address of a subroutine that computes the subquery. |
||
2146 | ** |
||
2147 | ** If the Expr is of type OP_Column, and the table it is selecting from |
||
2148 | ** is a disk table or the "old.*" pseudo-table, then pTab points to the |
||
2149 | ** corresponding table definition. |
||
2150 | ** |
||
2151 | ** ALLOCATION NOTES: |
||
2152 | ** |
||
2153 | ** Expr objects can use a lot of memory space in database schema. To |
||
2154 | ** help reduce memory requirements, sometimes an Expr object will be |
||
2155 | ** truncated. And to reduce the number of memory allocations, sometimes |
||
2156 | ** two or more Expr objects will be stored in a single memory allocation, |
||
2157 | ** together with Expr.zToken strings. |
||
2158 | ** |
||
2159 | ** If the EP_Reduced and EP_TokenOnly flags are set when |
||
2160 | ** an Expr object is truncated. When EP_Reduced is set, then all |
||
2161 | ** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees |
||
2162 | ** are contained within the same memory allocation. Note, however, that |
||
2163 | ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately |
||
2164 | ** allocated, regardless of whether or not EP_Reduced is set. |
||
2165 | */ |
||
2166 | public class Expr |
||
2167 | { |
||
2168 | #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL |
||
2169 | public u8 _op; /* Operation performed by this node */ |
||
2170 | public u8 op |
||
2171 | { |
||
2172 | get { return _op; } |
||
2173 | set { _op = value; } |
||
2174 | } |
||
2175 | #else |
||
2176 | public u8 op; /* Operation performed by this node */ |
||
2177 | #endif |
||
2178 | public char affinity; /* The affinity of the column or 0 if not a column */ |
||
2179 | #if DEBUG_CLASS_EXPR || DEBUG_CLASS_ALL |
||
2180 | public u16 _flags; /* Various flags. EP_* See below */ |
||
2181 | public u16 flags |
||
2182 | { |
||
2183 | get { return _flags; } |
||
2184 | set { _flags = value; } |
||
2185 | } |
||
2186 | public struct _u |
||
2187 | { |
||
2188 | public string _zToken; /* Token value. Zero terminated and dequoted */ |
||
2189 | public string zToken |
||
2190 | { |
||
2191 | get { return _zToken; } |
||
2192 | set { _zToken = value; } |
||
2193 | } |
||
2194 | public int iValue; /* Non-negative integer value if EP_IntValue */ |
||
2195 | } |
||
2196 | |||
2197 | #else |
||
2198 | public struct _u |
||
2199 | { |
||
2200 | public string zToken; /* Token value. Zero terminated and dequoted */ |
||
2201 | public int iValue; /* Non-negative integer value if EP_IntValue */ |
||
2202 | } |
||
2203 | public u16 flags; /* Various flags. EP_* See below */ |
||
2204 | #endif |
||
2205 | public _u u; |
||
2206 | |||
2207 | /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no |
||
2208 | ** space is allocated for the fields below this point. An attempt to |
||
2209 | ** access them will result in a segfault or malfunction. |
||
2210 | *********************************************************************/ |
||
2211 | |||
2212 | public Expr pLeft; /* Left subnode */ |
||
2213 | public Expr pRight; /* Right subnode */ |
||
2214 | public struct _x |
||
2215 | { |
||
2216 | public ExprList pList; /* Function arguments or in "<expr> IN (<expr-list)" */ |
||
2217 | public Select pSelect; /* Used for sub-selects and "<expr> IN (<select>)" */ |
||
2218 | } |
||
2219 | public _x x; |
||
2220 | public CollSeq pColl; /* The collation type of the column or 0 */ |
||
2221 | |||
2222 | /* If the EP_Reduced flag is set in the Expr.flags mask, then no |
||
2223 | ** space is allocated for the fields below this point. An attempt to |
||
2224 | ** access them will result in a segfault or malfunction. |
||
2225 | *********************************************************************/ |
||
2226 | |||
2227 | public int iTable; /* TK_COLUMN: cursor number of table holding column |
||
2228 | ** TK_REGISTER: register number |
||
2229 | ** TK_TRIGGER: 1 -> new, 0 -> old */ |
||
2230 | public ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. |
||
2231 | ** TK_VARIABLE: variable number (always >= 1). */ |
||
2232 | public i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ |
||
2233 | public i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ |
||
2234 | public u8 flags2; /* Second set of flags. EP2_... */ |
||
2235 | public u8 op2; /* If a TK_REGISTER, the original value of Expr.op */ |
||
2236 | public AggInfo pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ |
||
2237 | public Table pTab; /* Table for TK_COLUMN expressions. */ |
||
2238 | #if SQLITE_MAX_EXPR_DEPTH //>0 |
||
2239 | public int nHeight; /* Height of the tree headed by this node */ |
||
2240 | public Table pZombieTab; /* List of Table objects to delete after code gen */ |
||
2241 | #endif |
||
2242 | |||
2243 | #if DEBUG_CLASS |
||
2244 | public int op |
||
2245 | { |
||
2246 | get { return _op; } |
||
2247 | set { _op = value; } |
||
2248 | } |
||
2249 | #endif |
||
2250 | public void CopyFrom( Expr cf ) |
||
2251 | { |
||
2252 | op = cf.op; |
||
2253 | affinity = cf.affinity; |
||
2254 | flags = cf.flags; |
||
2255 | u = cf.u; |
||
2256 | pColl = cf.pColl == null ? null : cf.pColl.Copy(); |
||
2257 | iTable = cf.iTable; |
||
2258 | iColumn = cf.iColumn; |
||
2259 | pAggInfo = cf.pAggInfo == null ? null : cf.pAggInfo.Copy(); |
||
2260 | iAgg = cf.iAgg; |
||
2261 | iRightJoinTable = cf.iRightJoinTable; |
||
2262 | flags2 = cf.flags2; |
||
2263 | pTab = cf.pTab == null ? null : cf.pTab; |
||
2264 | #if SQLITE_TEST || SQLITE_MAX_EXPR_DEPTH //SQLITE_MAX_EXPR_DEPTH>0 |
||
2265 | nHeight = cf.nHeight; |
||
2266 | pZombieTab = cf.pZombieTab; |
||
2267 | #endif |
||
2268 | pLeft = cf.pLeft == null ? null : cf.pLeft.Copy(); |
||
2269 | pRight = cf.pRight == null ? null : cf.pRight.Copy(); |
||
2270 | x.pList = cf.x.pList == null ? null : cf.x.pList.Copy(); |
||
2271 | x.pSelect = cf.x.pSelect == null ? null : cf.x.pSelect.Copy(); |
||
2272 | } |
||
2273 | |||
2274 | public Expr Copy() |
||
2275 | { |
||
2276 | if ( this == null ) |
||
2277 | return null; |
||
2278 | else |
||
2279 | return Copy( flags ); |
||
2280 | } |
||
2281 | |||
2282 | public Expr Copy( int flag ) |
||
2283 | { |
||
2284 | Expr cp = new Expr(); |
||
2285 | cp.op = op; |
||
2286 | cp.affinity = affinity; |
||
2287 | cp.flags = flags; |
||
2288 | cp.u = u; |
||
2289 | if ( ( flag & EP_TokenOnly ) != 0 ) |
||
2290 | return cp; |
||
2291 | if ( pLeft != null ) |
||
2292 | cp.pLeft = pLeft.Copy(); |
||
2293 | if ( pRight != null ) |
||
2294 | cp.pRight = pRight.Copy(); |
||
2295 | cp.x = x; |
||
2296 | cp.pColl = pColl; |
||
2297 | if ( ( flag & EP_Reduced ) != 0 ) |
||
2298 | return cp; |
||
2299 | cp.iTable = iTable; |
||
2300 | cp.iColumn = iColumn; |
||
2301 | cp.iAgg = iAgg; |
||
2302 | cp.iRightJoinTable = iRightJoinTable; |
||
2303 | cp.flags2 = flags2; |
||
2304 | cp.op2 = op2; |
||
2305 | cp.pAggInfo = pAggInfo; |
||
2306 | cp.pTab = pTab; |
||
2307 | #if SQLITE_MAX_EXPR_DEPTH //>0 |
||
2308 | cp.nHeight = nHeight; |
||
2309 | cp.pZombieTab = pZombieTab; |
||
2310 | #endif |
||
2311 | return cp; |
||
2312 | } |
||
2313 | }; |
||
2314 | |||
2315 | /* |
||
2316 | ** The following are the meanings of bits in the Expr.flags field. |
||
2317 | */ |
||
2318 | //#define EP_FromJoin 0x0001 /* Originated in ON or USING clause of a join */ |
||
2319 | //#define EP_Agg 0x0002 /* Contains one or more aggregate functions */ |
||
2320 | //#define EP_Resolved 0x0004 /* IDs have been resolved to COLUMNs */ |
||
2321 | //#define EP_Error 0x0008 /* Expression contains one or more errors */ |
||
2322 | //#define EP_Distinct 0x0010 /* Aggregate function with DISTINCT keyword */ |
||
2323 | //#define EP_VarSelect 0x0020 /* pSelect is correlated, not constant */ |
||
2324 | //#define EP_DblQuoted 0x0040 /* token.z was originally in "..." */ |
||
2325 | //#define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */ |
||
2326 | //#define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */ |
||
2327 | //#define EP_FixedDest 0x0200 /* Result needed in a specific register */ |
||
2328 | //#define EP_IntValue 0x0400 /* Integer value contained in u.iValue */ |
||
2329 | //#define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */ |
||
2330 | |||
2331 | //#define EP_Reduced 0x1000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ |
||
2332 | //#define EP_TokenOnly 0x2000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ |
||
2333 | //#define EP_Static 0x4000 /* Held in memory not obtained from malloc() */ |
||
2334 | |||
2335 | const ushort EP_FromJoin = 0x0001; |
||
2336 | const ushort EP_Agg = 0x0002; |
||
2337 | const ushort EP_Resolved = 0x0004; |
||
2338 | const ushort EP_Error = 0x0008; |
||
2339 | const ushort EP_Distinct = 0x0010; |
||
2340 | const ushort EP_VarSelect = 0x0020; |
||
2341 | const ushort EP_DblQuoted = 0x0040; |
||
2342 | const ushort EP_InfixFunc = 0x0080; |
||
2343 | const ushort EP_ExpCollate = 0x0100; |
||
2344 | const ushort EP_FixedDest = 0x0200; |
||
2345 | const ushort EP_IntValue = 0x0400; |
||
2346 | const ushort EP_xIsSelect = 0x0800; |
||
2347 | |||
2348 | const ushort EP_Reduced = 0x1000; |
||
2349 | const ushort EP_TokenOnly = 0x2000; |
||
2350 | const ushort EP_Static = 0x4000; |
||
2351 | |||
2352 | /* |
||
2353 | ** The following are the meanings of bits in the Expr.flags2 field. |
||
2354 | */ |
||
2355 | //#define EP2_MallocedToken 0x0001 /* Need to sqlite3DbFree() Expr.zToken */ |
||
2356 | //#define EP2_Irreducible 0x0002 /* Cannot EXPRDUP_REDUCE this Expr */ |
||
2357 | const u8 EP2_MallocedToken = 0x0001; |
||
2358 | const u8 EP2_Irreducible = 0x0002; |
||
2359 | |||
2360 | /* |
||
2361 | ** The pseudo-routine sqlite3ExprSetIrreducible sets the EP2_Irreducible |
||
2362 | ** flag on an expression structure. This flag is used for VV&A only. The |
||
2363 | ** routine is implemented as a macro that only works when in debugging mode, |
||
2364 | ** so as not to burden production code. |
||
2365 | */ |
||
2366 | #if SQLITE_DEBUG |
||
2367 | //# define ExprSetIrreducible(X) (X)->flags2 |= EP2_Irreducible |
||
2368 | static void ExprSetIrreducible( Expr X ) |
||
2369 | { |
||
2370 | X.flags2 |= EP2_Irreducible; |
||
2371 | } |
||
2372 | #else |
||
2373 | //# define ExprSetIrreducible(X) |
||
2374 | static void ExprSetIrreducible( Expr X ) { } |
||
2375 | #endif |
||
2376 | |||
2377 | /* |
||
2378 | ** These macros can be used to test, set, or clear bits in the |
||
2379 | ** Expr.flags field. |
||
2380 | */ |
||
2381 | //#define ExprHasProperty(E,P) (((E)->flags&(P))==(P)) |
||
2382 | static bool ExprHasProperty( Expr E, int P ) |
||
2383 | { |
||
2384 | return ( E.flags & P ) == P; |
||
2385 | } |
||
2386 | //#define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0) |
||
2387 | static bool ExprHasAnyProperty( Expr E, int P ) |
||
2388 | { |
||
2389 | return ( E.flags & P ) != 0; |
||
2390 | } |
||
2391 | //#define ExprSetProperty(E,P) (E)->flags|=(P) |
||
2392 | static void ExprSetProperty( Expr E, int P ) |
||
2393 | { |
||
2394 | E.flags = (ushort)( E.flags | P ); |
||
2395 | } |
||
2396 | //#define ExprClearProperty(E,P) (E)->flags&=~(P) |
||
2397 | static void ExprClearProperty( Expr E, int P ) |
||
2398 | { |
||
2399 | E.flags = (ushort)( E.flags & ~P ); |
||
2400 | } |
||
2401 | |||
2402 | /* |
||
2403 | ** Macros to determine the number of bytes required by a normal Expr |
||
2404 | ** struct, an Expr struct with the EP_Reduced flag set in Expr.flags |
||
2405 | ** and an Expr struct with the EP_TokenOnly flag set. |
||
2406 | */ |
||
2407 | //#define EXPR_FULLSIZE sizeof(Expr) /* Full size */ |
||
2408 | //#define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */ |
||
2409 | //#define EXPR_TOKENONLYSIZE offsetof(Expr,pLeft) /* Fewer features */ |
||
2410 | |||
2411 | // We don't use these in C#, but define them anyway, |
||
2412 | const int EXPR_FULLSIZE = 48; |
||
2413 | const int EXPR_REDUCEDSIZE = 24; |
||
2414 | const int EXPR_TOKENONLYSIZE = 8; |
||
2415 | |||
2416 | /* |
||
2417 | ** Flags passed to the sqlite3ExprDup() function. See the header comment |
||
2418 | ** above sqlite3ExprDup() for details. |
||
2419 | */ |
||
2420 | //#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */ |
||
2421 | const int EXPRDUP_REDUCE = 0x0001; |
||
2422 | |||
2423 | /* |
||
2424 | ** A list of expressions. Each expression may optionally have a |
||
2425 | ** name. An expr/name combination can be used in several ways, such |
||
2426 | ** as the list of "expr AS ID" fields following a "SELECT" or in the |
||
2427 | ** list of "ID = expr" items in an UPDATE. A list of expressions can |
||
2428 | ** also be used as the argument to a function, in which case the a.zName |
||
2429 | ** field is not used. |
||
2430 | */ |
||
2431 | public class ExprList_item |
||
2432 | { |
||
2433 | public Expr pExpr; /* The list of expressions */ |
||
2434 | public string zName; /* Token associated with this expression */ |
||
2435 | public string zSpan; /* Original text of the expression */ |
||
2436 | public u8 sortOrder; /* 1 for DESC or 0 for ASC */ |
||
2437 | public u8 done; /* A flag to indicate when processing is finished */ |
||
2438 | public u16 iCol; /* For ORDER BY, column number in result set */ |
||
2439 | public u16 iAlias; /* Index into Parse.aAlias[] for zName */ |
||
2440 | } |
||
2441 | public class ExprList |
||
2442 | { |
||
2443 | public int nExpr; /* Number of expressions on the list */ |
||
2444 | public int nAlloc; /* Number of entries allocated below */ |
||
2445 | public int iECursor; /* VDBE VdbeCursor associated with this ExprList */ |
||
2446 | public ExprList_item[] a; /* One entry for each expression */ |
||
2447 | |||
2448 | public ExprList Copy() |
||
2449 | { |
||
2450 | if ( this == null ) |
||
2451 | return null; |
||
2452 | else |
||
2453 | { |
||
2454 | ExprList cp = (ExprList)MemberwiseClone(); |
||
2455 | a.CopyTo( cp.a, 0 ); |
||
2456 | return cp; |
||
2457 | } |
||
2458 | } |
||
2459 | |||
2460 | }; |
||
2461 | |||
2462 | /* |
||
2463 | ** An instance of this structure is used by the parser to record both |
||
2464 | ** the parse tree for an expression and the span of input text for an |
||
2465 | ** expression. |
||
2466 | */ |
||
2467 | public class ExprSpan |
||
2468 | { |
||
2469 | public Expr pExpr; /* The expression parse tree */ |
||
2470 | public string zStart; /* First character of input text */ |
||
2471 | public string zEnd; /* One character past the end of input text */ |
||
2472 | }; |
||
2473 | |||
2474 | /* |
||
2475 | ** An instance of this structure can hold a simple list of identifiers, |
||
2476 | ** such as the list "a,b,c" in the following statements: |
||
2477 | ** |
||
2478 | ** INSERT INTO t(a,b,c) VALUES ...; |
||
2479 | ** CREATE INDEX idx ON t(a,b,c); |
||
2480 | ** CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...; |
||
2481 | ** |
||
2482 | ** The IdList.a.idx field is used when the IdList represents the list of |
||
2483 | ** column names after a table name in an INSERT statement. In the statement |
||
2484 | ** |
||
2485 | ** INSERT INTO t(a,b,c) ... |
||
2486 | ** |
||
2487 | ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k. |
||
2488 | */ |
||
2489 | public class IdList_item |
||
2490 | { |
||
2491 | public string zName; /* Name of the identifier */ |
||
2492 | public int idx; /* Index in some Table.aCol[] of a column named zName */ |
||
2493 | } |
||
2494 | public class IdList |
||
2495 | { |
||
2496 | public IdList_item[] a; |
||
2497 | public int nId; /* Number of identifiers on the list */ |
||
2498 | public int nAlloc; /* Number of entries allocated for a[] below */ |
||
2499 | |||
2500 | public IdList Copy() |
||
2501 | { |
||
2502 | if ( this == null ) |
||
2503 | return null; |
||
2504 | else |
||
2505 | { |
||
2506 | IdList cp = (IdList)MemberwiseClone(); |
||
2507 | a.CopyTo( cp.a, 0 ); |
||
2508 | return cp; |
||
2509 | } |
||
2510 | } |
||
2511 | }; |
||
2512 | |||
2513 | /* |
||
2514 | ** The bitmask datatype defined below is used for various optimizations. |
||
2515 | ** |
||
2516 | ** Changing this from a 64-bit to a 32-bit type limits the number of |
||
2517 | ** tables in a join to 32 instead of 64. But it also reduces the size |
||
2518 | ** of the library by 738 bytes on ix86. |
||
2519 | */ |
||
2520 | //typedef u64 Bitmask; |
||
2521 | |||
2522 | /* |
||
2523 | ** The number of bits in a Bitmask. "BMS" means "BitMask Size". |
||
2524 | */ |
||
2525 | //#define BMS ((int)(sizeof(Bitmask)*8)) |
||
2526 | const int BMS = ( (int)( sizeof( Bitmask ) * 8 ) ); |
||
2527 | |||
2528 | |||
2529 | /* |
||
2530 | ** The following structure describes the FROM clause of a SELECT statement. |
||
2531 | ** Each table or subquery in the FROM clause is a separate element of |
||
2532 | ** the SrcList.a[] array. |
||
2533 | ** |
||
2534 | ** With the addition of multiple database support, the following structure |
||
2535 | ** can also be used to describe a particular table such as the table that |
||
2536 | ** is modified by an INSERT, DELETE, or UPDATE statement. In standard SQL, |
||
2537 | ** such a table must be a simple name: ID. But in SQLite, the table can |
||
2538 | ** now be identified by a database name, a dot, then the table name: ID.ID. |
||
2539 | ** |
||
2540 | ** The jointype starts out showing the join type between the current table |
||
2541 | ** and the next table on the list. The parser builds the list this way. |
||
2542 | ** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each |
||
2543 | ** jointype expresses the join between the table and the previous table. |
||
2544 | ** |
||
2545 | ** In the colUsed field, the high-order bit (bit 63) is set if the table |
||
2546 | ** contains more than 63 columns and the 64-th or later column is used. |
||
2547 | */ |
||
2548 | public class SrcList_item |
||
2549 | { |
||
2550 | public string zDatabase; /* Name of database holding this table */ |
||
2551 | public string zName; /* Name of the table */ |
||
2552 | public string zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ |
||
2553 | public Table pTab; /* An SQL table corresponding to zName */ |
||
2554 | public Select pSelect; /* A SELECT statement used in place of a table name */ |
||
2555 | public u8 isPopulated; /* Temporary table associated with SELECT is populated */ |
||
2556 | public u8 jointype; /* Type of join between this able and the previous */ |
||
2557 | public u8 notIndexed; /* True if there is a NOT INDEXED clause */ |
||
2558 | #if !SQLITE_OMIT_EXPLAIN |
||
2559 | public u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ |
||
2560 | #endif |
||
2561 | public int iCursor; /* The VDBE cursor number used to access this table */ |
||
2562 | public Expr pOn; /* The ON clause of a join */ |
||
2563 | public IdList pUsing; /* The USING clause of a join */ |
||
2564 | public Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ |
||
2565 | public string zIndex; /* Identifier from "INDEXED BY <zIndex>" clause */ |
||
2566 | public Index pIndex; /* Index structure corresponding to zIndex, if any */ |
||
2567 | } |
||
2568 | public class SrcList |
||
2569 | { |
||
2570 | public i16 nSrc; /* Number of tables or subqueries in the FROM clause */ |
||
2571 | public i16 nAlloc; /* Number of entries allocated in a[] below */ |
||
2572 | public SrcList_item[] a;/* One entry for each identifier on the list */ |
||
2573 | public SrcList Copy() |
||
2574 | { |
||
2575 | if ( this == null ) |
||
2576 | return null; |
||
2577 | else |
||
2578 | { |
||
2579 | SrcList cp = (SrcList)MemberwiseClone(); |
||
2580 | if ( a != null ) |
||
2581 | a.CopyTo( cp.a, 0 ); |
||
2582 | return cp; |
||
2583 | } |
||
2584 | } |
||
2585 | }; |
||
2586 | |||
2587 | /* |
||
2588 | ** Permitted values of the SrcList.a.jointype field |
||
2589 | */ |
||
2590 | const int JT_INNER = 0x0001; //#define JT_INNER 0x0001 /* Any kind of inner or cross join */ |
||
2591 | const int JT_CROSS = 0x0002; //#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ |
||
2592 | const int JT_NATURAL = 0x0004; //#define JT_NATURAL 0x0004 /* True for a "natural" join */ |
||
2593 | const int JT_LEFT = 0x0008; //#define JT_LEFT 0x0008 /* Left outer join */ |
||
2594 | const int JT_RIGHT = 0x0010; //#define JT_RIGHT 0x0010 /* Right outer join */ |
||
2595 | const int JT_OUTER = 0x0020; //#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ |
||
2596 | const int JT_ERROR = 0x0040; //#define JT_ERROR 0x0040 /* unknown or unsupported join type */ |
||
2597 | |||
2598 | |||
2599 | /* |
||
2600 | ** A WherePlan object holds information that describes a lookup |
||
2601 | ** strategy. |
||
2602 | ** |
||
2603 | ** This object is intended to be opaque outside of the where.c module. |
||
2604 | ** It is included here only so that that compiler will know how big it |
||
2605 | ** is. None of the fields in this object should be used outside of |
||
2606 | ** the where.c module. |
||
2607 | ** |
||
2608 | ** Within the union, pIdx is only used when wsFlags&WHERE_INDEXED is true. |
||
2609 | ** pTerm is only used when wsFlags&WHERE_MULTI_OR is true. And pVtabIdx |
||
2610 | ** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the |
||
2611 | ** case that more than one of these conditions is true. |
||
2612 | */ |
||
2613 | public class WherePlan |
||
2614 | { |
||
2615 | public u32 wsFlags; /* WHERE_* flags that describe the strategy */ |
||
2616 | public u32 nEq; /* Number of == constraints */ |
||
2617 | public double nRow; /* Estimated number of rows (for EQP) */ |
||
2618 | public class _u |
||
2619 | { |
||
2620 | public Index pIdx; /* Index when WHERE_INDEXED is true */ |
||
2621 | public WhereTerm pTerm; /* WHERE clause term for OR-search */ |
||
2622 | public sqlite3_index_info pVtabIdx; /* Virtual table index to use */ |
||
2623 | } |
||
2624 | public _u u = new _u(); |
||
2625 | public void Clear() |
||
2626 | { |
||
2627 | wsFlags = 0; |
||
2628 | nEq = 0; |
||
2629 | nRow = 0; |
||
2630 | u.pIdx = null; |
||
2631 | u.pTerm = null; |
||
2632 | u.pVtabIdx = null; |
||
2633 | } |
||
2634 | }; |
||
2635 | |||
2636 | /* |
||
2637 | ** For each nested loop in a WHERE clause implementation, the WhereInfo |
||
2638 | ** structure contains a single instance of this structure. This structure |
||
2639 | ** is intended to be private the the where.c module and should not be |
||
2640 | ** access or modified by other modules. |
||
2641 | ** |
||
2642 | ** The pIdxInfo field is used to help pick the best index on a |
||
2643 | ** virtual table. The pIdxInfo pointer contains indexing |
||
2644 | ** information for the i-th table in the FROM clause before reordering. |
||
2645 | ** All the pIdxInfo pointers are freed by whereInfoFree() in where.c. |
||
2646 | ** All other information in the i-th WhereLevel object for the i-th table |
||
2647 | ** after FROM clause ordering. |
||
2648 | */ |
||
2649 | public class InLoop |
||
2650 | { |
||
2651 | public int iCur; /* The VDBE cursor used by this IN operator */ |
||
2652 | public int addrInTop; /* Top of the IN loop */ |
||
2653 | } |
||
2654 | public class WhereLevel |
||
2655 | { |
||
2656 | public WherePlan plan = new WherePlan(); /* query plan for this element of the FROM clause */ |
||
2657 | public int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */ |
||
2658 | public int iTabCur; /* The VDBE cursor used to access the table */ |
||
2659 | public int iIdxCur; /* The VDBE cursor used to access pIdx */ |
||
2660 | public int addrBrk; /* Jump here to break out of the loop */ |
||
2661 | public int addrNxt; /* Jump here to start the next IN combination */ |
||
2662 | public int addrCont; /* Jump here to continue with the next loop cycle */ |
||
2663 | public int addrFirst; /* First instruction of interior of the loop */ |
||
2664 | public u8 iFrom; /* Which entry in the FROM clause */ |
||
2665 | public u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */ |
||
2666 | public int p1, p2; /* Operands of the opcode used to ends the loop */ |
||
2667 | public class _u |
||
2668 | { |
||
2669 | public class __in /* Information that depends on plan.wsFlags */ |
||
2670 | { |
||
2671 | public int nIn; /* Number of entries in aInLoop[] */ |
||
2672 | public InLoop[] aInLoop; /* Information about each nested IN operator */ |
||
2673 | } |
||
2674 | public __in _in = new __in(); /* Used when plan.wsFlags&WHERE_IN_ABLE */ |
||
2675 | } |
||
2676 | public _u u = new _u(); |
||
2677 | |||
2678 | |||
2679 | /* The following field is really not part of the current level. But |
||
2680 | ** we need a place to cache virtual table index information for each |
||
2681 | ** virtual table in the FROM clause and the WhereLevel structure is |
||
2682 | ** a convenient place since there is one WhereLevel for each FROM clause |
||
2683 | ** element. |
||
2684 | */ |
||
2685 | public sqlite3_index_info pIdxInfo; /* Index info for n-th source table */ |
||
2686 | }; |
||
2687 | |||
2688 | /* |
||
2689 | ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() |
||
2690 | ** and the WhereInfo.wctrlFlags member. |
||
2691 | */ |
||
2692 | //#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ |
||
2693 | //#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ |
||
2694 | //#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ |
||
2695 | //#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
||
2696 | //#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
||
2697 | //#define WHERE_OMIT_OPEN 0x0010 /* Table cursors are already open */ |
||
2698 | //#define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ |
||
2699 | //#define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ |
||
2700 | //#define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ |
||
2701 | const int WHERE_ORDERBY_NORMAL = 0x0000; |
||
2702 | const int WHERE_ORDERBY_MIN = 0x0001; |
||
2703 | const int WHERE_ORDERBY_MAX = 0x0002; |
||
2704 | const int WHERE_ONEPASS_DESIRED = 0x0004; |
||
2705 | const int WHERE_DUPLICATES_OK = 0x0008; |
||
2706 | const int WHERE_OMIT_OPEN = 0x0010; |
||
2707 | const int WHERE_OMIT_CLOSE = 0x0020; |
||
2708 | const int WHERE_FORCE_TABLE = 0x0040; |
||
2709 | const int WHERE_ONETABLE_ONLY = 0x0080; |
||
2710 | |||
2711 | /* |
||
2712 | ** The WHERE clause processing routine has two halves. The |
||
2713 | ** first part does the start of the WHERE loop and the second |
||
2714 | ** half does the tail of the WHERE loop. An instance of |
||
2715 | ** this structure is returned by the first half and passed |
||
2716 | ** into the second half to give some continuity. |
||
2717 | */ |
||
2718 | public class WhereInfo |
||
2719 | { |
||
2720 | public Parse pParse; /* Parsing and code generating context */ |
||
2721 | public u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ |
||
2722 | public u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */ |
||
2723 | public u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ |
||
2724 | public SrcList pTabList; /* List of tables in the join */ |
||
2725 | public int iTop; /* The very beginning of the WHERE loop */ |
||
2726 | public int iContinue; /* Jump here to continue with next record */ |
||
2727 | public int iBreak; /* Jump here to break out of the loop */ |
||
2728 | public int nLevel; /* Number of nested loop */ |
||
2729 | public WhereClause pWC; /* Decomposition of the WHERE clause */ |
||
2730 | public double savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
||
2731 | public double nRowOut; /* Estimated number of output rows */ |
||
2732 | public WhereLevel[] a = new WhereLevel[] { new WhereLevel() }; /* Information about each nest loop in the WHERE */ |
||
2733 | }; |
||
2734 | |||
2735 | /* |
||
2736 | ** A NameContext defines a context in which to resolve table and column |
||
2737 | ** names. The context consists of a list of tables (the pSrcList) field and |
||
2738 | ** a list of named expression (pEList). The named expression list may |
||
2739 | ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or |
||
2740 | ** to the table being operated on by INSERT, UPDATE, or DELETE. The |
||
2741 | ** pEList corresponds to the result set of a SELECT and is NULL for |
||
2742 | ** other statements. |
||
2743 | ** |
||
2744 | ** NameContexts can be nested. When resolving names, the inner-most |
||
2745 | ** context is searched first. If no match is found, the next outer |
||
2746 | ** context is checked. If there is still no match, the next context |
||
2747 | ** is checked. This process continues until either a match is found |
||
2748 | ** or all contexts are check. When a match is found, the nRef member of |
||
2749 | ** the context containing the match is incremented. |
||
2750 | ** |
||
2751 | ** Each subquery gets a new NameContext. The pNext field points to the |
||
2752 | ** NameContext in the parent query. Thus the process of scanning the |
||
2753 | ** NameContext list corresponds to searching through successively outer |
||
2754 | ** subqueries looking for a match. |
||
2755 | */ |
||
2756 | public class NameContext |
||
2757 | { |
||
2758 | public Parse pParse; /* The parser */ |
||
2759 | public SrcList pSrcList; /* One or more tables used to resolve names */ |
||
2760 | public ExprList pEList; /* Optional list of named expressions */ |
||
2761 | public int nRef; /* Number of names resolved by this context */ |
||
2762 | public int nErr; /* Number of errors encountered while resolving names */ |
||
2763 | public u8 allowAgg; /* Aggregate functions allowed here */ |
||
2764 | public u8 hasAgg; /* True if aggregates are seen */ |
||
2765 | public u8 isCheck; /* True if resolving names in a CHECK constraint */ |
||
2766 | public int nDepth; /* Depth of subquery recursion. 1 for no recursion */ |
||
2767 | public AggInfo pAggInfo; /* Information about aggregates at this level */ |
||
2768 | public NameContext pNext; /* Next outer name context. NULL for outermost */ |
||
2769 | }; |
||
2770 | |||
2771 | /* |
||
2772 | ** An instance of the following structure contains all information |
||
2773 | ** needed to generate code for a single SELECT statement. |
||
2774 | ** |
||
2775 | ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. |
||
2776 | ** If there is a LIMIT clause, the parser sets nLimit to the value of the |
||
2777 | ** limit and nOffset to the value of the offset (or 0 if there is not |
||
2778 | ** offset). But later on, nLimit and nOffset become the memory locations |
||
2779 | ** in the VDBE that record the limit and offset counters. |
||
2780 | ** |
||
2781 | ** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes. |
||
2782 | ** These addresses must be stored so that we can go back and fill in |
||
2783 | ** the P4_KEYINFO and P2 parameters later. Neither the KeyInfo nor |
||
2784 | ** the number of columns in P2 can be computed at the same time |
||
2785 | ** as the OP_OpenEphm instruction is coded because not |
||
2786 | ** enough information about the compound query is known at that point. |
||
2787 | ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences |
||
2788 | ** for the result set. The KeyInfo for addrOpenTran[2] contains collating |
||
2789 | ** sequences for the ORDER BY clause. |
||
2790 | */ |
||
2791 | public class Select |
||
2792 | { |
||
2793 | public ExprList pEList; /* The fields of the result */ |
||
2794 | public u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ |
||
2795 | public char affinity; /* MakeRecord with this affinity for SRT_Set */ |
||
2796 | public u16 selFlags; /* Various SF_* values */ |
||
2797 | public SrcList pSrc; /* The FROM clause */ |
||
2798 | public Expr pWhere; /* The WHERE clause */ |
||
2799 | public ExprList pGroupBy; /* The GROUP BY clause */ |
||
2800 | public Expr pHaving; /* The HAVING clause */ |
||
2801 | public ExprList pOrderBy; /* The ORDER BY clause */ |
||
2802 | public Select pPrior; /* Prior select in a compound select statement */ |
||
2803 | public Select pNext; /* Next select to the left in a compound */ |
||
2804 | public Select pRightmost; /* Right-most select in a compound select statement */ |
||
2805 | public Expr pLimit; /* LIMIT expression. NULL means not used. */ |
||
2806 | public Expr pOffset; /* OFFSET expression. NULL means not used. */ |
||
2807 | public int iLimit; |
||
2808 | public int iOffset; /* Memory registers holding LIMIT & OFFSET counters */ |
||
2809 | public int[] addrOpenEphm = new int[3]; /* OP_OpenEphem opcodes related to this select */ |
||
2810 | public double nSelectRow; /* Estimated number of result rows */ |
||
2811 | |||
2812 | public Select Copy() |
||
2813 | { |
||
2814 | if ( this == null ) |
||
2815 | return null; |
||
2816 | else |
||
2817 | { |
||
2818 | Select cp = (Select)MemberwiseClone(); |
||
2819 | if ( pEList != null ) |
||
2820 | cp.pEList = pEList.Copy(); |
||
2821 | if ( pSrc != null ) |
||
2822 | cp.pSrc = pSrc.Copy(); |
||
2823 | if ( pWhere != null ) |
||
2824 | cp.pWhere = pWhere.Copy(); |
||
2825 | if ( pGroupBy != null ) |
||
2826 | cp.pGroupBy = pGroupBy.Copy(); |
||
2827 | if ( pHaving != null ) |
||
2828 | cp.pHaving = pHaving.Copy(); |
||
2829 | if ( pOrderBy != null ) |
||
2830 | cp.pOrderBy = pOrderBy.Copy(); |
||
2831 | if ( pPrior != null ) |
||
2832 | cp.pPrior = pPrior.Copy(); |
||
2833 | if ( pNext != null ) |
||
2834 | cp.pNext = pNext.Copy(); |
||
2835 | if ( pRightmost != null ) |
||
2836 | cp.pRightmost = pRightmost.Copy(); |
||
2837 | if ( pLimit != null ) |
||
2838 | cp.pLimit = pLimit.Copy(); |
||
2839 | if ( pOffset != null ) |
||
2840 | cp.pOffset = pOffset.Copy(); |
||
2841 | return cp; |
||
2842 | } |
||
2843 | } |
||
2844 | }; |
||
2845 | |||
2846 | /* |
||
2847 | ** Allowed values for Select.selFlags. The "SF" prefix stands for |
||
2848 | ** "Select Flag". |
||
2849 | */ |
||
2850 | //#define SF_Distinct 0x0001 /* Output should be DISTINCT */ |
||
2851 | //#define SF_Resolved 0x0002 /* Identifiers have been resolved */ |
||
2852 | //#define SF_Aggregate 0x0004 /* Contains aggregate functions */ |
||
2853 | //#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ |
||
2854 | //#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ |
||
2855 | //#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ |
||
2856 | const int SF_Distinct = 0x0001; /* Output should be DISTINCT */ |
||
2857 | const int SF_Resolved = 0x0002; /* Identifiers have been resolved */ |
||
2858 | const int SF_Aggregate = 0x0004; /* Contains aggregate functions */ |
||
2859 | const int SF_UsesEphemeral = 0x0008; /* Uses the OpenEphemeral opcode */ |
||
2860 | const int SF_Expanded = 0x0010; /* sqlite3SelectExpand() called on this */ |
||
2861 | const int SF_HasTypeInfo = 0x0020; /* FROM subqueries have Table metadata */ |
||
2862 | |||
2863 | |||
2864 | /* |
||
2865 | ** The results of a select can be distributed in several ways. The |
||
2866 | ** "SRT" prefix means "SELECT Result Type". |
||
2867 | */ |
||
2868 | const int SRT_Union = 1;//#define SRT_Union 1 /* Store result as keys in an index */ |
||
2869 | const int SRT_Except = 2;//#define SRT_Except 2 /* Remove result from a UNION index */ |
||
2870 | const int SRT_Exists = 3;//#define SRT_Exists 3 /* Store 1 if the result is not empty */ |
||
2871 | const int SRT_Discard = 4;//#define SRT_Discard 4 /* Do not save the results anywhere */ |
||
2872 | |||
2873 | /* The ORDER BY clause is ignored for all of the above */ |
||
2874 | //#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard) |
||
2875 | |||
2876 | const int SRT_Output = 5;//#define SRT_Output 5 /* Output each row of result */ |
||
2877 | const int SRT_Mem = 6;//#define SRT_Mem 6 /* Store result in a memory cell */ |
||
2878 | const int SRT_Set = 7;//#define SRT_Set 7 /* Store results as keys in an index */ |
||
2879 | const int SRT_Table = 8;//#define SRT_Table 8 /* Store result as data with an automatic rowid */ |
||
2880 | const int SRT_EphemTab = 9;//#define SRT_EphemTab 9 /* Create transient tab and store like SRT_Table / |
||
2881 | const int SRT_Coroutine = 10;//#define SRT_Coroutine 10 /* Generate a single row of result */ |
||
2882 | |||
2883 | /* |
||
2884 | ** A structure used to customize the behavior of sqlite3Select(). See |
||
2885 | ** comments above sqlite3Select() for details. |
||
2886 | */ |
||
2887 | //typedef struct SelectDest SelectDest; |
||
2888 | public class SelectDest |
||
2889 | { |
||
2890 | public u8 eDest; /* How to dispose of the results */ |
||
2891 | public char affinity; /* Affinity used when eDest==SRT_Set */ |
||
2892 | public int iParm; /* A parameter used by the eDest disposal method */ |
||
2893 | public int iMem; /* Base register where results are written */ |
||
2894 | public int nMem; /* Number of registers allocated */ |
||
2895 | public SelectDest() |
||
2896 | { |
||
2897 | this.eDest = 0; |
||
2898 | this.affinity = '\0'; |
||
2899 | this.iParm = 0; |
||
2900 | this.iMem = 0; |
||
2901 | this.nMem = 0; |
||
2902 | } |
||
2903 | public SelectDest( u8 eDest, char affinity, int iParm ) |
||
2904 | { |
||
2905 | this.eDest = eDest; |
||
2906 | this.affinity = affinity; |
||
2907 | this.iParm = iParm; |
||
2908 | this.iMem = 0; |
||
2909 | this.nMem = 0; |
||
2910 | } |
||
2911 | public SelectDest( u8 eDest, char affinity, int iParm, int iMem, int nMem ) |
||
2912 | { |
||
2913 | this.eDest = eDest; |
||
2914 | this.affinity = affinity; |
||
2915 | this.iParm = iParm; |
||
2916 | this.iMem = iMem; |
||
2917 | this.nMem = nMem; |
||
2918 | } |
||
2919 | }; |
||
2920 | |||
2921 | /* |
||
2922 | ** During code generation of statements that do inserts into AUTOINCREMENT |
||
2923 | ** tables, the following information is attached to the Table.u.autoInc.p |
||
2924 | ** pointer of each autoincrement table to record some side information that |
||
2925 | ** the code generator needs. We have to keep per-table autoincrement |
||
2926 | ** information in case inserts are down within triggers. Triggers do not |
||
2927 | ** normally coordinate their activities, but we do need to coordinate the |
||
2928 | ** loading and saving of autoincrement information. |
||
2929 | */ |
||
2930 | public class AutoincInfo |
||
2931 | { |
||
2932 | public AutoincInfo pNext; /* Next info block in a list of them all */ |
||
2933 | public Table pTab; /* Table this info block refers to */ |
||
2934 | public int iDb; /* Index in sqlite3.aDb[] of database holding pTab */ |
||
2935 | public int regCtr; /* Memory register holding the rowid counter */ |
||
2936 | }; |
||
2937 | |||
2938 | /* |
||
2939 | ** Size of the column cache |
||
2940 | */ |
||
2941 | #if !SQLITE_N_COLCACHE |
||
2942 | //# define SQLITE_N_COLCACHE 10 |
||
2943 | const int SQLITE_N_COLCACHE = 10; |
||
2944 | #endif |
||
2945 | |||
2946 | /* |
||
2947 | ** At least one instance of the following structure is created for each |
||
2948 | ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE |
||
2949 | ** statement. All such objects are stored in the linked list headed at |
||
2950 | ** Parse.pTriggerPrg and deleted once statement compilation has been |
||
2951 | ** completed. |
||
2952 | ** |
||
2953 | ** A Vdbe sub-program that implements the body and WHEN clause of trigger |
||
2954 | ** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of |
||
2955 | ** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable. |
||
2956 | ** The Parse.pTriggerPrg list never contains two entries with the same |
||
2957 | ** values for both pTrigger and orconf. |
||
2958 | ** |
||
2959 | ** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns |
||
2960 | ** accessed (or set to 0 for triggers fired as a result of INSERT |
||
2961 | ** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to |
||
2962 | ** a mask of new.* columns used by the program. |
||
2963 | */ |
||
2964 | public class TriggerPrg |
||
2965 | { |
||
2966 | public Trigger pTrigger; /* Trigger this program was coded from */ |
||
2967 | public int orconf; /* Default ON CONFLICT policy */ |
||
2968 | public SubProgram pProgram; /* Program implementing pTrigger/orconf */ |
||
2969 | public u32[] aColmask = new u32[2]; /* Masks of old.*, new.* columns accessed */ |
||
2970 | public TriggerPrg pNext; /* Next entry in Parse.pTriggerPrg list */ |
||
2971 | }; |
||
2972 | |||
2973 | /* |
||
2974 | ** The yDbMask datatype for the bitmask of all attached databases. |
||
2975 | */ |
||
2976 | //#if SQLITE_MAX_ATTACHED>30 |
||
2977 | // typedef sqlite3_uint64 yDbMask; |
||
2978 | //#else |
||
2979 | // typedef unsigned int yDbMask; |
||
2980 | //#endif |
||
2981 | |||
2982 | /* |
||
2983 | ** An SQL parser context. A copy of this structure is passed through |
||
2984 | ** the parser and down into all the parser action routine in order to |
||
2985 | ** carry around information that is global to the entire parse. |
||
2986 | ** |
||
2987 | ** The structure is divided into two parts. When the parser and code |
||
2988 | ** generate call themselves recursively, the first part of the structure |
||
2989 | ** is constant but the second part is reset at the beginning and end of |
||
2990 | ** each recursion. |
||
2991 | ** |
||
2992 | ** The nTableLock and aTableLock variables are only used if the shared-cache |
||
2993 | ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are |
||
2994 | ** used to store the set of table-locks required by the statement being |
||
2995 | ** compiled. Function sqlite3TableLock() is used to add entries to the |
||
2996 | ** list. |
||
2997 | */ |
||
2998 | public class yColCache |
||
2999 | { |
||
3000 | public int iTable; /* Table cursor number */ |
||
3001 | public int iColumn; /* Table column number */ |
||
3002 | public u8 tempReg; /* iReg is a temp register that needs to be freed */ |
||
3003 | public int iLevel; /* Nesting level */ |
||
3004 | public int iReg; /* Reg with value of this column. 0 means none. */ |
||
3005 | public int lru; /* Least recently used entry has the smallest value */ |
||
3006 | } |
||
3007 | |||
3008 | public class Parse |
||
3009 | { |
||
3010 | public sqlite3 db; /* The main database structure */ |
||
3011 | public int rc; /* Return code from execution */ |
||
3012 | public string zErrMsg; /* An error message */ |
||
3013 | public Vdbe pVdbe; /* An engine for executing database bytecode */ |
||
3014 | public u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */ |
||
3015 | public u8 nameClash; /* A permanent table name clashes with temp table name */ |
||
3016 | public u8 checkSchema; /* Causes schema cookie check after an error */ |
||
3017 | public u8 nested; /* Number of nested calls to the parser/code generator */ |
||
3018 | public u8 parseError; /* True after a parsing error. Ticket #1794 */ |
||
3019 | public u8 nTempReg; /* Number of temporary registers in aTempReg[] */ |
||
3020 | public u8 nTempInUse; /* Number of aTempReg[] currently checked out */ |
||
3021 | public int[] aTempReg; /* Holding area for temporary registers */ |
||
3022 | public int nRangeReg; /* Size of the temporary register block */ |
||
3023 | public int iRangeReg; /* First register in temporary register block */ |
||
3024 | public int nErr; /* Number of errors seen */ |
||
3025 | public int nTab; /* Number of previously allocated VDBE cursors */ |
||
3026 | public int nMem; /* Number of memory cells used so far */ |
||
3027 | public int nSet; /* Number of sets used so far */ |
||
3028 | public int ckBase; /* Base register of data during check constraints */ |
||
3029 | public int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ |
||
3030 | public int iCacheCnt; /* Counter used to generate aColCache[].lru values */ |
||
3031 | public u8 nColCache; /* Number of entries in the column cache */ |
||
3032 | public u8 iColCache; /* Next entry of the cache to replace */ |
||
3033 | public yColCache[] aColCache;/* One for each valid column cache entry */ |
||
3034 | public yDbMask writeMask; /* Start a write transaction on these databases */ |
||
3035 | public yDbMask cookieMask; /* Bitmask of schema verified databases */ |
||
3036 | public u8 isMultiWrite; /* True if statement may affect/insert multiple rows */ |
||
3037 | public u8 mayAbort; /* True if statement may throw an ABORT exception */ |
||
3038 | public int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ |
||
3039 | public int[] cookieValue; /* Values of cookies to verify */ |
||
3040 | #if !SQLITE_OMIT_SHARED_CACHE |
||
3041 | public int nTableLock; /* Number of locks in aTableLock */ |
||
3042 | public TableLock[] aTableLock; /* Required table locks for shared-cache mode */ |
||
3043 | #endif |
||
3044 | public int regRowid; /* Register holding rowid of CREATE TABLE entry */ |
||
3045 | public int regRoot; /* Register holding root page number for new objects */ |
||
3046 | public AutoincInfo pAinc; /* Information about AUTOINCREMENT counters */ |
||
3047 | public int nMaxArg; /* Max args passed to user function by sub-program */ |
||
3048 | |||
3049 | /* Information used while coding trigger programs. */ |
||
3050 | public Parse pToplevel; /* Parse structure for main program (or NULL) */ |
||
3051 | public Table pTriggerTab; /* Table triggers are being coded for */ |
||
3052 | public u32 oldmask; /* Mask of old.* columns referenced */ |
||
3053 | public u32 newmask; /* Mask of new.* columns referenced */ |
||
3054 | public u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ |
||
3055 | public u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ |
||
3056 | public u8 disableTriggers; /* True to disable triggers */ |
||
3057 | public double nQueryLoop; /* Estimated number of iterations of a query */ |
||
3058 | |||
3059 | /* Above is constant between recursions. Below is reset before and after |
||
3060 | ** each recursion */ |
||
3061 | |||
3062 | public int nVar; /* Number of '?' variables seen in the SQL so far */ |
||
3063 | public int nzVar; /* Number of available slots in azVar[] */ |
||
3064 | public string[] azVar; /* Pointers to names of parameters */ |
||
3065 | public Vdbe pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ |
||
3066 | public int nAlias; /* Number of aliased result set columns */ |
||
3067 | public int nAliasAlloc; /* Number of allocated slots for aAlias[] */ |
||
3068 | public int[] aAlias; /* Register used to hold aliased result */ |
||
3069 | public u8 explain; /* True if the EXPLAIN flag is found on the query */ |
||
3070 | public Token sNameToken; /* Token with unqualified schema object name */ |
||
3071 | public Token sLastToken; /* The last token parsed */ |
||
3072 | public StringBuilder zTail; /* All SQL text past the last semicolon parsed */ |
||
3073 | public Table pNewTable; /* A table being constructed by CREATE TABLE */ |
||
3074 | public Trigger pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ |
||
3075 | public string zAuthContext; /* The 6th parameter to db.xAuth callbacks */ |
||
3076 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
3077 | public Token sArg; /* Complete text of a module argument */ |
||
3078 | public u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ |
||
3079 | public int nVtabLock; /* Number of virtual tables to lock */ |
||
3080 | public Table[] apVtabLock; /* Pointer to virtual tables needing locking */ |
||
3081 | #endif |
||
3082 | public int nHeight; /* Expression tree height of current sub-select */ |
||
3083 | public Table pZombieTab; /* List of Table objects to delete after code gen */ |
||
3084 | public TriggerPrg pTriggerPrg; /* Linked list of coded triggers */ |
||
3085 | #if !SQLITE_OMIT_EXPLAIN |
||
3086 | public int iSelectId; |
||
3087 | public int iNextSelectId; |
||
3088 | #endif |
||
3089 | |||
3090 | // We need to create instances of the col cache |
||
3091 | public Parse() |
||
3092 | { |
||
3093 | aTempReg = new int[8]; /* Holding area for temporary registers */ |
||
3094 | |||
3095 | aColCache = new yColCache[SQLITE_N_COLCACHE]; /* One for each valid column cache entry */ |
||
3096 | for ( int i = 0; i < this.aColCache.Length; i++ ) |
||
3097 | { |
||
3098 | this.aColCache[i] = new yColCache(); |
||
3099 | } |
||
3100 | |||
3101 | cookieValue = new int[SQLITE_MAX_ATTACHED + 2]; /* Values of cookies to verify */ |
||
3102 | |||
3103 | sLastToken = new Token(); /* The last token parsed */ |
||
3104 | |||
3105 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
3106 | sArg = new Token(); |
||
3107 | #endif |
||
3108 | } |
||
3109 | |||
3110 | public void ResetMembers() // Need to clear all the following variables during each recursion |
||
3111 | { |
||
3112 | nVar = 0; |
||
3113 | nzVar = 0; |
||
3114 | azVar = null; |
||
3115 | nAlias = 0; |
||
3116 | nAliasAlloc = 0; |
||
3117 | aAlias = null; |
||
3118 | explain = 0; |
||
3119 | sNameToken = new Token(); |
||
3120 | sLastToken = new Token(); |
||
3121 | zTail.Length = 0; |
||
3122 | pNewTable = null; |
||
3123 | pNewTrigger = null; |
||
3124 | zAuthContext = null; |
||
3125 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
3126 | sArg = new Token(); |
||
3127 | declareVtab = 0; |
||
3128 | nVtabLock = 0; |
||
3129 | apVtabLock = null; |
||
3130 | #endif |
||
3131 | nHeight = 0; |
||
3132 | pZombieTab = null; |
||
3133 | pTriggerPrg = null; |
||
3134 | } |
||
3135 | Parse[] SaveBuf = new Parse[10]; //For Recursion Storage |
||
3136 | public void RestoreMembers() // Need to clear all the following variables during each recursion |
||
3137 | { |
||
3138 | if ( SaveBuf[nested] != null ) |
||
3139 | { |
||
3140 | nVar = SaveBuf[nested].nVar; |
||
3141 | nzVar = SaveBuf[nested].nzVar; |
||
3142 | azVar = SaveBuf[nested].azVar; |
||
3143 | nAlias = SaveBuf[nested].nAlias; |
||
3144 | nAliasAlloc = SaveBuf[nested].nAliasAlloc; |
||
3145 | aAlias = SaveBuf[nested].aAlias; |
||
3146 | explain = SaveBuf[nested].explain; |
||
3147 | sNameToken = SaveBuf[nested].sNameToken; |
||
3148 | sLastToken = SaveBuf[nested].sLastToken; |
||
3149 | zTail = SaveBuf[nested].zTail; |
||
3150 | pNewTable = SaveBuf[nested].pNewTable; |
||
3151 | pNewTrigger = SaveBuf[nested].pNewTrigger; |
||
3152 | zAuthContext = SaveBuf[nested].zAuthContext; |
||
3153 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
3154 | sArg = SaveBuf[nested].sArg; |
||
3155 | declareVtab = SaveBuf[nested].declareVtab; |
||
3156 | nVtabLock = SaveBuf[nested].nVtabLock; |
||
3157 | apVtabLock = SaveBuf[nested].apVtabLock; |
||
3158 | #endif |
||
3159 | nHeight = SaveBuf[nested].nHeight; |
||
3160 | pZombieTab = SaveBuf[nested].pZombieTab; |
||
3161 | pTriggerPrg = SaveBuf[nested].pTriggerPrg; |
||
3162 | SaveBuf[nested] = null; |
||
3163 | } |
||
3164 | } |
||
3165 | public void SaveMembers() // Need to clear all the following variables during each recursion |
||
3166 | { |
||
3167 | SaveBuf[nested] = new Parse(); |
||
3168 | SaveBuf[nested].nVar = nVar; |
||
3169 | SaveBuf[nested].nzVar = nzVar; |
||
3170 | SaveBuf[nested].azVar = azVar; |
||
3171 | SaveBuf[nested].nAlias = nAlias; |
||
3172 | SaveBuf[nested].nAliasAlloc = nAliasAlloc; |
||
3173 | SaveBuf[nested].aAlias = aAlias; |
||
3174 | SaveBuf[nested].explain = explain; |
||
3175 | SaveBuf[nested].sNameToken = sNameToken; |
||
3176 | SaveBuf[nested].sLastToken = sLastToken; |
||
3177 | SaveBuf[nested].zTail = zTail; |
||
3178 | SaveBuf[nested].pNewTable = pNewTable; |
||
3179 | SaveBuf[nested].pNewTrigger = pNewTrigger; |
||
3180 | SaveBuf[nested].zAuthContext = zAuthContext; |
||
3181 | #if !SQLITE_OMIT_VIRTUALTABLE |
||
3182 | SaveBuf[nested].sArg = sArg; |
||
3183 | SaveBuf[nested].declareVtab = declareVtab; |
||
3184 | SaveBuf[nested].nVtabLock = nVtabLock; |
||
3185 | SaveBuf[nested].apVtabLock = apVtabLock; |
||
3186 | #endif |
||
3187 | SaveBuf[nested].nHeight = nHeight; |
||
3188 | SaveBuf[nested].pZombieTab = pZombieTab; |
||
3189 | SaveBuf[nested].pTriggerPrg = pTriggerPrg; |
||
3190 | } |
||
3191 | }; |
||
3192 | |||
3193 | #if SQLITE_OMIT_VIRTUALTABLE |
||
3194 | //#define IN_DECLARE_VTAB 0 |
||
3195 | static bool IN_DECLARE_VTAB( Parse pParse ) |
||
3196 | { |
||
3197 | return false; |
||
3198 | } |
||
3199 | #else |
||
3200 | //#define IN_DECLARE_VTAB (pParse.declareVtab) |
||
3201 | static bool IN_DECLARE_VTAB( Parse pParse ) |
||
3202 | { |
||
3203 | return pParse.declareVtab != 0; |
||
3204 | } |
||
3205 | #endif |
||
3206 | |||
3207 | /* |
||
3208 | ** An instance of the following structure can be declared on a stack and used |
||
3209 | ** to save the Parse.zAuthContext value so that it can be restored later. |
||
3210 | */ |
||
3211 | public class AuthContext |
||
3212 | { |
||
3213 | public string zAuthContext; /* Put saved Parse.zAuthContext here */ |
||
3214 | public Parse pParse; /* The Parse structure */ |
||
3215 | }; |
||
3216 | |||
3217 | /* |
||
3218 | ** Bitfield flags for P5 value in OP_Insert and OP_Delete |
||
3219 | */ |
||
3220 | //#define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ |
||
3221 | //#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ |
||
3222 | //#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ |
||
3223 | //#define OPFLAG_APPEND 0x08 /* This is likely to be an append */ |
||
3224 | //#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ |
||
3225 | //#define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ |
||
3226 | const byte OPFLAG_NCHANGE = 0x01; |
||
3227 | const byte OPFLAG_LASTROWID = 0x02; |
||
3228 | const byte OPFLAG_ISUPDATE = 0x04; |
||
3229 | const byte OPFLAG_APPEND = 0x08; |
||
3230 | const byte OPFLAG_USESEEKRESULT = 0x10; |
||
3231 | const byte OPFLAG_CLEARCACHE = 0x20; |
||
3232 | |||
3233 | /* |
||
3234 | * Each trigger present in the database schema is stored as an instance of |
||
3235 | * struct Trigger. |
||
3236 | * |
||
3237 | * Pointers to instances of struct Trigger are stored in two ways. |
||
3238 | * 1. In the "trigHash" hash table (part of the sqlite3* that represents the |
||
3239 | * database). This allows Trigger structures to be retrieved by name. |
||
3240 | * 2. All triggers associated with a single table form a linked list, using the |
||
3241 | * pNext member of struct Trigger. A pointer to the first element of the |
||
3242 | * linked list is stored as the "pTrigger" member of the associated |
||
3243 | * struct Table. |
||
3244 | * |
||
3245 | * The "step_list" member points to the first element of a linked list |
||
3246 | * containing the SQL statements specified as the trigger program. |
||
3247 | */ |
||
3248 | public class Trigger |
||
3249 | { |
||
3250 | public string zName; /* The name of the trigger */ |
||
3251 | public string table; /* The table or view to which the trigger applies */ |
||
3252 | public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ |
||
3253 | public u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ |
||
3254 | public Expr pWhen; /* The WHEN clause of the expression (may be NULL) */ |
||
3255 | public IdList pColumns; /* If this is an UPDATE OF <column-list> trigger, |
||
3256 | the <column-list> is stored here */ |
||
3257 | public Schema pSchema; /* Schema containing the trigger */ |
||
3258 | public Schema pTabSchema; /* Schema containing the table */ |
||
3259 | public TriggerStep step_list; /* Link list of trigger program steps */ |
||
3260 | public Trigger pNext; /* Next trigger associated with the table */ |
||
3261 | |||
3262 | public Trigger Copy() |
||
3263 | { |
||
3264 | if ( this == null ) |
||
3265 | return null; |
||
3266 | else |
||
3267 | { |
||
3268 | Trigger cp = (Trigger)MemberwiseClone(); |
||
3269 | if ( pWhen != null ) |
||
3270 | cp.pWhen = pWhen.Copy(); |
||
3271 | if ( pColumns != null ) |
||
3272 | cp.pColumns = pColumns.Copy(); |
||
3273 | if ( pSchema != null ) |
||
3274 | cp.pSchema = pSchema.Copy(); |
||
3275 | if ( pTabSchema != null ) |
||
3276 | cp.pTabSchema = pTabSchema.Copy(); |
||
3277 | if ( step_list != null ) |
||
3278 | cp.step_list = step_list.Copy(); |
||
3279 | if ( pNext != null ) |
||
3280 | cp.pNext = pNext.Copy(); |
||
3281 | return cp; |
||
3282 | } |
||
3283 | } |
||
3284 | }; |
||
3285 | |||
3286 | /* |
||
3287 | ** A trigger is either a BEFORE or an AFTER trigger. The following constants |
||
3288 | ** determine which. |
||
3289 | ** |
||
3290 | ** If there are multiple triggers, you might of some BEFORE and some AFTER. |
||
3291 | ** In that cases, the constants below can be ORed together. |
||
3292 | */ |
||
3293 | const u8 TRIGGER_BEFORE = 1;//#define TRIGGER_BEFORE 1 |
||
3294 | const u8 TRIGGER_AFTER = 2;//#define TRIGGER_AFTER 2 |
||
3295 | |||
3296 | /* |
||
3297 | * An instance of struct TriggerStep is used to store a single SQL statement |
||
3298 | * that is a part of a trigger-program. |
||
3299 | * |
||
3300 | * Instances of struct TriggerStep are stored in a singly linked list (linked |
||
3301 | * using the "pNext" member) referenced by the "step_list" member of the |
||
3302 | * associated struct Trigger instance. The first element of the linked list is |
||
3303 | * the first step of the trigger-program. |
||
3304 | * |
||
3305 | * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or |
||
3306 | * "SELECT" statement. The meanings of the other members is determined by the |
||
3307 | * value of "op" as follows: |
||
3308 | * |
||
3309 | * (op == TK_INSERT) |
||
3310 | * orconf -> stores the ON CONFLICT algorithm |
||
3311 | * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then |
||
3312 | * this stores a pointer to the SELECT statement. Otherwise NULL. |
||
3313 | * target -> A token holding the quoted name of the table to insert into. |
||
3314 | * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then |
||
3315 | * this stores values to be inserted. Otherwise NULL. |
||
3316 | * pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ... |
||
3317 | * statement, then this stores the column-names to be |
||
3318 | * inserted into. |
||
3319 | * |
||
3320 | * (op == TK_DELETE) |
||
3321 | * target -> A token holding the quoted name of the table to delete from. |
||
3322 | * pWhere -> The WHERE clause of the DELETE statement if one is specified. |
||
3323 | * Otherwise NULL. |
||
3324 | * |
||
3325 | * (op == TK_UPDATE) |
||
3326 | * target -> A token holding the quoted name of the table to update rows of. |
||
3327 | * pWhere -> The WHERE clause of the UPDATE statement if one is specified. |
||
3328 | * Otherwise NULL. |
||
3329 | * pExprList -> A list of the columns to update and the expressions to update |
||
3330 | * them to. See sqlite3Update() documentation of "pChanges" |
||
3331 | * argument. |
||
3332 | * |
||
3333 | */ |
||
3334 | public class TriggerStep |
||
3335 | { |
||
3336 | public u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ |
||
3337 | public u8 orconf; /* OE_Rollback etc. */ |
||
3338 | public Trigger pTrig; /* The trigger that this step is a part of */ |
||
3339 | public Select pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */ |
||
3340 | public Token target; /* Target table for DELETE, UPDATE, INSERT */ |
||
3341 | public Expr pWhere; /* The WHERE clause for DELETE or UPDATE steps */ |
||
3342 | public ExprList pExprList; /* SET clause for UPDATE. VALUES clause for INSERT */ |
||
3343 | public IdList pIdList; /* Column names for INSERT */ |
||
3344 | public TriggerStep pNext; /* Next in the link-list */ |
||
3345 | public TriggerStep pLast; /* Last element in link-list. Valid for 1st elem only */ |
||
3346 | |||
3347 | public TriggerStep() |
||
3348 | { |
||
3349 | target = new Token(); |
||
3350 | } |
||
3351 | public TriggerStep Copy() |
||
3352 | { |
||
3353 | if ( this == null ) |
||
3354 | return null; |
||
3355 | else |
||
3356 | { |
||
3357 | TriggerStep cp = (TriggerStep)MemberwiseClone(); |
||
3358 | return cp; |
||
3359 | } |
||
3360 | } |
||
3361 | }; |
||
3362 | |||
3363 | /* |
||
3364 | ** The following structure contains information used by the sqliteFix... |
||
3365 | ** routines as they walk the parse tree to make database references |
||
3366 | ** explicit. |
||
3367 | */ |
||
3368 | //typedef struct DbFixer DbFixer; |
||
3369 | public class DbFixer |
||
3370 | { |
||
3371 | public Parse pParse; /* The parsing context. Error messages written here */ |
||
3372 | public string zDb; /* Make sure all objects are contained in this database */ |
||
3373 | public string zType; /* Type of the container - used for error messages */ |
||
3374 | public Token pName; /* Name of the container - used for error messages */ |
||
3375 | }; |
||
3376 | |||
3377 | /* |
||
3378 | ** An objected used to accumulate the text of a string where we |
||
3379 | ** do not necessarily know how big the string will be in the end. |
||
3380 | */ |
||
3381 | public class StrAccum |
||
3382 | { |
||
3383 | public sqlite3 db; /* Optional database for lookaside. Can be NULL */ |
||
3384 | //public StringBuilder zBase; /* A base allocation. Not from malloc. */ |
||
3385 | public StringBuilder zText; /* The string collected so far */ |
||
3386 | //public int nChar; /* Length of the string so far */ |
||
3387 | //public int nAlloc; /* Amount of space allocated in zText */ |
||
3388 | public int mxAlloc; /* Maximum allowed string length */ |
||
3389 | // Cannot happen under C# |
||
3390 | //public u8 mallocFailed; /* Becomes true if any memory allocation fails */ |
||
3391 | //public u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */ |
||
3392 | //public u8 tooBig; /* Becomes true if string size exceeds limits */ |
||
3393 | public Mem Context; |
||
3394 | |||
3395 | public StrAccum( int n ) |
||
3396 | { |
||
3397 | db = null; |
||
3398 | //zBase = new StringBuilder( n ); |
||
3399 | zText = new StringBuilder( n ); |
||
3400 | //nChar = 0; |
||
3401 | //nAlloc = n; |
||
3402 | mxAlloc = 0; |
||
3403 | //useMalloc = 0; |
||
3404 | //tooBig = 0; |
||
3405 | Context = null; |
||
3406 | } |
||
3407 | |||
3408 | public i64 nChar |
||
3409 | { |
||
3410 | get |
||
3411 | { |
||
3412 | return zText.Length; |
||
3413 | } |
||
3414 | } |
||
3415 | |||
3416 | public bool tooBig |
||
3417 | { |
||
3418 | get |
||
3419 | { |
||
3420 | return mxAlloc > 0 && zText.Length > mxAlloc; |
||
3421 | } |
||
3422 | } |
||
3423 | }; |
||
3424 | |||
3425 | /* |
||
3426 | ** A pointer to this structure is used to communicate information |
||
3427 | ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. |
||
3428 | */ |
||
3429 | public class InitData |
||
3430 | { |
||
3431 | public sqlite3 db; /* The database being initialized */ |
||
3432 | public int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */ |
||
3433 | public string pzErrMsg; /* Error message stored here */ |
||
3434 | public int rc; /* Result code stored here */ |
||
3435 | } |
||
3436 | |||
3437 | /* |
||
3438 | ** Structure containing global configuration data for the SQLite library. |
||
3439 | ** |
||
3440 | ** This structure also contains some state information. |
||
3441 | */ |
||
3442 | public class Sqlite3Config |
||
3443 | { |
||
3444 | public bool bMemstat; /* True to enable memory status */ |
||
3445 | public bool bCoreMutex; /* True to enable core mutexing */ |
||
3446 | public bool bFullMutex; /* True to enable full mutexing */ |
||
3447 | public bool bOpenUri; /* True to interpret filenames as URIs */ |
||
3448 | public int mxStrlen; /* Maximum string length */ |
||
3449 | public int szLookaside; /* Default lookaside buffer size */ |
||
3450 | public int nLookaside; /* Default lookaside buffer count */ |
||
3451 | public sqlite3_mem_methods m; /* Low-level memory allocation interface */ |
||
3452 | public sqlite3_mutex_methods mutex; /* Low-level mutex interface */ |
||
3453 | public sqlite3_pcache_methods pcache; /* Low-level page-cache interface */ |
||
3454 | public byte[] pHeap; /* Heap storage space */ |
||
3455 | public int nHeap; /* Size of pHeap[] */ |
||
3456 | public int mnReq, mxReq; /* Min and max heap requests sizes */ |
||
3457 | public byte[][] pScratch2; /* Scratch memory */ |
||
3458 | public byte[][] pScratch; /* Scratch memory */ |
||
3459 | public int szScratch; /* Size of each scratch buffer */ |
||
3460 | public int nScratch; /* Number of scratch buffers */ |
||
3461 | public MemPage pPage; /* Page cache memory */ |
||
3462 | public int szPage; /* Size of each page in pPage[] */ |
||
3463 | public int nPage; /* Number of pages in pPage[] */ |
||
3464 | public int mxParserStack; /* maximum depth of the parser stack */ |
||
3465 | public bool sharedCacheEnabled; /* true if shared-cache mode enabled */ |
||
3466 | /* The above might be initialized to non-zero. The following need to always |
||
3467 | ** initially be zero, however. */ |
||
3468 | public int isInit; /* True after initialization has finished */ |
||
3469 | public int inProgress; /* True while initialization in progress */ |
||
3470 | public int isMutexInit; /* True after mutexes are initialized */ |
||
3471 | public int isMallocInit; /* True after malloc is initialized */ |
||
3472 | public int isPCacheInit; /* True after malloc is initialized */ |
||
3473 | public sqlite3_mutex pInitMutex; /* Mutex used by sqlite3_initialize() */ |
||
3474 | public int nRefInitMutex; /* Number of users of pInitMutex */ |
||
3475 | public dxLog xLog; //void (*xLog)(void*,int,const char); /* Function for logging */ |
||
3476 | public object pLogArg; /* First argument to xLog() */ |
||
3477 | public bool bLocaltimeFault; /* True to fail localtime() calls */ |
||
3478 | |||
3479 | public Sqlite3Config( |
||
3480 | int bMemstat |
||
3481 | , int bCoreMutex |
||
3482 | , bool bFullMutex |
||
3483 | , bool bOpenUri |
||
3484 | , int mxStrlen |
||
3485 | , int szLookaside |
||
3486 | , int nLookaside |
||
3487 | , sqlite3_mem_methods m |
||
3488 | , sqlite3_mutex_methods mutex |
||
3489 | , sqlite3_pcache_methods pcache |
||
3490 | , byte[] pHeap |
||
3491 | , int nHeap |
||
3492 | , int mnReq |
||
3493 | , int mxReq |
||
3494 | , byte[][] pScratch |
||
3495 | , int szScratch |
||
3496 | , int nScratch |
||
3497 | , MemPage pPage |
||
3498 | , int szPage |
||
3499 | , int nPage |
||
3500 | , int mxParserStack |
||
3501 | , bool sharedCacheEnabled |
||
3502 | , int isInit |
||
3503 | , int inProgress |
||
3504 | , int isMutexInit |
||
3505 | , int isMallocInit |
||
3506 | , int isPCacheInit |
||
3507 | , sqlite3_mutex pInitMutex |
||
3508 | , int nRefInitMutex |
||
3509 | , dxLog xLog |
||
3510 | , object pLogArg |
||
3511 | , bool bLocaltimeFault |
||
3512 | ) |
||
3513 | { |
||
3514 | this.bMemstat = bMemstat != 0; |
||
3515 | this.bCoreMutex = bCoreMutex != 0; |
||
3516 | this.bOpenUri = bOpenUri; |
||
3517 | this.bFullMutex = bFullMutex; |
||
3518 | this.mxStrlen = mxStrlen; |
||
3519 | this.szLookaside = szLookaside; |
||
3520 | this.nLookaside = nLookaside; |
||
3521 | this.m = m; |
||
3522 | this.mutex = mutex; |
||
3523 | this.pcache = pcache; |
||
3524 | this.pHeap = pHeap; |
||
3525 | this.nHeap = nHeap; |
||
3526 | this.mnReq = mnReq; |
||
3527 | this.mxReq = mxReq; |
||
3528 | this.pScratch = pScratch; |
||
3529 | this.szScratch = szScratch; |
||
3530 | this.nScratch = nScratch; |
||
3531 | this.pPage = pPage; |
||
3532 | this.szPage = szPage; |
||
3533 | this.nPage = nPage; |
||
3534 | this.mxParserStack = mxParserStack; |
||
3535 | this.sharedCacheEnabled = sharedCacheEnabled; |
||
3536 | this.isInit = isInit; |
||
3537 | this.inProgress = inProgress; |
||
3538 | this.isMutexInit = isMutexInit; |
||
3539 | this.isMallocInit = isMallocInit; |
||
3540 | this.isPCacheInit = isPCacheInit; |
||
3541 | this.pInitMutex = pInitMutex; |
||
3542 | this.nRefInitMutex = nRefInitMutex; |
||
3543 | this.xLog = xLog; |
||
3544 | this.pLogArg = pLogArg; |
||
3545 | this.bLocaltimeFault = bLocaltimeFault; |
||
3546 | } |
||
3547 | }; |
||
3548 | |||
3549 | /* |
||
3550 | ** Context pointer passed down through the tree-walk. |
||
3551 | */ |
||
3552 | public class Walker |
||
3553 | { |
||
3554 | public dxExprCallback xExprCallback; //)(Walker*, Expr); /* Callback for expressions */ |
||
3555 | public dxSelectCallback xSelectCallback; //)(Walker*,Select); /* Callback for SELECTs */ |
||
3556 | public Parse pParse; /* Parser context. */ |
||
3557 | public struct uw |
||
3558 | { /* Extra data for callback */ |
||
3559 | public NameContext pNC; /* Naming context */ |
||
3560 | public int i; /* Integer value */ |
||
3561 | } |
||
3562 | public uw u; |
||
3563 | }; |
||
3564 | |||
3565 | /* Forward declarations */ |
||
3566 | //int sqlite3WalkExpr(Walker*, Expr); |
||
3567 | //int sqlite3WalkExprList(Walker*, ExprList); |
||
3568 | //int sqlite3WalkSelect(Walker*, Select); |
||
3569 | //int sqlite3WalkSelectExpr(Walker*, Select); |
||
3570 | //int sqlite3WalkSelectFrom(Walker*, Select); |
||
3571 | |||
3572 | /* |
||
3573 | ** Return code from the parse-tree walking primitives and their |
||
3574 | ** callbacks. |
||
3575 | */ |
||
3576 | //#define WRC_Continue 0 /* Continue down into children */ |
||
3577 | //#define WRC_Prune 1 /* Omit children but continue walking siblings */ |
||
3578 | //#define WRC_Abort 2 /* Abandon the tree walk */ |
||
3579 | const int WRC_Continue = 0; |
||
3580 | const int WRC_Prune = 1; |
||
3581 | const int WRC_Abort = 2; |
||
3582 | |||
3583 | |||
3584 | /* |
||
3585 | ** Assuming zIn points to the first byte of a UTF-8 character, |
||
3586 | ** advance zIn to point to the first byte of the next UTF-8 character. |
||
3587 | */ |
||
3588 | //#define SQLITE_SKIP_UTF8(zIn) { \ |
||
3589 | // if( (*(zIn++))>=0xc0 ){ \ |
||
3590 | // while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ |
||
3591 | // } \ |
||
3592 | //} |
||
3593 | static void SQLITE_SKIP_UTF8( string zIn, ref int iz ) |
||
3594 | { |
||
3595 | iz++; |
||
3596 | if ( iz < zIn.Length && zIn[iz - 1] >= 0xC0 ) |
||
3597 | { |
||
3598 | while ( iz < zIn.Length && ( zIn[iz] & 0xC0 ) == 0x80 ) |
||
3599 | { |
||
3600 | iz++; |
||
3601 | } |
||
3602 | } |
||
3603 | } |
||
3604 | static void SQLITE_SKIP_UTF8( |
||
3605 | byte[] zIn, ref int iz ) |
||
3606 | { |
||
3607 | iz++; |
||
3608 | if ( iz < zIn.Length && zIn[iz - 1] >= 0xC0 ) |
||
3609 | { |
||
3610 | while ( iz < zIn.Length && ( zIn[iz] & 0xC0 ) == 0x80 ) |
||
3611 | { |
||
3612 | iz++; |
||
3613 | } |
||
3614 | } |
||
3615 | } |
||
3616 | |||
3617 | /* |
||
3618 | ** The SQLITE_*_BKPT macros are substitutes for the error codes with |
||
3619 | ** the same name but without the _BKPT suffix. These macros invoke |
||
3620 | ** routines that report the line-number on which the error originated |
||
3621 | ** using sqlite3_log(). The routines also provide a convenient place |
||
3622 | ** to set a debugger breakpoint. |
||
3623 | */ |
||
3624 | //int sqlite3CorruptError(int); |
||
3625 | //int sqlite3MisuseError(int); |
||
3626 | //int sqlite3CantopenError(int); |
||
3627 | #if DEBUG |
||
3628 | |||
3629 | //#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__) |
||
3630 | static int SQLITE_CORRUPT_BKPT() |
||
3631 | { |
||
3632 | return sqlite3CorruptError( 0 ); |
||
3633 | } |
||
3634 | |||
3635 | //#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) |
||
3636 | static int SQLITE_MISUSE_BKPT() |
||
3637 | { |
||
3638 | return sqlite3MisuseError( 0 ); |
||
3639 | } |
||
3640 | |||
3641 | //#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) |
||
3642 | static int SQLITE_CANTOPEN_BKPT() |
||
3643 | { |
||
3644 | return sqlite3CantopenError( 0 ); |
||
3645 | } |
||
3646 | #else |
||
3647 | static int SQLITE_CORRUPT_BKPT() {return SQLITE_CORRUPT;} |
||
3648 | static int SQLITE_MISUSE_BKPT() {return SQLITE_MISUSE;} |
||
3649 | static int SQLITE_CANTOPEN_BKPT() {return SQLITE_CANTOPEN;} |
||
3650 | #endif |
||
3651 | |||
3652 | /* |
||
3653 | ** FTS4 is really an extension for FTS3. It is enabled using the |
||
3654 | ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all |
||
3655 | ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. |
||
3656 | */ |
||
3657 | //#if (SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) |
||
3658 | //# define SQLITE_ENABLE_FTS3 |
||
3659 | //#endif |
||
3660 | |||
3661 | /* |
||
3662 | ** The ctype.h header is needed for non-ASCII systems. It is also |
||
3663 | ** needed by FTS3 when FTS3 is included in the amalgamation. |
||
3664 | */ |
||
3665 | //#if !defined(SQLITE_ASCII) || \ |
||
3666 | // (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) |
||
3667 | //# include <ctype.h> |
||
3668 | //#endif |
||
3669 | |||
3670 | |||
3671 | /* |
||
3672 | ** The following macros mimic the standard library functions toupper(), |
||
3673 | ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The |
||
3674 | ** sqlite versions only work for ASCII characters, regardless of locale. |
||
3675 | */ |
||
3676 | #if SQLITE_ASCII |
||
3677 | //# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20)) |
||
3678 | |||
3679 | //# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01) |
||
3680 | static bool sqlite3Isspace( byte x ) |
||
3681 | { |
||
3682 | return ( sqlite3CtypeMap[(byte)( x )] & 0x01 ) != 0; |
||
3683 | } |
||
3684 | static bool sqlite3Isspace( char x ) |
||
3685 | { |
||
3686 | return x < 256 && ( sqlite3CtypeMap[(byte)( x )] & 0x01 ) != 0; |
||
3687 | } |
||
3688 | |||
3689 | //# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06) |
||
3690 | static bool sqlite3Isalnum( byte x ) |
||
3691 | { |
||
3692 | return ( sqlite3CtypeMap[(byte)( x )] & 0x06 ) != 0; |
||
3693 | } |
||
3694 | static bool sqlite3Isalnum( char x ) |
||
3695 | { |
||
3696 | return x < 256 && ( sqlite3CtypeMap[(byte)( x )] & 0x06 ) != 0; |
||
3697 | } |
||
3698 | |||
3699 | //# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) |
||
3700 | |||
3701 | //# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) |
||
3702 | static bool sqlite3Isdigit( byte x ) |
||
3703 | { |
||
3704 | return ( sqlite3CtypeMap[( (byte)x )] & 0x04 ) != 0; |
||
3705 | } |
||
3706 | static bool sqlite3Isdigit( char x ) |
||
3707 | { |
||
3708 | return x < 256 && ( sqlite3CtypeMap[( (byte)x )] & 0x04 ) != 0; |
||
3709 | } |
||
3710 | |||
3711 | //# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) |
||
3712 | static bool sqlite3Isxdigit( byte x ) |
||
3713 | { |
||
3714 | return ( sqlite3CtypeMap[( (byte)x )] & 0x08 ) != 0; |
||
3715 | } |
||
3716 | static bool sqlite3Isxdigit( char x ) |
||
3717 | { |
||
3718 | return x < 256 && ( sqlite3CtypeMap[( (byte)x )] & 0x08 ) != 0; |
||
3719 | } |
||
3720 | |||
3721 | //# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) |
||
3722 | #else |
||
3723 | //# define sqlite3Toupper(x) toupper((unsigned char)(x)) |
||
3724 | //# define sqlite3Isspace(x) isspace((unsigned char)(x)) |
||
3725 | //# define sqlite3Isalnum(x) isalnum((unsigned char)(x)) |
||
3726 | //# define sqlite3Isalpha(x) isalpha((unsigned char)(x)) |
||
3727 | //# define sqlite3Isdigit(x) isdigit((unsigned char)(x)) |
||
3728 | //# define sqlite3Isxdigit(x) isxdigit((unsigned char)(x)) |
||
3729 | //# define sqlite3Tolower(x) tolower((unsigned char)(x)) |
||
3730 | #endif |
||
3731 | |||
3732 | /* |
||
3733 | ** Internal function prototypes |
||
3734 | */ |
||
3735 | //int sqlite3StrICmp(string , string ); |
||
3736 | //int sqlite3Strlen30(const char); |
||
3737 | //#define sqlite3StrNICmp sqlite3_strnicmp |
||
3738 | |||
3739 | //int sqlite3MallocInit(void); |
||
3740 | //void sqlite3MallocEnd(void); |
||
3741 | //void *sqlite3Malloc(int); |
||
3742 | //void *sqlite3MallocZero(int); |
||
3743 | //void *sqlite3DbMallocZero(sqlite3*, int); |
||
3744 | //void *sqlite3DbMallocRaw(sqlite3*, int); |
||
3745 | //char *sqlite3DbStrDup(sqlite3*,const char); |
||
3746 | //char *sqlite3DbStrNDup(sqlite3*,const char*, int); |
||
3747 | //void *sqlite3Realloc(void*, int); |
||
3748 | //void *sqlite3DbReallocOrFree(sqlite3 *, object *, int); |
||
3749 | //void *sqlite3DbRealloc(sqlite3 *, object *, int); |
||
3750 | //void sqlite3DbFree(sqlite3*, void); |
||
3751 | //int sqlite3MallocSize(void); |
||
3752 | //int sqlite3DbMallocSize(sqlite3*, void); |
||
3753 | //void *sqlite3ScratchMalloc(int); |
||
3754 | //void //sqlite3ScratchFree(void); |
||
3755 | //void *sqlite3PageMalloc(int); |
||
3756 | //void sqlite3PageFree(void); |
||
3757 | //void sqlite3MemSetDefault(void); |
||
3758 | //void sqlite3BenignMallocHooks(void ()(void), object ()(void)); |
||
3759 | //int sqlite3HeapNearlyFull(void); |
||
3760 | |||
3761 | /* |
||
3762 | ** On systems with ample stack space and that support alloca(), make |
||
3763 | ** use of alloca() to obtain space for large automatic objects. By default, |
||
3764 | ** obtain space from malloc(). |
||
3765 | ** |
||
3766 | ** The alloca() routine never returns NULL. This will cause code paths |
||
3767 | ** that deal with sqlite3StackAlloc() failures to be unreachable. |
||
3768 | */ |
||
3769 | #if SQLITE_USE_ALLOCA |
||
3770 | //# define sqlite3StackAllocRaw(D,N) alloca(N) |
||
3771 | //# define sqlite3StackAllocZero(D,N) memset(alloca(N), 0, N) |
||
3772 | //# define sqlite3StackFree(D,P) |
||
3773 | #else |
||
3774 | #if FALSE |
||
3775 | //# define sqlite3StackAllocRaw(D,N) sqlite3DbMallocRaw(D,N) |
||
3776 | static void sqlite3StackAllocRaw( sqlite3 D, int N ) { sqlite3DbMallocRaw( D, N ); } |
||
3777 | //# define sqlite3StackAllocZero(D,N) sqlite3DbMallocZero(D,N) |
||
3778 | static void sqlite3StackAllocZero( sqlite3 D, int N ) { sqlite3DbMallocZero( D, N ); } |
||
3779 | //# define sqlite3StackFree(D,P) sqlite3DbFree(D,P) |
||
3780 | static void sqlite3StackFree( sqlite3 D, object P ) {sqlite3DbFree( D, P ); } |
||
3781 | #endif |
||
3782 | #endif |
||
3783 | |||
3784 | #if SQLITE_ENABLE_MEMSYS3 |
||
3785 | const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); |
||
3786 | #endif |
||
3787 | #if SQLITE_ENABLE_MEMSYS5 |
||
3788 | const sqlite3_mem_methods *sqlite3MemGetMemsys5(void); |
||
3789 | #endif |
||
3790 | |||
3791 | #if !SQLITE_MUTEX_OMIT |
||
3792 | // sqlite3_mutex_methods const *sqlite3DefaultMutex(void); |
||
3793 | // sqlite3_mutex_methods const *sqlite3NoopMutex(void); |
||
3794 | // sqlite3_mutex *sqlite3MutexAlloc(int); |
||
3795 | // int sqlite3MutexInit(void); |
||
3796 | // int sqlite3MutexEnd(void); |
||
3797 | #endif |
||
3798 | |||
3799 | //int sqlite3StatusValue(int); |
||
3800 | //void sqlite3StatusAdd(int, int); |
||
3801 | //void sqlite3StatusSet(int, int); |
||
3802 | |||
3803 | //#if !SQLITE_OMIT_FLOATING_POINT |
||
3804 | // int sqlite3IsNaN(double); |
||
3805 | //#else |
||
3806 | //# define sqlite3IsNaN(X) 0 |
||
3807 | //#endif |
||
3808 | |||
3809 | //void sqlite3VXPrintf(StrAccum*, int, const char*, va_list); |
||
3810 | #if!SQLITE_OMIT_TRACE |
||
3811 | //void sqlite3XPrintf(StrAccum*, const char*, ...); |
||
3812 | #endif |
||
3813 | //char *sqlite3MPrintf(sqlite3*,const char*, ...); |
||
3814 | //char *sqlite3VMPrintf(sqlite3*,const char*, va_list); |
||
3815 | //char *sqlite3MAppendf(sqlite3*,char*,const char*,...); |
||
3816 | #if SQLITE_TEST || SQLITE_DEBUG |
||
3817 | // void sqlite3DebugPrintf(const char*, ...); |
||
3818 | #endif |
||
3819 | #if SQLITE_TEST |
||
3820 | // void *sqlite3TestTextToPtr(const char); |
||
3821 | #endif |
||
3822 | //void sqlite3SetString(char **, sqlite3*, const char*, ...); |
||
3823 | //void sqlite3ErrorMsg(Parse*, const char*, ...); |
||
3824 | //int sqlite3Dequote(char); |
||
3825 | //int sqlite3KeywordCode(const unsigned char*, int); |
||
3826 | //int sqlite3RunParser(Parse*, const char*, char *); |
||
3827 | //void sqlite3FinishCoding(Parse); |
||
3828 | //int sqlite3GetTempReg(Parse); |
||
3829 | //void sqlite3ReleaseTempReg(Parse*,int); |
||
3830 | //int sqlite3GetTempRange(Parse*,int); |
||
3831 | //void sqlite3ReleaseTempRange(Parse*,int,int); |
||
3832 | //Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); |
||
3833 | //Expr *sqlite3Expr(sqlite3*,int,const char); |
||
3834 | //void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr); |
||
3835 | //Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token); |
||
3836 | //Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr); |
||
3837 | //Expr *sqlite3ExprFunction(Parse*,ExprList*, Token); |
||
3838 | //void sqlite3ExprAssignVarNumber(Parse*, Expr); |
||
3839 | //void sqlite3ExprDelete(sqlite3*, Expr); |
||
3840 | //ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr); |
||
3841 | //void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); |
||
3842 | //void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan); |
||
3843 | //void sqlite3ExprListDelete(sqlite3*, ExprList); |
||
3844 | //int sqlite3Init(sqlite3*, char*); |
||
3845 | //int sqlite3InitCallback(void*, int, char**, char*); |
||
3846 | //void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); |
||
3847 | //void sqlite3ResetInternalSchema(sqlite3*, int); |
||
3848 | //void sqlite3BeginParse(Parse*,int); |
||
3849 | //void sqlite3CommitInternalChanges(sqlite3); |
||
3850 | //Table *sqlite3ResultSetOfSelect(Parse*,Select); |
||
3851 | //void sqlite3OpenMasterTable(Parse *, int); |
||
3852 | //void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); |
||
3853 | //void sqlite3AddColumn(Parse*,Token); |
||
3854 | //void sqlite3AddNotNull(Parse*, int); |
||
3855 | //void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); |
||
3856 | //void sqlite3AddCheckConstraint(Parse*, Expr); |
||
3857 | //void sqlite3AddColumnType(Parse*,Token); |
||
3858 | //void sqlite3AddDefaultValue(Parse*,ExprSpan); |
||
3859 | //void sqlite3AddCollateType(Parse*, Token); |
||
3860 | //void sqlite3EndTable(Parse*,Token*,Token*,Select); |
||
3861 | //int sqlite3ParseUri(const char*,const char*,unsigned int*, |
||
3862 | // sqlite3_vfs**,char**,char *); |
||
3863 | |||
3864 | //Bitvec *sqlite3BitvecCreate(u32); |
||
3865 | //int sqlite3BitvecTest(Bitvec*, u32); |
||
3866 | //int sqlite3BitvecSet(Bitvec*, u32); |
||
3867 | //void sqlite3BitvecClear(Bitvec*, u32, void); |
||
3868 | //void sqlite3BitvecDestroy(Bitvec); |
||
3869 | //u32 sqlite3BitvecSize(Bitvec); |
||
3870 | //int sqlite3BitvecBuiltinTest(int,int); |
||
3871 | |||
3872 | //RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int); |
||
3873 | //void sqlite3RowSetClear(RowSet); |
||
3874 | //void sqlite3RowSetInsert(RowSet*, i64); |
||
3875 | //int sqlite3RowSetTest(RowSet*, u8 iBatch, i64); |
||
3876 | //int sqlite3RowSetNext(RowSet*, i64); |
||
3877 | |||
3878 | //void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); |
||
3879 | |||
3880 | #if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_VIRTUALTABLE |
||
3881 | //int sqlite3ViewGetColumnNames(Parse*,Table); |
||
3882 | #else |
||
3883 | //# define sqlite3ViewGetColumnNames(A,B) 0 |
||
3884 | static int sqlite3ViewGetColumnNames( Parse A, Table B ) |
||
3885 | { |
||
3886 | return 0; |
||
3887 | } |
||
3888 | #endif |
||
3889 | |||
3890 | //void sqlite3DropTable(Parse*, SrcList*, int, int); |
||
3891 | //void sqlite3DeleteTable(sqlite3*, Table); |
||
3892 | //#if !SQLITE_OMIT_AUTOINCREMENT |
||
3893 | // void sqlite3AutoincrementBegin(Parse *pParse); |
||
3894 | // void sqlite3AutoincrementEnd(Parse *pParse); |
||
3895 | //#else |
||
3896 | //# define sqlite3AutoincrementBegin(X) |
||
3897 | //# define sqlite3AutoincrementEnd(X) |
||
3898 | //#endif |
||
3899 | //void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int); |
||
3900 | //void *sqlite3ArrayAllocate(sqlite3*,void*,int,int,int*,int*,int); |
||
3901 | //IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token); |
||
3902 | //int sqlite3IdListIndex(IdList*,const char); |
||
3903 | //SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); |
||
3904 | //SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token); |
||
3905 | //SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, |
||
3906 | // Token*, Select*, Expr*, IdList); |
||
3907 | //void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token ); |
||
3908 | //int sqlite3IndexedByLookup(Parse *, struct SrcList_item ); |
||
3909 | //void sqlite3SrcListShiftJoinType(SrcList); |
||
3910 | //void sqlite3SrcListAssignCursors(Parse*, SrcList); |
||
3911 | //void sqlite3IdListDelete(sqlite3*, IdList); |
||
3912 | //void sqlite3SrcListDelete(sqlite3*, SrcList); |
||
3913 | //Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
||
3914 | // Token*, int, int); |
||
3915 | //void sqlite3DropIndex(Parse*, SrcList*, int); |
||
3916 | //int sqlite3Select(Parse*, Select*, SelectDest); |
||
3917 | //Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
||
3918 | // Expr*,ExprList*,int,Expr*,Expr); |
||
3919 | //void sqlite3SelectDelete(sqlite3*, Select); |
||
3920 | //Table *sqlite3SrcListLookup(Parse*, SrcList); |
||
3921 | //int sqlite3IsReadOnly(Parse*, Table*, int); |
||
3922 | //void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
||
3923 | #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY) |
||
3924 | //Expr *sqlite3LimitWhere(Parse *, SrcList *, Expr *, ExprList *, Expr *, Expr *, char ); |
||
3925 | #endif |
||
3926 | //void sqlite3DeleteFrom(Parse*, SrcList*, Expr); |
||
3927 | //void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); |
||
3928 | //WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16); |
||
3929 | //void sqlite3WhereEnd(WhereInfo); |
||
3930 | //int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int); |
||
3931 | //void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); |
||
3932 | //void sqlite3ExprCodeMove(Parse*, int, int, int); |
||
3933 | //void sqlite3ExprCodeCopy(Parse*, int, int, int); |
||
3934 | //void sqlite3ExprCacheStore(Parse*, int, int, int); |
||
3935 | //void sqlite3ExprCachePush(Parse); |
||
3936 | //void sqlite3ExprCachePop(Parse*, int); |
||
3937 | //void sqlite3ExprCacheRemove(Parse*, int, int); |
||
3938 | //void sqlite3ExprCacheClear(Parse); |
||
3939 | //void sqlite3ExprCacheAffinityChange(Parse*, int, int); |
||
3940 | //int sqlite3ExprCode(Parse*, Expr*, int); |
||
3941 | //int sqlite3ExprCodeTemp(Parse*, Expr*, int); |
||
3942 | //int sqlite3ExprCodeTarget(Parse*, Expr*, int); |
||
3943 | //int sqlite3ExprCodeAndCache(Parse*, Expr*, int); |
||
3944 | //void sqlite3ExprCodeConstants(Parse*, Expr); |
||
3945 | //int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int); |
||
3946 | //void sqlite3ExprIfTrue(Parse*, Expr*, int, int); |
||
3947 | //void sqlite3ExprIfFalse(Parse*, Expr*, int, int); |
||
3948 | //Table *sqlite3FindTable(sqlite3*,const char*, const char); |
||
3949 | //Table *sqlite3LocateTable(Parse*,int isView,const char*, const char); |
||
3950 | //Index *sqlite3FindIndex(sqlite3*,const char*, const char); |
||
3951 | //void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char); |
||
3952 | //void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char); |
||
3953 | //void sqlite3Vacuum(Parse); |
||
3954 | //int sqlite3RunVacuum(char**, sqlite3); |
||
3955 | //char *sqlite3NameFromToken(sqlite3*, Token); |
||
3956 | //int sqlite3ExprCompare(Expr*, Expr); |
||
3957 | //int sqlite3ExprListCompare(ExprList*, ExprList); |
||
3958 | //void sqlite3ExprAnalyzeAggregates(NameContext*, Expr); |
||
3959 | //void sqlite3ExprAnalyzeAggList(NameContext*,ExprList); |
||
3960 | //Vdbe *sqlite3GetVdbe(Parse); |
||
3961 | //void sqlite3PrngSaveState(void); |
||
3962 | //void sqlite3PrngRestoreState(void); |
||
3963 | //void sqlite3PrngResetState(void); |
||
3964 | //void sqlite3RollbackAll(sqlite3); |
||
3965 | //void sqlite3CodeVerifySchema(Parse*, int); |
||
3966 | //void sqlite3CodeVerifyNamedSchema(Parse*, string zDb); |
||
3967 | //void sqlite3BeginTransaction(Parse*, int); |
||
3968 | //void sqlite3CommitTransaction(Parse); |
||
3969 | //void sqlite3RollbackTransaction(Parse); |
||
3970 | //void sqlite3Savepoint(Parse*, int, Token); |
||
3971 | //void sqlite3CloseSavepoints(sqlite3 ); |
||
3972 | //int sqlite3ExprIsConstant(Expr); |
||
3973 | //int sqlite3ExprIsConstantNotJoin(Expr); |
||
3974 | //int sqlite3ExprIsConstantOrFunction(Expr); |
||
3975 | //int sqlite3ExprIsInteger(Expr*, int); |
||
3976 | //int sqlite3ExprCanBeNull(const Expr); |
||
3977 | //void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); |
||
3978 | //int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
||
3979 | //int sqlite3IsRowid(const char); |
||
3980 | //void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); |
||
3981 | //void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int); |
||
3982 | //int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int); |
||
3983 | //void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, |
||
3984 | // int*,int,int,int,int,int); |
||
3985 | //void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); |
||
3986 | //int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); |
||
3987 | //void sqlite3BeginWriteOperation(Parse*, int, int); |
||
3988 | //void sqlite3MultiWrite(Parse); |
||
3989 | //void sqlite3MayAbort(Parse ); |
||
3990 | //void sqlite3HaltConstraint(Parse*, int, char*, int); |
||
3991 | //Expr *sqlite3ExprDup(sqlite3*,Expr*,int); |
||
3992 | //ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); |
||
3993 | //SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); |
||
3994 | //IdList *sqlite3IdListDup(sqlite3*,IdList); |
||
3995 | //Select *sqlite3SelectDup(sqlite3*,Select*,int); |
||
3996 | //void sqlite3FuncDefInsert(FuncDefHash*, FuncDef); |
||
3997 | //FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); |
||
3998 | //void sqlite3RegisterBuiltinFunctions(sqlite3); |
||
3999 | //void sqlite3RegisterDateTimeFunctions(void); |
||
4000 | //void sqlite3RegisterGlobalFunctions(void); |
||
4001 | //int sqlite3SafetyCheckOk(sqlite3); |
||
4002 | //int sqlite3SafetyCheckSickOrOk(sqlite3); |
||
4003 | //void sqlite3ChangeCookie(Parse*, int); |
||
4004 | #if !(SQLITE_OMIT_VIEW) && !(SQLITE_OMIT_TRIGGER) |
||
4005 | //void sqlite3MaterializeView(Parse*, Table*, Expr*, int); |
||
4006 | #endif |
||
4007 | |||
4008 | #if !SQLITE_OMIT_TRIGGER |
||
4009 | //void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*, |
||
4010 | // Expr*,int, int); |
||
4011 | //void sqlite3FinishTrigger(Parse*, TriggerStep*, Token); |
||
4012 | //void sqlite3DropTrigger(Parse*, SrcList*, int); |
||
4013 | //Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask); |
||
4014 | //Trigger *sqlite3TriggerList(Parse *, Table ); |
||
4015 | // void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *, |
||
4016 | // int, int, int); |
||
4017 | //void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList); |
||
4018 | //void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep); |
||
4019 | //TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select); |
||
4020 | //TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, |
||
4021 | // ExprList*,Select*,u8); |
||
4022 | //TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8); |
||
4023 | //TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr); |
||
4024 | //void sqlite3DeleteTrigger(sqlite3*, Trigger); |
||
4025 | //void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char); |
||
4026 | // u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); |
||
4027 | //# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p)) |
||
4028 | static Parse sqlite3ParseToplevel( Parse p ) |
||
4029 | { |
||
4030 | return p.pToplevel != null ? p.pToplevel : p; |
||
4031 | } |
||
4032 | #else |
||
4033 | static void sqlite3BeginTrigger( Parse A, Token B, Token C, int D, int E, IdList F, SrcList G, Expr H, int I, int J ) |
||
4034 | { |
||
4035 | } |
||
4036 | static void sqlite3FinishTrigger( Parse P, TriggerStep TS, Token T ) |
||
4037 | { |
||
4038 | } |
||
4039 | static TriggerStep sqlite3TriggerSelectStep( sqlite3 A, Select B ) |
||
4040 | { |
||
4041 | return null; |
||
4042 | } |
||
4043 | static TriggerStep sqlite3TriggerInsertStep( sqlite3 A, Token B, IdList C, ExprList D, Select E, u8 F ) |
||
4044 | { |
||
4045 | return null; |
||
4046 | } |
||
4047 | static TriggerStep sqlite3TriggerInsertStep( sqlite3 A, Token B, IdList C, int D, Select E, u8 F ) |
||
4048 | { |
||
4049 | return null; |
||
4050 | } |
||
4051 | static TriggerStep sqlite3TriggerInsertStep( sqlite3 A, Token B, IdList C, ExprList D, int E, u8 F ) |
||
4052 | { |
||
4053 | return null; |
||
4054 | } |
||
4055 | static TriggerStep sqlite3TriggerUpdateStep( sqlite3 A, Token B, ExprList C, Expr D, u8 E ) |
||
4056 | { |
||
4057 | return null; |
||
4058 | } |
||
4059 | static TriggerStep sqlite3TriggerDeleteStep( sqlite3 A, Token B, Expr C ) |
||
4060 | { |
||
4061 | return null; |
||
4062 | } |
||
4063 | static u32 sqlite3TriggerColmask( Parse A, Trigger B, ExprList C, int D, int E, Table F, int G ) |
||
4064 | { |
||
4065 | return 0; |
||
4066 | } |
||
4067 | |||
4068 | //# define sqlite3TriggersExist(B,C,D,E,F) 0 |
||
4069 | static Trigger sqlite3TriggersExist( Parse B, Table C, int D, ExprList E, ref int F ) |
||
4070 | { |
||
4071 | return null; |
||
4072 | } |
||
4073 | |||
4074 | //# define sqlite3DeleteTrigger(A,B) |
||
4075 | static void sqlite3DeleteTrigger( sqlite3 A, ref Trigger B ) |
||
4076 | { |
||
4077 | } |
||
4078 | static void sqlite3DeleteTriggerStep( sqlite3 A, ref TriggerStep B ) |
||
4079 | { |
||
4080 | } |
||
4081 | |||
4082 | //# define sqlite3DropTriggerPtr(A,B) |
||
4083 | static void sqlite3DropTriggerPtr( Parse A, Trigger B ) |
||
4084 | { |
||
4085 | } |
||
4086 | static void sqlite3DropTrigger( Parse A, SrcList B, int C ) |
||
4087 | { |
||
4088 | } |
||
4089 | |||
4090 | //# define sqlite3UnlinkAndDeleteTrigger(A,B,C) |
||
4091 | static void sqlite3UnlinkAndDeleteTrigger( sqlite3 A, int B, string C ) |
||
4092 | { |
||
4093 | } |
||
4094 | |||
4095 | //# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I) |
||
4096 | static void sqlite3CodeRowTrigger( Parse A, Trigger B, int C, ExprList D, int E, Table F, int G, int H, int I ) |
||
4097 | { |
||
4098 | } |
||
4099 | |||
4100 | //# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F) |
||
4101 | static Trigger sqlite3TriggerList( Parse pParse, Table pTab ) |
||
4102 | { |
||
4103 | return null; |
||
4104 | } //# define sqlite3TriggerList(X, Y) 0 |
||
4105 | |||
4106 | //# define sqlite3ParseToplevel(p) p |
||
4107 | static Parse sqlite3ParseToplevel( Parse p ) |
||
4108 | { |
||
4109 | return p; |
||
4110 | } |
||
4111 | |||
4112 | //# define sqlite3TriggerOldmask(A,B,C,D,E,F) 0 |
||
4113 | static u32 sqlite3TriggerOldmask( Parse A, Trigger B, int C, ExprList D, Table E, int F ) |
||
4114 | { |
||
4115 | return 0; |
||
4116 | } |
||
4117 | #endif |
||
4118 | |||
4119 | //int sqlite3JoinType(Parse*, Token*, Token*, Token); |
||
4120 | //void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); |
||
4121 | //void sqlite3DeferForeignKey(Parse*, int); |
||
4122 | #if !SQLITE_OMIT_AUTHORIZATION |
||
4123 | void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList); |
||
4124 | int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char); |
||
4125 | void sqlite3AuthContextPush(Parse*, AuthContext*, const char); |
||
4126 | void sqlite3AuthContextPop(AuthContext); |
||
4127 | int sqlite3AuthReadCol(Parse*, string , string , int); |
||
4128 | #else |
||
4129 | //# define sqlite3AuthRead(a,b,c,d) |
||
4130 | static void sqlite3AuthRead( Parse a, Expr b, Schema c, SrcList d ) |
||
4131 | { |
||
4132 | } |
||
4133 | |||
4134 | //# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK |
||
4135 | static int sqlite3AuthCheck( Parse a, int b, string c, byte[] d, byte[] e ) |
||
4136 | { |
||
4137 | return SQLITE_OK; |
||
4138 | } |
||
4139 | |||
4140 | //# define sqlite3AuthContextPush(a,b,c) |
||
4141 | static void sqlite3AuthContextPush( Parse a, AuthContext b, string c ) |
||
4142 | { |
||
4143 | } |
||
4144 | |||
4145 | //# define sqlite3AuthContextPop(a) ((void)(a)) |
||
4146 | static Parse sqlite3AuthContextPop( Parse a ) |
||
4147 | { |
||
4148 | return a; |
||
4149 | } |
||
4150 | #endif |
||
4151 | //void sqlite3Attach(Parse*, Expr*, Expr*, Expr); |
||
4152 | //void sqlite3Detach(Parse*, Expr); |
||
4153 | //int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token); |
||
4154 | //int sqlite3FixSrcList(DbFixer*, SrcList); |
||
4155 | //int sqlite3FixSelect(DbFixer*, Select); |
||
4156 | //int sqlite3FixExpr(DbFixer*, Expr); |
||
4157 | //int sqlite3FixExprList(DbFixer*, ExprList); |
||
4158 | //int sqlite3FixTriggerStep(DbFixer*, TriggerStep); |
||
4159 | //sqlite3AtoF(string z, double*, int, u8) |
||
4160 | //int sqlite3GetInt32(string , int); |
||
4161 | //int sqlite3Atoi(string ); |
||
4162 | //int sqlite3Utf16ByteLen(const void pData, int nChar); |
||
4163 | //int sqlite3Utf8CharLen(const char pData, int nByte); |
||
4164 | //u32 sqlite3Utf8Read(const u8*, const u8*); |
||
4165 | |||
4166 | /* |
||
4167 | ** Routines to read and write variable-length integers. These used to |
||
4168 | ** be defined locally, but now we use the varint routines in the util.c |
||
4169 | ** file. Code should use the MACRO forms below, as the Varint32 versions |
||
4170 | ** are coded to assume the single byte case is already handled (which |
||
4171 | ** the MACRO form does). |
||
4172 | */ |
||
4173 | //int sqlite3PutVarint(unsigned char*, u64); |
||
4174 | //int putVarint32(unsigned char*, u32); |
||
4175 | //u8 sqlite3GetVarint(const unsigned char *, u64 ); |
||
4176 | //u8 sqlite3GetVarint32(const unsigned char *, u32 ); |
||
4177 | //int sqlite3VarintLen(u64 v); |
||
4178 | |||
4179 | /* |
||
4180 | ** The header of a record consists of a sequence variable-length integers. |
||
4181 | ** These integers are almost always small and are encoded as a single byte. |
||
4182 | ** The following macros take advantage this fact to provide a fast encode |
||
4183 | ** and decode of the integers in a record header. It is faster for the common |
||
4184 | ** case where the integer is a single byte. It is a little slower when the |
||
4185 | ** integer is two or more bytes. But overall it is faster. |
||
4186 | ** |
||
4187 | ** The following expressions are equivalent: |
||
4188 | ** |
||
4189 | ** x = sqlite3GetVarint32( A, B ); |
||
4190 | ** x = putVarint32( A, B ); |
||
4191 | ** |
||
4192 | ** x = getVarint32( A, B ); |
||
4193 | ** x = putVarint32( A, B ); |
||
4194 | ** |
||
4195 | */ |
||
4196 | //#define getVarint32(A,B) (u8)((*(A)<(u8)0x80) ? ((B) = (u32)*(A)),1 : sqlite3GetVarint32((A), (u32 )&(B))) |
||
4197 | //#define putVarint32(A,B) (u8)(((u32)(B)<(u32)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite3PutVarint32((A), (B))) |
||
4198 | //#define getVarint sqlite3GetVarint |
||
4199 | //#define putVarint sqlite3PutVarint |
||
4200 | |||
4201 | |||
4202 | //string sqlite3IndexAffinityStr(Vdbe *, Index ); |
||
4203 | //void sqlite3TableAffinityStr(Vdbe *, Table ); |
||
4204 | //char sqlite3CompareAffinity(Expr pExpr, char aff2); |
||
4205 | //int sqlite3IndexAffinityOk(Expr pExpr, char idx_affinity); |
||
4206 | //char sqlite3ExprAffinity(Expr pExpr); |
||
4207 | //int sqlite3Atoi64(const char*, i64*, int, u8); |
||
4208 | //void sqlite3Error(sqlite3*, int, const char*,...); |
||
4209 | //void *sqlite3HexToBlob(sqlite3*, string z, int n); |
||
4210 | //u8 sqlite3HexToInt(int h); |
||
4211 | //int sqlite3TwoPartName(Parse *, Token *, Token *, Token *); |
||
4212 | //string sqlite3ErrStr(int); |
||
4213 | //int sqlite3ReadSchema(Parse pParse); |
||
4214 | //CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); |
||
4215 | //CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); |
||
4216 | //CollSeq *sqlite3ExprCollSeq(Parse pParse, Expr pExpr); |
||
4217 | //Expr *sqlite3ExprSetColl(Expr*, CollSeq); |
||
4218 | //Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr*, Token); |
||
4219 | //int sqlite3CheckCollSeq(Parse *, CollSeq ); |
||
4220 | //int sqlite3CheckObjectName(Parse *, string ); |
||
4221 | //void sqlite3VdbeSetChanges(sqlite3 *, int); |
||
4222 | //int sqlite3AddInt64(i64*,i64); |
||
4223 | //int sqlite3SubInt64(i64*,i64); |
||
4224 | //int sqlite3MulInt64(i64*,i64); |
||
4225 | //int sqlite3AbsInt32(int); |
||
4226 | #if SQLITE_ENABLE_8_3_NAMES |
||
4227 | //void sqlite3FileSuffix3(const char*, char); |
||
4228 | #else |
||
4229 | //# define sqlite3FileSuffix3(X,Y) |
||
4230 | static void sqlite3FileSuffix3(string X, string Y){} |
||
4231 | #endif |
||
4232 | //u8 sqlite3GetBoolean(string z); |
||
4233 | |||
4234 | //const void *sqlite3ValueText(sqlite3_value*, u8); |
||
4235 | //int sqlite3ValueBytes(sqlite3_value*, u8); |
||
4236 | //void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, |
||
4237 | // // void()(void)); |
||
4238 | //void sqlite3ValueFree(sqlite3_value); |
||
4239 | //sqlite3_value *sqlite3ValueNew(sqlite3 ); |
||
4240 | //char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); |
||
4241 | //#if SQLITE_ENABLE_STAT2 |
||
4242 | //char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int ); |
||
4243 | //#endif |
||
4244 | //int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value *); |
||
4245 | //void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); |
||
4246 | //#if !SQLITE_AMALGAMATION |
||
4247 | //extern const unsigned char sqlite3OpcodeProperty[]; |
||
4248 | //extern const unsigned char sqlite3UpperToLower[]; |
||
4249 | //extern const unsigned char sqlite3CtypeMap[]; |
||
4250 | //extern const Token sqlite3IntTokens[]; |
||
4251 | //extern SQLITE_WSD struct Sqlite3Config sqlite3Config; |
||
4252 | //extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; |
||
4253 | //#if !SQLITE_OMIT_WSD |
||
4254 | //extern int sqlite3PendingByte; |
||
4255 | //#endif |
||
4256 | //#endif |
||
4257 | //void sqlite3RootPageMoved(sqlite3*, int, int, int); |
||
4258 | //void sqlite3Reindex(Parse*, Token*, Token); |
||
4259 | //void sqlite3AlterFunctions(void); |
||
4260 | //void sqlite3AlterRenameTable(Parse*, SrcList*, Token); |
||
4261 | //int sqlite3GetToken(const unsigned char *, int ); |
||
4262 | //void sqlite3NestedParse(Parse*, const char*, ...); |
||
4263 | //void sqlite3ExpirePreparedStatements(sqlite3); |
||
4264 | //int sqlite3CodeSubselect(Parse *, Expr *, int, int); |
||
4265 | //void sqlite3SelectPrep(Parse*, Select*, NameContext); |
||
4266 | //int sqlite3ResolveExprNames(NameContext*, Expr); |
||
4267 | //void sqlite3ResolveSelectNames(Parse*, Select*, NameContext); |
||
4268 | //int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char); |
||
4269 | //void sqlite3ColumnDefault(Vdbe *, Table *, int, int); |
||
4270 | //void sqlite3AlterFinishAddColumn(Parse *, Token ); |
||
4271 | //void sqlite3AlterBeginAddColumn(Parse *, SrcList ); |
||
4272 | //CollSeq *sqlite3GetCollSeq(sqlite3*, u8, CollSeq *, const char); |
||
4273 | //char sqlite3AffinityType(const char); |
||
4274 | //void sqlite3Analyze(Parse*, Token*, Token); |
||
4275 | //int sqlite3InvokeBusyHandler(BusyHandler); |
||
4276 | //int sqlite3FindDb(sqlite3*, Token); |
||
4277 | //int sqlite3FindDbName(sqlite3 *, string ); |
||
4278 | //int sqlite3AnalysisLoad(sqlite3*,int iDB); |
||
4279 | //void sqlite3DeleteIndexSamples(sqlite3*,Index); |
||
4280 | //void sqlite3DefaultRowEst(Index); |
||
4281 | //void sqlite3RegisterLikeFunctions(sqlite3*, int); |
||
4282 | //int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char); |
||
4283 | //void sqlite3MinimumFileFormat(Parse*, int, int); |
||
4284 | //void sqlite3SchemaClear(void ); |
||
4285 | //Schema *sqlite3SchemaGet(sqlite3 *, Btree ); |
||
4286 | //int sqlite3SchemaToIndex(sqlite3 db, Schema ); |
||
4287 | //KeyInfo *sqlite3IndexKeyinfo(Parse *, Index ); |
||
4288 | //int sqlite3CreateFunc(sqlite3 *, string , int, int, object *, |
||
4289 | // void ()(sqlite3_context*,int,sqlite3_value *), |
||
4290 | // void ()(sqlite3_context*,int,sqlite3_value *), object ()(sqlite3_context), |
||
4291 | // FuncDestructor *pDestructor |
||
4292 | //); |
||
4293 | //int sqlite3ApiExit(sqlite3 db, int); |
||
4294 | //int sqlite3OpenTempDatabase(Parse ); |
||
4295 | |||
4296 | //void sqlite3StrAccumAppend(StrAccum*,const char*,int); |
||
4297 | //char *sqlite3StrAccumFinish(StrAccum); |
||
4298 | //void sqlite3StrAccumReset(StrAccum); |
||
4299 | //void sqlite3SelectDestInit(SelectDest*,int,int); |
||
4300 | //Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); |
||
4301 | |||
4302 | //void sqlite3BackupRestart(sqlite3_backup ); |
||
4303 | //void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 ); |
||
4304 | |||
4305 | /* |
||
4306 | ** The interface to the LEMON-generated parser |
||
4307 | */ |
||
4308 | //void *sqlite3ParserAlloc(void*()(size_t)); |
||
4309 | //void sqlite3ParserFree(void*, void()(void)); |
||
4310 | //void sqlite3Parser(void*, int, Token, Parse); |
||
4311 | #if YYTRACKMAXSTACKDEPTH |
||
4312 | int sqlite3ParserStackPeak(void); |
||
4313 | #endif |
||
4314 | |||
4315 | //void sqlite3AutoLoadExtensions(sqlite3); |
||
4316 | #if !SQLITE_OMIT_LOAD_EXTENSION |
||
4317 | //void sqlite3CloseExtensions(sqlite3); |
||
4318 | #else |
||
4319 | //# define sqlite3CloseExtensions(X) |
||
4320 | #endif |
||
4321 | |||
4322 | #if !SQLITE_OMIT_SHARED_CACHE |
||
4323 | //void sqlite3TableLock(Parse *, int, int, u8, string ); |
||
4324 | #else |
||
4325 | //#define sqlite3TableLock(v,w,x,y,z) |
||
4326 | static void sqlite3TableLock( Parse p, int p1, int p2, u8 p3, byte[] p4 ) |
||
4327 | { |
||
4328 | } |
||
4329 | static void sqlite3TableLock( Parse p, int p1, int p2, u8 p3, string p4 ) |
||
4330 | { |
||
4331 | } |
||
4332 | #endif |
||
4333 | |||
4334 | #if SQLITE_TEST |
||
4335 | ///int sqlite3Utf8To8(unsigned char); |
||
4336 | #endif |
||
4337 | |||
4338 | #if SQLITE_OMIT_VIRTUALTABLE |
||
4339 | //# define sqlite3VtabClear(D, Y) |
||
4340 | static void sqlite3VtabClear( sqlite3 db, Table Y ) |
||
4341 | { |
||
4342 | } |
||
4343 | |||
4344 | //# define sqlite3VtabSync(X,Y) SQLITE_OK |
||
4345 | static int sqlite3VtabSync( sqlite3 X, ref string Y ) |
||
4346 | { |
||
4347 | return SQLITE_OK; |
||
4348 | } |
||
4349 | |||
4350 | //# define sqlite3VtabRollback(X) |
||
4351 | static void sqlite3VtabRollback( sqlite3 X ) |
||
4352 | { |
||
4353 | } |
||
4354 | |||
4355 | //# define sqlite3VtabCommit(X) |
||
4356 | static void sqlite3VtabCommit( sqlite3 X ) |
||
4357 | { |
||
4358 | } |
||
4359 | |||
4360 | //# define sqlite3VtabLock(X) |
||
4361 | static void sqlite3VtabLock( VTable X ) |
||
4362 | { |
||
4363 | } |
||
4364 | |||
4365 | //# define sqlite3VtabUnlock(X) |
||
4366 | static void sqlite3VtabUnlock( VTable X ) |
||
4367 | { |
||
4368 | } |
||
4369 | |||
4370 | //# define sqlite3VtabUnlockList(X) |
||
4371 | static void sqlite3VtabUnlockList( sqlite3 X ) |
||
4372 | { |
||
4373 | } |
||
4374 | //# define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK |
||
4375 | static int sqlite3VtabSavepoint( sqlite3 X, int Y, int Z ) |
||
4376 | { |
||
4377 | return SQLITE_OK; |
||
4378 | } |
||
4379 | //# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) |
||
4380 | static bool sqlite3VtabInSync( sqlite3 db ) |
||
4381 | { |
||
4382 | return false; |
||
4383 | } |
||
4384 | |||
4385 | //# define sqlite3VtabArgExtend(P, T) |
||
4386 | static void sqlite3VtabArgExtend( Parse P, Token T ) |
||
4387 | { |
||
4388 | } |
||
4389 | |||
4390 | //# define sqlite3VtabArgInit(P) |
||
4391 | static void sqlite3VtabArgInit( Parse P ) |
||
4392 | { |
||
4393 | } |
||
4394 | |||
4395 | //# define sqlite3VtabBeginParse(P, T, T1, T2); |
||
4396 | static void sqlite3VtabBeginParse( Parse P, Token T, Token T1, Token T2 ) |
||
4397 | { |
||
4398 | } |
||
4399 | |||
4400 | //# define sqlite3VtabFinishParse(P, T) |
||
4401 | static void sqlite3VtabFinishParse<T>( Parse P, T t ) |
||
4402 | { |
||
4403 | } |
||
4404 | |||
4405 | static VTable sqlite3GetVTable( sqlite3 db, Table T ) |
||
4406 | { |
||
4407 | return null; |
||
4408 | } |
||
4409 | #else |
||
4410 | //void sqlite3VtabClear(sqlite3 db, Table); |
||
4411 | //int sqlite3VtabSync(sqlite3 db, int rc); |
||
4412 | //int sqlite3VtabRollback(sqlite3 db); |
||
4413 | //int sqlite3VtabCommit(sqlite3 db); |
||
4414 | //void sqlite3VtabLock(VTable ); |
||
4415 | //void sqlite3VtabUnlock(VTable ); |
||
4416 | //void sqlite3VtabUnlockList(sqlite3); |
||
4417 | //int sqlite3VtabSavepoint(sqlite3 *, int, int); |
||
4418 | //# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) |
||
4419 | static bool sqlite3VtabInSync( sqlite3 db ) |
||
4420 | { |
||
4421 | return ( db.nVTrans > 0 && db.aVTrans == null ); |
||
4422 | } |
||
4423 | #endif |
||
4424 | //void sqlite3VtabMakeWritable(Parse*,Table); |
||
4425 | //void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token); |
||
4426 | //void sqlite3VtabFinishParse(Parse*, Token); |
||
4427 | //void sqlite3VtabArgInit(Parse); |
||
4428 | //void sqlite3VtabArgExtend(Parse*, Token); |
||
4429 | //int sqlite3VtabCallCreate(sqlite3*, int, string , char *); |
||
4430 | //int sqlite3VtabCallConnect(Parse*, Table); |
||
4431 | //int sqlite3VtabCallDestroy(sqlite3*, int, string ); |
||
4432 | //int sqlite3VtabBegin(sqlite3 *, VTable ); |
||
4433 | //FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr); |
||
4434 | //void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value*); |
||
4435 | //int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); |
||
4436 | //int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt ); |
||
4437 | //int sqlite3Reprepare(Vdbe); |
||
4438 | //void sqlite3ExprListCheckLength(Parse*, ExprList*, const char); |
||
4439 | //CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr ); |
||
4440 | //int sqlite3TempInMemory(const sqlite3); |
||
4441 | //VTable *sqlite3GetVTable(sqlite3*, Table); |
||
4442 | //string sqlite3JournalModename(int); |
||
4443 | //int sqlite3Checkpoint(sqlite3*, int, int, int*, int); |
||
4444 | //int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); |
||
4445 | |||
4446 | /* Declarations for functions in fkey.c. All of these are replaced by |
||
4447 | ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign |
||
4448 | ** key functionality is available. If OMIT_TRIGGER is defined but |
||
4449 | ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In |
||
4450 | ** this case foreign keys are parsed, but no other functionality is |
||
4451 | ** provided (enforcement of FK constraints requires the triggers sub-system). |
||
4452 | */ |
||
4453 | #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER) |
||
4454 | //void sqlite3FkCheck(Parse*, Table*, int, int); |
||
4455 | //void sqlite3FkDropTable(Parse*, SrcList *, Table); |
||
4456 | //void sqlite3FkActions(Parse*, Table*, ExprList*, int); |
||
4457 | //int sqlite3FkRequired(Parse*, Table*, int*, int); |
||
4458 | //u32 sqlite3FkOldmask(Parse*, Table); |
||
4459 | //FKey *sqlite3FkReferences(vtable ); |
||
4460 | #else |
||
4461 | //#define sqlite3FkActions(a,b,c,d) |
||
4462 | static void sqlite3FkActions( Parse a, Table b, ExprList c, int d ) { } |
||
4463 | |||
4464 | //#define sqlite3FkCheck(a,b,c,d) |
||
4465 | static void sqlite3FkCheck( Parse a, Table b, int c, int d ) { } |
||
4466 | |||
4467 | //#define sqlite3FkDropTable(a,b,c) |
||
4468 | static void sqlite3FkDropTable( Parse a, SrcList b, Table c ) { } |
||
4469 | |||
4470 | //#define sqlite3FkOldmask(a,b) 0 |
||
4471 | static u32 sqlite3FkOldmask( Parse a, Table b ) { return 0; } |
||
4472 | |||
4473 | //#define sqlite3FkRequired(a,b,c,d) 0 |
||
4474 | static int sqlite3FkRequired( Parse a, Table b, int[] c, int d ) { return 0; } |
||
4475 | #endif |
||
4476 | #if !SQLITE_OMIT_FOREIGN_KEY |
||
4477 | //void sqlite3FkDelete(sqlite3 *, Table); |
||
4478 | #else |
||
4479 | //#define sqlite3FkDelete(a, b) |
||
4480 | static void sqlite3FkDelete(sqlite3 a, Table b) {} |
||
4481 | #endif |
||
4482 | |||
4483 | /* |
||
4484 | ** Available fault injectors. Should be numbered beginning with 0. |
||
4485 | */ |
||
4486 | const int SQLITE_FAULTINJECTOR_MALLOC = 0;//#define SQLITE_FAULTINJECTOR_MALLOC 0 |
||
4487 | const int SQLITE_FAULTINJECTOR_COUNT = 1;//#define SQLITE_FAULTINJECTOR_COUNT 1 |
||
4488 | |||
4489 | /* |
||
4490 | ** The interface to the code in fault.c used for identifying "benign" |
||
4491 | ** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST |
||
4492 | ** is not defined. |
||
4493 | */ |
||
4494 | #if !SQLITE_OMIT_BUILTIN_TEST |
||
4495 | //void sqlite3BeginBenignMalloc(void); |
||
4496 | //void sqlite3EndBenignMalloc(void); |
||
4497 | #else |
||
4498 | //#define sqlite3BeginBenignMalloc() |
||
4499 | //#define sqlite3EndBenignMalloc() |
||
4500 | #endif |
||
4501 | |||
4502 | const int IN_INDEX_ROWID = 1;//#define IN_INDEX_ROWID 1 |
||
4503 | const int IN_INDEX_EPH = 2;//#define IN_INDEX_EPH 2 |
||
4504 | const int IN_INDEX_INDEX = 3;//#define IN_INDEX_INDEX 3 |
||
4505 | //int sqlite3FindInIndex(Parse *, Expr *, int); |
||
4506 | |||
4507 | #if SQLITE_ENABLE_ATOMIC_WRITE |
||
4508 | // int sqlite3JournalOpen(sqlite3_vfs *, string , sqlite3_file *, int, int); |
||
4509 | // int sqlite3JournalSize(sqlite3_vfs ); |
||
4510 | // int sqlite3JournalCreate(sqlite3_file ); |
||
4511 | #else |
||
4512 | //#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) |
||
4513 | static int sqlite3JournalSize( sqlite3_vfs pVfs ) |
||
4514 | { |
||
4515 | return pVfs.szOsFile; |
||
4516 | } |
||
4517 | #endif |
||
4518 | |||
4519 | //void sqlite3MemJournalOpen(sqlite3_file ); |
||
4520 | //int sqlite3MemJournalSize(void); |
||
4521 | //int sqlite3IsMemJournal(sqlite3_file ); |
||
4522 | |||
4523 | #if SQLITE_MAX_EXPR_DEPTH//>0 |
||
4524 | // void sqlite3ExprSetHeight(Parse pParse, Expr p); |
||
4525 | // int sqlite3SelectExprHeight(Select ); |
||
4526 | //int sqlite3ExprCheckHeight(Parse*, int); |
||
4527 | #else |
||
4528 | //#define sqlite3ExprSetHeight(x,y) |
||
4529 | //#define sqlite3SelectExprHeight(x) 0 |
||
4530 | //#define sqlite3ExprCheckHeight(x,y) |
||
4531 | #endif |
||
4532 | |||
4533 | //u32 sqlite3Get4byte(const u8); |
||
4534 | //void sqlite3sqlite3Put4byte(u8*, u32); |
||
4535 | |||
4536 | #if SQLITE_ENABLE_UNLOCK_NOTIFY |
||
4537 | void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 ); |
||
4538 | void sqlite3ConnectionUnlocked(sqlite3 db); |
||
4539 | void sqlite3ConnectionClosed(sqlite3 db); |
||
4540 | #else |
||
4541 | static void sqlite3ConnectionBlocked( sqlite3 x, sqlite3 y ) |
||
4542 | { |
||
4543 | } //#define sqlite3ConnectionBlocked(x,y) |
||
4544 | static void sqlite3ConnectionUnlocked( sqlite3 x ) |
||
4545 | { |
||
4546 | } //#define sqlite3ConnectionUnlocked(x) |
||
4547 | static void sqlite3ConnectionClosed( sqlite3 x ) |
||
4548 | { |
||
4549 | } //#define sqlite3ConnectionClosed(x) |
||
4550 | #endif |
||
4551 | |||
4552 | #if SQLITE_DEBUG |
||
4553 | // void sqlite3ParserTrace(FILE*, char ); |
||
4554 | #endif |
||
4555 | |||
4556 | /* |
||
4557 | ** If the SQLITE_ENABLE IOTRACE exists then the global variable |
||
4558 | ** sqlite3IoTrace is a pointer to a printf-like routine used to |
||
4559 | ** print I/O tracing messages. |
||
4560 | */ |
||
4561 | #if SQLITE_ENABLE_IOTRACE |
||
4562 | static bool SQLite3IoTrace = false; |
||
4563 | //#define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; } |
||
4564 | static void IOTRACE( string X, params object[] ap ) { if ( SQLite3IoTrace ) { printf( X, ap ); } } |
||
4565 | |||
4566 | // void sqlite3VdbeIOTraceSql(Vdbe); |
||
4567 | //SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...); |
||
4568 | #else |
||
4569 | //#define IOTRACE(A) |
||
4570 | static void IOTRACE( string F, params object[] ap ) |
||
4571 | { |
||
4572 | } |
||
4573 | //#define sqlite3VdbeIOTraceSql(X) |
||
4574 | static void sqlite3VdbeIOTraceSql( Vdbe X ) |
||
4575 | { |
||
4576 | } |
||
4577 | #endif |
||
4578 | |||
4579 | /* |
||
4580 | ** These routines are available for the mem2.c debugging memory allocator |
||
4581 | ** only. They are used to verify that different "types" of memory |
||
4582 | ** allocations are properly tracked by the system. |
||
4583 | ** |
||
4584 | ** sqlite3MemdebugSetType() sets the "type" of an allocation to one of |
||
4585 | ** the MEMTYPE_* macros defined below. The type must be a bitmask with |
||
4586 | ** a single bit set. |
||
4587 | ** |
||
4588 | ** sqlite3MemdebugHasType() returns true if any of the bits in its second |
||
4589 | ** argument match the type set by the previous sqlite3MemdebugSetType(). |
||
4590 | ** sqlite3MemdebugHasType() is intended for use inside Debug.Assert() statements. |
||
4591 | ** |
||
4592 | ** sqlite3MemdebugNoType() returns true if none of the bits in its second |
||
4593 | ** argument match the type set by the previous sqlite3MemdebugSetType(). |
||
4594 | ** |
||
4595 | ** Perhaps the most important point is the difference between MEMTYPE_HEAP |
||
4596 | ** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means |
||
4597 | ** it might have been allocated by lookaside, except the allocation was |
||
4598 | ** too large or lookaside was already full. It is important to verify |
||
4599 | ** that allocations that might have been satisfied by lookaside are not |
||
4600 | ** passed back to non-lookaside free() routines. Asserts such as the |
||
4601 | ** example above are placed on the non-lookaside free() routines to verify |
||
4602 | ** this constraint. |
||
4603 | ** |
||
4604 | ** All of this is no-op for a production build. It only comes into |
||
4605 | ** play when the SQLITE_MEMDEBUG compile-time option is used. |
||
4606 | */ |
||
4607 | #if SQLITE_MEMDEBUG |
||
4608 | // void sqlite3MemdebugSetType(void*,u8); |
||
4609 | // int sqlite3MemdebugHasType(void*,u8); |
||
4610 | // int sqlite3MemdebugNoType(void*,u8); |
||
4611 | #else |
||
4612 | //# define sqlite3MemdebugSetType(X,Y) /* no-op */ |
||
4613 | static void sqlite3MemdebugSetType<T>( T X, int Y ) |
||
4614 | { |
||
4615 | } |
||
4616 | //# define sqlite3MemdebugHasType(X,Y) 1 |
||
4617 | static bool sqlite3MemdebugHasType<T>( T X, int Y ) |
||
4618 | { |
||
4619 | return true; |
||
4620 | } |
||
4621 | //# define sqlite3MemdebugNoType(X,Y) 1 |
||
4622 | static bool sqlite3MemdebugNoType<T>( T X, int Y ) |
||
4623 | { |
||
4624 | return true; |
||
4625 | } |
||
4626 | #endif |
||
4627 | //#define MEMTYPE_HEAP 0x01 /* General heap allocations */ |
||
4628 | //#define MEMTYPE_LOOKASIDE 0x02 /* Might have been lookaside memory */ |
||
4629 | //#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */ |
||
4630 | //#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ |
||
4631 | //#define MEMTYPE_DB 0x10 /* Uses sqlite3DbMalloc, not sqlite_malloc */ |
||
4632 | public const int MEMTYPE_HEAP = 0x01; |
||
4633 | public const int MEMTYPE_LOOKASIDE = 0x02; |
||
4634 | public const int MEMTYPE_SCRATCH = 0x04; |
||
4635 | public const int MEMTYPE_PCACHE = 0x08; |
||
4636 | public const int MEMTYPE_DB = 0x10; |
||
4637 | |||
4638 | //#endif //* _SQLITEINT_H_ */ |
||
4639 | |||
4640 | } |
||
4641 | } |