📄 sqliteint.h
字号:
** 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]))/*** Forward references to structures*/typedef struct AggInfo AggInfo;typedef struct AuthContext AuthContext;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 IdList IdList;typedef struct Index Index;typedef struct KeyClass KeyClass;typedef struct KeyInfo KeyInfo;typedef struct Module Module;typedef struct NameContext NameContext;typedef struct Parse Parse;typedef struct Select Select;typedef struct SrcList SrcList;typedef struct ThreadData ThreadData;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 WhereInfo WhereInfo;typedef struct WhereLevel WhereLevel;#include "os.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) *//*** 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** 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.*/struct sqlite3 { int nDb; /* Number of backends currently in use */ Db *aDb; /* All backends */ int flags; /* Miscellanous flags. See below */ int errCode; /* Most recent error code (SQLITE_*) */ int errMask; /* & result codes with this before returning */ u8 autoCommit; /* The auto-commit flag. */ u8 temp_store; /* 1: file 2: memory 0: default */ int nTable; /* Number of tables in the database */ CollSeq *pDfltColl; /* The default collating sequence (BINARY) */ i64 lastRowid; /* ROWID of most recent insert (see above) */ i64 priorNewRowid; /* Last randomly generated ROWID */ int magic; /* Magic number for detect library misuse */ int nChange; /* Value returned by sqlite3_changes() */ int nTotalChange; /* Value returned by sqlite3_total_changes() */ struct sqlite3InitInfo { /* Information used during initialization */ int iDb; /* When back is being initialized */ int newTnum; /* Rootpage of table being initialized */ u8 busy; /* TRUE if currently initializing */ } init; int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared libraray handles */ struct Vdbe *pVdbe; /* List of active virtual machines */ int activeVdbeCnt; /* Number of vdbes currently executing */ void (*xTrace)(void*,const char*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ void *pCommitArg; /* Argument to xCommitCallback() */ int (*xCommitCallback)(void*); /* Invoked at every commit. */ void *pRollbackArg; /* Argument to xRollbackCallback() */ void (*xRollbackCallback)(void*); /* Invoked at every commit. */ void *pUpdateArg; void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64); void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*); void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*); void *pCollNeededArg; sqlite3_value *pErr; /* Most recent error message */ char *zErrMsg; /* Most recent error message (UTF-8 encoded) */ char *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ union { int isInterrupted; /* True if sqlite3_interrupt has been called */ double notUsed1; /* Spacer */ } u1;#ifndef SQLITE_OMIT_AUTHORIZATION int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); /* Access authorization function */ void *pAuthArg; /* 1st argument to the access auth function */#endif#ifndef SQLITE_OMIT_PROGRESS_CALLBACK int (*xProgress)(void *); /* The progress callback */ void *pProgressArg; /* Argument to the progress callback */ int nProgressOps; /* Number of opcodes for progress callback */#endif#ifndef SQLITE_OMIT_VIRTUALTABLE Hash aModule; /* populated by sqlite3_create_module() */ Table *pVTab; /* vtab with active Connect/Create method */ sqlite3_vtab **aVTrans; /* Virtual tables with open transactions */ int nVTrans; /* Allocated size of aVTrans */#endif Hash aFunc; /* All functions that can be in SQL exprs */ Hash aCollSeq; /* All collating sequences */ BusyHandler busyHandler; /* Busy callback */ int busyTimeout; /* Busy handler timeout, in msec */ Db aDbStatic[2]; /* Static space for the 2 default backends */#ifdef SQLITE_SSE sqlite3_stmt *pFetch; /* Used by SSE to fetch stored statements */#endif u8 dfltLockMode; /* Default locking-mode for attached dbs */};/*** A macro to discover the encoding of a database.*/#define ENC(db) ((db)->aDb[0].pSchema->enc)/*** Possible values for the sqlite.flags and or Db.flags fields.**** On sqlite.flags, the SQLITE_InTrans value means that we have** executed a BEGIN. On Db.flags, SQLITE_InTrans means a statement** transaction is active on that particular database file.*/#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */#define SQLITE_InTrans 0x00000008 /* True if in a transaction */#define SQLITE_InternChanges 0x00000010 /* Uncommitted Hash table changes */#define SQLITE_FullColNames 0x00000020 /* Show full column names on SELECT */#define SQLITE_ShortColNames 0x00000040 /* Show short columns names */#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */ /* DELETE, or UPDATE and return */ /* the count using a callback. */#define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */ /* result set is empty */#define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */#define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */#define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */#define SQLITE_NoReadlock 0x00001000 /* Readlocks are omitted when ** accessing read-only databases */#define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */#define SQLITE_ReadUncommitted 0x00004000 /* For shared-cache mode */#define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */#define SQLITE_FullFSync 0x00010000 /* Use full fsync on the backend */#define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */#define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors *//*** 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.*/#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */#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.*/struct FuncDef { i16 nArg; /* Number of arguments. -1 means unlimited */ u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ u8 needCollSeq; /* True if sqlite3GetFuncCollSeq() might be called */ u8 flags; /* Some combination of SQLITE_FUNC_* */ void *pUserData; /* User data parameter */ FuncDef *pNext; /* Next function with same name */ void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */ void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */ void (*xFinalize)(sqlite3_context*); /* Aggregate finializer */ char zName[1]; /* SQL name of the function. MUST BE LAST */};/*** Each SQLite module (virtual table definition) is defined by an** instance of the following structure, stored in the sqlite3.aModule** hash table.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -