PageRenderTime 67ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/library/Library/WP7/SQLiteDriver/sqlite/sqliteInt_h.cs

https://bitbucket.org/digitalizarte/coolstorage
C# | 4518 lines | 2102 code | 277 blank | 2139 comment | 174 complexity | 1f13484fd3b40b0cbf5f6932196c0383 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. #define SQLITE_MAX_EXPR_DEPTH
  2. using System;
  3. using System.Diagnostics;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using Bitmask = System.UInt64;
  7. using i16 = System.Int16;
  8. using i64 = System.Int64;
  9. using sqlite3_int64 = System.Int64;
  10. using u8 = System.Byte;
  11. using u16 = System.UInt16;
  12. using u32 = System.UInt32;
  13. using u64 = System.UInt64;
  14. using unsigned = System.UInt64;
  15. using Pgno = System.UInt32;
  16. #if !SQLITE_MAX_VARIABLE_NUMBER
  17. using ynVar = System.Int16;
  18. #else
  19. using ynVar = System.Int32;
  20. #endif
  21. namespace Community.CsharpSqlite
  22. {
  23. using sqlite3_value = Sqlite3.Mem;
  24. public partial class Sqlite3
  25. {
  26. /*
  27. ** 2001 September 15
  28. **
  29. ** The author disclaims copyright to this source code. In place of
  30. ** a legal notice, here is a blessing:
  31. **
  32. ** May you do good and not evil.
  33. ** May you find forgiveness for yourself and forgive others.
  34. ** May you share freely, never taking more than you give.
  35. **
  36. *************************************************************************
  37. ** Internal interface definitions for SQLite.
  38. **
  39. *************************************************************************
  40. ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
  41. ** C#-SQLite is an independent reimplementation of the SQLite software library
  42. **
  43. ** SQLITE_SOURCE_ID: 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7
  44. **
  45. *************************************************************************
  46. */
  47. //#if !_SQLITEINT_H_
  48. //#define _SQLITEINT_H_
  49. /*
  50. ** These #defines should enable >2GB file support on POSIX if the
  51. ** underlying operating system supports it. If the OS lacks
  52. ** large file support, or if the OS is windows, these should be no-ops.
  53. **
  54. ** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any
  55. ** system #includes. Hence, this block of code must be the very first
  56. ** code in all source files.
  57. **
  58. ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
  59. ** on the compiler command line. This is necessary if you are compiling
  60. ** on a recent machine (ex: Red Hat 7.2) but you want your code to work
  61. ** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
  62. ** without this option, LFS is enable. But LFS does not exist in the kernel
  63. ** in Red Hat 6.0, so the code won't work. Hence, for maximum binary
  64. ** portability you should omit LFS.
  65. **
  66. ** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later.
  67. */
  68. //#if !SQLITE_DISABLE_LFS
  69. //# define _LARGE_FILE 1
  70. //# ifndef _FILE_OFFSET_BITS
  71. //# define _FILE_OFFSET_BITS 64
  72. //# endif
  73. //# define _LARGEFILE_SOURCE 1
  74. //#endif
  75. /*
  76. ** Include the configuration header output by 'configure' if we're using the
  77. ** autoconf-based build
  78. */
  79. #if _HAVE_SQLITE_CONFIG_H
  80. //#include "config.h"
  81. #endif
  82. //#include "sqliteLimit.h"
  83. /* Disable nuisance warnings on Borland compilers */
  84. //#if (__BORLANDC__)
  85. //#pragma warn -rch /* unreachable code */
  86. //#pragma warn -ccc /* Condition is always true or false */
  87. //#pragma warn -aus /* Assigned value is never used */
  88. //#pragma warn -csu /* Comparing signed and unsigned */
  89. //#pragma warn -spa /* Suspicious pointer arithmetic */
  90. //#endif
  91. /* Needed for various definitions... */
  92. //#if !_GNU_SOURCE
  93. //#define _GNU_SOURCE
  94. //#endif
  95. /*
  96. ** Include standard header files as necessary
  97. */
  98. #if HAVE_STDINT_H
  99. //#include <stdint.h>
  100. #endif
  101. #if HAVE_INTTYPES_H
  102. //#include <inttypes.h>
  103. #endif
  104. /*
  105. ** The number of samples of an index that SQLite takes in order to
  106. ** construct a histogram of the table content when running ANALYZE
  107. ** and with SQLITE_ENABLE_STAT2
  108. */
  109. //#define SQLITE_INDEX_SAMPLES 10
  110. public const int SQLITE_INDEX_SAMPLES = 10;
  111. /*
  112. ** The following macros are used to cast pointers to integers and
  113. ** integers to pointers. The way you do this varies from one compiler
  114. ** to the next, so we have developed the following set of #if statements
  115. ** to generate appropriate macros for a wide range of compilers.
  116. **
  117. ** The correct "ANSI" way to do this is to use the intptr_t type.
  118. ** Unfortunately, that typedef is not available on all compilers, or
  119. ** if it is available, it requires an #include of specific headers
  120. ** that vary from one machine to the next.
  121. **
  122. ** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
  123. ** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
  124. ** So we have to define the macros in different ways depending on the
  125. ** compiler.
  126. */
  127. //#if (__PTRDIFF_TYPE__) /* This case should work for GCC */
  128. //# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
  129. //# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
  130. //#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
  131. //# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
  132. //# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
  133. //#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
  134. //# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
  135. //# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
  136. //#else /* Generates a warning - but it always works */
  137. //# define SQLITE_INT_TO_PTR(X) ((void*)(X))
  138. //# define SQLITE_PTR_TO_INT(X) ((int)(X))
  139. //#endif
  140. /*
  141. ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
  142. ** 0 means mutexes are permanently disable and the library is never
  143. ** threadsafe. 1 means the library is serialized which is the highest
  144. ** level of threadsafety. 2 means the libary is multithreaded - multiple
  145. ** threads can use SQLite as long as no two threads try to use the same
  146. ** database connection at the same time.
  147. **
  148. ** Older versions of SQLite used an optional THREADSAFE macro.
  149. ** We support that for legacy.
  150. */
  151. #if !SQLITE_THREADSAFE
  152. //# define SQLITE_THREADSAFE 2
  153. const int SQLITE_THREADSAFE = 2;
  154. #else
  155. const int SQLITE_THREADSAFE = 2; /* IMP: R-07272-22309 */
  156. #endif
  157. /*
  158. ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
  159. ** It determines whether or not the features related to
  160. ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
  161. ** be overridden at runtime using the sqlite3_config() API.
  162. */
  163. #if !(SQLITE_DEFAULT_MEMSTATUS)
  164. //# define SQLITE_DEFAULT_MEMSTATUS 1
  165. const int SQLITE_DEFAULT_MEMSTATUS = 0;
  166. #else
  167. const int SQLITE_DEFAULT_MEMSTATUS = 1;
  168. #endif
  169. /*
  170. ** Exactly one of the following macros must be defined in order to
  171. ** specify which memory allocation subsystem to use.
  172. **
  173. ** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
  174. ** SQLITE_MEMDEBUG // Debugging version of system malloc()
  175. **
  176. ** (Historical note: There used to be several other options, but we've
  177. ** pared it down to just these two.)
  178. **
  179. ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
  180. ** the default.
  181. */
  182. //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\
  183. //# error "At most one of the following compile-time configuration options\
  184. // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG"
  185. //#endif
  186. //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\
  187. //# define SQLITE_SYSTEM_MALLOC 1
  188. //#endif
  189. /*
  190. ** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
  191. ** sizes of memory allocations below this value where possible.
  192. */
  193. #if !(SQLITE_MALLOC_SOFT_LIMIT)
  194. const int SQLITE_MALLOC_SOFT_LIMIT = 1024;
  195. #endif
  196. /*
  197. ** We need to define _XOPEN_SOURCE as follows in order to enable
  198. ** recursive mutexes on most Unix systems. But Mac OS X is different.
  199. ** The _XOPEN_SOURCE define causes problems for Mac OS X we are told,
  200. ** so it is omitted there. See ticket #2673.
  201. **
  202. ** Later we learn that _XOPEN_SOURCE is poorly or incorrectly
  203. ** implemented on some systems. So we avoid defining it at all
  204. ** if it is already defined or if it is unneeded because we are
  205. ** not doing a threadsafe build. Ticket #2681.
  206. **
  207. ** See also ticket #2741.
  208. */
  209. #if !_XOPEN_SOURCE && !__DARWIN__ && !__APPLE__ && SQLITE_THREADSAFE
  210. const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */
  211. #endif
  212. /*
  213. ** The TCL headers are only needed when compiling the TCL bindings.
  214. */
  215. #if SQLITE_TCL || TCLSH
  216. //# include <tcl.h>
  217. #endif
  218. /*
  219. ** Many people are failing to set -DNDEBUG=1 when compiling SQLite.
  220. ** Setting NDEBUG makes the code smaller and run faster. So the following
  221. ** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1
  222. ** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out
  223. ** feature.
  224. */
  225. #if !NDEBUG && !SQLITE_DEBUG
  226. const int NDEBUG = 1;//# define NDEBUG 1
  227. #endif
  228. /*
  229. ** The testcase() macro is used to aid in coverage testing. When
  230. ** doing coverage testing, the condition inside the argument to
  231. ** testcase() must be evaluated both true and false in order to
  232. ** get full branch coverage. The testcase() macro is inserted
  233. ** to help ensure adequate test coverage in places where simple
  234. ** condition/decision coverage is inadequate. For example, testcase()
  235. ** can be used to make sure boundary values are tested. For
  236. ** bitmask tests, testcase() can be used to make sure each bit
  237. ** is significant and used at least once. On switch statements
  238. ** where multiple cases go to the same block of code, testcase()
  239. ** can insure that all cases are evaluated.
  240. **
  241. */
  242. #if SQLITE_COVERAGE_TEST
  243. void sqlite3Coverage(int);
  244. //# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
  245. #else
  246. //# define testcase(X)
  247. static void testcase<T>( T X )
  248. {
  249. }
  250. #endif
  251. /*
  252. ** The TESTONLY macro is used to enclose variable declarations or
  253. ** other bits of code that are needed to support the arguments
  254. ** within testcase() and assert() macros.
  255. */
  256. #if !NDEBUG || SQLITE_COVERAGE_TEST
  257. //# define TESTONLY(X) X
  258. // -- Need workaround for C#, since inline macros don't exist
  259. #else
  260. //# define TESTONLY(X)
  261. #endif
  262. /*
  263. ** Sometimes we need a small amount of code such as a variable initialization
  264. ** to setup for a later assert() statement. We do not want this code to
  265. ** appear when assert() is disabled. The following macro is therefore
  266. ** used to contain that setup code. The "VVA" acronym stands for
  267. ** "Verification, Validation, and Accreditation". In other words, the
  268. ** code within VVA_ONLY() will only run during verification processes.
  269. */
  270. #if !NDEBUG
  271. //# define VVA_ONLY(X) X
  272. #else
  273. //# define VVA_ONLY(X)
  274. #endif
  275. /*
  276. ** The ALWAYS and NEVER macros surround boolean expressions which
  277. ** are intended to always be true or false, respectively. Such
  278. ** expressions could be omitted from the code completely. But they
  279. ** are included in a few cases in order to enhance the resilience
  280. ** of SQLite to unexpected behavior - to make the code "self-healing"
  281. ** or "ductile" rather than being "brittle" and crashing at the first
  282. ** hint of unplanned behavior.
  283. **
  284. ** In other words, ALWAYS and NEVER are added for defensive code.
  285. **
  286. ** When doing coverage testing ALWAYS and NEVER are hard-coded to
  287. ** be true and false so that the unreachable code then specify will
  288. ** not be counted as untested code.
  289. */
  290. #if SQLITE_COVERAGE_TEST
  291. //# define ALWAYS(X) (1)
  292. //# define NEVER(X) (0)
  293. #elif !NDEBUG
  294. //# define ALWAYS(X) ((X)?1:(assert(0),0))
  295. static bool ALWAYS( bool X )
  296. {
  297. if ( X != true )
  298. Debug.Assert( false );
  299. return true;
  300. }
  301. static int ALWAYS( int X )
  302. {
  303. if ( X == 0 )
  304. Debug.Assert( false );
  305. return 1;
  306. }
  307. static bool ALWAYS<T>( T X )
  308. {
  309. if ( X == null )
  310. Debug.Assert( false );
  311. return true;
  312. }
  313. //# define NEVER(X) ((X)?(assert(0),1):0)
  314. static bool NEVER( bool X )
  315. {
  316. if ( X == true )
  317. Debug.Assert( false );
  318. return false;
  319. }
  320. static byte NEVER( byte X )
  321. {
  322. if ( X != 0 )
  323. Debug.Assert( false );
  324. return 0;
  325. }
  326. static int NEVER( int X )
  327. {
  328. if ( X != 0 )
  329. Debug.Assert( false );
  330. return 0;
  331. }
  332. static bool NEVER<T>( T X )
  333. {
  334. if ( X != null )
  335. Debug.Assert( false );
  336. return false;
  337. }
  338. #else
  339. //# define ALWAYS(X) (X)
  340. static bool ALWAYS(bool X) { return X; }
  341. static byte ALWAYS(byte X) { return X; }
  342. static int ALWAYS(int X) { return X; }
  343. static bool ALWAYS<T>( T X ) { return true; }
  344. //# define NEVER(X) (X)
  345. static bool NEVER(bool X) { return X; }
  346. static byte NEVER(byte X) { return X; }
  347. static int NEVER(int X) { return X; }
  348. static bool NEVER<T>(T X) { return false; }
  349. #endif
  350. /*
  351. ** Return true (non-zero) if the input is a integer that is too large
  352. ** to fit in 32-bits. This macro is used inside of various testcase()
  353. ** macros to verify that we have tested SQLite for large-file support.
  354. */
  355. static bool IS_BIG_INT( i64 X )
  356. {
  357. return ( ( ( X ) & ~(i64)0xffffffff ) != 0 );
  358. }//#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
  359. /*
  360. ** The macro unlikely() is a hint that surrounds a boolean
  361. ** expression that is usually false. Macro likely() surrounds
  362. ** a boolean expression that is usually true. GCC is able to
  363. ** use these hints to generate better code, sometimes.
  364. */
  365. #if (__GNUC__) && FALSE
  366. //# define likely(X) __builtin_expect((X),1)
  367. //# define unlikely(X) __builtin_expect((X),0)
  368. #else
  369. //# define likely(X) !!(X)
  370. static bool likely( bool X )
  371. {
  372. return !!X;
  373. }
  374. //# define unlikely(X) !!(X)
  375. static bool unlikely( bool X )
  376. {
  377. return !!X;
  378. }
  379. #endif
  380. //#include "sqlite3.h"
  381. //#include "hash.h"
  382. //#include "parse.h"
  383. //#include <stdio.h>
  384. //#include <stdlib.h>
  385. //#include <string.h>
  386. //#include <assert.h>
  387. //#include <stddef.h>
  388. /*
  389. ** If compiling for a processor that lacks floating point support,
  390. ** substitute integer for floating-point
  391. */
  392. #if SQLITE_OMIT_FLOATING_POINT
  393. //# define double sqlite_int64
  394. //# define float sqlite_int64
  395. //# define LONGDOUBLE_TYPE sqlite_int64
  396. //#if !SQLITE_BIG_DBL
  397. //# define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
  398. //# endif
  399. //# define SQLITE_OMIT_DATETIME_FUNCS 1
  400. //# define SQLITE_OMIT_TRACE 1
  401. //# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
  402. //# undef SQLITE_HAVE_ISNAN
  403. #endif
  404. #if !SQLITE_BIG_DBL
  405. const double SQLITE_BIG_DBL = ( ( (sqlite3_int64)1 ) << 60 );//# define SQLITE_BIG_DBL (1e99)
  406. #endif
  407. /*
  408. ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0
  409. ** afterward. Having this macro allows us to cause the C compiler
  410. ** to omit code used by TEMP tables without messy #if !statements.
  411. */
  412. #if SQLITE_OMIT_TEMPDB
  413. //#define OMIT_TEMPDB 1
  414. #else
  415. static int OMIT_TEMPDB = 0;
  416. #endif
  417. /*
  418. ** The "file format" number is an integer that is incremented whenever
  419. ** the VDBE-level file format changes. The following macros define the
  420. ** the default file format for new databases and the maximum file format
  421. ** that the library can read.
  422. */
  423. static public int SQLITE_MAX_FILE_FORMAT = 4;//#define SQLITE_MAX_FILE_FORMAT 4
  424. //#if !SQLITE_DEFAULT_FILE_FORMAT
  425. static int SQLITE_DEFAULT_FILE_FORMAT = 1;//# define SQLITE_DEFAULT_FILE_FORMAT 1
  426. //#endif
  427. /*
  428. ** Determine whether triggers are recursive by default. This can be
  429. ** changed at run-time using a pragma.
  430. */
  431. #if !SQLITE_DEFAULT_RECURSIVE_TRIGGERS
  432. //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0
  433. static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = false;
  434. #else
  435. static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = true;
  436. #endif
  437. /*
  438. ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
  439. ** on the command-line
  440. */
  441. //#if !SQLITE_TEMP_STORE
  442. static int SQLITE_TEMP_STORE = 1;//#define SQLITE_TEMP_STORE 1
  443. //#endif
  444. /*
  445. ** GCC does not define the offsetof() macro so we'll have to do it
  446. ** ourselves.
  447. */
  448. #if !offsetof
  449. //#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
  450. #endif
  451. /*
  452. ** Check to see if this machine uses EBCDIC. (Yes, believe it or
  453. ** not, there are still machines out there that use EBCDIC.)
  454. */
  455. #if FALSE //'A' == '\301'
  456. //# define SQLITE_EBCDIC 1
  457. #else
  458. const int SQLITE_ASCII = 1;//#define SQLITE_ASCII 1
  459. #endif
  460. /*
  461. ** Integers of known sizes. These typedefs might change for architectures
  462. ** where the sizes very. Preprocessor macros are available so that the
  463. ** types can be conveniently redefined at compile-type. Like this:
  464. **
  465. ** cc '-Du32PTR_TYPE=long long int' ...
  466. */
  467. //#if !u32_TYPE
  468. //# ifdef HAVE_u32_T
  469. //# define u32_TYPE u32_t
  470. //# else
  471. //# define u32_TYPE unsigned int
  472. //# endif
  473. //#endif
  474. //#if !u3216_TYPE
  475. //# ifdef HAVE_u3216_T
  476. //# define u3216_TYPE u3216_t
  477. //# else
  478. //# define u3216_TYPE unsigned short int
  479. //# endif
  480. //#endif
  481. //#if !INT16_TYPE
  482. //# ifdef HAVE_INT16_T
  483. //# define INT16_TYPE int16_t
  484. //# else
  485. //# define INT16_TYPE short int
  486. //# endif
  487. //#endif
  488. //#if !u328_TYPE
  489. //# ifdef HAVE_u328_T
  490. //# define u328_TYPE u328_t
  491. //# else
  492. //# define u328_TYPE unsigned char
  493. //# endif
  494. //#endif
  495. //#if !INT8_TYPE
  496. //# ifdef HAVE_INT8_T
  497. //# define INT8_TYPE int8_t
  498. //# else
  499. //# define INT8_TYPE signed char
  500. //# endif
  501. //#endif
  502. //#if !LONGDOUBLE_TYPE
  503. //# define LONGDOUBLE_TYPE long double
  504. //#endif
  505. //typedef sqlite_int64 i64; /* 8-byte signed integer */
  506. //typedef sqlite_u3264 u64; /* 8-byte unsigned integer */
  507. //typedef u32_TYPE u32; /* 4-byte unsigned integer */
  508. //typedef u3216_TYPE u16; /* 2-byte unsigned integer */
  509. //typedef INT16_TYPE i16; /* 2-byte signed integer */
  510. //typedef u328_TYPE u8; /* 1-byte unsigned integer */
  511. //typedef INT8_TYPE i8; /* 1-byte signed integer */
  512. /*
  513. ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value
  514. ** that can be stored in a u32 without loss of data. The value
  515. ** is 0x00000000ffffffff. But because of quirks of some compilers, we
  516. ** have to specify the value in the less intuitive manner shown:
  517. */
  518. //#define SQLITE_MAX_U32 ((((u64)1)<<32)-1)
  519. const u32 SQLITE_MAX_U32 = (u32)( ( ( (u64)1 ) << 32 ) - 1 );
  520. /*
  521. ** Macros to determine whether the machine is big or little endian,
  522. ** evaluated at runtime.
  523. */
  524. #if SQLITE_AMALGAMATION
  525. //const int sqlite3one = 1;
  526. #else
  527. const bool sqlite3one = true;
  528. #endif
  529. #if i386 || __i386__ || _M_IX86
  530. const int ;//#define SQLITE_BIGENDIAN 0
  531. const int ;//#define SQLITE_LITTLEENDIAN 1
  532. const int ;//#define SQLITE_UTF16NATIVE SQLITE_UTF16LE
  533. #else
  534. static u8 SQLITE_BIGENDIAN = 0;//#define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)
  535. static u8 SQLITE_LITTLEENDIAN = 1;//#define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
  536. static u8 SQLITE_UTF16NATIVE = ( SQLITE_BIGENDIAN != 0 ? SQLITE_UTF16BE : SQLITE_UTF16LE );//#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
  537. #endif
  538. /*
  539. ** Constants for the largest and smallest possible 64-bit signed integers.
  540. ** These macros are designed to work correctly on both 32-bit and 64-bit
  541. ** compilers.
  542. */
  543. //#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
  544. //#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
  545. const i64 LARGEST_INT64 = i64.MaxValue;//( 0xffffffff | ( ( (i64)0x7fffffff ) << 32 ) );
  546. const i64 SMALLEST_INT64 = i64.MinValue;//( ( ( i64 ) - 1 ) - LARGEST_INT64 );
  547. /*
  548. ** Round up a number to the next larger multiple of 8. This is used
  549. ** to force 8-byte alignment on 64-bit architectures.
  550. */
  551. //#define ROUND8(x) (((x)+7)&~7)
  552. static int ROUND8( int x )
  553. {
  554. return ( x + 7 ) & ~7;
  555. }
  556. /*
  557. ** Round down to the nearest multiple of 8
  558. */
  559. //#define ROUNDDOWN8(x) ((x)&~7)
  560. static int ROUNDDOWN8( int x )
  561. {
  562. return x & ~7;
  563. }
  564. /*
  565. ** Assert that the pointer X is aligned to an 8-byte boundary. This
  566. ** macro is used only within assert() to verify that the code gets
  567. ** all alignment restrictions correct.
  568. **
  569. ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
  570. ** underlying malloc() implemention might return us 4-byte aligned
  571. ** pointers. In that case, only verify 4-byte alignment.
  572. */
  573. //#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
  574. //# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0)
  575. //#else
  576. //# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0)
  577. //#endif
  578. /*
  579. ** An instance of the following structure is used to store the busy-handler
  580. ** callback for a given sqlite handle.
  581. **
  582. ** The sqlite.busyHandler member of the sqlite struct contains the busy
  583. ** callback for the database handle. Each pager opened via the sqlite
  584. ** handle is passed a pointer to sqlite.busyHandler. The busy-handler
  585. ** callback is currently invoked only from within pager.c.
  586. */
  587. //typedef struct BusyHandler BusyHandler;
  588. public class BusyHandler
  589. {
  590. public dxBusy xFunc;//)(void *,int); /* The busy callback */
  591. public object pArg; /* First arg to busy callback */
  592. public int nBusy; /* Incremented with each busy call */
  593. };
  594. /*
  595. ** Name of the master database table. The master database table
  596. ** is a special table that holds the names and attributes of all
  597. ** user tables and indices.
  598. */
  599. const string MASTER_NAME = "sqlite_master";//#define MASTER_NAME "sqlite_master"
  600. const string TEMP_MASTER_NAME = "sqlite_temp_master";//#define TEMP_MASTER_NAME "sqlite_temp_master"
  601. /*
  602. ** The root-page of the master database table.
  603. */
  604. const int MASTER_ROOT = 1;//#define MASTER_ROOT 1
  605. /*
  606. ** The name of the schema table.
  607. */
  608. static string SCHEMA_TABLE( int x ) //#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)
  609. {
  610. return ( ( OMIT_TEMPDB == 0 ) && ( x == 1 ) ? TEMP_MASTER_NAME : MASTER_NAME );
  611. }
  612. /*
  613. ** A convenience macro that returns the number of elements in
  614. ** an array.
  615. */
  616. //#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0])))
  617. static int ArraySize<T>( T[] x )
  618. {
  619. return x.Length;
  620. }
  621. /*
  622. ** The following value as a destructor means to use sqlite3DbFree().
  623. ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT.
  624. */
  625. //#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree)
  626. static dxDel SQLITE_DYNAMIC;
  627. /*
  628. ** When SQLITE_OMIT_WSD is defined, it means that the target platform does
  629. ** not support Writable Static Data (WSD) such as global and static variables.
  630. ** All variables must either be on the stack or dynamically allocated from
  631. ** the heap. When WSD is unsupported, the variable declarations scattered
  632. ** throughout the SQLite code must become constants instead. The SQLITE_WSD
  633. ** macro is used for this purpose. And instead of referencing the variable
  634. ** directly, we use its constant as a key to lookup the run-time allocated
  635. ** buffer that holds real variable. The constant is also the initializer
  636. ** for the run-time allocated buffer.
  637. **
  638. ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL
  639. ** macros become no-ops and have zero performance impact.
  640. */
  641. #if SQLITE_OMIT_WSD
  642. //#define SQLITE_WSD const
  643. //#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
  644. //#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
  645. int sqlite3_wsd_init(int N, int J);
  646. void *sqlite3_wsd_find(void *K, int L);
  647. #else
  648. //#define SQLITE_WSD
  649. //#define GLOBAL(t,v) v
  650. //#define sqlite3GlobalConfig sqlite3Config
  651. static Sqlite3Config sqlite3GlobalConfig;
  652. #endif
  653. /*
  654. ** The following macros are used to suppress compiler warnings and to
  655. ** make it clear to human readers when a function parameter is deliberately
  656. ** left unused within the body of a function. This usually happens when
  657. ** a function is called via a function pointer. For example the
  658. ** implementation of an SQL aggregate step callback may not use the
  659. ** parameter indicating the number of arguments passed to the aggregate,
  660. ** if it knows that this is enforced elsewhere.
  661. **
  662. ** When a function parameter is not used at all within the body of a function,
  663. ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer.
  664. ** However, these macros may also be used to suppress warnings related to
  665. ** parameters that may or may not be used depending on compilation options.
  666. ** For example those parameters only used in assert() statements. In these
  667. ** cases the parameters are named as per the usual conventions.
  668. */
  669. //#define UNUSED_PARAMETER(x) (void)(x)
  670. static void UNUSED_PARAMETER<T>( T x )
  671. {
  672. }
  673. //#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)
  674. static void UNUSED_PARAMETER2<T1, T2>( T1 x, T2 y )
  675. {
  676. UNUSED_PARAMETER( x );
  677. UNUSED_PARAMETER( y );
  678. }
  679. /*
  680. ** Forward references to structures
  681. */
  682. //typedef struct AggInfo AggInfo;
  683. //typedef struct AuthContext AuthContext;
  684. //typedef struct AutoincInfo AutoincInfo;
  685. //typedef struct Bitvec Bitvec;
  686. //typedef struct CollSeq CollSeq;
  687. //typedef struct Column Column;
  688. //typedef struct Db Db;
  689. //typedef struct Schema Schema;
  690. //typedef struct Expr Expr;
  691. //typedef struct ExprList ExprList;
  692. //typedef struct ExprSpan ExprSpan;
  693. //typedef struct FKey FKey;
  694. //typedef struct FuncDestructor FuncDestructor;
  695. //typedef struct FuncDef FuncDef;
  696. //typedef struct IdList IdList;
  697. //typedef struct Index Index;
  698. //typedef struct IndexSample IndexSample;
  699. //typedef struct KeyClass KeyClass;
  700. //typedef struct KeyInfo KeyInfo;
  701. //typedef struct Lookaside Lookaside;
  702. //typedef struct LookasideSlot LookasideSlot;
  703. //typedef struct Module Module;
  704. //typedef struct NameContext NameContext;
  705. //typedef struct Parse Parse;
  706. //typedef struct RowSet RowSet;
  707. //typedef struct Savepoint Savepoint;
  708. //typedef struct Select Select;
  709. //typedef struct SrcList SrcList;
  710. //typedef struct StrAccum StrAccum;
  711. //typedef struct Table Table;
  712. //typedef struct TableLock TableLock;
  713. //typedef struct Token Token;
  714. //typedef struct Trigger Trigger;
  715. //typedef struct TriggerPrg TriggerPrg;
  716. //typedef struct TriggerStep TriggerStep;
  717. //typedef struct UnpackedRecord UnpackedRecord;
  718. //typedef struct VTable VTable;
  719. //typedef struct Walker Walker;
  720. //typedef struct WherePlan WherePlan;
  721. //typedef struct WhereInfo WhereInfo;
  722. //typedef struct WhereLevel WhereLevel;
  723. /*
  724. ** Defer sourcing vdbe.h and btree.h until after the "u8" and
  725. ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque
  726. ** pointer types (i.e. FuncDef) defined above.
  727. */
  728. //#include "btree.h"
  729. //#include "vdbe.h"
  730. //#include "pager.h"
  731. //#include "pcache_g.h"
  732. //#include "os.h"
  733. //#include "mutex.h"
  734. /*
  735. ** Each database file to be accessed by the system is an instance
  736. ** of the following structure. There are normally two of these structures
  737. ** in the sqlite.aDb[] array. aDb[0] is the main database file and
  738. ** aDb[1] is the database file used to hold temporary tables. Additional
  739. ** databases may be attached.
  740. */
  741. public class Db
  742. {
  743. public string zName; /* Name of this database */
  744. public Btree pBt; /* The B Tree structure for this database file */
  745. public u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */
  746. public u8 safety_level; /* How aggressive at syncing data to disk */
  747. public Schema pSchema; /* Pointer to database schema (possibly shared) */
  748. };
  749. /*
  750. ** An instance of the following structure stores a database schema.
  751. */
  752. public class Schema
  753. {
  754. public int schema_cookie; /* Database schema version number for this file */
  755. public Hash tblHash = new Hash(); /* All tables indexed by name */
  756. public Hash idxHash = new Hash(); /* All (named) indices indexed by name */
  757. public Hash trigHash = new Hash();/* All triggers indexed by name */
  758. public Hash fkeyHash = new Hash();/* All foreign keys by referenced table name */
  759. public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
  760. public u8 file_format; /* Schema format version for this file */
  761. public u8 enc; /* Text encoding used by this database */
  762. public u16 flags; /* Flags associated with this schema */
  763. public int cache_size; /* Number of pages to use in the cache */
  764. public Schema Copy()
  765. {
  766. if ( this == null )
  767. return null;
  768. else
  769. {
  770. Schema cp = (Schema)MemberwiseClone();
  771. return cp;
  772. }
  773. }
  774. public void Clear()
  775. {
  776. if ( this != null )
  777. {
  778. schema_cookie = 0;
  779. tblHash = new Hash();
  780. idxHash = new Hash();
  781. trigHash = new Hash();
  782. fkeyHash = new Hash();
  783. pSeqTab = null;
  784. flags = 0;
  785. }
  786. }
  787. };
  788. /*
  789. ** These macros can be used to test, set, or clear bits in the
  790. ** Db.pSchema->flags field.
  791. */
  792. //#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P))
  793. static bool DbHasProperty( sqlite3 D, int I, ushort P )
  794. {
  795. return ( D.aDb[I].pSchema.flags & P ) == P;
  796. }
  797. //#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0)
  798. //#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P)
  799. static void DbSetProperty( sqlite3 D, int I, ushort P )
  800. {
  801. D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags | P );
  802. }
  803. //#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P)
  804. static void DbClearProperty( sqlite3 D, int I, ushort P )
  805. {
  806. D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags & ~P );
  807. }
  808. /*
  809. ** Allowed values for the DB.pSchema->flags field.
  810. **
  811. ** The DB_SchemaLoaded flag is set after the database schema has been
  812. ** read into internal hash tables.
  813. **
  814. ** DB_UnresetViews means that one or more views have column names that
  815. ** have been filled out. If the schema changes, these column names might
  816. ** changes and so the view will need to be reset.
  817. */
  818. //#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */
  819. //#define DB_UnresetViews 0x0002 /* Some views have defined column names */
  820. //#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */
  821. const u16 DB_SchemaLoaded = 0x0001;
  822. const u16 DB_UnresetViews = 0x0002;
  823. const u16 DB_Empty = 0x0004;
  824. /*
  825. ** The number of different kinds of things that can be limited
  826. ** using the sqlite3_limit() interface.
  827. */
  828. //#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1)
  829. const int SQLITE_N_LIMIT = SQLITE_LIMIT_TRIGGER_DEPTH + 1;
  830. /*
  831. ** Lookaside malloc is a set of fixed-size buffers that can be used
  832. ** to satisfy small transient memory allocation requests for objects
  833. ** associated with a particular database connection. The use of
  834. ** lookaside malloc provides a significant performance enhancement
  835. ** (approx 10%) by avoiding numerous malloc/free requests while parsing
  836. ** SQL statements.
  837. **
  838. ** The Lookaside structure holds configuration information about the
  839. ** lookaside malloc subsystem. Each available memory allocation in
  840. ** the lookaside subsystem is stored on a linked list of LookasideSlot
  841. ** objects.
  842. **
  843. ** Lookaside allocations are only allowed for objects that are associated
  844. ** with a particular database connection. Hence, schema information cannot
  845. ** be stored in lookaside because in shared cache mode the schema information
  846. ** is shared by multiple database connections. Therefore, while parsing
  847. ** schema information, the Lookaside.bEnabled flag is cleared so that
  848. ** lookaside allocations are not used to construct the schema objects.
  849. */
  850. public class Lookaside
  851. {
  852. public int sz; /* Size of each buffer in bytes */
  853. public u8 bEnabled; /* False to disable new lookaside allocations */
  854. public bool bMalloced; /* True if pStart obtained from sqlite3_malloc() */
  855. public int nOut; /* Number of buffers currently checked out */
  856. public int mxOut; /* Highwater mark for nOut */
  857. public int[] anStat = new int[3]; /* 0: hits. 1: size misses. 2: full misses */
  858. public LookasideSlot pFree; /* List of available buffers */
  859. public int pStart; /* First byte of available memory space */
  860. public int pEnd; /* First byte past end of available space */
  861. };
  862. public class LookasideSlot
  863. {
  864. public LookasideSlot pNext; /* Next buffer in the list of free buffers */
  865. };
  866. /*
  867. ** A hash table for function definitions.
  868. **
  869. ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.
  870. ** Collisions are on the FuncDef.pHash chain.
  871. */
  872. public class FuncDefHash
  873. {
  874. public FuncDef[] a = new FuncDef[23]; /* Hash table for functions */
  875. };
  876. /*
  877. ** Each database connection is an instance of the following structure.
  878. **
  879. ** The sqlite.lastRowid records the last insert rowid generated by an
  880. ** insert statement. Inserts on views do not affect its value. Each
  881. ** trigger has its own context, so that lastRowid can be updated inside
  882. ** triggers as usual. The previous value will be restored once the trigger
  883. ** exits. Upon entering a before or instead of trigger, lastRowid is no
  884. ** longer (since after version 2.8.12) reset to -1.
  885. **
  886. ** The sqlite.nChange does not count changes within triggers and keeps no
  887. ** context. It is reset at start of sqlite3_exec.
  888. ** The sqlite.lsChange represents the number of changes made by the last
  889. ** insert, update, or delete statement. It remains constant throughout the
  890. ** length of a statement and is then updated by OP_SetCounts. It keeps a
  891. ** context stack just like lastRowid so that the count of changes
  892. ** within a trigger is not seen outside the trigger. Changes to views do not
  893. ** affect the value of lsChange.
  894. ** The sqlite.csChange keeps track of the number of current changes (since
  895. ** the last statement) and is used to update sqlite_lsChange.
  896. **
  897. ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16
  898. ** store the most recent error code and, if applicable, string. The
  899. ** internal function sqlite3Error() is used to set these variables
  900. ** consistently.
  901. */
  902. public class sqlite3
  903. {
  904. public sqlite3_vfs pVfs; /* OS Interface */
  905. public int nDb; /* Number of backends currently in use */
  906. public Db[] aDb = new Db[SQLITE_MAX_ATTACHED]; /* All backends */
  907. public int flags; /* Miscellaneous flags. See below */
  908. public int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
  909. public int errCode; /* Most recent error code (SQLITE_*) */
  910. public int errMask; /* & result codes with this before returning */
  911. public u8 autoCommit; /* The auto-commit flag. */
  912. public u8 temp_store; /* 1: file 2: memory 0: default */
  913. // Cannot happen under C#
  914. // public u8 mallocFailed; /* True if we have seen a malloc failure */
  915. public u8 dfltLockMode; /* Default locking-mode for attached dbs */
  916. public int nextAutovac; /* Autovac setting after VACUUM if >=0 */
  917. public u8 suppressErr; /* Do not issue error messages if true */
  918. public int nextPagesize; /* Pagesize after VACUUM if >0 */
  919. public int nTable; /* Number of tables in the database */
  920. public CollSeq pDfltColl; /* The default collating sequence (BINARY) */
  921. public i64 lastRowid; /* ROWID of most recent insert (see above) */
  922. public u32 magic; /* Magic number for detect library misuse */
  923. public int nChange; /* Value returned by sqlite3_changes() */
  924. public int nTotalChange; /* Value returned by sqlite3_total_changes() */
  925. public sqlite3_mutex mutex; /* Connection mutex */
  926. public int[] aLimit = new int[SQLITE_N_LIMIT]; /* Limits */
  927. public class sqlite3InitInfo
  928. { /* Information used during initialization */
  929. public int iDb; /* When back is being initialized */
  930. public int newTnum; /* Rootpage of table being initialized */
  931. public u8 busy; /* TRUE if currently initializing */
  932. public u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
  933. };
  934. public sqlite3InitInfo init = new sqlite3InitInfo();
  935. public int nExtension; /* Number of loaded extensions */
  936. public object[] aExtension; /* Array of shared library handles */
  937. public Vdbe pVdbe; /* List of active virtual machines */
  938. public int activeVdbeCnt; /* Number of VDBEs currently executing */
  939. public int writeVdbeCnt; /* Number of active VDBEs that are writing */
  940. public int vdbeExecCnt; /* Number of nested calls to VdbeExec() */
  941. public dxTrace xTrace;//)(void*,const char*); /* Trace function */
  942. public object pTraceArg; /* Argument to the trace function */
  943. public dxProfile xProfile;//)(void*,const char*,u64); /* Profiling function */
  944. public object pProfileArg; /* Argument to profile function */
  945. public object pCommitArg; /* Argument to xCommitCallback() */
  946. public dxCommitCallback xCommitCallback;//)(void*); /* Invoked at every commit. */
  947. public object pRollbackArg; /* Argument to xRollbackCallback() */
  948. public dxRollbackCallback xRollbackCallback;//)(void*); /* Invoked at every commit. */
  949. public object pUpdateArg;
  950. public dxUpdateCallback xUpdateCallback;//)(void*,int, const char*,const char*,sqlite_int64);
  951. #if !SQLITE_OMIT_WAL
  952. //int (*xWalCallback)(void *, sqlite3 *, const char *, int);
  953. //void *pWalArg;
  954. #endif
  955. public dxCollNeeded xCollNeeded;//)(void*,sqlite3*,int eTextRep,const char*);
  956. public dxCollNeeded xCollNeeded16;//)(void*,sqlite3*,int eTextRep,const void*);
  957. public object pCollNeededArg;
  958. public sqlite3_value pErr; /* Most recent error message */
  959. public string zErrMsg; /* Most recent error message (UTF-8 encoded) */
  960. public string zErrMsg16; /* Most recent error message (UTF-16 encoded) */
  961. public struct _u1
  962. {
  963. public bool isInterrupted; /* True if sqlite3_interrupt has been called */
  964. public double notUsed1; /* Spacer */
  965. }
  966. public _u1 u1;
  967. public Lookaside lookaside = new Lookaside(); /* Lookaside malloc configuration */
  968. #if !SQLITE_OMIT_AUTHORIZATION
  969. public dxAuth xAuth;//)(void*,int,const char*,const char*,const char*,const char*);
  970. /* Access authorization function */
  971. public object pAuthArg; /* 1st argument to the access auth function */
  972. #endif
  973. #if !SQLITE_OMIT_PROGRESS_CALLBACK
  974. public dxProgress xProgress;//)(void *); /* The progress callback */
  975. public object pProgressArg; /* Argument to the progress callback */
  976. public int nProgressOps; /* Number of opcodes for progress callback */
  977. #endif
  978. #if !SQLITE_OMIT_VIRTUALTABLE
  979. public Hash aModule; /* populated by sqlite3_create_module() */
  980. public Table pVTab; /* vtab with active Connect/Create method */
  981. public VTable aVTrans; /* Virtual tables with open transactions */
  982. public int nVTrans; /* Allocated size of aVTrans */
  983. public VTable pDisconnect; /* Disconnect these in next sqlite3_prepare() */
  984. #endif
  985. public FuncDefHash aFunc = new FuncDefHash(); /* Hash table of connection functions */
  986. public Hash aCollSeq = new Hash(); /* All collating sequences */
  987. public BusyHandler busyHandler = new BusyHandler(); /* Busy callback */
  988. public int busyTimeout; /* Busy handler timeout, in msec */
  989. public Db[] aDbStatic = new Db[] { new Db(), new Db() }; /* Static space for the 2 default backends */
  990. public Savepoint pSavepoint; /* List of active savepoints */
  991. public int nSavepoint; /* Number of non-transaction savepoints */
  992. public int nStatement; /* Number of nested statement-transactions */
  993. public u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
  994. public i64 nDeferredCons; /* Net deferred constraints this transaction. */
  995. public int pnBytesFreed; /* If not NULL, increment this in DbFree() */
  996. #if SQLITE_ENABLE_UNLOCK_NOTIFY
  997. /* The following variables are all protected by the STATIC_MASTER
  998. ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
  999. **
  1000. ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
  1001. ** unlock so that it can proceed.
  1002. **
  1003. ** When X.pBlockingConnection==Y, that means that something that X tried
  1004. ** tried to do recently failed with an SQLITE_LOCKED error due to locks
  1005. ** held by Y.
  1006. */
  1007. sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */
  1008. sqlite3 *pUnlockConnection; /* Connection to watch for unlock */
  1009. void *pUnlockArg; /* Argument to xUnlockNotify */
  1010. void (*xUnlockNotify)(void **, int); /* Unlock notify callback */
  1011. sqlite3 *pNextBlocked; /* Next in list of all blocked connections */
  1012. #endif
  1013. };
  1014. /*
  1015. ** A macro to discover the encoding of a database.
  1016. */
  1017. //#define ENC(db) ((db)->aDb[0].pSchema->enc)
  1018. static u8 ENC( sqlite3 db )
  1019. {
  1020. return db.aDb[0].pSchema.enc;
  1021. }
  1022. /*
  1023. ** Possible values for the sqlite3.flags.
  1024. */
  1025. //#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */
  1026. //#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */
  1027. //#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */
  1028. //#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */
  1029. //#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */
  1030. // /* DELETE, or UPDATE and return */
  1031. // /* the count using a callback. */
  1032. //#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */
  1033. // /* result set is empty */
  1034. //#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */
  1035. //#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */
  1036. //#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */
  1037. //#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when
  1038. // ** accessing read-only databases */
  1039. //#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */
  1040. //#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */
  1041. //#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */
  1042. //#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */
  1043. //#define SQLITE_CkptFullFSync 0x00400000 /* Use full fsync for checkpoint */
  1044. //#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */
  1045. //#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */
  1046. //#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */
  1047. //#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */
  1048. //#define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */
  1049. //#define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */
  1050. //#define SQLITE_LoadExtension 0x20000000 /* Enable load_extension */
  1051. const int SQLITE_VdbeTrace = 0x00000100;
  1052. const int SQLITE_InternChanges = 0x00000200;
  1053. const int SQLITE_FullColNames = 0x00000400;
  1054. const int SQLITE_ShortColNames = 0x00000800;
  1055. const int SQLITE_CountRows = 0x00001000;
  1056. const int SQLITE_NullCallback = 0x00002000;
  1057. const int SQLITE_SqlTrace = 0x00004000;
  1058. const int SQLITE_VdbeListing = 0x00008000;
  1059. const int SQLITE_WriteSchema = 0x00010000;
  1060. const int SQLITE_NoReadlock = 0x00020000;
  1061. const int SQLITE_IgnoreChecks = 0x00040000;
  1062. const int SQLITE_ReadUncommitted = 0x0080000;
  1063. const int SQLITE_LegacyFileFmt = 0x00100000;
  1064. const int SQLITE_FullFSync = 0x00200000;
  1065. const int SQLITE_CkptFullFSync = 0x00400000;
  1066. const int SQLITE_RecoveryMode = 0x00800000;
  1067. const int SQLITE_ReverseOrder = 0x01000000;
  1068. const int SQLITE_RecTriggers = 0x02000000;
  1069. const int SQLITE_ForeignKeys = 0x04000000;
  1070. const int SQLITE_AutoIndex = 0x08000000;
  1071. const int SQLITE_PreferBuiltin = 0x10000000;
  1072. const int SQLITE_LoadExtension = 0x20000000;
  1073. /*
  1074. ** Bits of the sqlite3.flags field that are used by the
  1075. ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface.
  1076. ** These must be the low-order bits of the flags field.
  1077. */
  1078. //#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */
  1079. //#define SQLITE_ColumnCache 0x02 /* Disable the column cache */
  1080. //#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */
  1081. //#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */
  1082. //#define SQLITE_IndexCover 0x10 /* Disable index covering table */
  1083. //#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */
  1084. //#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */
  1085. //#define SQLITE_OptMask 0xff /* Mask of all disablable opts */
  1086. const int SQLITE_QueryFlattener = 0x01;
  1087. const int SQLITE_ColumnCache = 0x02;
  1088. const int SQLITE_IndexSort = 0x04;
  1089. const int SQLITE_IndexSearch = 0x08;
  1090. const int SQLITE_IndexCover = 0x10;
  1091. const int SQLITE_GroupByOrder = 0x20;
  1092. const int SQLITE_FactorOutConst = 0x40;
  1093. const int SQLITE_OptMask = 0xff;
  1094. /*
  1095. ** Possible values for the sqlite.magic field.
  1096. ** The numbers are obtained at random and have no special meaning, other
  1097. ** than being distinct from one another.
  1098. */
  1099. const int SQLITE_MAGIC_OPEN = 0x1029a697; //#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
  1100. const int SQLITE_MAGIC_CLOSED = 0x2f3c2d33; //#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */
  1101. const int SQLITE_MAGIC_SICK = 0x3b771290; //#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */
  1102. const int SQLITE_MAGIC_BUSY = 0x403b7906; //#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */
  1103. const int SQLITE_MAGIC_ERROR = 0x55357930; //#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */
  1104. /*
  1105. ** Each SQL function is defined by an instance of the following
  1106. ** structure. A pointer to this structure is stored in the sqlite.aFunc
  1107. ** hash table. When multiple functions have the same name, the hash table
  1108. ** points to a linked list of these structures.
  1109. */
  1110. public class FuncDef
  1111. {
  1112. public i16 nArg; /* Number of arguments. -1 means unlimited */
  1113. public u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */
  1114. public u8 flags; /* Some combination of SQLITE_FUNC_* */
  1115. public object pUserData; /* User data parameter */
  1116. public FuncDef pNext; /* Next function with same name */
  1117. public dxFunc xFunc;//)(sqlite3_context*,int,sqlite3_value**); /* Regular function */
  1118. public dxStep xStep;//)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */
  1119. public dxFinal xFinalize;//)(sqlite3_context*); /* Aggregate finalizer */
  1120. public string zName; /* SQL name of the function. */
  1121. public FuncDef pHash; /* Next with a different name but the same hash */
  1122. public FuncDestructor pDestructor; /* Reference counted destructor function */
  1123. public FuncDef()
  1124. {
  1125. }
  1126. public FuncDef( i16 nArg, u8 iPrefEnc, u8 iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor )
  1127. {
  1128. this.nArg = nArg;
  1129. this.iPrefEnc = iPrefEnc;
  1130. this.flags = iflags;
  1131. this.pUserData = pUserData;
  1132. this.pNext = pNext;
  1133. this.xFunc = xFunc;
  1134. this.xStep = xStep;
  1135. this.xFinalize = xFinalize;
  1136. this.zName = zName;
  1137. this.pHash = pHash;
  1138. this.pDestructor = pDestructor;
  1139. }
  1140. public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxFunc xFunc )
  1141. {
  1142. this.nArg = nAr

Large files files are truncated, but you can click here to view the full file