⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqliteint.h

📁 sqlite数据库管理系统开放源码
💻 H
📖 第 1 页 / 共 4 页
字号:
/*** 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.**** @(#) $Id: sqliteInt.h,v 1.220.2.2 2005/06/06 15:07:03 drh Exp $*/#include "config.h"#include "sqlite.h"#include "hash.h"#include "parse.h"#include "btree.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>/*** The maximum number of in-memory pages to use for the main database** table and for temporary tables.*/#define MAX_PAGES   2000#define TEMP_PAGES   500/*** If the following macro is set to 1, then NULL values are considered** distinct for the SELECT DISTINCT statement and for UNION or EXCEPT** compound queries.  No other SQL database engine (among those tested) ** works this way except for OCELOT.  But the SQL92 spec implies that** this is how things should work.**** If the following macro is set to 0, then NULLs are indistinct for** SELECT DISTINCT and for UNION.*/#define NULL_ALWAYS_DISTINCT 0/*** If the following macro is set to 1, then NULL values are considered** distinct when determining whether or not two entries are the same** in a UNIQUE index.  This is the way PostgreSQL, Oracle, DB2, MySQL,** OCELOT, and Firebird all work.  The SQL92 spec explicitly says this** is the way things are suppose to work.**** If the following macro is set to 0, the NULLs are indistinct for** a UNIQUE index.  In this mode, you can only have a single NULL entry** for a column declared UNIQUE.  This is the way Informix and SQL Server** work.*/#define NULL_DISTINCT_FOR_UNIQUE 1/*** The maximum number of attached databases.  This must be at least 2** in order to support the main database file (0) and the file used to** hold temporary tables (1).  And it must be less than 256 because** an unsigned character is used to stored the database index.*/#define MAX_ATTACHED 10/*** The next macro is used to determine where TEMP tables and indices** are stored.  Possible values:****   0    Always use a temporary files**   1    Use a file unless overridden by "PRAGMA temp_store"**   2    Use memory unless overridden by "PRAGMA temp_store"**   3    Always use memory*/#ifndef TEMP_STORE# define TEMP_STORE 1#endif/*** When building SQLite for embedded systems where memory is scarce,** you can define one or more of the following macros to omit extra** features of the library and thus keep the size of the library to** a minimum.*//* #define SQLITE_OMIT_AUTHORIZATION  1 *//* #define SQLITE_OMIT_INMEMORYDB     1 *//* #define SQLITE_OMIT_VACUUM         1 *//* #define SQLITE_OMIT_DATETIME_FUNCS 1 *//* #define SQLITE_OMIT_PROGRESS_CALLBACK 1 *//*** 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# define UINT32_TYPE unsigned int#endif#ifndef UINT16_TYPE# define UINT16_TYPE unsigned short int#endif#ifndef INT16_TYPE# define INT16_TYPE short int#endif#ifndef UINT8_TYPE# define UINT8_TYPE unsigned char#endif#ifndef INT8_TYPE# define INT8_TYPE signed char#endif#ifndef INTPTR_TYPE# if SQLITE_PTR_SZ==4#   define INTPTR_TYPE int# else#   define INTPTR_TYPE long long# endif#endiftypedef 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 UINT8_TYPE i8;             /* 1-byte signed integer */typedef INTPTR_TYPE ptr;           /* Big enough to hold a pointer */typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer *//*** Defer sourcing vdbe.h until after the "u8" typedef is defined.*/#include "vdbe.h"/*** Most C compilers these days recognize "long double", don't they?** Just in case we encounter one that does not, we will create a macro** for long double so that it can be easily changed to just "double".*/#ifndef LONGDOUBLE_TYPE# define LONGDOUBLE_TYPE long double#endif/*** This macro casts a pointer to an integer.  Useful for doing** pointer arithmetic.*/#define Addr(X)  ((uptr)X)/*** The maximum number of bytes of data that can be put into a single** row of a single table.  The upper bound on this limit is 16777215** bytes (or 16MB-1).  We have arbitrarily set the limit to just 1MB** here because the overflow page chain is inefficient for really big** records and we want to discourage people from thinking that ** multi-megabyte records are OK.  If your needs are different, you can** change this define and recompile to increase or decrease the record** size.**** The 16777198 is computed as follows:  238 bytes of payload on the** original pages plus 16448 overflow pages each holding 1020 bytes of** data.*/#define MAX_BYTES_PER_ROW  1048576/* #define MAX_BYTES_PER_ROW 16777198 *//*** If memory allocation problems are found, recompile with****      -DMEMORY_DEBUG=1**** to enable some sanity checking on malloc() and free().  To** check for memory leaks, recompile with****      -DMEMORY_DEBUG=2**** and a line of text will be written to standard error for** each malloc() and free().  This output can be analyzed** by an AWK script to determine if there are any leaks.*/#ifdef MEMORY_DEBUG# define sqliteMalloc(X)    sqliteMalloc_(X,1,__FILE__,__LINE__)# define sqliteMallocRaw(X) sqliteMalloc_(X,0,__FILE__,__LINE__)# define sqliteFree(X)      sqliteFree_(X,__FILE__,__LINE__)# define sqliteRealloc(X,Y) sqliteRealloc_(X,Y,__FILE__,__LINE__)# define sqliteStrDup(X)    sqliteStrDup_(X,__FILE__,__LINE__)# define sqliteStrNDup(X,Y) sqliteStrNDup_(X,Y,__FILE__,__LINE__)  void sqliteStrRealloc(char**);#else# define sqliteRealloc_(X,Y) sqliteRealloc(X,Y)# define sqliteStrRealloc(X)#endif/*** This variable gets set if malloc() ever fails.  After it gets set,** the SQLite library shuts down permanently.*/extern int sqlite_malloc_failed;/*** The following global variables are used for testing and debugging** only.  They only work if MEMORY_DEBUG is defined.*/#ifdef MEMORY_DEBUGextern int sqlite_nMalloc;       /* Number of sqliteMalloc() calls */extern int sqlite_nFree;         /* Number of sqliteFree() calls */extern int sqlite_iMallocFail;   /* Fail sqliteMalloc() after this many calls */#endif/*** 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 name of the schema table.*/#define SCHEMA_TABLE(x)  (x?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 Column Column;typedef struct Table Table;typedef struct Index Index;typedef struct Instruction Instruction;typedef struct Expr Expr;typedef struct ExprList ExprList;typedef struct Parse Parse;typedef struct Token Token;typedef struct IdList IdList;typedef struct SrcList SrcList;typedef struct WhereInfo WhereInfo;typedef struct WhereLevel WhereLevel;typedef struct Select Select;typedef struct AggExpr AggExpr;typedef struct FuncDef FuncDef;typedef struct Trigger Trigger;typedef struct TriggerStep TriggerStep;typedef struct TriggerStack TriggerStack;typedef struct FKey FKey;typedef struct Db Db;typedef struct AuthContext AuthContext;/*** 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 */  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 */  u8 inTrans;          /* 0: not writable.  1: Transaction.  2: Checkpoint */  u16 flags;           /* Flags associated with this database */  void *pAux;          /* Auxiliary data.  Usually NULL */  void (*xFreeAux)(void*);  /* Routine to free pAux */};/*** These macros can be used to test, set, or clear bits in the ** Db.flags field.*/#define DbHasProperty(D,I,P)     (((D)->aDb[I].flags&(P))==(P))#define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].flags&(P))!=0)#define DbSetProperty(D,I,P)     (D)->aDb[I].flags|=(P)#define DbClearProperty(D,I,P)   (D)->aDb[I].flags&=~(P)/*** Allowed values for the DB.flags field.**** The DB_Locked flag is set when the first OP_Transaction or OP_Checkpoint** opcode is emitted for a database.  This prevents multiple occurances** of those opcodes for the same database in the same program.  Similarly,** the DB_Cookie flag is set when the OP_VerifyCookie opcode is emitted,** and prevents duplicate OP_VerifyCookies from taking up space and slowing** down execution.**** 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_Locked          0x0001  /* OP_Transaction opcode has been emitted */#define DB_Cookie          0x0002  /* OP_VerifyCookie opcode has been emiited */#define DB_SchemaLoaded    0x0004  /* The schema has been loaded */#define DB_UnresetViews    0x0008  /* Some views have defined column names *//*** Each database is an instance of the following structure.**** The sqlite.file_format is initialized by the database file** and helps determines how the data in the database file is** represented.  This field allows newer versions of the library** to read and write older databases.  The various file formats** are as follows:****     file_format==1    Version 2.1.0.**     file_format==2    Version 2.2.0. Add support for INTEGER PRIMARY KEY.**     file_format==3    Version 2.6.0. Fix empty-string index bug.**     file_format==4    Version 2.7.0. Add support for separate numeric and

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -