📄 sqliteint.h
字号:
/*** Check to see if this machine uses EBCDIC. (Yes, believe it or** not, there are still machines out there that use EBCDIC.)*/#if 'A' == '\301'# define SQLITE_EBCDIC 1#else# 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 '-DUINTPTR_TYPE=long long int' ...*/#ifndef UINT32_TYPE# ifdef HAVE_UINT32_T# define UINT32_TYPE uint32_t# else# define UINT32_TYPE unsigned int# endif#endif#ifndef UINT16_TYPE# ifdef HAVE_UINT16_T# define UINT16_TYPE uint16_t# else# define UINT16_TYPE unsigned short int# endif#endif#ifndef INT16_TYPE# ifdef HAVE_INT16_T# define INT16_TYPE int16_t# else# define INT16_TYPE short int# endif#endif#ifndef UINT8_TYPE# ifdef HAVE_UINT8_T# define UINT8_TYPE uint8_t# else# define UINT8_TYPE unsigned char# endif#endif#ifndef INT8_TYPE# ifdef HAVE_INT8_T# define INT8_TYPE int8_t# else# define INT8_TYPE signed char# endif#endif#ifndef LONGDOUBLE_TYPE# define LONGDOUBLE_TYPE long double#endiftypedef sqlite_int64 i64; /* 8-byte signed integer */typedef sqlite_uint64 u64; /* 8-byte unsigned integer */typedef UINT32_TYPE u32; /* 4-byte unsigned integer */typedef UINT16_TYPE u16; /* 2-byte unsigned integer */typedef INT16_TYPE i16; /* 2-byte signed integer */typedef UINT8_TYPE u8; /* 1-byte unsigned integer */typedef INT8_TYPE i8; /* 1-byte signed integer *//*** Macros to determine whether the machine is big or little endian,** evaluated at runtime.*/#ifdef SQLITE_AMALGAMATIONconst int sqlite3one;#elseextern const int sqlite3one;#endif#if defined(i386) || defined(__i386__) || defined(_M_IX86)# define SQLITE_BIGENDIAN 0# define SQLITE_LITTLEENDIAN 1# define SQLITE_UTF16NATIVE SQLITE_UTF16LE#else# define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)# 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)/*** 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;struct BusyHandler { int (*xFunc)(void *,int); /* The busy callback */ void *pArg; /* First arg to busy callback */ 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.*/#define MASTER_NAME "sqlite_master"#define TEMP_MASTER_NAME "sqlite_temp_master"/*** The root-page of the master database table.*/#define MASTER_ROOT 1/*** The name of the schema table.*/#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)/*** A convenience macro that returns the number of elements in** an array.*/#define ArraySize(X) (sizeof(X)/sizeof(X[0]))/*** 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)/*** Forward references to structures*/typedef struct AggInfo AggInfo;typedef struct AuthContext AuthContext;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 FKey FKey;typedef struct FuncDef FuncDef;typedef struct FuncDefHash FuncDefHash;typedef struct IdList IdList;typedef struct Index Index;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 Select Select;typedef struct SrcList SrcList;typedef struct StrAccum StrAccum;typedef struct Table Table;typedef struct TableLock TableLock;typedef struct Token Token;typedef struct TriggerStack TriggerStack;typedef struct TriggerStep TriggerStep;typedef struct Trigger Trigger;typedef struct UnpackedRecord UnpackedRecord;typedef struct Walker Walker;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.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.*/struct Db { char *zName; /* Name of this database */ Btree *pBt; /* The B*Tree structure for this database file */ u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ u8 safety_level; /* How aggressive at synching data to disk */ void *pAux; /* Auxiliary data. Usually NULL */ void (*xFreeAux)(void*); /* Routine to free pAux */ Schema *pSchema; /* Pointer to database schema (possibly shared) */};/*** An instance of the following structure stores a database schema.**** If there are no virtual tables configured in this schema, the** Schema.db variable is set to NULL. After the first virtual table** has been added, it is set to point to the database connection ** used to create the connection. Once a virtual table has been** added to the Schema structure and the Schema.db variable populated, ** only that database connection may use the Schema to prepare ** statements.*/struct Schema { int schema_cookie; /* Database schema version number for this file */ Hash tblHash; /* All tables indexed by name */ Hash idxHash; /* All (named) indices indexed by name */ Hash trigHash; /* All triggers indexed by name */ Hash aFKey; /* Foreign keys indexed by to-table */ Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ u8 file_format; /* Schema format version for this file */ u8 enc; /* Text encoding used by this database */ u16 flags; /* Flags associated with this schema */ int cache_size; /* Number of pages to use in the cache */#ifndef SQLITE_OMIT_VIRTUALTABLE sqlite3 *db; /* "Owner" connection. See comment above */#endif};/*** These macros can be used to test, set, or clear bits in the ** Db.flags field.*/#define DbHasProperty(D,I,P) (((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)#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P)/*** Allowed values for the DB.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) *//*** The number of different kinds of things that can be limited** using the sqlite3_limit() interface.*/#define SQLITE_N_LIMIT (SQLITE_LIMIT_VARIABLE_NUMBER+1)/*** Lookaside malloc is a set of fixed-size buffers that can be used** to satisify 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.*/struct Lookaside { u16 sz; /* Size of each buffer in bytes */ u8 bEnabled; /* True if use lookaside. False to ignore it */ u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ int nOut; /* Number of buffers currently checked out */ int mxOut; /* Highwater mark for nOut */ LookasideSlot *pFree; /* List of available buffers */ void *pStart; /* First byte of available memory space */ void *pEnd; /* First byte past end of available space */};struct LookasideSlot { 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.*/struct FuncDefHash { FuncDef *a[23]; /* Hash table for functions */};/*** Each database 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -