/drivers/sqlite-wp7/sqlite/sqliteInt_h.cs
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
- #define SQLITE_MAX_EXPR_DEPTH
- using System;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Text;
- using Bitmask = System.UInt64;
- using i16 = System.Int16;
- using i64 = System.Int64;
- using sqlite3_int64 = System.Int64;
- using u8 = System.Byte;
- using u16 = System.UInt16;
- using u32 = System.UInt32;
- using u64 = System.UInt64;
- using unsigned = System.UInt64;
- using Pgno = System.UInt32;
- #if !SQLITE_MAX_VARIABLE_NUMBER
- using ynVar = System.Int16;
- #else
- using ynVar = System.Int32;
- #endif
- namespace Community.CsharpSqlite
- {
- using sqlite3_value = Sqlite3.Mem;
- public partial class Sqlite3
- {
- /*
- ** 2001 September 15
- **
- ** The author disclaims copyright to this source code. In place of
- ** a legal notice, here is a blessing:
- **
- ** May you do good and not evil.
- ** May you find forgiveness for yourself and forgive others.
- ** May you share freely, never taking more than you give.
- **
- *************************************************************************
- ** Internal interface definitions for SQLite.
- **
- *************************************************************************
- ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
- ** C#-SQLite is an independent reimplementation of the SQLite software library
- **
- ** SQLITE_SOURCE_ID: 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7
- **
- *************************************************************************
- */
- //#if !_SQLITEINT_H_
- //#define _SQLITEINT_H_
- /*
- ** These #defines should enable >2GB file support on POSIX if the
- ** underlying operating system supports it. If the OS lacks
- ** large file support, or if the OS is windows, these should be no-ops.
- **
- ** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any
- ** system #includes. Hence, this block of code must be the very first
- ** code in all source files.
- **
- ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
- ** on the compiler command line. This is necessary if you are compiling
- ** on a recent machine (ex: Red Hat 7.2) but you want your code to work
- ** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
- ** without this option, LFS is enable. But LFS does not exist in the kernel
- ** in Red Hat 6.0, so the code won't work. Hence, for maximum binary
- ** portability you should omit LFS.
- **
- ** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later.
- */
- //#if !SQLITE_DISABLE_LFS
- //# define _LARGE_FILE 1
- //# ifndef _FILE_OFFSET_BITS
- //# define _FILE_OFFSET_BITS 64
- //# endif
- //# define _LARGEFILE_SOURCE 1
- //#endif
- /*
- ** Include the configuration header output by 'configure' if we're using the
- ** autoconf-based build
- */
- #if _HAVE_SQLITE_CONFIG_H
- //#include "config.h"
- #endif
- //#include "sqliteLimit.h"
- /* Disable nuisance warnings on Borland compilers */
- //#if (__BORLANDC__)
- //#pragma warn -rch /* unreachable code */
- //#pragma warn -ccc /* Condition is always true or false */
- //#pragma warn -aus /* Assigned value is never used */
- //#pragma warn -csu /* Comparing signed and unsigned */
- //#pragma warn -spa /* Suspicious pointer arithmetic */
- //#endif
- /* Needed for various definitions... */
- //#if !_GNU_SOURCE
- //#define _GNU_SOURCE
- //#endif
- /*
- ** Include standard header files as necessary
- */
- #if HAVE_STDINT_H
- //#include <stdint.h>
- #endif
- #if HAVE_INTTYPES_H
- //#include <inttypes.h>
- #endif
- /*
- ** The number of samples of an index that SQLite takes in order to
- ** construct a histogram of the table content when running ANALYZE
- ** and with SQLITE_ENABLE_STAT2
- */
- //#define SQLITE_INDEX_SAMPLES 10
- public const int SQLITE_INDEX_SAMPLES = 10;
- /*
- ** The following macros are used to cast pointers to integers and
- ** integers to pointers. The way you do this varies from one compiler
- ** to the next, so we have developed the following set of #if statements
- ** to generate appropriate macros for a wide range of compilers.
- **
- ** The correct "ANSI" way to do this is to use the intptr_t type.
- ** Unfortunately, that typedef is not available on all compilers, or
- ** if it is available, it requires an #include of specific headers
- ** that vary from one machine to the next.
- **
- ** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
- ** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
- ** So we have to define the macros in different ways depending on the
- ** compiler.
- */
- //#if (__PTRDIFF_TYPE__) /* This case should work for GCC */
- //# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
- //# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
- //#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
- //# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
- //# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
- //#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
- //# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
- //# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
- //#else /* Generates a warning - but it always works */
- //# define SQLITE_INT_TO_PTR(X) ((void*)(X))
- //# define SQLITE_PTR_TO_INT(X) ((int)(X))
- //#endif
- /*
- ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
- ** 0 means mutexes are permanently disable and the library is never
- ** threadsafe. 1 means the library is serialized which is the highest
- ** level of threadsafety. 2 means the libary is multithreaded - multiple
- ** threads can use SQLite as long as no two threads try to use the same
- ** database connection at the same time.
- **
- ** Older versions of SQLite used an optional THREADSAFE macro.
- ** We support that for legacy.
- */
- #if !SQLITE_THREADSAFE
- //# define SQLITE_THREADSAFE 2
- const int SQLITE_THREADSAFE = 2;
- #else
- const int SQLITE_THREADSAFE = 2; /* IMP: R-07272-22309 */
- #endif
- /*
- ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
- ** It determines whether or not the features related to
- ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
- ** be overridden at runtime using the sqlite3_config() API.
- */
- #if !(SQLITE_DEFAULT_MEMSTATUS)
- //# define SQLITE_DEFAULT_MEMSTATUS 1
- const int SQLITE_DEFAULT_MEMSTATUS = 0;
- #else
- const int SQLITE_DEFAULT_MEMSTATUS = 1;
- #endif
- /*
- ** Exactly one of the following macros must be defined in order to
- ** specify which memory allocation subsystem to use.
- **
- ** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
- ** SQLITE_MEMDEBUG // Debugging version of system malloc()
- **
- ** (Historical note: There used to be several other options, but we've
- ** pared it down to just these two.)
- **
- ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
- ** the default.
- */
- //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\
- //# error "At most one of the following compile-time configuration options\
- // is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG"
- //#endif
- //#if (SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\
- //# define SQLITE_SYSTEM_MALLOC 1
- //#endif
- /*
- ** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
- ** sizes of memory allocations below this value where possible.
- */
- #if !(SQLITE_MALLOC_SOFT_LIMIT)
- const int SQLITE_MALLOC_SOFT_LIMIT = 1024;
- #endif
- /*
- ** We need to define _XOPEN_SOURCE as follows in order to enable
- ** recursive mutexes on most Unix systems. But Mac OS X is different.
- ** The _XOPEN_SOURCE define causes problems for Mac OS X we are told,
- ** so it is omitted there. See ticket #2673.
- **
- ** Later we learn that _XOPEN_SOURCE is poorly or incorrectly
- ** implemented on some systems. So we avoid defining it at all
- ** if it is already defined or if it is unneeded because we are
- ** not doing a threadsafe build. Ticket #2681.
- **
- ** See also ticket #2741.
- */
- #if !_XOPEN_SOURCE && !__DARWIN__ && !__APPLE__ && SQLITE_THREADSAFE
- const int _XOPEN_SOURCE = 500;//#define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */
- #endif
- /*
- ** The TCL headers are only needed when compiling the TCL bindings.
- */
- #if SQLITE_TCL || TCLSH
- //# include <tcl.h>
- #endif
- /*
- ** Many people are failing to set -DNDEBUG=1 when compiling SQLite.
- ** Setting NDEBUG makes the code smaller and run faster. So the following
- ** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1
- ** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out
- ** feature.
- */
- #if !NDEBUG && !SQLITE_DEBUG
- const int NDEBUG = 1;//# define NDEBUG 1
- #endif
- /*
- ** The testcase() macro is used to aid in coverage testing. When
- ** doing coverage testing, the condition inside the argument to
- ** testcase() must be evaluated both true and false in order to
- ** get full branch coverage. The testcase() macro is inserted
- ** to help ensure adequate test coverage in places where simple
- ** condition/decision coverage is inadequate. For example, testcase()
- ** can be used to make sure boundary values are tested. For
- ** bitmask tests, testcase() can be used to make sure each bit
- ** is significant and used at least once. On switch statements
- ** where multiple cases go to the same block of code, testcase()
- ** can insure that all cases are evaluated.
- **
- */
- #if SQLITE_COVERAGE_TEST
- void sqlite3Coverage(int);
- //# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
- #else
- //# define testcase(X)
- static void testcase<T>( T X )
- {
- }
- #endif
- /*
- ** The TESTONLY macro is used to enclose variable declarations or
- ** other bits of code that are needed to support the arguments
- ** within testcase() and assert() macros.
- */
- #if !NDEBUG || SQLITE_COVERAGE_TEST
- //# define TESTONLY(X) X
- // -- Need workaround for C#, since inline macros don't exist
- #else
- //# define TESTONLY(X)
- #endif
- /*
- ** Sometimes we need a small amount of code such as a variable initialization
- ** to setup for a later assert() statement. We do not want this code to
- ** appear when assert() is disabled. The following macro is therefore
- ** used to contain that setup code. The "VVA" acronym stands for
- ** "Verification, Validation, and Accreditation". In other words, the
- ** code within VVA_ONLY() will only run during verification processes.
- */
- #if !NDEBUG
- //# define VVA_ONLY(X) X
- #else
- //# define VVA_ONLY(X)
- #endif
- /*
- ** The ALWAYS and NEVER macros surround boolean expressions which
- ** are intended to always be true or false, respectively. Such
- ** expressions could be omitted from the code completely. But they
- ** are included in a few cases in order to enhance the resilience
- ** of SQLite to unexpected behavior - to make the code "self-healing"
- ** or "ductile" rather than being "brittle" and crashing at the first
- ** hint of unplanned behavior.
- **
- ** In other words, ALWAYS and NEVER are added for defensive code.
- **
- ** When doing coverage testing ALWAYS and NEVER are hard-coded to
- ** be true and false so that the unreachable code then specify will
- ** not be counted as untested code.
- */
- #if SQLITE_COVERAGE_TEST
- //# define ALWAYS(X) (1)
- //# define NEVER(X) (0)
- #elif !NDEBUG
- //# define ALWAYS(X) ((X)?1:(assert(0),0))
- static bool ALWAYS( bool X )
- {
- if ( X != true )
- Debug.Assert( false );
- return true;
- }
- static int ALWAYS( int X )
- {
- if ( X == 0 )
- Debug.Assert( false );
- return 1;
- }
- static bool ALWAYS<T>( T X )
- {
- if ( X == null )
- Debug.Assert( false );
- return true;
- }
- //# define NEVER(X) ((X)?(assert(0),1):0)
- static bool NEVER( bool X )
- {
- if ( X == true )
- Debug.Assert( false );
- return false;
- }
- static byte NEVER( byte X )
- {
- if ( X != 0 )
- Debug.Assert( false );
- return 0;
- }
- static int NEVER( int X )
- {
- if ( X != 0 )
- Debug.Assert( false );
- return 0;
- }
- static bool NEVER<T>( T X )
- {
- if ( X != null )
- Debug.Assert( false );
- return false;
- }
- #else
- //# define ALWAYS(X) (X)
- static bool ALWAYS(bool X) { return X; }
- static byte ALWAYS(byte X) { return X; }
- static int ALWAYS(int X) { return X; }
- static bool ALWAYS<T>( T X ) { return true; }
- //# define NEVER(X) (X)
- static bool NEVER(bool X) { return X; }
- static byte NEVER(byte X) { return X; }
- static int NEVER(int X) { return X; }
- static bool NEVER<T>(T X) { return false; }
- #endif
- /*
- ** Return true (non-zero) if the input is a integer that is too large
- ** to fit in 32-bits. This macro is used inside of various testcase()
- ** macros to verify that we have tested SQLite for large-file support.
- */
- static bool IS_BIG_INT( i64 X )
- {
- return ( ( ( X ) & ~(i64)0xffffffff ) != 0 );
- }//#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
- /*
- ** The macro unlikely() is a hint that surrounds a boolean
- ** expression that is usually false. Macro likely() surrounds
- ** a boolean expression that is usually true. GCC is able to
- ** use these hints to generate better code, sometimes.
- */
- #if (__GNUC__) && FALSE
- //# define likely(X) __builtin_expect((X),1)
- //# define unlikely(X) __builtin_expect((X),0)
- #else
- //# define likely(X) !!(X)
- static bool likely( bool X )
- {
- return !!X;
- }
- //# define unlikely(X) !!(X)
- static bool unlikely( bool X )
- {
- return !!X;
- }
- #endif
- //#include "sqlite3.h"
- //#include "hash.h"
- //#include "parse.h"
- //#include <stdio.h>
- //#include <stdlib.h>
- //#include <string.h>
- //#include <assert.h>
- //#include <stddef.h>
- /*
- ** If compiling for a processor that lacks floating point support,
- ** substitute integer for floating-point
- */
- #if SQLITE_OMIT_FLOATING_POINT
- //# define double sqlite_int64
- //# define float sqlite_int64
- //# define LONGDOUBLE_TYPE sqlite_int64
- //#if !SQLITE_BIG_DBL
- //# define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
- //# endif
- //# define SQLITE_OMIT_DATETIME_FUNCS 1
- //# define SQLITE_OMIT_TRACE 1
- //# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
- //# undef SQLITE_HAVE_ISNAN
- #endif
- #if !SQLITE_BIG_DBL
- const double SQLITE_BIG_DBL = ( ( (sqlite3_int64)1 ) << 60 );//# define SQLITE_BIG_DBL (1e99)
- #endif
- /*
- ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0
- ** afterward. Having this macro allows us to cause the C compiler
- ** to omit code used by TEMP tables without messy #if !statements.
- */
- #if SQLITE_OMIT_TEMPDB
- //#define OMIT_TEMPDB 1
- #else
- static int OMIT_TEMPDB = 0;
- #endif
- /*
- ** The "file format" number is an integer that is incremented whenever
- ** the VDBE-level file format changes. The following macros define the
- ** the default file format for new databases and the maximum file format
- ** that the library can read.
- */
- static public int SQLITE_MAX_FILE_FORMAT = 4;//#define SQLITE_MAX_FILE_FORMAT 4
- //#if !SQLITE_DEFAULT_FILE_FORMAT
- static int SQLITE_DEFAULT_FILE_FORMAT = 1;//# define SQLITE_DEFAULT_FILE_FORMAT 1
- //#endif
- /*
- ** Determine whether triggers are recursive by default. This can be
- ** changed at run-time using a pragma.
- */
- #if !SQLITE_DEFAULT_RECURSIVE_TRIGGERS
- //# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0
- static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = false;
- #else
- static public bool SQLITE_DEFAULT_RECURSIVE_TRIGGERS = true;
- #endif
- /*
- ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
- ** on the command-line
- */
- //#if !SQLITE_TEMP_STORE
- static int SQLITE_TEMP_STORE = 1;//#define SQLITE_TEMP_STORE 1
- //#endif
- /*
- ** GCC does not define the offsetof() macro so we'll have to do it
- ** ourselves.
- */
- #if !offsetof
- //#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
- #endif
- /*
- ** Check to see if this machine uses EBCDIC. (Yes, believe it or
- ** not, there are still machines out there that use EBCDIC.)
- */
- #if FALSE //'A' == '\301'
- //# define SQLITE_EBCDIC 1
- #else
- const int SQLITE_ASCII = 1;//#define SQLITE_ASCII 1
- #endif
- /*
- ** Integers of known sizes. These typedefs might change for architectures
- ** where the sizes very. Preprocessor macros are available so that the
- ** types can be conveniently redefined at compile-type. Like this:
- **
- ** cc '-Du32PTR_TYPE=long long int' ...
- */
- //#if !u32_TYPE
- //# ifdef HAVE_u32_T
- //# define u32_TYPE u32_t
- //# else
- //# define u32_TYPE unsigned int
- //# endif
- //#endif
- //#if !u3216_TYPE
- //# ifdef HAVE_u3216_T
- //# define u3216_TYPE u3216_t
- //# else
- //# define u3216_TYPE unsigned short int
- //# endif
- //#endif
- //#if !INT16_TYPE
- //# ifdef HAVE_INT16_T
- //# define INT16_TYPE int16_t
- //# else
- //# define INT16_TYPE short int
- //# endif
- //#endif
- //#if !u328_TYPE
- //# ifdef HAVE_u328_T
- //# define u328_TYPE u328_t
- //# else
- //# define u328_TYPE unsigned char
- //# endif
- //#endif
- //#if !INT8_TYPE
- //# ifdef HAVE_INT8_T
- //# define INT8_TYPE int8_t
- //# else
- //# define INT8_TYPE signed char
- //# endif
- //#endif
- //#if !LONGDOUBLE_TYPE
- //# define LONGDOUBLE_TYPE long double
- //#endif
- //typedef sqlite_int64 i64; /* 8-byte signed integer */
- //typedef sqlite_u3264 u64; /* 8-byte unsigned integer */
- //typedef u32_TYPE u32; /* 4-byte unsigned integer */
- //typedef u3216_TYPE u16; /* 2-byte unsigned integer */
- //typedef INT16_TYPE i16; /* 2-byte signed integer */
- //typedef u328_TYPE u8; /* 1-byte unsigned integer */
- //typedef INT8_TYPE i8; /* 1-byte signed integer */
- /*
- ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value
- ** that can be stored in a u32 without loss of data. The value
- ** is 0x00000000ffffffff. But because of quirks of some compilers, we
- ** have to specify the value in the less intuitive manner shown:
- */
- //#define SQLITE_MAX_U32 ((((u64)1)<<32)-1)
- const u32 SQLITE_MAX_U32 = (u32)( ( ( (u64)1 ) << 32 ) - 1 );
- /*
- ** Macros to determine whether the machine is big or little endian,
- ** evaluated at runtime.
- */
- #if SQLITE_AMALGAMATION
- //const int sqlite3one = 1;
- #else
- const bool sqlite3one = true;
- #endif
- #if i386 || __i386__ || _M_IX86
- const int ;//#define SQLITE_BIGENDIAN 0
- const int ;//#define SQLITE_LITTLEENDIAN 1
- const int ;//#define SQLITE_UTF16NATIVE SQLITE_UTF16LE
- #else
- static u8 SQLITE_BIGENDIAN = 0;//#define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)
- static u8 SQLITE_LITTLEENDIAN = 1;//#define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
- static u8 SQLITE_UTF16NATIVE = ( SQLITE_BIGENDIAN != 0 ? SQLITE_UTF16BE : SQLITE_UTF16LE );//#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
- #endif
- /*
- ** Constants for the largest and smallest possible 64-bit signed integers.
- ** These macros are designed to work correctly on both 32-bit and 64-bit
- ** compilers.
- */
- //#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
- //#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
- const i64 LARGEST_INT64 = i64.MaxValue;//( 0xffffffff | ( ( (i64)0x7fffffff ) << 32 ) );
- const i64 SMALLEST_INT64 = i64.MinValue;//( ( ( i64 ) - 1 ) - LARGEST_INT64 );
- /*
- ** Round up a number to the next larger multiple of 8. This is used
- ** to force 8-byte alignment on 64-bit architectures.
- */
- //#define ROUND8(x) (((x)+7)&~7)
- static int ROUND8( int x )
- {
- return ( x + 7 ) & ~7;
- }
- /*
- ** Round down to the nearest multiple of 8
- */
- //#define ROUNDDOWN8(x) ((x)&~7)
- static int ROUNDDOWN8( int x )
- {
- return x & ~7;
- }
- /*
- ** Assert that the pointer X is aligned to an 8-byte boundary. This
- ** macro is used only within assert() to verify that the code gets
- ** all alignment restrictions correct.
- **
- ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
- ** underlying malloc() implemention might return us 4-byte aligned
- ** pointers. In that case, only verify 4-byte alignment.
- */
- //#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
- //# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0)
- //#else
- //# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0)
- //#endif
- /*
- ** An instance of the following structure is used to store the busy-handler
- ** callback for a given sqlite handle.
- **
- ** The sqlite.busyHandler member of the sqlite struct contains the busy
- ** callback for the database handle. Each pager opened via the sqlite
- ** handle is passed a pointer to sqlite.busyHandler. The busy-handler
- ** callback is currently invoked only from within pager.c.
- */
- //typedef struct BusyHandler BusyHandler;
- public class BusyHandler
- {
- public dxBusy xFunc;//)(void *,int); /* The busy callback */
- public object pArg; /* First arg to busy callback */
- public int nBusy; /* Incremented with each busy call */
- };
- /*
- ** Name of the master database table. The master database table
- ** is a special table that holds the names and attributes of all
- ** user tables and indices.
- */
- const string MASTER_NAME = "sqlite_master";//#define MASTER_NAME "sqlite_master"
- const string TEMP_MASTER_NAME = "sqlite_temp_master";//#define TEMP_MASTER_NAME "sqlite_temp_master"
- /*
- ** The root-page of the master database table.
- */
- const int MASTER_ROOT = 1;//#define MASTER_ROOT 1
- /*
- ** The name of the schema table.
- */
- static string SCHEMA_TABLE( int x ) //#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)
- {
- return ( ( OMIT_TEMPDB == 0 ) && ( x == 1 ) ? TEMP_MASTER_NAME : MASTER_NAME );
- }
- /*
- ** A convenience macro that returns the number of elements in
- ** an array.
- */
- //#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0])))
- static int ArraySize<T>( T[] x )
- {
- return x.Length;
- }
- /*
- ** The following value as a destructor means to use sqlite3DbFree().
- ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT.
- */
- //#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree)
- static dxDel SQLITE_DYNAMIC;
- /*
- ** When SQLITE_OMIT_WSD is defined, it means that the target platform does
- ** not support Writable Static Data (WSD) such as global and static variables.
- ** All variables must either be on the stack or dynamically allocated from
- ** the heap. When WSD is unsupported, the variable declarations scattered
- ** throughout the SQLite code must become constants instead. The SQLITE_WSD
- ** macro is used for this purpose. And instead of referencing the variable
- ** directly, we use its constant as a key to lookup the run-time allocated
- ** buffer that holds real variable. The constant is also the initializer
- ** for the run-time allocated buffer.
- **
- ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL
- ** macros become no-ops and have zero performance impact.
- */
- #if SQLITE_OMIT_WSD
- //#define SQLITE_WSD const
- //#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
- //#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
- int sqlite3_wsd_init(int N, int J);
- void *sqlite3_wsd_find(void *K, int L);
- #else
- //#define SQLITE_WSD
- //#define GLOBAL(t,v) v
- //#define sqlite3GlobalConfig sqlite3Config
- static Sqlite3Config sqlite3GlobalConfig;
- #endif
- /*
- ** The following macros are used to suppress compiler warnings and to
- ** make it clear to human readers when a function parameter is deliberately
- ** left unused within the body of a function. This usually happens when
- ** a function is called via a function pointer. For example the
- ** implementation of an SQL aggregate step callback may not use the
- ** parameter indicating the number of arguments passed to the aggregate,
- ** if it knows that this is enforced elsewhere.
- **
- ** When a function parameter is not used at all within the body of a function,
- ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer.
- ** However, these macros may also be used to suppress warnings related to
- ** parameters that may or may not be used depending on compilation options.
- ** For example those parameters only used in assert() statements. In these
- ** cases the parameters are named as per the usual conventions.
- */
- //#define UNUSED_PARAMETER(x) (void)(x)
- static void UNUSED_PARAMETER<T>( T x )
- {
- }
- //#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)
- static void UNUSED_PARAMETER2<T1, T2>( T1 x, T2 y )
- {
- UNUSED_PARAMETER( x );
- UNUSED_PARAMETER( y );
- }
- /*
- ** Forward references to structures
- */
- //typedef struct AggInfo AggInfo;
- //typedef struct AuthContext AuthContext;
- //typedef struct AutoincInfo AutoincInfo;
- //typedef struct Bitvec Bitvec;
- //typedef struct CollSeq CollSeq;
- //typedef struct Column Column;
- //typedef struct Db Db;
- //typedef struct Schema Schema;
- //typedef struct Expr Expr;
- //typedef struct ExprList ExprList;
- //typedef struct ExprSpan ExprSpan;
- //typedef struct FKey FKey;
- //typedef struct FuncDestructor FuncDestructor;
- //typedef struct FuncDef FuncDef;
- //typedef struct IdList IdList;
- //typedef struct Index Index;
- //typedef struct IndexSample IndexSample;
- //typedef struct KeyClass KeyClass;
- //typedef struct KeyInfo KeyInfo;
- //typedef struct Lookaside Lookaside;
- //typedef struct LookasideSlot LookasideSlot;
- //typedef struct Module Module;
- //typedef struct NameContext NameContext;
- //typedef struct Parse Parse;
- //typedef struct RowSet RowSet;
- //typedef struct Savepoint Savepoint;
- //typedef struct Select Select;
- //typedef struct SrcList SrcList;
- //typedef struct StrAccum StrAccum;
- //typedef struct Table Table;
- //typedef struct TableLock TableLock;
- //typedef struct Token Token;
- //typedef struct Trigger Trigger;
- //typedef struct TriggerPrg TriggerPrg;
- //typedef struct TriggerStep TriggerStep;
- //typedef struct UnpackedRecord UnpackedRecord;
- //typedef struct VTable VTable;
- //typedef struct Walker Walker;
- //typedef struct WherePlan WherePlan;
- //typedef struct WhereInfo WhereInfo;
- //typedef struct WhereLevel WhereLevel;
- /*
- ** Defer sourcing vdbe.h and btree.h until after the "u8" and
- ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque
- ** pointer types (i.e. FuncDef) defined above.
- */
- //#include "btree.h"
- //#include "vdbe.h"
- //#include "pager.h"
- //#include "pcache_g.h"
- //#include "os.h"
- //#include "mutex.h"
- /*
- ** Each database file to be accessed by the system is an instance
- ** of the following structure. There are normally two of these structures
- ** in the sqlite.aDb[] array. aDb[0] is the main database file and
- ** aDb[1] is the database file used to hold temporary tables. Additional
- ** databases may be attached.
- */
- public class Db
- {
- public string zName; /* Name of this database */
- public Btree pBt; /* The B Tree structure for this database file */
- public u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */
- public u8 safety_level; /* How aggressive at syncing data to disk */
- public Schema pSchema; /* Pointer to database schema (possibly shared) */
- };
- /*
- ** An instance of the following structure stores a database schema.
- */
- public class Schema
- {
- public int schema_cookie; /* Database schema version number for this file */
- public Hash tblHash = new Hash(); /* All tables indexed by name */
- public Hash idxHash = new Hash(); /* All (named) indices indexed by name */
- public Hash trigHash = new Hash();/* All triggers indexed by name */
- public Hash fkeyHash = new Hash();/* All foreign keys by referenced table name */
- public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
- public u8 file_format; /* Schema format version for this file */
- public u8 enc; /* Text encoding used by this database */
- public u16 flags; /* Flags associated with this schema */
- public int cache_size; /* Number of pages to use in the cache */
- public Schema Copy()
- {
- if ( this == null )
- return null;
- else
- {
- Schema cp = (Schema)MemberwiseClone();
- return cp;
- }
- }
- public void Clear()
- {
- if ( this != null )
- {
- schema_cookie = 0;
- tblHash = new Hash();
- idxHash = new Hash();
- trigHash = new Hash();
- fkeyHash = new Hash();
- pSeqTab = null;
- flags = 0;
- }
- }
- };
- /*
- ** These macros can be used to test, set, or clear bits in the
- ** Db.pSchema->flags field.
- */
- //#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P))
- static bool DbHasProperty( sqlite3 D, int I, ushort P )
- {
- return ( D.aDb[I].pSchema.flags & P ) == P;
- }
- //#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0)
- //#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P)
- static void DbSetProperty( sqlite3 D, int I, ushort P )
- {
- D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags | P );
- }
- //#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P)
- static void DbClearProperty( sqlite3 D, int I, ushort P )
- {
- D.aDb[I].pSchema.flags = (u16)( D.aDb[I].pSchema.flags & ~P );
- }
- /*
- ** Allowed values for the DB.pSchema->flags field.
- **
- ** The DB_SchemaLoaded flag is set after the database schema has been
- ** read into internal hash tables.
- **
- ** DB_UnresetViews means that one or more views have column names that
- ** have been filled out. If the schema changes, these column names might
- ** changes and so the view will need to be reset.
- */
- //#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */
- //#define DB_UnresetViews 0x0002 /* Some views have defined column names */
- //#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */
- const u16 DB_SchemaLoaded = 0x0001;
- const u16 DB_UnresetViews = 0x0002;
- const u16 DB_Empty = 0x0004;
- /*
- ** The number of different kinds of things that can be limited
- ** using the sqlite3_limit() interface.
- */
- //#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1)
- const int SQLITE_N_LIMIT = SQLITE_LIMIT_TRIGGER_DEPTH + 1;
- /*
- ** Lookaside malloc is a set of fixed-size buffers that can be used
- ** to satisfy small transient memory allocation requests for objects
- ** associated with a particular database connection. The use of
- ** lookaside malloc provides a significant performance enhancement
- ** (approx 10%) by avoiding numerous malloc/free requests while parsing
- ** SQL statements.
- **
- ** The Lookaside structure holds configuration information about the
- ** lookaside malloc subsystem. Each available memory allocation in
- ** the lookaside subsystem is stored on a linked list of LookasideSlot
- ** objects.
- **
- ** Lookaside allocations are only allowed for objects that are associated
- ** with a particular database connection. Hence, schema information cannot
- ** be stored in lookaside because in shared cache mode the schema information
- ** is shared by multiple database connections. Therefore, while parsing
- ** schema information, the Lookaside.bEnabled flag is cleared so that
- ** lookaside allocations are not used to construct the schema objects.
- */
- public class Lookaside
- {
- public int sz; /* Size of each buffer in bytes */
- public u8 bEnabled; /* False to disable new lookaside allocations */
- public bool bMalloced; /* True if pStart obtained from sqlite3_malloc() */
- public int nOut; /* Number of buffers currently checked out */
- public int mxOut; /* Highwater mark for nOut */
- public int[] anStat = new int[3]; /* 0: hits. 1: size misses. 2: full misses */
- public LookasideSlot pFree; /* List of available buffers */
- public int pStart; /* First byte of available memory space */
- public int pEnd; /* First byte past end of available space */
- };
- public class LookasideSlot
- {
- public LookasideSlot pNext; /* Next buffer in the list of free buffers */
- };
- /*
- ** A hash table for function definitions.
- **
- ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.
- ** Collisions are on the FuncDef.pHash chain.
- */
- public class FuncDefHash
- {
- public FuncDef[] a = new FuncDef[23]; /* Hash table for functions */
- };
- /*
- ** Each database connection is an instance of the following structure.
- **
- ** The sqlite.lastRowid records the last insert rowid generated by an
- ** insert statement. Inserts on views do not affect its value. Each
- ** trigger has its own context, so that lastRowid can be updated inside
- ** triggers as usual. The previous value will be restored once the trigger
- ** exits. Upon entering a before or instead of trigger, lastRowid is no
- ** longer (since after version 2.8.12) reset to -1.
- **
- ** The sqlite.nChange does not count changes within triggers and keeps no
- ** context. It is reset at start of sqlite3_exec.
- ** The sqlite.lsChange represents the number of changes made by the last
- ** insert, update, or delete statement. It remains constant throughout the
- ** length of a statement and is then updated by OP_SetCounts. It keeps a
- ** context stack just like lastRowid so that the count of changes
- ** within a trigger is not seen outside the trigger. Changes to views do not
- ** affect the value of lsChange.
- ** The sqlite.csChange keeps track of the number of current changes (since
- ** the last statement) and is used to update sqlite_lsChange.
- **
- ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16
- ** store the most recent error code and, if applicable, string. The
- ** internal function sqlite3Error() is used to set these variables
- ** consistently.
- */
- public class sqlite3
- {
- public sqlite3_vfs pVfs; /* OS Interface */
- public int nDb; /* Number of backends currently in use */
- public Db[] aDb = new Db[SQLITE_MAX_ATTACHED]; /* All backends */
- public int flags; /* Miscellaneous flags. See below */
- public int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
- public int errCode; /* Most recent error code (SQLITE_*) */
- public int errMask; /* & result codes with this before returning */
- public u8 autoCommit; /* The auto-commit flag. */
- public u8 temp_store; /* 1: file 2: memory 0: default */
- // Cannot happen under C#
- // public u8 mallocFailed; /* True if we have seen a malloc failure */
- public u8 dfltLockMode; /* Default locking-mode for attached dbs */
- public int nextAutovac; /* Autovac setting after VACUUM if >=0 */
- public u8 suppressErr; /* Do not issue error messages if true */
- public int nextPagesize; /* Pagesize after VACUUM if >0 */
- public int nTable; /* Number of tables in the database */
- public CollSeq pDfltColl; /* The default collating sequence (BINARY) */
- public i64 lastRowid; /* ROWID of most recent insert (see above) */
- public u32 magic; /* Magic number for detect library misuse */
- public int nChange; /* Value returned by sqlite3_changes() */
- public int nTotalChange; /* Value returned by sqlite3_total_changes() */
- public sqlite3_mutex mutex; /* Connection mutex */
- public int[] aLimit = new int[SQLITE_N_LIMIT]; /* Limits */
- public class sqlite3InitInfo
- { /* Information used during initialization */
- public int iDb; /* When back is being initialized */
- public int newTnum; /* Rootpage of table being initialized */
- public u8 busy; /* TRUE if currently initializing */
- public u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
- };
- public sqlite3InitInfo init = new sqlite3InitInfo();
- public int nExtension; /* Number of loaded extensions */
- public object[] aExtension; /* Array of shared library handles */
- public Vdbe pVdbe; /* List of active virtual machines */
- public int activeVdbeCnt; /* Number of VDBEs currently executing */
- public int writeVdbeCnt; /* Number of active VDBEs that are writing */
- public int vdbeExecCnt; /* Number of nested calls to VdbeExec() */
- public dxTrace xTrace;//)(void*,const char*); /* Trace function */
- public object pTraceArg; /* Argument to the trace function */
- public dxProfile xProfile;//)(void*,const char*,u64); /* Profiling function */
- public object pProfileArg; /* Argument to profile function */
- public object pCommitArg; /* Argument to xCommitCallback() */
- public dxCommitCallback xCommitCallback;//)(void*); /* Invoked at every commit. */
- public object pRollbackArg; /* Argument to xRollbackCallback() */
- public dxRollbackCallback xRollbackCallback;//)(void*); /* Invoked at every commit. */
- public object pUpdateArg;
- public dxUpdateCallback xUpdateCallback;//)(void*,int, const char*,const char*,sqlite_int64);
- #if !SQLITE_OMIT_WAL
- //int (*xWalCallback)(void *, sqlite3 *, const char *, int);
- //void *pWalArg;
- #endif
- public dxCollNeeded xCollNeeded;//)(void*,sqlite3*,int eTextRep,const char*);
- public dxCollNeeded xCollNeeded16;//)(void*,sqlite3*,int eTextRep,const void*);
- public object pCollNeededArg;
- public sqlite3_value pErr; /* Most recent error message */
- public string zErrMsg; /* Most recent error message (UTF-8 encoded) */
- public string zErrMsg16; /* Most recent error message (UTF-16 encoded) */
- public struct _u1
- {
- public bool isInterrupted; /* True if sqlite3_interrupt has been called */
- public double notUsed1; /* Spacer */
- }
- public _u1 u1;
- public Lookaside lookaside = new Lookaside(); /* Lookaside malloc configuration */
- #if !SQLITE_OMIT_AUTHORIZATION
- public dxAuth xAuth;//)(void*,int,const char*,const char*,const char*,const char*);
- /* Access authorization function */
- public object pAuthArg; /* 1st argument to the access auth function */
- #endif
- #if !SQLITE_OMIT_PROGRESS_CALLBACK
- public dxProgress xProgress;//)(void *); /* The progress callback */
- public object pProgressArg; /* Argument to the progress callback */
- public int nProgressOps; /* Number of opcodes for progress callback */
- #endif
- #if !SQLITE_OMIT_VIRTUALTABLE
- public Hash aModule; /* populated by sqlite3_create_module() */
- public Table pVTab; /* vtab with active Connect/Create method */
- public VTable aVTrans; /* Virtual tables with open transactions */
- public int nVTrans; /* Allocated size of aVTrans */
- public VTable pDisconnect; /* Disconnect these in next sqlite3_prepare() */
- #endif
- public FuncDefHash aFunc = new FuncDefHash(); /* Hash table of connection functions */
- public Hash aCollSeq = new Hash(); /* All collating sequences */
- public BusyHandler busyHandler = new BusyHandler(); /* Busy callback */
- public int busyTimeout; /* Busy handler timeout, in msec */
- public Db[] aDbStatic = new Db[] { new Db(), new Db() }; /* Static space for the 2 default backends */
- public Savepoint pSavepoint; /* List of active savepoints */
- public int nSavepoint; /* Number of non-transaction savepoints */
- public int nStatement; /* Number of nested statement-transactions */
- public u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
- public i64 nDeferredCons; /* Net deferred constraints this transaction. */
- public int pnBytesFreed; /* If not NULL, increment this in DbFree() */
- #if SQLITE_ENABLE_UNLOCK_NOTIFY
- /* The following variables are all protected by the STATIC_MASTER
- ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
- **
- ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
- ** unlock so that it can proceed.
- **
- ** When X.pBlockingConnection==Y, that means that something that X tried
- ** tried to do recently failed with an SQLITE_LOCKED error due to locks
- ** held by Y.
- */
- sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */
- sqlite3 *pUnlockConnection; /* Connection to watch for unlock */
- void *pUnlockArg; /* Argument to xUnlockNotify */
- void (*xUnlockNotify)(void **, int); /* Unlock notify callback */
- sqlite3 *pNextBlocked; /* Next in list of all blocked connections */
- #endif
- };
- /*
- ** A macro to discover the encoding of a database.
- */
- //#define ENC(db) ((db)->aDb[0].pSchema->enc)
- static u8 ENC( sqlite3 db )
- {
- return db.aDb[0].pSchema.enc;
- }
- /*
- ** Possible values for the sqlite3.flags.
- */
- //#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */
- //#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */
- //#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */
- //#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */
- //#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */
- // /* DELETE, or UPDATE and return */
- // /* the count using a callback. */
- //#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */
- // /* result set is empty */
- //#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */
- //#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */
- //#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */
- //#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when
- // ** accessing read-only databases */
- //#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */
- //#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */
- //#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */
- //#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */
- //#define SQLITE_CkptFullFSync 0x00400000 /* Use full fsync for checkpoint */
- //#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */
- //#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */
- //#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */
- //#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */
- //#define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */
- //#define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */
- //#define SQLITE_LoadExtension 0x20000000 /* Enable load_extension */
- const int SQLITE_VdbeTrace = 0x00000100;
- const int SQLITE_InternChanges = 0x00000200;
- const int SQLITE_FullColNames = 0x00000400;
- const int SQLITE_ShortColNames = 0x00000800;
- const int SQLITE_CountRows = 0x00001000;
- const int SQLITE_NullCallback = 0x00002000;
- const int SQLITE_SqlTrace = 0x00004000;
- const int SQLITE_VdbeListing = 0x00008000;
- const int SQLITE_WriteSchema = 0x00010000;
- const int SQLITE_NoReadlock = 0x00020000;
- const int SQLITE_IgnoreChecks = 0x00040000;
- const int SQLITE_ReadUncommitted = 0x0080000;
- const int SQLITE_LegacyFileFmt = 0x00100000;
- const int SQLITE_FullFSync = 0x00200000;
- const int SQLITE_CkptFullFSync = 0x00400000;
- const int SQLITE_RecoveryMode = 0x00800000;
- const int SQLITE_ReverseOrder = 0x01000000;
- const int SQLITE_RecTriggers = 0x02000000;
- const int SQLITE_ForeignKeys = 0x04000000;
- const int SQLITE_AutoIndex = 0x08000000;
- const int SQLITE_PreferBuiltin = 0x10000000;
- const int SQLITE_LoadExtension = 0x20000000;
- /*
- ** Bits of the sqlite3.flags field that are used by the
- ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface.
- ** These must be the low-order bits of the flags field.
- */
- //#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */
- //#define SQLITE_ColumnCache 0x02 /* Disable the column cache */
- //#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */
- //#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */
- //#define SQLITE_IndexCover 0x10 /* Disable index covering table */
- //#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */
- //#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */
- //#define SQLITE_OptMask 0xff /* Mask of all disablable opts */
- const int SQLITE_QueryFlattener = 0x01;
- const int SQLITE_ColumnCache = 0x02;
- const int SQLITE_IndexSort = 0x04;
- const int SQLITE_IndexSearch = 0x08;
- const int SQLITE_IndexCover = 0x10;
- const int SQLITE_GroupByOrder = 0x20;
- const int SQLITE_FactorOutConst = 0x40;
- const int SQLITE_OptMask = 0xff;
- /*
- ** Possible values for the sqlite.magic field.
- ** The numbers are obtained at random and have no special meaning, other
- ** than being distinct from one another.
- */
- const int SQLITE_MAGIC_OPEN = 0x1029a697; //#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
- const int SQLITE_MAGIC_CLOSED = 0x2f3c2d33; //#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */
- const int SQLITE_MAGIC_SICK = 0x3b771290; //#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */
- const int SQLITE_MAGIC_BUSY = 0x403b7906; //#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */
- const int SQLITE_MAGIC_ERROR = 0x55357930; //#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */
- /*
- ** Each SQL function is defined by an instance of the following
- ** structure. A pointer to this structure is stored in the sqlite.aFunc
- ** hash table. When multiple functions have the same name, the hash table
- ** points to a linked list of these structures.
- */
- public class FuncDef
- {
- public i16 nArg; /* Number of arguments. -1 means unlimited */
- public u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */
- public u8 flags; /* Some combination of SQLITE_FUNC_* */
- public object pUserData; /* User data parameter */
- public FuncDef pNext; /* Next function with same name */
- public dxFunc xFunc;//)(sqlite3_context*,int,sqlite3_value**); /* Regular function */
- public dxStep xStep;//)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */
- public dxFinal xFinalize;//)(sqlite3_context*); /* Aggregate finalizer */
- public string zName; /* SQL name of the function. */
- public FuncDef pHash; /* Next with a different name but the same hash */
- public FuncDestructor pDestructor; /* Reference counted destructor function */
- public FuncDef()
- {
- }
- public FuncDef( i16 nArg, u8 iPrefEnc, u8 iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor )
- {
- this.nArg = nArg;
- this.iPrefEnc = iPrefEnc;
- this.flags = iflags;
- this.pUserData = pUserData;
- this.pNext = pNext;
- this.xFunc = xFunc;
- this.xStep = xStep;
- this.xFinalize = xFinalize;
- this.zName = zName;
- this.pHash = pHash;
- this.pDestructor = pDestructor;
- }
- public FuncDef( string zName, u8 iPrefEnc, i16 nArg, int iArg, u8 iflags, dxFunc xFunc )
- {
- this.nArg = nAr…
Large files files are truncated, but you can click here to view the full file