📄 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.764 2008/08/29 18:42:30 rse Exp $*/#ifndef _SQLITEINT_H_#define _SQLITEINT_H_/*** Include the configuration header output by 'configure' if we're using the** autoconf-based build*/#ifdef _HAVE_SQLITE_CONFIG_H#include "config.h"#endif#include "sqliteLimit.h"/* Disable nuisance warnings on Borland compilers */#if defined(__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 /* Suspicous pointer arithmetic */#endif/* Needed for various definitions... */#ifndef _GNU_SOURCE# define _GNU_SOURCE#endif/*** Include standard header files as necessary*/#ifdef HAVE_STDINT_H#include <stdint.h>#endif#ifdef HAVE_INTTYPES_H#include <inttypes.h>#endif/*** A macro used to aid in coverage testing. When doing coverage** testing, the condition inside the argument must be evaluated ** both true and false in order to get full branch coverage.** This macro can be inserted to ensure adequate test coverage** in places where simple condition/decision coverage is inadequate.*/#ifdef SQLITE_COVERAGE_TEST void sqlite3Coverage(int);# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }#else# define testcase(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.**** 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.*/#ifdef SQLITE_COVERAGE_TEST# define ALWAYS(X) (1)# define NEVER(X) (0)#else# define ALWAYS(X) (X)# define NEVER(X) (X)#endif/*** 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 defined(__GNUC__) && 0# define likely(X) __builtin_expect((X),1)# define unlikely(X) __builtin_expect((X),0)#else# define likely(X) !!(X)# define unlikely(X) !!(X)#endif/* * This macro is used to "hide" some ugliness in casting an int * value to a ptr value under the MSVC 64-bit compiler. Casting * non 64-bit values to ptr types results in a "hard" error with * the MSVC 64-bit compiler which this attempts to avoid. * * A simple compiler pragma or casting sequence could not be found * to correct this in all situations, so this macro was introduced. * * It could be argued that the intptr_t type could be used in this * case, but that type is not available on all compilers, or * requires the #include of specific headers which differs between * platforms. */#define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])#define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))/*** 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: 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/*** The SQLITE_THREADSAFE macro must be defined as either 0 or 1.** Older versions of SQLite used an optional THREADSAFE macro.** We support that for legacy*/#if !defined(SQLITE_THREADSAFE)#if defined(THREADSAFE)# define SQLITE_THREADSAFE THREADSAFE#else# define SQLITE_THREADSAFE 1#endif#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()** SQLITE_MEMORY_SIZE // internal allocator #1** SQLITE_MMAP_HEAP_SIZE // internal mmap() allocator** SQLITE_POW2_MEMORY_SIZE // internal power-of-two allocator**** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as** the default.*/#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ defined(SQLITE_MEMORY_SIZE)+defined(SQLITE_MMAP_HEAP_SIZE)+\ defined(SQLITE_POW2_MEMORY_SIZE)>1# error "At most one of the following compile-time configuration options\ is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG, SQLITE_MEMORY_SIZE,\ SQLITE_MMAP_HEAP_SIZE, SQLITE_POW2_MEMORY_SIZE"#endif#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ defined(SQLITE_MEMORY_SIZE)+defined(SQLITE_MMAP_HEAP_SIZE)+\ defined(SQLITE_POW2_MEMORY_SIZE)==0# define SQLITE_SYSTEM_MALLOC 1#endif/*** If SQLITE_MALLOC_SOFT_LIMIT is defined, then try to keep the** sizes of memory allocations below this value where possible.*/#if defined(SQLITE_POW2_MEMORY_SIZE) && !defined(SQLITE_MALLOC_SOFT_LIMIT)# define 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 !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) && SQLITE_THREADSAFE# define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */#endif/*** The TCL headers are only needed when compiling the TCL bindings.*/#if defined(SQLITE_TCL) || defined(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 !defined(NDEBUG) && !defined(SQLITE_DEBUG) # define NDEBUG 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>/*** If compiling for a processor that lacks floating point support,** substitute integer for floating-point*/#ifdef SQLITE_OMIT_FLOATING_POINT# define double sqlite_int64# define LONGDOUBLE_TYPE sqlite_int64# ifndef SQLITE_BIG_DBL# define SQLITE_BIG_DBL (0x7fffffffffffffff)# endif# define SQLITE_OMIT_DATETIME_FUNCS 1# define SQLITE_OMIT_TRACE 1# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT#endif#ifndef SQLITE_BIG_DBL# 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 #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 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 "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.*/#define SQLITE_MAX_FILE_FORMAT 4#ifndef SQLITE_DEFAULT_FILE_FORMAT# define SQLITE_DEFAULT_FILE_FORMAT 1#endif/*** Provide a default value for SQLITE_TEMP_STORE in case it is not specified** on the command-line*/#ifndef SQLITE_TEMP_STORE# define SQLITE_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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -