📄 sqliteint.h
字号:
/*** 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.387 2005/06/12 21:35:52 drh Exp $*/#ifndef _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.**** 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: RedHat 7.2) but you want your code to work** on an older machine (ex: RedHat 6.0). If you compile on RedHat 7.2** without this option, LFS is enable. But LFS does not exist in the kernel** in RedHat 6.0, so the code won't work. Hence, for maximum binary** portability you should omit LFS.**** Similar is true for MacOS. LFS is only supported on MacOS 9 and later.*/#ifndef SQLITE_DISABLE_LFS# define _LARGE_FILE 1# ifndef _FILE_OFFSET_BITS# define _FILE_OFFSET_BITS 64# endif# define _LARGEFILE_SOURCE 1#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>/*** The maximum number of in-memory pages to use for the main database** table and for temporary tables. Internally, the MAX_PAGES and ** TEMP_PAGES macros are used. To override the default values at** compilation time, the SQLITE_DEFAULT_CACHE_SIZE and ** SQLITE_DEFAULT_TEMP_CACHE_SIZE macros should be set.*/#ifdef SQLITE_DEFAULT_CACHE_SIZE# define MAX_PAGES SQLITE_DEFAULT_CACHE_SIZE#else# define MAX_PAGES 2000#endif#ifdef SQLITE_DEFAULT_TEMP_CACHE_SIZE# define TEMP_PAGES SQLITE_DEFAULT_TEMP_CACHE_SIZE#else# define TEMP_PAGES 500#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 #ifndef statements.*/#ifdef SQLITE_OMIT_TEMPDB#define OMIT_TEMPDB 1#else#define OMIT_TEMPDB 0#endif/*** 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 32 because** we use a bitmask of databases with a u32 in places (for example** the Parse.cookieMask field).*/#define MAX_ATTACHED 10/*** The maximum value of a ?nnn wildcard that the parser will accept.*/#define SQLITE_MAX_VARIABLE_NUMBER 999/*** 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_MEMORYDB 1 *//* #define SQLITE_OMIT_VACUUM 1 *//* #define SQLITE_OMIT_DATETIME_FUNCS 1 *//* #define SQLITE_OMIT_PROGRESS_CALLBACK 1 *//* #define SQLITE_OMIT_AUTOVACUUM *//* #define SQLITE_OMIT_ALTERTABLE *//*** Provide a default value for TEMP_STORE in case it is not specified** on the command-line*/#ifndef TEMP_STORE# define TEMP_STORE 1#endif/*** GCC does not define the offsetof() macro so we'll have to do it** ourselves.*/#ifndef offsetof#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))#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 UINT64_TYPE# if defined(_MSC_VER) || defined(__BORLANDC__)# define UINT64_TYPE unsigned __int64# else# define UINT64_TYPE unsigned long long int# endif#endif#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 LONGDOUBLE_TYPE# define LONGDOUBLE_TYPE long double#endiftypedef sqlite_int64 i64; /* 8-byte signed integer */typedef UINT64_TYPE 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 UINT8_TYPE i8; /* 1-byte signed integer *//*** Macros to determine whether the machine is big or little endian,** evaluated at runtime.*/extern const int sqlite3one;#define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)#define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)/*** 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 */};/*** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler typedefs.*/#include "vdbe.h"#include "btree.h"/*** This macro casts a pointer to an integer. Useful for doing** pointer arithmetic.*/#define Addr(X) ((uptr)X)/*** If memory allocation problems are found, recompile with**** -DSQLITE_DEBUG=1**** to enable some sanity checking on malloc() and free(). To** check for memory leaks, recompile with**** -DSQLITE_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 SQLITE_MEMDEBUG# define sqliteMalloc(X) sqlite3Malloc_(X,1,__FILE__,__LINE__)# define sqliteMallocRaw(X) sqlite3Malloc_(X,0,__FILE__,__LINE__)# define sqliteFree(X) sqlite3Free_(X,__FILE__,__LINE__)# define sqliteRealloc(X,Y) sqlite3Realloc_(X,Y,__FILE__,__LINE__)# define sqliteStrDup(X) sqlite3StrDup_(X,__FILE__,__LINE__)# define sqliteStrNDup(X,Y) sqlite3StrNDup_(X,Y,__FILE__,__LINE__)#else# define sqliteFree sqlite3FreeX# define sqliteMalloc sqlite3Malloc# define sqliteMallocRaw sqlite3MallocRaw# define sqliteRealloc sqlite3Realloc# define sqliteStrDup sqlite3StrDup# define sqliteStrNDup sqlite3StrNDup#endif/*** This variable gets set if malloc() ever fails. After it gets set,** the SQLite library shuts down permanently.*/extern int sqlite3_malloc_failed;/*** The following global variables are used for testing and debugging** only. They only work if SQLITE_DEBUG is defined.*/#ifdef SQLITE_MEMDEBUGextern int sqlite3_nMalloc; /* Number of sqliteMalloc() calls */extern int sqlite3_nFree; /* Number of sqliteFree() calls */extern int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */extern int sqlite3_iMallocReset; /* Set iMallocFail to this when it reaches 0 */#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 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]))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -