#ifndef SQLITEINT_H
#define SQLITEINT_H
#ifndef SQLITE_TCLAPI
# define SQLITE_TCLAPI
#endif
#include "msvc.h"
#include "vxworks.h"
#ifndef SQLITE_DISABLE_LFS
# define _LARGE_FILE 1
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
# endif
# define _LARGEFILE_SOURCE 1
#endif
#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)
# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
#else
# define GCC_VERSION 0
#endif
#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)
# define MSVC_VERSION _MSC_VER
#else
# define MSVC_VERSION 0
#endif
#ifndef SQLITE_HAVE_C99_MATH_FUNCS
# if MSVC_VERSION==0 || MSVC_VERSION>=1800
# define SQLITE_HAVE_C99_MATH_FUNCS (1)
# else
# define SQLITE_HAVE_C99_MATH_FUNCS (0)
# endif
#endif
#if defined(__GNUC__) && !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif
#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
# define _BSD_SOURCE
#endif
#if GCC_VERSION>=7000000
# define deliberate_fall_through __attribute__((fallthrough));
#else
# define deliberate_fall_through
#endif
#if defined(_HAVE_MINGW_H)
# include "mingw.h"
#elif defined(_HAVE__MINGW_H)
# include "_mingw.h"
#endif
#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \
defined(_WIN32) && !defined(_WIN64) && \
defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
defined(__MSVCRT__)
# define _USE_32BIT_TIME_T
#endif
#ifdef SQLITE_CUSTOM_INCLUDE
# define INC_STRINGIFY_(f) #f
# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
#endif
#include "sqlite3.h"
#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_VFS1
#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
#include "sqlite_cfg.h"
#define SQLITECONFIG_H 1
#endif
#include "sqliteLimit.h"
#if defined(__BORLANDC__)
#pragma warn -rch
#pragma warn -ccc
#pragma warn -aus
#pragma warn -csu
#pragma warn -spa
#endif
#ifndef __has_extension
# define __has_extension(x) 0
#endif
#if GCC_VERSION>=4007000 || __has_extension(c_atomic)
# define SQLITE_ATOMIC_INTRINSICS 1
# define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED)
# define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
#else
# define SQLITE_ATOMIC_INTRINSICS 0
# define AtomicLoad(PTR) (*(PTR))
# define AtomicStore(PTR,VAL) (*(PTR) = (VAL))
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#if defined(HAVE_STDINT_H)
# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
#elif defined(__PTRDIFF_TYPE__)
# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
#elif !defined(__GNUC__)
# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
#else
# define SQLITE_INT_TO_PTR(X) ((void*)(X))
# define SQLITE_PTR_TO_INT(X) ((int)(X))
#endif
#if defined(__GNUC__)
# define SQLITE_NOINLINE __attribute__((noinline))
# define SQLITE_INLINE __attribute__((always_inline)) inline
#elif defined(_MSC_VER) && _MSC_VER>=1310
# define SQLITE_NOINLINE __declspec(noinline)
# define SQLITE_INLINE __forceinline
#else
# define SQLITE_NOINLINE
# define SQLITE_INLINE
#endif
#if defined(SQLITE_COVERAGE_TEST) || defined(__STRICT_ANSI__)
# undef SQLITE_INLINE
# define SQLITE_INLINE
#endif
#if !defined(SQLITE_DISABLE_INTRINSIC)
# if defined(_MSC_VER) && _MSC_VER>=1400
# if !defined(_WIN32_WCE)
# include <intrin.h>
# pragma intrinsic(_byteswap_ushort)
# pragma intrinsic(_byteswap_ulong)
# pragma intrinsic(_byteswap_uint64)
# pragma intrinsic(_ReadWriteBarrier)
# else
# include <cmnintrin.h>
# endif
# endif
#endif
#if !defined(SQLITE_THREADSAFE)
# if defined(THREADSAFE)
# define SQLITE_THREADSAFE THREADSAFE
# else
# define SQLITE_THREADSAFE 1
# endif
#endif
#ifndef SQLITE_POWERSAFE_OVERWRITE
# define SQLITE_POWERSAFE_OVERWRITE 1
#endif
#if !defined(SQLITE_DEFAULT_MEMSTATUS)
# define SQLITE_DEFAULT_MEMSTATUS 1
#endif
#if defined(SQLITE_SYSTEM_MALLOC) \
+ defined(SQLITE_WIN32_MALLOC) \
+ defined(SQLITE_ZERO_MALLOC) \
+ defined(SQLITE_MEMDEBUG)>1
# error "Two or more of the following compile-time configuration options\
are defined but at most one is allowed:\
SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\
SQLITE_ZERO_MALLOC"
#endif
#if defined(SQLITE_SYSTEM_MALLOC) \
+ defined(SQLITE_WIN32_MALLOC) \
+ defined(SQLITE_ZERO_MALLOC) \
+ defined(SQLITE_MEMDEBUG)==0
# define SQLITE_SYSTEM_MALLOC 1
#endif
#if !defined(SQLITE_MALLOC_SOFT_LIMIT)
# define SQLITE_MALLOC_SOFT_LIMIT 1024
#endif
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
# define _XOPEN_SOURCE 600
#endif
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
# define NDEBUG 1
#endif
#if defined(NDEBUG) && defined(SQLITE_DEBUG)
# undef NDEBUG
#endif
#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
#endif
#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
# ifndef SQLITE_AMALGAMATION
extern unsigned int sqlite3CoverageCounter;
# endif
# define testcase(X) if( X ){ sqlite3CoverageCounter += (unsigned)__LINE__; }
#else
# define testcase(X)
#endif
#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
# define TESTONLY(X) X
#else
# define TESTONLY(X)
#endif
#ifndef NDEBUG
# define VVA_ONLY(X) X
#else
# define VVA_ONLY(X)
#endif
#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
#endif
#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
# define ALWAYS(X) (1)
# define NEVER(X) (0)
#elif !defined(NDEBUG)
# define ALWAYS(X) ((X)?1:(assert(0),0))
# define NEVER(X) ((X)?(assert(0),1):0)
#else
# define ALWAYS(X) (X)
# define NEVER(X) (X)
#endif
#if defined(SQLITE_MUTATION_TEST)
# define OK_IF_ALWAYS_TRUE(X) (1)
# define OK_IF_ALWAYS_FALSE(X) (0)
#else
# define OK_IF_ALWAYS_TRUE(X) (X)
# define OK_IF_ALWAYS_FALSE(X) (X)
#endif
#if defined(SQLITE_TEST_REALLOC_STRESS)
# define ONLY_IF_REALLOC_STRESS(X) (X)
#elif !defined(NDEBUG)
# define ONLY_IF_REALLOC_STRESS(X) ((X)?(assert(0),1):0)
#else
# define ONLY_IF_REALLOC_STRESS(X) (0)
#endif
#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
(defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
extern int sqlite3OSTrace;
# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
# define SQLITE_HAVE_OS_TRACE
#else
# define OSTRACE(X)
# undef SQLITE_HAVE_OS_TRACE
#endif
#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \
(defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
# define SQLITE_NEED_ERR_NAME
#else
# undef SQLITE_NEED_ERR_NAME
#endif
#ifdef SQLITE_OMIT_EXPLAIN
# undef SQLITE_ENABLE_EXPLAIN_COMMENTS
#endif
#if defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_ALTERTABLE)
# define SQLITE_OMIT_ALTERTABLE
#endif
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
#define likely(X) (X)
#define unlikely(X) (X)
#include "hash.h"
#include "parse.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stddef.h>
#ifdef SQLITE_INLINE_MEMCPY
# define memcpy(D,S,N) {char*xxd=(char*)(D);const char*xxs=(const char*)(S);\
int xxn=(N);while(xxn-->0)*(xxd++)=*(xxs++);}
#endif
#ifdef SQLITE_OMIT_FLOATING_POINT
# define double sqlite_int64
# define float sqlite_int64
# define LONGDOUBLE_TYPE sqlite_int64
# ifndef SQLITE_BIG_DBL
# define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
# endif
# define SQLITE_OMIT_DATETIME_FUNCS 1
# define SQLITE_OMIT_TRACE 1
# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
# undef SQLITE_HAVE_ISNAN
#endif
#ifndef SQLITE_BIG_DBL
# define SQLITE_BIG_DBL (1e99)
#endif
#ifdef SQLITE_OMIT_TEMPDB
#define OMIT_TEMPDB 1
#else
#define OMIT_TEMPDB 0
#endif
#define SQLITE_MAX_FILE_FORMAT 4
#ifndef SQLITE_DEFAULT_FILE_FORMAT
# define SQLITE_DEFAULT_FILE_FORMAT 4
#endif
#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS
# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0
#endif
#ifndef SQLITE_TEMP_STORE
# define SQLITE_TEMP_STORE 1
#endif
#if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0
# undef SQLITE_MAX_WORKER_THREADS
# define SQLITE_MAX_WORKER_THREADS 0
#endif
#ifndef SQLITE_MAX_WORKER_THREADS
# define SQLITE_MAX_WORKER_THREADS 8
#endif
#ifndef SQLITE_DEFAULT_WORKER_THREADS
# define SQLITE_DEFAULT_WORKER_THREADS 0
#endif
#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS
# undef SQLITE_MAX_WORKER_THREADS
# define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS
#endif
#ifndef SQLITE_DEFAULT_PCACHE_INITSZ
# define SQLITE_DEFAULT_PCACHE_INITSZ 20
#endif
#ifndef SQLITE_DEFAULT_SORTERREF_SIZE
# define SQLITE_DEFAULT_SORTERREF_SIZE 0x7fffffff
#endif
#if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
#error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE
#endif
#ifndef offsetof
#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
#endif
#ifndef MIN
# define MIN(A,B) ((A)<(B)?(A):(B))
#endif
#ifndef MAX
# define MAX(A,B) ((A)>(B)?(A):(B))
#endif
#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
#if 'A' == '\301'
# define SQLITE_EBCDIC 1
#else
# define SQLITE_ASCII 1
#endif
#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
#endif
typedef sqlite_int64 i64;
typedef sqlite_uint64 u64;
typedef UINT32_TYPE u32;
typedef UINT16_TYPE u16;
typedef INT16_TYPE i16;
typedef UINT8_TYPE u8;
typedef INT8_TYPE i8;
#define SQLITE_MAX_U32 ((((u64)1)<<32)-1)
typedef u64 tRowcnt;
typedef INT16_TYPE LogEst;
#ifndef SQLITE_PTRSIZE
# if defined(__SIZEOF_POINTER__)
# define SQLITE_PTRSIZE __SIZEOF_POINTER__
# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
defined(_M_ARM) || defined(__arm__) || defined(__x86) || \
(defined(__APPLE__) && defined(__POWERPC__)) || \
(defined(__TOS_AIX__) && !defined(__64BIT__))
# define SQLITE_PTRSIZE 4
# else
# define SQLITE_PTRSIZE 8
# endif
#endif
#if defined(HAVE_STDINT_H)
typedef uintptr_t uptr;
#elif SQLITE_PTRSIZE==4
typedef u32 uptr;
#else
typedef u64 uptr;
#endif
#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))
#ifndef SQLITE_BYTEORDER
# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \
defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64)
# define SQLITE_BYTEORDER 1234
# elif defined(sparc) || defined(__ppc__) || \
defined(__ARMEB__) || defined(__AARCH64EB__)
# define SQLITE_BYTEORDER 4321
# else
# define SQLITE_BYTEORDER 0
# endif
#endif
#if SQLITE_BYTEORDER==4321
# define SQLITE_BIGENDIAN 1
# define SQLITE_LITTLEENDIAN 0
# define SQLITE_UTF16NATIVE SQLITE_UTF16BE
#elif SQLITE_BYTEORDER==1234
# define SQLITE_BIGENDIAN 0
# define SQLITE_LITTLEENDIAN 1
# define SQLITE_UTF16NATIVE SQLITE_UTF16LE
#else
# ifdef SQLITE_AMALGAMATION
const int sqlite3one = 1;
# else
extern const int sqlite3one;
# endif
# define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)
# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
#endif
#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
#define LARGEST_UINT64 (0xffffffff|(((u64)0xffffffff)<<32))
#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
#define ROUND8(x) (((x)+7)&~7)
#if SQLITE_PTRSIZE==8
# define ROUND8P(x) (x)
#else
# define ROUND8P(x) (((x)+7)&~7)
#endif
#define ROUNDDOWN8(x) ((x)&~7)
#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
# define EIGHT_BYTE_ALIGNMENT(X) ((((uptr)(X) - (uptr)0)&3)==0)
#else
# define EIGHT_BYTE_ALIGNMENT(X) ((((uptr)(X) - (uptr)0)&7)==0)
#endif
#if defined(__OpenBSD__) || defined(__QNXNTO__)
# undef SQLITE_MAX_MMAP_SIZE
# define SQLITE_MAX_MMAP_SIZE 0
#endif
#ifdef __APPLE__
# include <TargetConditionals.h>
#endif
#ifndef SQLITE_MAX_MMAP_SIZE
# if defined(__linux__) \
|| defined(_WIN32) \
|| (defined(__APPLE__) && defined(__MACH__)) \
|| defined(__sun) \
|| defined(__FreeBSD__) \
|| defined(__DragonFly__)
# define SQLITE_MAX_MMAP_SIZE 0x7fff0000
# else
# define SQLITE_MAX_MMAP_SIZE 0
# endif
#endif
#ifndef SQLITE_DEFAULT_MMAP_SIZE
# define SQLITE_DEFAULT_MMAP_SIZE 0
#endif
#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
# undef SQLITE_DEFAULT_MMAP_SIZE
# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
#endif
#if !defined(SQLITE_AMALGAMATION)
extern u32 sqlite3TreeTrace;
#endif
#if defined(SQLITE_DEBUG) \
&& (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_SELECTTRACE) \
|| defined(SQLITE_ENABLE_TREETRACE))
# define TREETRACE_ENABLED 1
# define TREETRACE(K,P,S,X) \
if(sqlite3TreeTrace&(K)) \
sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\
sqlite3DebugPrintf X
#else
# define TREETRACE(K,P,S,X)
# define TREETRACE_ENABLED 0
#endif
extern u32 sqlite3WhereTrace;
#if defined(SQLITE_DEBUG) \
&& (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))
# define WHERETRACE(K,X) if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X
# define WHERETRACE_ENABLED 1
#else
# define WHERETRACE(K,X)
#endif
typedef struct BusyHandler BusyHandler;
struct BusyHandler {
int (*xBusyHandler)(void *,int);
void *pBusyArg;
int nBusy;
};
#define LEGACY_SCHEMA_TABLE "sqlite_master"
#define LEGACY_TEMP_SCHEMA_TABLE "sqlite_temp_master"
#define PREFERRED_SCHEMA_TABLE "sqlite_schema"
#define PREFERRED_TEMP_SCHEMA_TABLE "sqlite_temp_schema"
#define SCHEMA_ROOT 1
#define SCHEMA_TABLE(x) \
((!OMIT_TEMPDB)&&(x==1)?LEGACY_TEMP_SCHEMA_TABLE:LEGACY_SCHEMA_TABLE)
#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0])))
#define IsPowerOfTwo(X) (((X)&((X)-1))==0)
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3OomClear)
#ifdef SQLITE_OMIT_WSD
#define SQLITE_WSD const
#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
int sqlite3_wsd_init(int N, int J);
void *sqlite3_wsd_find(void *K, int L);
#else
#define SQLITE_WSD
#define GLOBAL(t,v) v
#define sqlite3GlobalConfig sqlite3Config
#endif
#define UNUSED_PARAMETER(x) (void)(x)
#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)
typedef struct AggInfo AggInfo;
typedef struct AuthContext AuthContext;
typedef struct AutoincInfo AutoincInfo;
typedef struct Bitvec Bitvec;
typedef struct CollSeq CollSeq;
typedef struct Column Column;
typedef struct Cte Cte;
typedef struct CteUse CteUse;
typedef struct Db Db;
typedef struct DbFixer DbFixer;
typedef struct Schema Schema;
typedef struct Expr Expr;
typedef struct ExprList ExprList;
typedef struct FKey FKey;
typedef struct FuncDestructor FuncDestructor;
typedef struct FuncDef FuncDef;
typedef struct FuncDefHash FuncDefHash;
typedef struct IdList IdList;
typedef struct Index Index;
typedef struct IndexedExpr IndexedExpr;
typedef struct IndexSample IndexSample;
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 OnOrUsing OnOrUsing;
typedef struct Parse Parse;
typedef struct ParseCleanup ParseCleanup;
typedef struct PreUpdate PreUpdate;
typedef struct PrintfArguments PrintfArguments;
typedef struct RenameToken RenameToken;
typedef struct Returning Returning;
typedef struct RowSet RowSet;
typedef struct Savepoint Savepoint;
typedef struct Select Select;
typedef struct SQLiteThread SQLiteThread;
typedef struct SelectDest SelectDest;
typedef struct SrcItem SrcItem;
typedef struct SrcList SrcList;
typedef struct sqlite3_str StrAccum;
typedef struct Table Table;
typedef struct TableLock TableLock;
typedef struct Token Token;
typedef struct TreeView TreeView;
typedef struct Trigger Trigger;
typedef struct TriggerPrg TriggerPrg;
typedef struct TriggerStep TriggerStep;
typedef struct UnpackedRecord UnpackedRecord;
typedef struct Upsert Upsert;
typedef struct VTable VTable;
typedef struct VtabCtx VtabCtx;
typedef struct Walker Walker;
typedef struct WhereInfo WhereInfo;
typedef struct Window Window;
typedef struct With With;
#ifdef SQLITE_BITMASK_TYPE
typedef SQLITE_BITMASK_TYPE Bitmask;
#else
typedef u64 Bitmask;
#endif
#define BMS ((int)(sizeof(Bitmask)*8))
#define MASKBIT(n) (((Bitmask)1)<<(n))
#define MASKBIT64(n) (((u64)1)<<(n))
#define MASKBIT32(n) (((unsigned int)1)<<(n))
#define SMASKBIT32(n) ((n)<=31?((unsigned int)1)<<(n):0)
#define ALLBITS ((Bitmask)-1)
#define TOPBIT (((Bitmask)1)<<(BMS-1))
typedef int VList;
#include "os.h"
#include "pager.h"
#include "btree.h"
#include "vdbe.h"
#include "pcache.h"
#include "mutex.h"
#ifdef SQLITE_EXTRA_DURABLE
# warning Use SQLITE_DEFAULT_SYNCHRONOUS=3 instead of SQLITE_EXTRA_DURABLE
# define SQLITE_DEFAULT_SYNCHRONOUS 3
#endif
#ifndef SQLITE_DEFAULT_SYNCHRONOUS
# define SQLITE_DEFAULT_SYNCHRONOUS 2
#endif
#ifndef SQLITE_DEFAULT_WAL_SYNCHRONOUS
# define SQLITE_DEFAULT_WAL_SYNCHRONOUS SQLITE_DEFAULT_SYNCHRONOUS
#endif
struct Db {
char *zDbSName;
Btree *pBt;
u8 safety_level;
u8 bSyncSet;
Schema *pSchema;
};
struct Schema {
int schema_cookie;
int iGeneration;
Hash tblHash;
Hash idxHash;
Hash trigHash;
Hash fkeyHash;
Table *pSeqTab;
u8 file_format;
u8 enc;
u16 schemaFlags;
int cache_size;
};
#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->schemaFlags&(P))==(P))
#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->schemaFlags&(P))!=0)
#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->schemaFlags|=(P)
#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->schemaFlags&=~(P)
#define DB_SchemaLoaded 0x0001
#define DB_UnresetViews 0x0002
#define DB_ResetWanted 0x0008
#define SQLITE_N_LIMIT (SQLITE_LIMIT_WORKER_THREADS+1)
struct Lookaside {
u32 bDisable;
u16 sz;
u16 szTrue;
u8 bMalloced;
u32 nSlot;
u32 anStat[3];
LookasideSlot *pInit;
LookasideSlot *pFree;
#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
LookasideSlot *pSmallInit;
LookasideSlot *pSmallFree;
void *pMiddle;
#endif
void *pStart;
void *pEnd;
void *pTrueEnd;
};
struct LookasideSlot {
LookasideSlot *pNext;
};
#define DisableLookaside db->lookaside.bDisable++;db->lookaside.sz=0
#define EnableLookaside db->lookaside.bDisable--;\
db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue
#ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE
# define LOOKASIDE_SMALL 0
#else
# define LOOKASIDE_SMALL 128
#endif
#define SQLITE_FUNC_HASH_SZ 23
struct FuncDefHash {
FuncDef *a[SQLITE_FUNC_HASH_SZ];
};
#define SQLITE_FUNC_HASH(C,L) (((C)+(L))%SQLITE_FUNC_HASH_SZ)
#ifdef SQLITE_USER_AUTHENTICATION
typedef struct sqlite3_userauth sqlite3_userauth;
struct sqlite3_userauth {
u8 authLevel;
int nAuthPW;
char *zAuthPW;
char *zAuthUser;
};
#define UAUTH_Unknown 0
#define UAUTH_Fail 1
#define UAUTH_User 2
#define UAUTH_Admin 3
int sqlite3UserAuthTable(const char*);
int sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);
void sqlite3UserAuthInit(sqlite3*);
void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);
#endif
#ifdef SQLITE_USER_AUTHENTICATION
typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
const char*, const char*);
#else
typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
const char*);
#endif
#ifndef SQLITE_OMIT_DEPRECATED
#define SQLITE_TRACE_LEGACY 0x40
#define SQLITE_TRACE_XPROFILE 0x80
#else
#define SQLITE_TRACE_LEGACY 0
#define SQLITE_TRACE_XPROFILE 0
#endif
#define SQLITE_TRACE_NONLEGACY_MASK 0x0f
#define SQLITE_MAX_DB (SQLITE_MAX_ATTACHED+2)
struct sqlite3 {
sqlite3_vfs *pVfs;
struct Vdbe *pVdbe;
CollSeq *pDfltColl;
sqlite3_mutex *mutex;
Db *aDb;
int nDb;
u32 mDbFlags;
u64 flags;
i64 lastRowid;
i64 szMmap;
u32 nSchemaLock;
unsigned int openFlags;
int errCode;
int errByteOffset;
int errMask;
int iSysErrno;
u32 dbOptFlags;
u8 enc;
u8 autoCommit;
u8 temp_store;
u8 mallocFailed;
u8 bBenignMalloc;
u8 dfltLockMode;
signed char nextAutovac;
u8 suppressErr;
u8 vtabOnConflict;
u8 isTransactionSavepoint;
u8 mTrace;
u8 noSharedCache;
u8 nSqlExec;
u8 eOpenState;
int nextPagesize;
i64 nChange;
i64 nTotalChange;
int aLimit[SQLITE_N_LIMIT];
int nMaxSorterMmap;
struct sqlite3InitInfo {
Pgno newTnum;
u8 iDb;
u8 busy;
unsigned orphanTrigger : 1;
unsigned imposterTable : 1;
unsigned reopenMemdb : 1;
const char **azInit;
} init;
int nVdbeActive;
int nVdbeRead;
int nVdbeWrite;
int nVdbeExec;
int nVDestroy;
int nExtension;
void **aExtension;
union {
void (*xLegacy)(void*,const char*);
int (*xV2)(u32,void*,void*,void*);
} trace;
void *pTraceArg;
#ifndef SQLITE_OMIT_DEPRECATED
void (*xProfile)(void*,const char*,u64);
void *pProfileArg;
#endif
void *pCommitArg;
int (*xCommitCallback)(void*);
void *pRollbackArg;
void (*xRollbackCallback)(void*);
void *pUpdateArg;
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
void *pAutovacPagesArg;
void (*xAutovacDestr)(void*);
unsigned int (*xAutovacPages)(void*,const char*,u32,u32,u32);
Parse *pParse;
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
void *pPreUpdateArg;
void (*xPreUpdateCallback)(
void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64
);
PreUpdate *pPreUpdate;
#endif
#ifndef SQLITE_OMIT_WAL
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
void *pWalArg;
#endif
void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);
void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);
void *pCollNeededArg;
sqlite3_value *pErr;
union {
volatile int isInterrupted;
double notUsed1;
} u1;
Lookaside lookaside;
#ifndef SQLITE_OMIT_AUTHORIZATION
sqlite3_xauth xAuth;
void *pAuthArg;
#endif
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
int (*xProgress)(void *);
void *pProgressArg;
unsigned nProgressOps;
#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
int nVTrans;
Hash aModule;
VtabCtx *pVtabCtx;
VTable **aVTrans;
VTable *pDisconnect;
#endif
Hash aFunc;
Hash aCollSeq;
BusyHandler busyHandler;
Db aDbStatic[2];
Savepoint *pSavepoint;
int nAnalysisLimit;
int busyTimeout;
int nSavepoint;
int nStatement;
i64 nDeferredCons;
i64 nDeferredImmCons;
int *pnBytesFreed;
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
sqlite3 *pBlockingConnection;
sqlite3 *pUnlockConnection;
void *pUnlockArg;
void (*xUnlockNotify)(void **, int);
sqlite3 *pNextBlocked;
#endif
#ifdef SQLITE_USER_AUTHENTICATION
sqlite3_userauth auth;
#endif
};
#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
#define ENC(db) ((db)->enc)
#define HI(X) ((u64)(X)<<32)
#define SQLITE_WriteSchema 0x00000001
#define SQLITE_LegacyFileFmt 0x00000002
#define SQLITE_FullColNames 0x00000004
#define SQLITE_FullFSync 0x00000008
#define SQLITE_CkptFullFSync 0x00000010
#define SQLITE_CacheSpill 0x00000020
#define SQLITE_ShortColNames 0x00000040
#define SQLITE_TrustedSchema 0x00000080
#define SQLITE_NullCallback 0x00000100
#define SQLITE_IgnoreChecks 0x00000200
#define SQLITE_StmtScanStatus 0x00000400
#define SQLITE_NoCkptOnClose 0x00000800
#define SQLITE_ReverseOrder 0x00001000
#define SQLITE_RecTriggers 0x00002000
#define SQLITE_ForeignKeys 0x00004000
#define SQLITE_AutoIndex 0x00008000
#define SQLITE_LoadExtension 0x00010000
#define SQLITE_LoadExtFunc 0x00020000
#define SQLITE_EnableTrigger 0x00040000
#define SQLITE_DeferFKs 0x00080000
#define SQLITE_QueryOnly 0x00100000
#define SQLITE_CellSizeCk 0x00200000
#define SQLITE_Fts3Tokenizer 0x00400000
#define SQLITE_EnableQPSG 0x00800000
#define SQLITE_TriggerEQP 0x01000000
#define SQLITE_ResetDatabase 0x02000000
#define SQLITE_LegacyAlter 0x04000000
#define SQLITE_NoSchemaError 0x08000000
#define SQLITE_Defensive 0x10000000
#define SQLITE_DqsDDL 0x20000000
#define SQLITE_DqsDML 0x40000000
#define SQLITE_EnableView 0x80000000
#define SQLITE_CountRows HI(0x00001)
#define SQLITE_CorruptRdOnly HI(0x00002)
#define SQLITE_ReadUncommit HI(0x00004)
#ifdef SQLITE_DEBUG
#define SQLITE_SqlTrace HI(0x0100000)
#define SQLITE_VdbeListing HI(0x0200000)
#define SQLITE_VdbeTrace HI(0x0400000)
#define SQLITE_VdbeAddopTrace HI(0x0800000)
#define SQLITE_VdbeEQP HI(0x1000000)
#define SQLITE_ParserTrace HI(0x2000000)
#endif
#define DBFLAG_SchemaChange 0x0001
#define DBFLAG_PreferBuiltin 0x0002
#define DBFLAG_Vacuum 0x0004
#define DBFLAG_VacuumInto 0x0008
#define DBFLAG_SchemaKnownOk 0x0010
#define DBFLAG_InternalFunc 0x0020
#define DBFLAG_EncodingFixed 0x0040
#define SQLITE_QueryFlattener 0x00000001
#define SQLITE_WindowFunc 0x00000002
#define SQLITE_GroupByOrder 0x00000004
#define SQLITE_FactorOutConst 0x00000008
#define SQLITE_DistinctOpt 0x00000010
#define SQLITE_CoverIdxScan 0x00000020
#define SQLITE_OrderByIdxJoin 0x00000040
#define SQLITE_Transitive 0x00000080
#define SQLITE_OmitNoopJoin 0x00000100
#define SQLITE_CountOfView 0x00000200
#define SQLITE_CursorHints 0x00000400
#define SQLITE_Stat4 0x00000800
#define SQLITE_PushDown 0x00001000
#define SQLITE_SimplifyJoin 0x00002000
#define SQLITE_SkipScan 0x00004000
#define SQLITE_PropagateConst 0x00008000
#define SQLITE_MinMaxOpt 0x00010000
#define SQLITE_SeekScan 0x00020000
#define SQLITE_OmitOrderBy 0x00040000
#define SQLITE_BloomFilter 0x00080000
#define SQLITE_BloomPulldown 0x00100000
#define SQLITE_BalancedMerge 0x00200000
#define SQLITE_ReleaseReg 0x00400000
#define SQLITE_FlttnUnionAll 0x00800000
#define SQLITE_IndexedExpr 0x01000000
#define SQLITE_Coroutines 0x02000000
#define SQLITE_NullUnusedCols 0x04000000
#define SQLITE_AllOpts 0xffffffff
#define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0)
#define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0)
#define ConstFactorOk(P) ((P)->okConstFactor)
#define SQLITE_STATE_OPEN 0x76
#define SQLITE_STATE_CLOSED 0xce
#define SQLITE_STATE_SICK 0xba
#define SQLITE_STATE_BUSY 0x6d
#define SQLITE_STATE_ERROR 0xd5
#define SQLITE_STATE_ZOMBIE 0xa7
struct FuncDef {
i8 nArg;
u32 funcFlags;
void *pUserData;
FuncDef *pNext;
void (*xSFunc)(sqlite3_context*,int,sqlite3_value**);
void (*xFinalize)(sqlite3_context*);
void (*xValue)(sqlite3_context*);
void (*xInverse)(sqlite3_context*,int,sqlite3_value**);
const char *zName;
union {
FuncDef *pHash;
FuncDestructor *pDestructor;
} u;
};
struct FuncDestructor {
int nRef;
void (*xDestroy)(void *);
void *pUserData;
};
#define SQLITE_FUNC_ENCMASK 0x0003
#define SQLITE_FUNC_LIKE 0x0004
#define SQLITE_FUNC_CASE 0x0008
#define SQLITE_FUNC_EPHEM 0x0010
#define SQLITE_FUNC_NEEDCOLL 0x0020
#define SQLITE_FUNC_LENGTH 0x0040
#define SQLITE_FUNC_TYPEOF 0x0080
#define SQLITE_FUNC_COUNT 0x0100
#define SQLITE_FUNC_UNLIKELY 0x0400
#define SQLITE_FUNC_CONSTANT 0x0800
#define SQLITE_FUNC_MINMAX 0x1000
#define SQLITE_FUNC_SLOCHNG 0x2000
#define SQLITE_FUNC_TEST 0x4000
#define SQLITE_FUNC_WINDOW 0x00010000
#define SQLITE_FUNC_INTERNAL 0x00040000
#define SQLITE_FUNC_DIRECT 0x00080000
#define SQLITE_FUNC_SUBTYPE 0x00100000
#define SQLITE_FUNC_UNSAFE 0x00200000
#define SQLITE_FUNC_INLINE 0x00400000
#define SQLITE_FUNC_BUILTIN 0x00800000
#define SQLITE_FUNC_ANYORDER 0x08000000
#define INLINEFUNC_coalesce 0
#define INLINEFUNC_implies_nonnull_row 1
#define INLINEFUNC_expr_implies_expr 2
#define INLINEFUNC_expr_compare 3
#define INLINEFUNC_affinity 4
#define INLINEFUNC_iif 5
#define INLINEFUNC_sqlite_offset 6
#define INLINEFUNC_unlikely 99
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define MFUNCTION(zName, nArg, xPtr, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
xPtr, 0, xFunc, 0, 0, 0, #zName, {0} }
#define JFUNCTION(zName, nArg, iArg, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|\
SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define INLINE_FUNC(zName, nArg, iArg, mFlags) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} }
#define TEST_FUNC(zName, nArg, iArg, mFlags) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_UTF8|SQLITE_FUNC_INTERNAL|SQLITE_FUNC_TEST| \
SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} }
#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \
0, 0, xFunc, 0, 0, 0, #zName, {0} }
#define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
(void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} }
#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
pArg, 0, xFunc, 0, 0, 0, #zName, }
#define LIKEFUNC(zName, nArg, arg, flags) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
(void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
#define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
#define INTERNAL_FUNCTION(zName, nArg, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
0, 0, xFunc, 0, 0, 0, #zName, {0} }
struct Savepoint {
char *zName;
i64 nDeferredCons;
i64 nDeferredImmCons;
Savepoint *pNext;
};
#define SAVEPOINT_BEGIN 0
#define SAVEPOINT_RELEASE 1
#define SAVEPOINT_ROLLBACK 2
struct Module {
const sqlite3_module *pModule;
const char *zName;
int nRefModule;
void *pAux;
void (*xDestroy)(void *);
Table *pEpoTab;
};
struct Column {
char *zCnName;
unsigned notNull :4;
unsigned eCType :4;
char affinity;
u8 szEst;
u8 hName;
u16 iDflt;
u16 colFlags;
};
#define COLTYPE_CUSTOM 0
#define COLTYPE_ANY 1
#define COLTYPE_BLOB 2
#define COLTYPE_INT 3
#define COLTYPE_INTEGER 4
#define COLTYPE_REAL 5
#define COLTYPE_TEXT 6
#define SQLITE_N_STDTYPE 6
#define COLFLAG_PRIMKEY 0x0001
#define COLFLAG_HIDDEN 0x0002
#define COLFLAG_HASTYPE 0x0004
#define COLFLAG_UNIQUE 0x0008
#define COLFLAG_SORTERREF 0x0010
#define COLFLAG_VIRTUAL 0x0020
#define COLFLAG_STORED 0x0040
#define COLFLAG_NOTAVAIL 0x0080
#define COLFLAG_BUSY 0x0100
#define COLFLAG_HASCOLL 0x0200
#define COLFLAG_NOEXPAND 0x0400
#define COLFLAG_GENERATED 0x0060
#define COLFLAG_NOINSERT 0x0062
struct CollSeq {
char *zName;
u8 enc;
void *pUser;
int (*xCmp)(void*,int, const void*, int, const void*);
void (*xDel)(void*);
};
#define SQLITE_SO_ASC 0
#define SQLITE_SO_DESC 1
#define SQLITE_SO_UNDEFINED -1
#define SQLITE_AFF_NONE 0x40
#define SQLITE_AFF_BLOB 0x41
#define SQLITE_AFF_TEXT 0x42
#define SQLITE_AFF_NUMERIC 0x43
#define SQLITE_AFF_INTEGER 0x44
#define SQLITE_AFF_REAL 0x45
#define SQLITE_AFF_FLEXNUM 0x46
#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC)
#define SQLITE_AFF_MASK 0x47
#define SQLITE_JUMPIFNULL 0x10
#define SQLITE_NULLEQ 0x80
#define SQLITE_NOTNULL 0x90
struct VTable {
sqlite3 *db;
Module *pMod;
sqlite3_vtab *pVtab;
int nRef;
u8 bConstraint;
u8 bAllSchemas;
u8 eVtabRisk;
int iSavepoint;
VTable *pNext;
};
#define SQLITE_VTABRISK_Low 0
#define SQLITE_VTABRISK_Normal 1
#define SQLITE_VTABRISK_High 2
struct Table {
char *zName;
Column *aCol;
Index *pIndex;
char *zColAff;
ExprList *pCheck;
Pgno tnum;
u32 nTabRef;
u32 tabFlags;
i16 iPKey;
i16 nCol;
i16 nNVCol;
LogEst nRowLogEst;
LogEst szTabRow;
#ifdef SQLITE_ENABLE_COSTMULT
LogEst costMult;
#endif
u8 keyConf;
u8 eTabType;
union {
struct {
int addColOffset;
FKey *pFKey;
ExprList *pDfltList;
} tab;
struct {
Select *pSelect;
} view;
struct {
int nArg;
char **azArg;
VTable *p;
} vtab;
} u;
Trigger *pTrigger;
Schema *pSchema;
};
#define TF_Readonly 0x00000001
#define TF_HasHidden 0x00000002
#define TF_HasPrimaryKey 0x00000004
#define TF_Autoincrement 0x00000008
#define TF_HasStat1 0x00000010
#define TF_HasVirtual 0x00000020
#define TF_HasStored 0x00000040
#define TF_HasGenerated 0x00000060
#define TF_WithoutRowid 0x00000080
#define TF_StatsUsed 0x00000100
#define TF_NoVisibleRowid 0x00000200
#define TF_OOOHidden 0x00000400
#define TF_HasNotNull 0x00000800
#define TF_Shadow 0x00001000
#define TF_HasStat4 0x00002000
#define TF_Ephemeral 0x00004000
#define TF_Eponymous 0x00008000
#define TF_Strict 0x00010000
#define TABTYP_NORM 0
#define TABTYP_VTAB 1
#define TABTYP_VIEW 2
#define IsView(X) ((X)->eTabType==TABTYP_VIEW)
#define IsOrdinaryTable(X) ((X)->eTabType==TABTYP_NORM)
#ifndef SQLITE_OMIT_VIRTUALTABLE
# define IsVirtual(X) ((X)->eTabType==TABTYP_VTAB)
# define ExprIsVtab(X) \
((X)->op==TK_COLUMN && (X)->y.pTab->eTabType==TABTYP_VTAB)
#else
# define IsVirtual(X) 0
# define ExprIsVtab(X) 0
#endif
#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)
# define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
# define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
#elif !defined(SQLITE_OMIT_VIRTUALTABLE)
# define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
# define IsOrdinaryHiddenColumn(X) 0
#else
# define IsHiddenColumn(X) 0
# define IsOrdinaryHiddenColumn(X) 0
#endif
#define HasRowid(X) (((X)->tabFlags & TF_WithoutRowid)==0)
#define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)
struct FKey {
Table *pFrom;
FKey *pNextFrom;
char *zTo;
FKey *pNextTo;
FKey *pPrevTo;
int nCol;
u8 isDeferred;
u8 aAction[2];
Trigger *apTrigger[2];
struct sColMap {
int iFrom;
char *zCol;
} aCol[1];
};
#define OE_None 0
#define OE_Rollback 1
#define OE_Abort 2
#define OE_Fail 3
#define OE_Ignore 4
#define OE_Replace 5
#define OE_Update 6
#define OE_Restrict 7
#define OE_SetNull 8
#define OE_SetDflt 9
#define OE_Cascade 10
#define OE_Default 11
struct KeyInfo {
u32 nRef;
u8 enc;
u16 nKeyField;
u16 nAllField;
sqlite3 *db;
u8 *aSortFlags;
CollSeq *aColl[1];
};
#define KEYINFO_ORDER_DESC 0x01
#define KEYINFO_ORDER_BIGNULL 0x02
struct UnpackedRecord {
KeyInfo *pKeyInfo;
Mem *aMem;
union {
char *z;
i64 i;
} u;
int n;
u16 nField;
i8 default_rc;
u8 errCode;
i8 r1;
i8 r2;
u8 eqSeen;
};
struct Index {
char *zName;
i16 *aiColumn;
LogEst *aiRowLogEst;
Table *pTable;
char *zColAff;
Index *pNext;
Schema *pSchema;
u8 *aSortOrder;
const char **azColl;
Expr *pPartIdxWhere;
ExprList *aColExpr;
Pgno tnum;
LogEst szIdxRow;
u16 nKeyCol;
u16 nColumn;
u8 onError;
unsigned idxType:2;
unsigned bUnordered:1;
unsigned uniqNotNull:1;
unsigned isResized:1;
unsigned isCovering:1;
unsigned noSkipScan:1;
unsigned hasStat1:1;
unsigned bNoQuery:1;
unsigned bAscKeyBug:1;
unsigned bHasVCol:1;
unsigned bHasExpr:1;
#ifdef SQLITE_ENABLE_STAT4
int nSample;
int mxSample;
int nSampleCol;
tRowcnt *aAvgEq;
IndexSample *aSample;
tRowcnt *aiRowEst;
tRowcnt nRowEst0;
#endif
Bitmask colNotIdxed;
};
#define SQLITE_IDXTYPE_APPDEF 0
#define SQLITE_IDXTYPE_UNIQUE 1
#define SQLITE_IDXTYPE_PRIMARYKEY 2
#define SQLITE_IDXTYPE_IPK 3
#define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)
#define IsUniqueIndex(X) ((X)->onError!=OE_None)
#define XN_ROWID (-1)
#define XN_EXPR (-2)
struct IndexSample {
void *p;
int n;
tRowcnt *anEq;
tRowcnt *anLt;
tRowcnt *anDLt;
};
#define SQLITE_TOKEN_QUOTED 0x1
#define SQLITE_TOKEN_KEYWORD 0x2
struct Token {
const char *z;
unsigned int n;
};
struct AggInfo {
u8 directMode;
u8 useSortingIdx;
u16 nSortingColumn;
int sortingIdx;
int sortingIdxPTab;
int iFirstReg;
ExprList *pGroupBy;
struct AggInfo_col {
Table *pTab;
Expr *pCExpr;
int iTable;
i16 iColumn;
i16 iSorterColumn;
} *aCol;
int nColumn;
int nAccumulator;
struct AggInfo_func {
Expr *pFExpr;
FuncDef *pFunc;
int iDistinct;
int iDistAddr;
} *aFunc;
int nFunc;
u32 selId;
#ifdef SQLITE_DEBUG
Select *pSelect;
#endif
};
#define AggInfoColumnReg(A,I) (assert((A)->iFirstReg),(A)->iFirstReg+(I))
#define AggInfoFuncReg(A,I) \
(assert((A)->iFirstReg),(A)->iFirstReg+(A)->nColumn+(I))
#if SQLITE_MAX_VARIABLE_NUMBER<32767
typedef i16 ynVar;
#else
typedef int ynVar;
#endif
struct Expr {
u8 op;
char affExpr;
u8 op2;
#ifdef SQLITE_DEBUG
u8 vvaFlags;
#endif
u32 flags;
union {
char *zToken;
int iValue;
} u;
Expr *pLeft;
Expr *pRight;
union {
ExprList *pList;
Select *pSelect;
} x;
#if SQLITE_MAX_EXPR_DEPTH>0
int nHeight;
#endif
int iTable;
ynVar iColumn;
i16 iAgg;
union {
int iJoin;
int iOfst;
} w;
AggInfo *pAggInfo;
union {
Table *pTab;
Window *pWin;
struct {
int iAddr;
int regReturn;
} sub;
} y;
};
#define EP_OuterON 0x000001
#define EP_InnerON 0x000002
#define EP_Distinct 0x000004
#define EP_HasFunc 0x000008
#define EP_Agg 0x000010
#define EP_FixedCol 0x000020
#define EP_VarSelect 0x000040
#define EP_DblQuoted 0x000080
#define EP_InfixFunc 0x000100
#define EP_Collate 0x000200
#define EP_Commuted 0x000400
#define EP_IntValue 0x000800
#define EP_xIsSelect 0x001000
#define EP_Skip 0x002000
#define EP_Reduced 0x004000
#define EP_Win 0x008000
#define EP_TokenOnly 0x010000
#define EP_IfNullRow 0x040000
#define EP_Unlikely 0x080000
#define EP_ConstFunc 0x100000
#define EP_CanBeNull 0x200000
#define EP_Subquery 0x400000
#define EP_Leaf 0x800000
#define EP_WinFunc 0x1000000
#define EP_Subrtn 0x2000000
#define EP_Quoted 0x4000000
#define EP_Static 0x8000000
#define EP_IsTrue 0x10000000
#define EP_IsFalse 0x20000000
#define EP_FromDDL 0x40000000
#define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc)
#define ExprHasProperty(E,P) (((E)->flags&(P))!=0)
#define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P))
#define ExprSetProperty(E,P) (E)->flags|=(P)
#define ExprClearProperty(E,P) (E)->flags&=~(P)
#define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue)
#define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse)
#define ExprUseUToken(E) (((E)->flags&EP_IntValue)==0)
#define ExprUseUValue(E) (((E)->flags&EP_IntValue)!=0)
#define ExprUseWOfst(E) (((E)->flags&(EP_InnerON|EP_OuterON))==0)
#define ExprUseWJoin(E) (((E)->flags&(EP_InnerON|EP_OuterON))!=0)
#define ExprUseXList(E) (((E)->flags&EP_xIsSelect)==0)
#define ExprUseXSelect(E) (((E)->flags&EP_xIsSelect)!=0)
#define ExprUseYTab(E) (((E)->flags&(EP_WinFunc|EP_Subrtn))==0)
#define ExprUseYWin(E) (((E)->flags&EP_WinFunc)!=0)
#define ExprUseYSub(E) (((E)->flags&EP_Subrtn)!=0)
#define EP_NoReduce 0x01
#define EP_Immutable 0x02
#ifdef SQLITE_DEBUG
# define ExprSetVVAProperty(E,P) (E)->vvaFlags|=(P)
# define ExprHasVVAProperty(E,P) (((E)->vvaFlags&(P))!=0)
# define ExprClearVVAProperties(E) (E)->vvaFlags = 0
#else
# define ExprSetVVAProperty(E,P)
# define ExprHasVVAProperty(E,P) 0
# define ExprClearVVAProperties(E)
#endif
#define EXPR_FULLSIZE sizeof(Expr)
#define EXPR_REDUCEDSIZE offsetof(Expr,iTable)
#define EXPR_TOKENONLYSIZE offsetof(Expr,pLeft)
#define EXPRDUP_REDUCE 0x0001
#ifdef SQLITE_OMIT_WINDOWFUNC
# define IsWindowFunc(p) 0
#else
# define IsWindowFunc(p) ( \
ExprHasProperty((p), EP_WinFunc) && p->y.pWin->eFrmType!=TK_FILTER \
)
#endif
struct ExprList {
int nExpr;
int nAlloc;
struct ExprList_item {
Expr *pExpr;
char *zEName;
struct {
u8 sortFlags;
unsigned eEName :2;
unsigned done :1;
unsigned reusable :1;
unsigned bSorterRef :1;
unsigned bNulls :1;
unsigned bUsed :1;
unsigned bUsingTerm:1;
unsigned bNoExpand: 1;
} fg;
union {
struct {
u16 iOrderByCol;
u16 iAlias;
} x;
int iConstExprReg;
} u;
} a[1];
};
#define ENAME_NAME 0
#define ENAME_SPAN 1
#define ENAME_TAB 2
struct IdList {
int nId;
u8 eU4;
struct IdList_item {
char *zName;
union {
int idx;
Expr *pExpr;
} u4;
} a[1];
};
#define EU4_NONE 0
#define EU4_IDX 1
#define EU4_EXPR 2
struct SrcItem {
Schema *pSchema;
char *zDatabase;
char *zName;
char *zAlias;
Table *pTab;
Select *pSelect;
int addrFillSub;
int regReturn;
int regResult;
struct {
u8 jointype;
unsigned notIndexed :1;
unsigned isIndexedBy :1;
unsigned isTabFunc :1;
unsigned isCorrelated :1;
unsigned isMaterialized:1;
unsigned viaCoroutine :1;
unsigned isRecursive :1;
unsigned fromDDL :1;
unsigned isCte :1;
unsigned notCte :1;
unsigned isUsing :1;
unsigned isOn :1;
unsigned isSynthUsing :1;
unsigned isNestedFrom :1;
} fg;
int iCursor;
union {
Expr *pOn;
IdList *pUsing;
} u3;
Bitmask colUsed;
union {
char *zIndexedBy;
ExprList *pFuncArg;
} u1;
union {
Index *pIBIndex;
CteUse *pCteUse;
} u2;
};
struct OnOrUsing {
Expr *pOn;
IdList *pUsing;
};
struct SrcList {
int nSrc;
u32 nAlloc;
SrcItem a[1];
};
#define JT_INNER 0x01
#define JT_CROSS 0x02
#define JT_NATURAL 0x04
#define JT_LEFT 0x08
#define JT_RIGHT 0x10
#define JT_OUTER 0x20
#define JT_LTORJ 0x40
#define JT_ERROR 0x80
#define WHERE_ORDERBY_NORMAL 0x0000
#define WHERE_ORDERBY_MIN 0x0001
#define WHERE_ORDERBY_MAX 0x0002
#define WHERE_ONEPASS_DESIRED 0x0004
#define WHERE_ONEPASS_MULTIROW 0x0008
#define WHERE_DUPLICATES_OK 0x0010
#define WHERE_OR_SUBCLAUSE 0x0020
#define WHERE_GROUPBY 0x0040
#define WHERE_DISTINCTBY 0x0080
#define WHERE_WANT_DISTINCT 0x0100
#define WHERE_SORTBYGROUP 0x0200
#define WHERE_AGG_DISTINCT 0x0400
#define WHERE_ORDERBY_LIMIT 0x0800
#define WHERE_RIGHT_JOIN 0x1000
#define WHERE_USE_LIMIT 0x4000
#define WHERE_DISTINCT_NOOP 0
#define WHERE_DISTINCT_UNIQUE 1
#define WHERE_DISTINCT_ORDERED 2
#define WHERE_DISTINCT_UNORDERED 3
struct NameContext {
Parse *pParse;
SrcList *pSrcList;
union {
ExprList *pEList;
AggInfo *pAggInfo;
Upsert *pUpsert;
int iBaseReg;
} uNC;
NameContext *pNext;
int nRef;
int nNcErr;
int ncFlags;
Select *pWinSelect;
};
#define NC_AllowAgg 0x000001
#define NC_PartIdx 0x000002
#define NC_IsCheck 0x000004
#define NC_GenCol 0x000008
#define NC_HasAgg 0x000010
#define NC_IdxExpr 0x000020
#define NC_SelfRef 0x00002e
#define NC_Subquery 0x000040
#define NC_UEList 0x000080
#define NC_UAggInfo 0x000100
#define NC_UUpsert 0x000200
#define NC_UBaseReg 0x000400
#define NC_MinMaxAgg 0x001000
#define NC_Complex 0x002000
#define NC_AllowWin 0x004000
#define NC_HasWin 0x008000
#define NC_IsDDL 0x010000
#define NC_InAggFunc 0x020000
#define NC_FromDDL 0x040000
#define NC_NoSelect 0x080000
#define NC_OrderAgg 0x8000000
struct Upsert {
ExprList *pUpsertTarget;
Expr *pUpsertTargetWhere;
ExprList *pUpsertSet;
Expr *pUpsertWhere;
Upsert *pNextUpsert;
u8 isDoUpdate;
void *pToFree;
Index *pUpsertIdx;
SrcList *pUpsertSrc;
int regData;
int iDataCur;
int iIdxCur;
};
struct Select {
u8 op;
LogEst nSelectRow;
u32 selFlags;
int iLimit, iOffset;
u32 selId;
int addrOpenEphm[2];
ExprList *pEList;
SrcList *pSrc;
Expr *pWhere;
ExprList *pGroupBy;
Expr *pHaving;
ExprList *pOrderBy;
Select *pPrior;
Select *pNext;
Expr *pLimit;
With *pWith;
#ifndef SQLITE_OMIT_WINDOWFUNC
Window *pWin;
Window *pWinDefn;
#endif
};
#define SF_Distinct 0x0000001
#define SF_All 0x0000002
#define SF_Resolved 0x0000004
#define SF_Aggregate 0x0000008
#define SF_HasAgg 0x0000010
#define SF_UsesEphemeral 0x0000020
#define SF_Expanded 0x0000040
#define SF_HasTypeInfo 0x0000080
#define SF_Compound 0x0000100
#define SF_Values 0x0000200
#define SF_MultiValue 0x0000400
#define SF_NestedFrom 0x0000800
#define SF_MinMaxAgg 0x0001000
#define SF_Recursive 0x0002000
#define SF_FixedLimit 0x0004000
#define SF_MaybeConvert 0x0008000
#define SF_Converted 0x0010000
#define SF_IncludeHidden 0x0020000
#define SF_ComplexResult 0x0040000
#define SF_WhereBegin 0x0080000
#define SF_WinRewrite 0x0100000
#define SF_View 0x0200000
#define SF_NoopOrderBy 0x0400000
#define SF_UFSrcCheck 0x0800000
#define SF_PushDown 0x1000000
#define SF_MultiPart 0x2000000
#define SF_CopyCte 0x4000000
#define SF_OrderByReqd 0x8000000
#define SF_UpdateFrom 0x10000000
#define IsNestedFrom(S) ((S)!=0 && ((S)->selFlags&SF_NestedFrom)!=0)
#define SRT_Union 1
#define SRT_Except 2
#define SRT_Exists 3
#define SRT_Discard 4
#define SRT_DistFifo 5
#define SRT_DistQueue 6
#define IgnorableDistinct(X) ((X->eDest)<=SRT_DistQueue)
#define SRT_Queue 7
#define SRT_Fifo 8
#define IgnorableOrderby(X) ((X->eDest)<=SRT_Fifo)
#define SRT_Output 9
#define SRT_Mem 10
#define SRT_Set 11
#define SRT_EphemTab 12
#define SRT_Coroutine 13
#define SRT_Table 14
#define SRT_Upfrom 15
struct SelectDest {
u8 eDest;
int iSDParm;
int iSDParm2;
int iSdst;
int nSdst;
char *zAffSdst;
ExprList *pOrderBy;
};
struct AutoincInfo {
AutoincInfo *pNext;
Table *pTab;
int iDb;
int regCtr;
};
struct TriggerPrg {
Trigger *pTrigger;
TriggerPrg *pNext;
SubProgram *pProgram;
int orconf;
u32 aColmask[2];
};
#if SQLITE_MAX_ATTACHED>30
typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED+9)/8];
# define DbMaskTest(M,I) (((M)[(I)/8]&(1<<((I)&7)))!=0)
# define DbMaskZero(M) memset((M),0,sizeof(M))
# define DbMaskSet(M,I) (M)[(I)/8]|=(1<<((I)&7))
# define DbMaskAllZero(M) sqlite3DbMaskAllZero(M)
# define DbMaskNonZero(M) (sqlite3DbMaskAllZero(M)==0)
#else
typedef unsigned int yDbMask;
# define DbMaskTest(M,I) (((M)&(((yDbMask)1)<<(I)))!=0)
# define DbMaskZero(M) ((M)=0)
# define DbMaskSet(M,I) ((M)|=(((yDbMask)1)<<(I)))
# define DbMaskAllZero(M) ((M)==0)
# define DbMaskNonZero(M) ((M)!=0)
#endif
struct IndexedExpr {
Expr *pExpr;
int iDataCur;
int iIdxCur;
int iIdxCol;
u8 bMaybeNullRow;
u8 aff;
IndexedExpr *pIENext;
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
const char *zIdxName;
#endif
};
struct ParseCleanup {
ParseCleanup *pNext;
void *pPtr;
void (*xCleanup)(sqlite3*,void*);
};
struct Parse {
sqlite3 *db;
char *zErrMsg;
Vdbe *pVdbe;
int rc;
u8 colNamesSet;
u8 checkSchema;
u8 nested;
u8 nTempReg;
u8 isMultiWrite;
u8 mayAbort;
u8 hasCompound;
u8 okConstFactor;
u8 disableLookaside;
u8 prepFlags;
u8 withinRJSubrtn;
#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
u8 earlyCleanup;
#endif
#ifdef SQLITE_DEBUG
u8 ifNotExists;
#endif
int nRangeReg;
int iRangeReg;
int nErr;
int nTab;
int nMem;
int szOpAlloc;
int iSelfTab;
int nLabel;
int nLabelAlloc;
int *aLabel;
ExprList *pConstExpr;
IndexedExpr *pIdxEpr;
Token constraintName;
yDbMask writeMask;
yDbMask cookieMask;
int regRowid;
int regRoot;
int nMaxArg;
int nSelect;
#ifndef SQLITE_OMIT_SHARED_CACHE
int nTableLock;
TableLock *aTableLock;
#endif
AutoincInfo *pAinc;
Parse *pToplevel;
Table *pTriggerTab;
TriggerPrg *pTriggerPrg;
ParseCleanup *pCleanup;
union {
int addrCrTab;
Returning *pReturning;
} u1;
u32 nQueryLoop;
u32 oldmask;
u32 newmask;
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
u32 nProgressSteps;
#endif
u8 eTriggerOp;
u8 bReturning;
u8 eOrconf;
u8 disableTriggers;
int aTempReg[8];
Parse *pOuterParse;
Token sNameToken;
Token sLastToken;
ynVar nVar;
u8 iPkSortOrder;
u8 explain;
u8 eParseMode;
#ifndef SQLITE_OMIT_VIRTUALTABLE
int nVtabLock;
#endif
int nHeight;
#ifndef SQLITE_OMIT_EXPLAIN
int addrExplain;
#endif
VList *pVList;
Vdbe *pReprepare;
const char *zTail;
Table *pNewTable;
Index *pNewIndex;
Trigger *pNewTrigger;
const char *zAuthContext;
#ifndef SQLITE_OMIT_VIRTUALTABLE
Token sArg;
Table **apVtabLock;
#endif
With *pWith;
#ifndef SQLITE_OMIT_ALTERTABLE
RenameToken *pRename;
#endif
};
#define PARSE_MODE_NORMAL 0
#define PARSE_MODE_DECLARE_VTAB 1
#define PARSE_MODE_RENAME 2
#define PARSE_MODE_UNMAP 3
#define PARSE_HDR(X) (((char*)(X))+offsetof(Parse,zErrMsg))
#define PARSE_HDR_SZ (offsetof(Parse,aTempReg)-offsetof(Parse,zErrMsg))
#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken)
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ)
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ)
#ifdef SQLITE_OMIT_VIRTUALTABLE
#define IN_DECLARE_VTAB 0
#else
#define IN_DECLARE_VTAB (pParse->eParseMode==PARSE_MODE_DECLARE_VTAB)
#endif
#if defined(SQLITE_OMIT_ALTERTABLE)
#define IN_RENAME_OBJECT 0
#else
#define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME)
#endif
#if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE)
#define IN_SPECIAL_PARSE 0
#else
#define IN_SPECIAL_PARSE (pParse->eParseMode!=PARSE_MODE_NORMAL)
#endif
struct AuthContext {
const char *zAuthContext;
Parse *pParse;
};
#define OPFLAG_NCHANGE 0x01
#define OPFLAG_NOCHNG 0x01
#define OPFLAG_EPHEM 0x01
#define OPFLAG_LASTROWID 0x20
#define OPFLAG_ISUPDATE 0x04
#define OPFLAG_APPEND 0x08
#define OPFLAG_USESEEKRESULT 0x10
#define OPFLAG_ISNOOP 0x40
#define OPFLAG_LENGTHARG 0x40
#define OPFLAG_TYPEOFARG 0x80
#define OPFLAG_BULKCSR 0x01
#define OPFLAG_SEEKEQ 0x02
#define OPFLAG_FORDELETE 0x08
#define OPFLAG_P2ISREG 0x10
#define OPFLAG_PERMUTE 0x01
#define OPFLAG_SAVEPOSITION 0x02
#define OPFLAG_AUXDELETE 0x04
#define OPFLAG_NOCHNG_MAGIC 0x6d
#define OPFLAG_PREFORMAT 0x80
struct Trigger {
char *zName;
char *table;
u8 op;
u8 tr_tm;
u8 bReturning;
Expr *pWhen;
IdList *pColumns;
Schema *pSchema;
Schema *pTabSchema;
TriggerStep *step_list;
Trigger *pNext;
};
#define TRIGGER_BEFORE 1
#define TRIGGER_AFTER 2
struct TriggerStep {
u8 op;
u8 orconf;
Trigger *pTrig;
Select *pSelect;
char *zTarget;
SrcList *pFrom;
Expr *pWhere;
ExprList *pExprList;
IdList *pIdList;
Upsert *pUpsert;
char *zSpan;
TriggerStep *pNext;
TriggerStep *pLast;
};
struct Returning {
Parse *pParse;
ExprList *pReturnEL;
Trigger retTrig;
TriggerStep retTStep;
int iRetCur;
int nRetCol;
int iRetReg;
};
struct sqlite3_str {
sqlite3 *db;
char *zText;
u32 nAlloc;
u32 mxAlloc;
u32 nChar;
u8 accError;
u8 printfFlags;
};
#define SQLITE_PRINTF_INTERNAL 0x01
#define SQLITE_PRINTF_SQLFUNC 0x02
#define SQLITE_PRINTF_MALLOCED 0x04
#define isMalloced(X) (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)
typedef struct {
sqlite3 *db;
char **pzErrMsg;
int iDb;
int rc;
u32 mInitFlags;
u32 nInitRow;
Pgno mxPage;
} InitData;
#define INITFLAG_AlterMask 0x0003
#define INITFLAG_AlterRename 0x0001
#define INITFLAG_AlterDrop 0x0002
#define INITFLAG_AlterAdd 0x0003
#define SQLITE_NTUNE 6
#ifdef SQLITE_DEBUG
# define Tuning(X) (sqlite3Config.aTune[(X)-1])
#else
# define Tuning(X) 0
#endif
struct Sqlite3Config {
int bMemstat;
u8 bCoreMutex;
u8 bFullMutex;
u8 bOpenUri;
u8 bUseCis;
u8 bSmallMalloc;
u8 bExtraSchemaChecks;
int mxStrlen;
int neverCorrupt;
int szLookaside;
int nLookaside;
int nStmtSpill;
sqlite3_mem_methods m;
sqlite3_mutex_methods mutex;
sqlite3_pcache_methods2 pcache2;
void *pHeap;
int nHeap;
int mnReq, mxReq;
sqlite3_int64 szMmap;
sqlite3_int64 mxMmap;
void *pPage;
int szPage;
int nPage;
int mxParserStack;
int sharedCacheEnabled;
u32 szPma;
int isInit;
int inProgress;
int isMutexInit;
int isMallocInit;
int isPCacheInit;
int nRefInitMutex;
sqlite3_mutex *pInitMutex;
void (*xLog)(void*,int,const char*);
void *pLogArg;
#ifdef SQLITE_ENABLE_SQLLOG
void(*xSqllog)(void*,sqlite3*,const char*, int);
void *pSqllogArg;
#endif
#ifdef SQLITE_VDBE_COVERAGE
void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx);
void *pVdbeBranchArg;
#endif
#ifndef SQLITE_OMIT_DESERIALIZE
sqlite3_int64 mxMemdbSize;
#endif
#ifndef SQLITE_UNTESTABLE
int (*xTestCallback)(int);
#endif
int bLocaltimeFault;
int (*xAltLocaltime)(const void*,void*);
int iOnceResetThreshold;
u32 szSorterRef;
unsigned int iPrngSeed;
#ifdef SQLITE_DEBUG
sqlite3_int64 aTune[SQLITE_NTUNE];
#endif
};
#define CORRUPT_DB (sqlite3Config.neverCorrupt==0)
struct Walker {
Parse *pParse;
int (*xExprCallback)(Walker*, Expr*);
int (*xSelectCallback)(Walker*,Select*);
void (*xSelectCallback2)(Walker*,Select*);
int walkerDepth;
u16 eCode;
u16 mWFlags;
union {
NameContext *pNC;
int n;
int iCur;
SrcList *pSrcList;
struct CCurHint *pCCurHint;
struct RefSrcList *pRefSrcList;
int *aiCol;
struct IdxCover *pIdxCover;
ExprList *pGroupBy;
Select *pSelect;
struct WindowRewrite *pRewrite;
struct WhereConst *pConst;
struct RenameCtx *pRename;
struct Table *pTab;
struct CoveringIndexCheck *pCovIdxCk;
SrcItem *pSrcItem;
DbFixer *pFix;
Mem *aMem;
} u;
};
struct DbFixer {
Parse *pParse;
Walker w;
Schema *pSchema;
u8 bTemp;
const char *zDb;
const char *zType;
const Token *pName;
};
int sqlite3WalkExpr(Walker*, Expr*);
int sqlite3WalkExprList(Walker*, ExprList*);
int sqlite3WalkSelect(Walker*, Select*);
int sqlite3WalkSelectExpr(Walker*, Select*);
int sqlite3WalkSelectFrom(Walker*, Select*);
int sqlite3ExprWalkNoop(Walker*, Expr*);
int sqlite3SelectWalkNoop(Walker*, Select*);
int sqlite3SelectWalkFail(Walker*, Select*);
int sqlite3WalkerDepthIncrease(Walker*,Select*);
void sqlite3WalkerDepthDecrease(Walker*,Select*);
void sqlite3WalkWinDefnDummyCallback(Walker*,Select*);
#ifdef SQLITE_DEBUG
void sqlite3SelectWalkAssert2(Walker*, Select*);
#endif
#ifndef SQLITE_OMIT_CTE
void sqlite3SelectPopWith(Walker*, Select*);
#else
# define sqlite3SelectPopWith 0
#endif
#define WRC_Continue 0
#define WRC_Prune 1
#define WRC_Abort 2
struct Cte {
char *zName;
ExprList *pCols;
Select *pSelect;
const char *zCteErr;
CteUse *pUse;
u8 eM10d;
};
#define M10d_Yes 0
#define M10d_Any 1
#define M10d_No 2
struct With {
int nCte;
int bView;
With *pOuter;
Cte a[1];
};
struct CteUse {
int nUse;
int addrM9e;
int regRtn;
int iCur;
LogEst nRowEst;
u8 eM10d;
};
#ifdef SQLITE_DEBUG
struct TreeView {
int iLevel;
u8 bLine[100];
};
#endif
struct Window {
char *zName;
char *zBase;
ExprList *pPartition;
ExprList *pOrderBy;
u8 eFrmType;
u8 eStart;
u8 eEnd;
u8 bImplicitFrame;
u8 eExclude;
Expr *pStart;
Expr *pEnd;
Window **ppThis;
Window *pNextWin;
Expr *pFilter;
FuncDef *pWFunc;
int iEphCsr;
int regAccum;
int regResult;
int csrApp;
int regApp;
int regPart;
Expr *pOwner;
int nBufferCol;
int iArgCol;
int regOne;
int regStartRowid;
int regEndRowid;
u8 bExprArgs;
};
#ifndef SQLITE_OMIT_WINDOWFUNC
void sqlite3WindowDelete(sqlite3*, Window*);
void sqlite3WindowUnlinkFromSelect(Window*);
void sqlite3WindowListDelete(sqlite3 *db, Window *p);
Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8);
void sqlite3WindowAttach(Parse*, Expr*, Window*);
void sqlite3WindowLink(Select *pSel, Window *pWin);
int sqlite3WindowCompare(const Parse*, const Window*, const Window*, int);
void sqlite3WindowCodeInit(Parse*, Select*);
void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
int sqlite3WindowRewrite(Parse*, Select*);
void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);
Window *sqlite3WindowListDup(sqlite3 *db, Window *p);
void sqlite3WindowFunctions(void);
void sqlite3WindowChain(Parse*, Window*, Window*);
Window *sqlite3WindowAssemble(Parse*, Window*, ExprList*, ExprList*, Token*);
#else
# define sqlite3WindowDelete(a,b)
# define sqlite3WindowFunctions()
# define sqlite3WindowAttach(a,b,c)
#endif
#define SQLITE_SKIP_UTF8(zIn) { \
if( (*(zIn++))>=0xc0 ){ \
while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
} \
}
int sqlite3ReportError(int iErr, int lineno, const char *zType);
int sqlite3CorruptError(int);
int sqlite3MisuseError(int);
int sqlite3CantopenError(int);
#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)
#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
#ifdef SQLITE_DEBUG
int sqlite3NomemError(int);
int sqlite3IoerrnomemError(int);
# define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)
# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)
#else
# define SQLITE_NOMEM_BKPT SQLITE_NOMEM
# define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_CORRUPT_PGNO)
int sqlite3CorruptPgnoError(int,Pgno);
# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))
#else
# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptError(__LINE__)
#endif
#if defined(SQLITE_OMIT_VIRTUALTABLE)
# undef SQLITE_ENABLE_FTS3
# undef SQLITE_ENABLE_FTS4
#endif
#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
# define SQLITE_ENABLE_FTS3 1
#endif
#if !defined(SQLITE_ASCII) || \
(defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))
# include <ctype.h>
#endif
#ifdef SQLITE_ASCII
# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20))
# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01)
# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06)
# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02)
# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04)
# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08)
# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)])
# define sqlite3Isquote(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x80)
# define sqlite3JsonId1(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x42)
# define sqlite3JsonId2(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x46)
#else
# define sqlite3Toupper(x) toupper((unsigned char)(x))
# define sqlite3Isspace(x) isspace((unsigned char)(x))
# define sqlite3Isalnum(x) isalnum((unsigned char)(x))
# define sqlite3Isalpha(x) isalpha((unsigned char)(x))
# define sqlite3Isdigit(x) isdigit((unsigned char)(x))
# define sqlite3Isxdigit(x) isxdigit((unsigned char)(x))
# define sqlite3Tolower(x) tolower((unsigned char)(x))
# define sqlite3Isquote(x) ((x)=='"'||(x)=='\''||(x)=='['||(x)=='`')
# define sqlite3JsonId1(x) (sqlite3IsIdChar(x)&&(x)<'0')
# define sqlite3JsonId2(x) sqlite3IsIdChar(x)
#endif
int sqlite3IsIdChar(u8);
int sqlite3StrICmp(const char*,const char*);
int sqlite3Strlen30(const char*);
#define sqlite3Strlen30NN(C) (strlen(C)&0x3fffffff)
char *sqlite3ColumnType(Column*,char*);
#define sqlite3StrNICmp sqlite3_strnicmp
int sqlite3MallocInit(void);
void sqlite3MallocEnd(void);
void *sqlite3Malloc(u64);
void *sqlite3MallocZero(u64);
void *sqlite3DbMallocZero(sqlite3*, u64);
void *sqlite3DbMallocRaw(sqlite3*, u64);
void *sqlite3DbMallocRawNN(sqlite3*, u64);
char *sqlite3DbStrDup(sqlite3*,const char*);
char *sqlite3DbStrNDup(sqlite3*,const char*, u64);
char *sqlite3DbSpanDup(sqlite3*,const char*,const char*);
void *sqlite3Realloc(void*, u64);
void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);
void *sqlite3DbRealloc(sqlite3 *, void *, u64);
void sqlite3DbFree(sqlite3*, void*);
void sqlite3DbFreeNN(sqlite3*, void*);
void sqlite3DbNNFreeNN(sqlite3*, void*);
int sqlite3MallocSize(const void*);
int sqlite3DbMallocSize(sqlite3*, const void*);
void *sqlite3PageMalloc(int);
void sqlite3PageFree(void*);
void sqlite3MemSetDefault(void);
#ifndef SQLITE_UNTESTABLE
void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
#endif
int sqlite3HeapNearlyFull(void);
#ifdef SQLITE_USE_ALLOCA
# define sqlite3StackAllocRaw(D,N) alloca(N)
# define sqlite3StackAllocRawNN(D,N) alloca(N)
# define sqlite3StackFree(D,P)
# define sqlite3StackFreeNN(D,P)
#else
# define sqlite3StackAllocRaw(D,N) sqlite3DbMallocRaw(D,N)
# define sqlite3StackAllocRawNN(D,N) sqlite3DbMallocRawNN(D,N)
# define sqlite3StackFree(D,P) sqlite3DbFree(D,P)
# define sqlite3StackFreeNN(D,P) sqlite3DbFreeNN(D,P)
#endif
#ifdef SQLITE_ENABLE_MEMSYS5
const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
#undef SQLITE_ENABLE_MEMSYS3
#endif
#ifdef SQLITE_ENABLE_MEMSYS3
const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
#endif
#ifndef SQLITE_MUTEX_OMIT
sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
sqlite3_mutex_methods const *sqlite3NoopMutex(void);
sqlite3_mutex *sqlite3MutexAlloc(int);
int sqlite3MutexInit(void);
int sqlite3MutexEnd(void);
#endif
#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)
void sqlite3MemoryBarrier(void);
#else
# define sqlite3MemoryBarrier()
#endif
sqlite3_int64 sqlite3StatusValue(int);
void sqlite3StatusUp(int, int);
void sqlite3StatusDown(int, int);
void sqlite3StatusHighwater(int, int);
int sqlite3LookasideUsed(sqlite3*,int*);
sqlite3_mutex *sqlite3Pcache1Mutex(void);
sqlite3_mutex *sqlite3MallocMutex(void);
#if defined(SQLITE_ENABLE_MULTITHREADED_CHECKS) && !defined(SQLITE_MUTEX_OMIT)
void sqlite3MutexWarnOnContention(sqlite3_mutex*);
#else
# define sqlite3MutexWarnOnContention(x)
#endif
#ifndef SQLITE_OMIT_FLOATING_POINT
# define EXP754 (((u64)0x7ff)<<52)
# define MAN754 ((((u64)1)<<52)-1)
# define IsNaN(X) (((X)&EXP754)==EXP754 && ((X)&MAN754)!=0)
int sqlite3IsNaN(double);
#else
# define IsNaN(X) 0
# define sqlite3IsNaN(X) 0
#endif
struct PrintfArguments {
int nArg;
int nUsed;
sqlite3_value **apArg;
};
char *sqlite3MPrintf(sqlite3*,const char*, ...);
char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
void sqlite3DebugPrintf(const char*, ...);
#endif
#if defined(SQLITE_TEST)
void *sqlite3TestTextToPtr(const char*);
#endif
#if defined(SQLITE_DEBUG)
void sqlite3TreeViewLine(TreeView*, const char *zFormat, ...);
void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
void sqlite3TreeViewBareIdList(TreeView*, const IdList*, const char*);
void sqlite3TreeViewIdList(TreeView*, const IdList*, u8, const char*);
void sqlite3TreeViewColumnList(TreeView*, const Column*, int, u8);
void sqlite3TreeViewSrcList(TreeView*, const SrcList*);
void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
void sqlite3TreeViewWith(TreeView*, const With*, u8);
void sqlite3TreeViewUpsert(TreeView*, const Upsert*, u8);
#if TREETRACE_ENABLED
void sqlite3TreeViewDelete(const With*, const SrcList*, const Expr*,
const ExprList*,const Expr*, const Trigger*);
void sqlite3TreeViewInsert(const With*, const SrcList*,
const IdList*, const Select*, const ExprList*,
int, const Upsert*, const Trigger*);
void sqlite3TreeViewUpdate(const With*, const SrcList*, const ExprList*,
const Expr*, int, const ExprList*, const Expr*,
const Upsert*, const Trigger*);
#endif
#ifndef SQLITE_OMIT_TRIGGER
void sqlite3TreeViewTriggerStep(TreeView*, const TriggerStep*, u8, u8);
void sqlite3TreeViewTrigger(TreeView*, const Trigger*, u8, u8);
#endif
#ifndef SQLITE_OMIT_WINDOWFUNC
void sqlite3TreeViewWindow(TreeView*, const Window*, u8);
void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
#endif
void sqlite3ShowExpr(const Expr*);
void sqlite3ShowExprList(const ExprList*);
void sqlite3ShowIdList(const IdList*);
void sqlite3ShowSrcList(const SrcList*);
void sqlite3ShowSelect(const Select*);
void sqlite3ShowWith(const With*);
void sqlite3ShowUpsert(const Upsert*);
#ifndef SQLITE_OMIT_TRIGGER
void sqlite3ShowTriggerStep(const TriggerStep*);
void sqlite3ShowTriggerStepList(const TriggerStep*);
void sqlite3ShowTrigger(const Trigger*);
void sqlite3ShowTriggerList(const Trigger*);
#endif
#ifndef SQLITE_OMIT_WINDOWFUNC
void sqlite3ShowWindow(const Window*);
void sqlite3ShowWinFunc(const Window*);
#endif
#endif
void sqlite3SetString(char **, sqlite3*, const char*);
void sqlite3ProgressCheck(Parse*);
void sqlite3ErrorMsg(Parse*, const char*, ...);
int sqlite3ErrorToParser(sqlite3*,int);
void sqlite3Dequote(char*);
void sqlite3DequoteExpr(Expr*);
void sqlite3DequoteToken(Token*);
void sqlite3TokenInit(Token*,char*);
int sqlite3KeywordCode(const unsigned char*, int);
int sqlite3RunParser(Parse*, const char*);
void sqlite3FinishCoding(Parse*);
int sqlite3GetTempReg(Parse*);
void sqlite3ReleaseTempReg(Parse*,int);
int sqlite3GetTempRange(Parse*,int);
void sqlite3ReleaseTempRange(Parse*,int,int);
void sqlite3ClearTempRegCache(Parse*);
void sqlite3TouchRegister(Parse*,int);
#if defined(SQLITE_ENABLE_STAT4) || defined(SQLITE_DEBUG)
int sqlite3FirstAvailableRegister(Parse*,int);
#endif
#ifdef SQLITE_DEBUG
int sqlite3NoTempsInRange(Parse*,int,int);
#endif
Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);
Expr *sqlite3Expr(sqlite3*,int,const char*);
void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);
Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*);
void sqlite3PExprAddSelect(Parse*, Expr*, Select*);
Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*);
Expr *sqlite3ExprSimplifiedAndOr(Expr*);
Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int);
void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*);
void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
void sqlite3ExprDelete(sqlite3*, Expr*);
void sqlite3ExprDeferredDelete(Parse*, Expr*);
void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
Select *sqlite3ExprListToValues(Parse*, int, ExprList*);
void sqlite3ExprListSetSortOrder(ExprList*,int,int);
void sqlite3ExprListSetName(Parse*,ExprList*,const Token*,int);
void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
void sqlite3ExprListDelete(sqlite3*, ExprList*);
u32 sqlite3ExprListFlags(const ExprList*);
int sqlite3IndexHasDuplicateRootPage(Index*);
int sqlite3Init(sqlite3*, char**);
int sqlite3InitCallback(void*, int, char**, char**);
int sqlite3InitOne(sqlite3*, int, char**, u32);
void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
#ifndef SQLITE_OMIT_VIRTUALTABLE
Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);
#endif
void sqlite3ResetAllSchemasOfConnection(sqlite3*);
void sqlite3ResetOneSchema(sqlite3*,int);
void sqlite3CollapseDatabaseArray(sqlite3*);
void sqlite3CommitInternalChanges(sqlite3*);
void sqlite3ColumnSetExpr(Parse*,Table*,Column*,Expr*);
Expr *sqlite3ColumnExpr(Table*,Column*);
void sqlite3ColumnSetColl(sqlite3*,Column*,const char*zColl);
const char *sqlite3ColumnColl(Column*);
void sqlite3DeleteColumnNames(sqlite3*,Table*);
void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect);
int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
void sqlite3SubqueryColumnTypes(Parse*,Table*,Select*,char);
Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
void sqlite3OpenSchemaTable(Parse *, int);
Index *sqlite3PrimaryKeyIndex(Table*);
i16 sqlite3TableColumnToIndex(Index*, i16);
#ifdef SQLITE_OMIT_GENERATED_COLUMNS
# define sqlite3TableColumnToStorage(T,X) (X)
# define sqlite3StorageColumnToTable(T,X) (X)
#else
i16 sqlite3TableColumnToStorage(Table*, i16);
i16 sqlite3StorageColumnToTable(Table*, i16);
#endif
void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
#if SQLITE_ENABLE_HIDDEN_COLUMNS
void sqlite3ColumnPropertiesFromName(Table*, Column*);
#else
# define sqlite3ColumnPropertiesFromName(T,C)
#endif
void sqlite3AddColumn(Parse*,Token,Token);
void sqlite3AddNotNull(Parse*, int);
void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
void sqlite3AddCheckConstraint(Parse*, Expr*, const char*, const char*);
void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
void sqlite3AddCollateType(Parse*, Token*);
void sqlite3AddGenerated(Parse*,Expr*,Token*);
void sqlite3EndTable(Parse*,Token*,Token*,u32,Select*);
void sqlite3AddReturning(Parse*,ExprList*);
int sqlite3ParseUri(const char*,const char*,unsigned int*,
sqlite3_vfs**,char**,char **);
#define sqlite3CodecQueryParameters(A,B,C) 0
Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
#ifdef SQLITE_UNTESTABLE
# define sqlite3FaultSim(X) SQLITE_OK
#else
int sqlite3FaultSim(int);
#endif
Bitvec *sqlite3BitvecCreate(u32);
int sqlite3BitvecTest(Bitvec*, u32);
int sqlite3BitvecTestNotNull(Bitvec*, u32);
int sqlite3BitvecSet(Bitvec*, u32);
void sqlite3BitvecClear(Bitvec*, u32, void*);
void sqlite3BitvecDestroy(Bitvec*);
u32 sqlite3BitvecSize(Bitvec*);
#ifndef SQLITE_UNTESTABLE
int sqlite3BitvecBuiltinTest(int,int*);
#endif
RowSet *sqlite3RowSetInit(sqlite3*);
void sqlite3RowSetDelete(void*);
void sqlite3RowSetClear(void*);
void sqlite3RowSetInsert(RowSet*, i64);
int sqlite3RowSetTest(RowSet*, int iBatch, i64);
int sqlite3RowSetNext(RowSet*, i64*);
void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int);
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
int sqlite3ViewGetColumnNames(Parse*,Table*);
#else
# define sqlite3ViewGetColumnNames(A,B) 0
#endif
#if SQLITE_MAX_ATTACHED>30
int sqlite3DbMaskAllZero(yDbMask);
#endif
void sqlite3DropTable(Parse*, SrcList*, int, int);
void sqlite3CodeDropTable(Parse*, Table*, int, int);
void sqlite3DeleteTable(sqlite3*, Table*);
void sqlite3FreeIndex(sqlite3*, Index*);
#ifndef SQLITE_OMIT_AUTOINCREMENT
void sqlite3AutoincrementBegin(Parse *pParse);
void sqlite3AutoincrementEnd(Parse *pParse);
#else
# define sqlite3AutoincrementBegin(X)
# define sqlite3AutoincrementEnd(X)
#endif
void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
void sqlite3ComputeGeneratedColumns(Parse*, int, Table*);
#endif
void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
int sqlite3IdListIndex(IdList*,const char*);
SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int);
SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2);
SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*);
SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
Token*, Select*, OnOrUsing*);
void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);
void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*);
int sqlite3IndexedByLookup(Parse *, SrcItem *);
void sqlite3SrcListShiftJoinType(Parse*,SrcList*);
void sqlite3SrcListAssignCursors(Parse*, SrcList*);
void sqlite3IdListDelete(sqlite3*, IdList*);
void sqlite3ClearOnOrUsing(sqlite3*, OnOrUsing*);
void sqlite3SrcListDelete(sqlite3*, SrcList*);
Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);
void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
Expr*, int, int, u8);
void sqlite3DropIndex(Parse*, SrcList*, int);
int sqlite3Select(Parse*, Select*, SelectDest*);
Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
Expr*,ExprList*,u32,Expr*);
void sqlite3SelectDelete(sqlite3*, Select*);
Table *sqlite3SrcListLookup(Parse*, SrcList*);
int sqlite3IsReadOnly(Parse*, Table*, Trigger*);
void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
void sqlite3CodeChangeCount(Vdbe*,int,const char*);
void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
Upsert*);
WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,
ExprList*,Select*,u16,int);
void sqlite3WhereEnd(WhereInfo*);
LogEst sqlite3WhereOutputRowCount(WhereInfo*);
int sqlite3WhereIsDistinct(WhereInfo*);
int sqlite3WhereIsOrdered(WhereInfo*);
int sqlite3WhereOrderByLimitOptLabel(WhereInfo*);
void sqlite3WhereMinMaxOptEarlyOut(Vdbe*,WhereInfo*);
int sqlite3WhereIsSorted(WhereInfo*);
int sqlite3WhereContinueLabel(WhereInfo*);
int sqlite3WhereBreakLabel(WhereInfo*);
int sqlite3WhereOkOnePass(WhereInfo*, int*);
#define ONEPASS_OFF 0
#define ONEPASS_SINGLE 1
#define ONEPASS_MULTI 2
int sqlite3WhereUsesDeferredSeek(WhereInfo*);
void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
void sqlite3ExprCodeMove(Parse*, int, int, int);
void sqlite3ExprCode(Parse*, Expr*, int);
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int);
#endif
void sqlite3ExprCodeCopy(Parse*, Expr*, int);
void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
int sqlite3ExprCodeRunJustOnce(Parse*, Expr*, int);
int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
int sqlite3ExprCodeTarget(Parse*, Expr*, int);
int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
#define SQLITE_ECEL_DUP 0x01
#define SQLITE_ECEL_FACTOR 0x02
#define SQLITE_ECEL_REF 0x04
#define SQLITE_ECEL_OMITREF 0x08
void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
Table *sqlite3FindTable(sqlite3*,const char*, const char*);
#define LOCATE_VIEW 0x01
#define LOCATE_NOERR 0x02
Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);
const char *sqlite3PreferredTableName(const char*);
Table *sqlite3LocateTableItem(Parse*,u32 flags,SrcItem *);
Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
void sqlite3Vacuum(Parse*,Token*,Expr*);
int sqlite3RunVacuum(char**, sqlite3*, int, sqlite3_value*);
char *sqlite3NameFromToken(sqlite3*, const Token*);
int sqlite3ExprCompare(const Parse*,const Expr*,const Expr*, int);
int sqlite3ExprCompareSkip(Expr*,Expr*,int);
int sqlite3ExprListCompare(const ExprList*,const ExprList*, int);
int sqlite3ExprImpliesExpr(const Parse*,const Expr*,const Expr*, int);
int sqlite3ExprImpliesNonNullRow(Expr*,int,int);
void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*);
void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
int sqlite3ReferencesSrcList(Parse*, Expr*, SrcList*);
Vdbe *sqlite3GetVdbe(Parse*);
#ifndef SQLITE_UNTESTABLE
void sqlite3PrngSaveState(void);
void sqlite3PrngRestoreState(void);
#endif
void sqlite3RollbackAll(sqlite3*,int);
void sqlite3CodeVerifySchema(Parse*, int);
void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
void sqlite3BeginTransaction(Parse*, int);
void sqlite3EndTransaction(Parse*,int);
void sqlite3Savepoint(Parse*, int, Token*);
void sqlite3CloseSavepoints(sqlite3 *);
void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
u32 sqlite3IsTrueOrFalse(const char*);
int sqlite3ExprIdToTrueFalse(Expr*);
int sqlite3ExprTruthValue(const Expr*);
int sqlite3ExprIsConstant(Expr*);
int sqlite3ExprIsConstantNotJoin(Expr*);
int sqlite3ExprIsConstantOrFunction(Expr*, u8);
int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);
int sqlite3ExprIsTableConstant(Expr*,int);
int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int);
#ifdef SQLITE_ENABLE_CURSOR_HINTS
int sqlite3ExprContainsSubquery(Expr*);
#endif
int sqlite3ExprIsInteger(const Expr*, int*);
int sqlite3ExprCanBeNull(const Expr*);
int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
int sqlite3IsRowid(const char*);
void sqlite3GenerateRowDelete(
Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
void sqlite3ResolvePartIdxLabel(Parse*,int);
int sqlite3ExprReferencesUpdatedColumn(Expr*,int*,int);
void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
u8,u8,int,int*,int*,Upsert*);
#ifdef SQLITE_ENABLE_NULL_TRIM
void sqlite3SetMakeRecordP5(Vdbe*,Table*);
#else
# define sqlite3SetMakeRecordP5(A,B)
#endif
void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
void sqlite3BeginWriteOperation(Parse*, int, int);
void sqlite3MultiWrite(Parse*);
void sqlite3MayAbort(Parse*);
void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8);
void sqlite3UniqueConstraint(Parse*, int, Index*);
void sqlite3RowidConstraint(Parse*, int, Table*);
Expr *sqlite3ExprDup(sqlite3*,const Expr*,int);
ExprList *sqlite3ExprListDup(sqlite3*,const ExprList*,int);
SrcList *sqlite3SrcListDup(sqlite3*,const SrcList*,int);
IdList *sqlite3IdListDup(sqlite3*,const IdList*);
Select *sqlite3SelectDup(sqlite3*,const Select*,int);
FuncDef *sqlite3FunctionSearch(int,const char*);
void sqlite3InsertBuiltinFuncs(FuncDef*,int);
FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
void sqlite3QuoteValue(StrAccum*,sqlite3_value*);
void sqlite3RegisterBuiltinFunctions(void);
void sqlite3RegisterDateTimeFunctions(void);
void sqlite3RegisterJsonFunctions(void);
void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
int sqlite3JsonTableFunctions(sqlite3*);
#endif
int sqlite3SafetyCheckOk(sqlite3*);
int sqlite3SafetyCheckSickOrOk(sqlite3*);
void sqlite3ChangeCookie(Parse*, int);
With *sqlite3WithDup(sqlite3 *db, With *p);
#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
#endif
#ifndef SQLITE_OMIT_TRIGGER
void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,
Expr*,int, int);
void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);
void sqlite3DropTrigger(Parse*, SrcList*, int);
void sqlite3DropTriggerPtr(Parse*, Trigger*);
Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
Trigger *sqlite3TriggerList(Parse *, Table *);
void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
int, int, int);
void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
const char*,const char*);
TriggerStep *sqlite3TriggerInsertStep(Parse*,Token*, IdList*,
Select*,u8,Upsert*,
const char*,const char*);
TriggerStep *sqlite3TriggerUpdateStep(Parse*,Token*,SrcList*,ExprList*,
Expr*, u8, const char*,const char*);
TriggerStep *sqlite3TriggerDeleteStep(Parse*,Token*, Expr*,
const char*,const char*);
void sqlite3DeleteTrigger(sqlite3*, Trigger*);
void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
SrcList *sqlite3TriggerStepSrc(Parse*, TriggerStep*);
# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
# define sqlite3IsToplevel(p) ((p)->pToplevel==0)
#else
# define sqlite3TriggersExist(B,C,D,E,F) 0
# define sqlite3DeleteTrigger(A,B)
# define sqlite3DropTriggerPtr(A,B)
# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)
# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
# define sqlite3TriggerList(X, Y) 0
# define sqlite3ParseToplevel(p) p
# define sqlite3IsToplevel(p) 1
# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
# define sqlite3TriggerStepSrc(A,B) 0
#endif
int sqlite3JoinType(Parse*, Token*, Token*, Token*);
int sqlite3ColumnIndex(Table *pTab, const char *zCol);
void sqlite3SrcItemColumnUsed(SrcItem*,int);
void sqlite3SetJoinExpr(Expr*,int,u32);
void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
void sqlite3DeferForeignKey(Parse*, int);
#ifndef SQLITE_OMIT_AUTHORIZATION
void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);
void sqlite3AuthContextPop(AuthContext*);
int sqlite3AuthReadCol(Parse*, const char *, const char *, int);
#else
# define sqlite3AuthRead(a,b,c,d)
# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK
# define sqlite3AuthContextPush(a,b,c)
# define sqlite3AuthContextPop(a) ((void)(a))
#endif
int sqlite3DbIsNamed(sqlite3 *db, int iDb, const char *zName);
void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);
void sqlite3Detach(Parse*, Expr*);
void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
int sqlite3FixSrcList(DbFixer*, SrcList*);
int sqlite3FixSelect(DbFixer*, Select*);
int sqlite3FixExpr(DbFixer*, Expr*);
int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
int sqlite3RealSameAsInt(double,sqlite3_int64);
i64 sqlite3RealToI64(double);
int sqlite3Int64ToText(i64,char*);
int sqlite3AtoF(const char *z, double*, int, u8);
int sqlite3GetInt32(const char *, int*);
int sqlite3GetUInt32(const char*, u32*);
int sqlite3Atoi(const char*);
#ifndef SQLITE_OMIT_UTF16
int sqlite3Utf16ByteLen(const void *pData, int nChar);
#endif
int sqlite3Utf8CharLen(const char *pData, int nByte);
u32 sqlite3Utf8Read(const u8**);
LogEst sqlite3LogEst(u64);
LogEst sqlite3LogEstAdd(LogEst,LogEst);
LogEst sqlite3LogEstFromDouble(double);
u64 sqlite3LogEstToInt(LogEst);
VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
const char *sqlite3VListNumToName(VList*,int);
int sqlite3VListNameToNum(VList*,const char*,int);
int sqlite3PutVarint(unsigned char*, u64);
u8 sqlite3GetVarint(const unsigned char *, u64 *);
u8 sqlite3GetVarint32(const unsigned char *, u32 *);
int sqlite3VarintLen(u64 v);
#define getVarint32(A,B) \
(u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))
#define getVarint32NR(A,B) \
B=(u32)*(A);if(B>=0x80)sqlite3GetVarint32((A),(u32*)&(B))
#define putVarint32(A,B) \
(u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\
sqlite3PutVarint((A),(B)))
#define getVarint sqlite3GetVarint
#define putVarint sqlite3PutVarint
const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
char *sqlite3TableAffinityStr(sqlite3*,const Table*);
void sqlite3TableAffinity(Vdbe*, Table*, int);
char sqlite3CompareAffinity(const Expr *pExpr, char aff2);
int sqlite3IndexAffinityOk(const Expr *pExpr, char idx_affinity);
char sqlite3TableColumnAffinity(const Table*,int);
char sqlite3ExprAffinity(const Expr *pExpr);
int sqlite3ExprDataType(const Expr *pExpr);
int sqlite3Atoi64(const char*, i64*, int, u8);
int sqlite3DecOrHexToI64(const char*, i64*);
void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
void sqlite3Error(sqlite3*,int);
void sqlite3ErrorClear(sqlite3*);
void sqlite3SystemError(sqlite3*,int);
void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
u8 sqlite3HexToInt(int h);
int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
#if defined(SQLITE_NEED_ERR_NAME)
const char *sqlite3ErrName(int);
#endif
#ifndef SQLITE_OMIT_DESERIALIZE
int sqlite3MemdbInit(void);
int sqlite3IsMemdb(const sqlite3_vfs*);
#else
# define sqlite3IsMemdb(X) 0
#endif
const char *sqlite3ErrStr(int);
int sqlite3ReadSchema(Parse *pParse);
CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
int sqlite3IsBinary(const CollSeq*);
CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
void sqlite3SetTextEncoding(sqlite3 *db, u8);
CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr);
CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, const Expr *pExpr);
int sqlite3ExprCollSeqMatch(Parse*,const Expr*,const Expr*);
Expr *sqlite3ExprAddCollateToken(const Parse *pParse, Expr*, const Token*, int);
Expr *sqlite3ExprAddCollateString(const Parse*,Expr*,const char*);
Expr *sqlite3ExprSkipCollate(Expr*);
Expr *sqlite3ExprSkipCollateAndLikely(Expr*);
int sqlite3CheckCollSeq(Parse *, CollSeq *);
int sqlite3WritableSchema(sqlite3*);
int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*);
void sqlite3VdbeSetChanges(sqlite3 *, i64);
int sqlite3AddInt64(i64*,i64);
int sqlite3SubInt64(i64*,i64);
int sqlite3MulInt64(i64*,i64);
int sqlite3AbsInt32(int);
#ifdef SQLITE_ENABLE_8_3_NAMES
void sqlite3FileSuffix3(const char*, char*);
#else
# define sqlite3FileSuffix3(X,Y)
#endif
u8 sqlite3GetBoolean(const char *z,u8);
const void *sqlite3ValueText(sqlite3_value*, u8);
int sqlite3ValueBytes(sqlite3_value*, u8);
void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,
void(*)(void*));
void sqlite3ValueSetNull(sqlite3_value*);
void sqlite3ValueFree(sqlite3_value*);
#ifndef SQLITE_UNTESTABLE
void sqlite3ResultIntReal(sqlite3_context*);
#endif
sqlite3_value *sqlite3ValueNew(sqlite3 *);
#ifndef SQLITE_OMIT_UTF16
char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
#endif
int sqlite3ValueFromExpr(sqlite3 *, const Expr *, u8, u8, sqlite3_value **);
void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
#ifndef SQLITE_AMALGAMATION
extern const unsigned char sqlite3OpcodeProperty[];
extern const char sqlite3StrBINARY[];
extern const unsigned char sqlite3StdTypeLen[];
extern const char sqlite3StdTypeAffinity[];
extern const char *sqlite3StdType[];
extern const unsigned char sqlite3UpperToLower[];
extern const unsigned char *sqlite3aLTb;
extern const unsigned char *sqlite3aEQb;
extern const unsigned char *sqlite3aGTb;
extern const unsigned char sqlite3CtypeMap[];
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
extern FuncDefHash sqlite3BuiltinFunctions;
#ifndef SQLITE_OMIT_WSD
extern int sqlite3PendingByte;
#endif
#endif
#ifdef VDBE_PROFILE
extern sqlite3_uint64 sqlite3NProfileCnt;
#endif
void sqlite3RootPageMoved(sqlite3*, int, Pgno, Pgno);
void sqlite3Reindex(Parse*, Token*, Token*);
void sqlite3AlterFunctions(void);
void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
int sqlite3GetToken(const unsigned char *, int *);
void sqlite3NestedParse(Parse*, const char*, ...);
void sqlite3ExpirePreparedStatements(sqlite3*, int);
void sqlite3CodeRhsOfIN(Parse*, Expr*, int);
int sqlite3CodeSubselect(Parse*, Expr*);
void sqlite3SelectPrep(Parse*, Select*, NameContext*);
int sqlite3ExpandSubquery(Parse*, SrcItem*);
void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
int sqlite3MatchEName(
const struct ExprList_item*,
const char*,
const char*,
const char*
);
Bitmask sqlite3ExprColUsed(Expr*);
u8 sqlite3StrIHash(const char*);
int sqlite3ResolveExprNames(NameContext*, Expr*);
int sqlite3ResolveExprListNames(NameContext*, ExprList*);
void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
int sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
void sqlite3AlterFinishAddColumn(Parse *, Token *);
void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
void sqlite3AlterDropColumn(Parse*, SrcList*, const Token*);
const void *sqlite3RenameTokenMap(Parse*, const void*, const Token*);
void sqlite3RenameTokenRemap(Parse*, const void *pTo, const void *pFrom);
void sqlite3RenameExprUnmap(Parse*, Expr*);
void sqlite3RenameExprlistUnmap(Parse*, ExprList*);
CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
char sqlite3AffinityType(const char*, Column*);
void sqlite3Analyze(Parse*, Token*, Token*);
int sqlite3InvokeBusyHandler(BusyHandler*);
int sqlite3FindDb(sqlite3*, Token*);
int sqlite3FindDbName(sqlite3 *, const char *);
int sqlite3AnalysisLoad(sqlite3*,int iDB);
void sqlite3DeleteIndexSamples(sqlite3*,Index*);
void sqlite3DefaultRowEst(Index*);
void sqlite3RegisterLikeFunctions(sqlite3*, int);
int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
void sqlite3SchemaClear(void *);
Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
void sqlite3KeyInfoUnref(KeyInfo*);
KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
const char *sqlite3SelectOpName(int);
int sqlite3HasExplicitNulls(Parse*, ExprList*);
#ifdef SQLITE_DEBUG
int sqlite3KeyInfoIsWriteable(KeyInfo*);
#endif
int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
void (*)(sqlite3_context*,int,sqlite3_value **),
void (*)(sqlite3_context*,int,sqlite3_value **),
void (*)(sqlite3_context*),
void (*)(sqlite3_context*),
void (*)(sqlite3_context*,int,sqlite3_value **),
FuncDestructor *pDestructor
);
void sqlite3NoopDestructor(void*);
void *sqlite3OomFault(sqlite3*);
void sqlite3OomClear(sqlite3*);
int sqlite3ApiExit(sqlite3 *db, int);
int sqlite3OpenTempDatabase(Parse *);
void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
int sqlite3StrAccumEnlarge(StrAccum*, i64);
char *sqlite3StrAccumFinish(StrAccum*);
void sqlite3StrAccumSetError(StrAccum*, u8);
void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
void sqlite3SelectDestInit(SelectDest*,int,int);
Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
void sqlite3RecordErrorByteOffset(sqlite3*,const char*);
void sqlite3RecordErrorOffsetOfExpr(sqlite3*,const Expr*);
void sqlite3BackupRestart(sqlite3_backup *);
void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
#ifndef SQLITE_OMIT_SUBQUERY
int sqlite3ExprCheckIN(Parse*, Expr*);
#else
# define sqlite3ExprCheckIN(x,y) SQLITE_OK
#endif
#ifdef SQLITE_ENABLE_STAT4
int sqlite3Stat4ProbeSetValue(
Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);
int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
void sqlite3Stat4ProbeFree(UnpackedRecord*);
int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);
#endif
#ifndef SQLITE_AMALGAMATION
void *sqlite3ParserAlloc(void*(*)(u64), Parse*);
void sqlite3ParserFree(void*, void(*)(void*));
#endif
void sqlite3Parser(void*, int, Token);
int sqlite3ParserFallback(int);
#ifdef YYTRACKMAXSTACKDEPTH
int sqlite3ParserStackPeak(void*);
#endif
void sqlite3AutoLoadExtensions(sqlite3*);
#ifndef SQLITE_OMIT_LOAD_EXTENSION
void sqlite3CloseExtensions(sqlite3*);
#else
# define sqlite3CloseExtensions(X)
#endif
#ifndef SQLITE_OMIT_SHARED_CACHE
void sqlite3TableLock(Parse *, int, Pgno, u8, const char *);
#else
#define sqlite3TableLock(v,w,x,y,z)
#endif
#ifdef SQLITE_TEST
int sqlite3Utf8To8(unsigned char*);
#endif
#ifdef SQLITE_OMIT_VIRTUALTABLE
# define sqlite3VtabClear(D,T)
# define sqlite3VtabSync(X,Y) SQLITE_OK
# define sqlite3VtabRollback(X)
# define sqlite3VtabCommit(X)
# define sqlite3VtabInSync(db) 0
# define sqlite3VtabLock(X)
# define sqlite3VtabUnlock(X)
# define sqlite3VtabModuleUnref(D,X)
# define sqlite3VtabUnlockList(X)
# define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
# define sqlite3GetVTable(X,Y) ((VTable*)0)
#else
void sqlite3VtabClear(sqlite3 *db, Table*);
void sqlite3VtabDisconnect(sqlite3 *db, Table *p);
int sqlite3VtabSync(sqlite3 *db, Vdbe*);
int sqlite3VtabRollback(sqlite3 *db);
int sqlite3VtabCommit(sqlite3 *db);
void sqlite3VtabLock(VTable *);
void sqlite3VtabUnlock(VTable *);
void sqlite3VtabModuleUnref(sqlite3*,Module*);
void sqlite3VtabUnlockList(sqlite3*);
int sqlite3VtabSavepoint(sqlite3 *, int, int);
void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);
VTable *sqlite3GetVTable(sqlite3*, Table*);
Module *sqlite3VtabCreateModule(
sqlite3*,
const char*,
const sqlite3_module*,
void*,
void(*)(void*)
);
# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
#endif
int sqlite3ReadOnlyShadowTables(sqlite3 *db);
#ifndef SQLITE_OMIT_VIRTUALTABLE
int sqlite3ShadowTableName(sqlite3 *db, const char *zName);
int sqlite3IsShadowTableOf(sqlite3*,Table*,const char*);
void sqlite3MarkAllShadowTablesOf(sqlite3*, Table*);
#else
# define sqlite3ShadowTableName(A,B) 0
# define sqlite3IsShadowTableOf(A,B,C) 0
# define sqlite3MarkAllShadowTablesOf(A,B)
#endif
int sqlite3VtabEponymousTableInit(Parse*,Module*);
void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
void sqlite3VtabMakeWritable(Parse*,Table*);
void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
void sqlite3VtabFinishParse(Parse*, Token*);
void sqlite3VtabArgInit(Parse*);
void sqlite3VtabArgExtend(Parse*, Token*);
int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
int sqlite3VtabCallConnect(Parse*, Table*);
int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
int sqlite3VtabBegin(sqlite3 *, VTable *);
FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
void sqlite3VtabUsesAllSchemas(Parse*);
sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
void sqlite3ParseObjectInit(Parse*,sqlite3*);
void sqlite3ParseObjectReset(Parse*);
void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
#ifdef SQLITE_ENABLE_NORMALIZE
char *sqlite3Normalize(Vdbe*, const char*);
#endif
int sqlite3Reprepare(Vdbe*);
void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
CollSeq *sqlite3ExprCompareCollSeq(Parse*,const Expr*);
CollSeq *sqlite3BinaryCompareCollSeq(Parse *, const Expr*, const Expr*);
int sqlite3TempInMemory(const sqlite3*);
const char *sqlite3JournalModename(int);
#ifndef SQLITE_OMIT_WAL
int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);
#endif
#ifndef SQLITE_OMIT_CTE
Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8);
void sqlite3CteDelete(sqlite3*,Cte*);
With *sqlite3WithAdd(Parse*,With*,Cte*);
void sqlite3WithDelete(sqlite3*,With*);
With *sqlite3WithPush(Parse*, With*, u8);
#else
# define sqlite3CteNew(P,T,E,S) ((void*)0)
# define sqlite3CteDelete(D,C)
# define sqlite3CteWithAdd(P,W,C) ((void*)0)
# define sqlite3WithDelete(x,y)
# define sqlite3WithPush(x,y,z) ((void*)0)
#endif
#ifndef SQLITE_OMIT_UPSERT
Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*);
void sqlite3UpsertDelete(sqlite3*,Upsert*);
Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);
int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*);
void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int);
Upsert *sqlite3UpsertOfIndex(Upsert*,Index*);
int sqlite3UpsertNextIsIPK(Upsert*);
#else
#define sqlite3UpsertNew(u,v,w,x,y,z) ((Upsert*)0)
#define sqlite3UpsertDelete(x,y)
#define sqlite3UpsertDup(x,y) ((Upsert*)0)
#define sqlite3UpsertOfIndex(x,y) ((Upsert*)0)
#define sqlite3UpsertNextIsIPK(x) 0
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
void sqlite3FkCheck(Parse*, Table*, int, int, int*, int);
void sqlite3FkDropTable(Parse*, SrcList *, Table*);
void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int);
int sqlite3FkRequired(Parse*, Table*, int*, int);
u32 sqlite3FkOldmask(Parse*, Table*);
FKey *sqlite3FkReferences(Table *);
void sqlite3FkClearTriggerCache(sqlite3*,int);
#else
#define sqlite3FkActions(a,b,c,d,e,f)
#define sqlite3FkCheck(a,b,c,d,e,f)
#define sqlite3FkDropTable(a,b,c)
#define sqlite3FkOldmask(a,b) 0
#define sqlite3FkRequired(a,b,c,d) 0
#define sqlite3FkReferences(a) 0
#define sqlite3FkClearTriggerCache(a,b)
#endif
#ifndef SQLITE_OMIT_FOREIGN_KEY
void sqlite3FkDelete(sqlite3 *, Table*);
int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
#else
#define sqlite3FkDelete(a,b)
#define sqlite3FkLocateIndex(a,b,c,d,e)
#endif
#define SQLITE_FAULTINJECTOR_MALLOC 0
#define SQLITE_FAULTINJECTOR_COUNT 1
#ifndef SQLITE_UNTESTABLE
void sqlite3BeginBenignMalloc(void);
void sqlite3EndBenignMalloc(void);
#else
#define sqlite3BeginBenignMalloc()
#define sqlite3EndBenignMalloc()
#endif
#define IN_INDEX_ROWID 1
#define IN_INDEX_EPH 2
#define IN_INDEX_INDEX_ASC 3
#define IN_INDEX_INDEX_DESC 4
#define IN_INDEX_NOOP 5
#define IN_INDEX_NOOP_OK 0x0001
#define IN_INDEX_MEMBERSHIP 0x0002
#define IN_INDEX_LOOP 0x0004
int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*, int*);
int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
int sqlite3JournalSize(sqlite3_vfs *);
#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \
|| defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
int sqlite3JournalCreate(sqlite3_file *);
#endif
int sqlite3JournalIsInMemory(sqlite3_file *p);
void sqlite3MemJournalOpen(sqlite3_file *);
void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);
#if SQLITE_MAX_EXPR_DEPTH>0
int sqlite3SelectExprHeight(const Select *);
int sqlite3ExprCheckHeight(Parse*, int);
#else
#define sqlite3SelectExprHeight(x) 0
#define sqlite3ExprCheckHeight(x,y)
#endif
void sqlite3ExprSetErrorOffset(Expr*,int);
u32 sqlite3Get4byte(const u8*);
void sqlite3Put4byte(u8*, u32);
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *);
void sqlite3ConnectionUnlocked(sqlite3 *db);
void sqlite3ConnectionClosed(sqlite3 *db);
#else
#define sqlite3ConnectionBlocked(x,y)
#define sqlite3ConnectionUnlocked(x)
#define sqlite3ConnectionClosed(x)
#endif
#ifdef SQLITE_DEBUG
void sqlite3ParserTrace(FILE*, char *);
#endif
#if defined(YYCOVERAGE)
int sqlite3ParserCoverage(FILE*);
#endif
#ifdef SQLITE_ENABLE_IOTRACE
# define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
void sqlite3VdbeIOTraceSql(Vdbe*);
SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
#else
# define IOTRACE(A)
# define sqlite3VdbeIOTraceSql(X)
#endif
#ifdef SQLITE_MEMDEBUG
void sqlite3MemdebugSetType(void*,u8);
int sqlite3MemdebugHasType(const void*,u8);
int sqlite3MemdebugNoType(const void*,u8);
#else
# define sqlite3MemdebugSetType(X,Y)
# define sqlite3MemdebugHasType(X,Y) 1
# define sqlite3MemdebugNoType(X,Y) 1
#endif
#define MEMTYPE_HEAP 0x01
#define MEMTYPE_LOOKASIDE 0x02
#define MEMTYPE_PCACHE 0x04
#if SQLITE_MAX_WORKER_THREADS>0
int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);
int sqlite3ThreadJoin(SQLiteThread*, void**);
#endif
#if defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)
int sqlite3DbpageRegister(sqlite3*);
#endif
#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
int sqlite3DbstatRegister(sqlite3*);
#endif
int sqlite3ExprVectorSize(const Expr *pExpr);
int sqlite3ExprIsVector(const Expr *pExpr);
Expr *sqlite3VectorFieldSubexpr(Expr*, int);
Expr *sqlite3ExprForVectorField(Parse*,Expr*,int,int);
void sqlite3VectorErrorMsg(Parse*, Expr*);
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
const char **sqlite3CompileOptions(int *pnOpt);
#endif
#if SQLITE_OS_UNIX && defined(SQLITE_OS_KV_OPTIONAL)
int sqlite3KvvfsInit(void);
#endif
#if defined(VDBE_PROFILE) \
|| defined(SQLITE_PERFORMANCE_TRACE) \
|| defined(SQLITE_ENABLE_STMT_SCANSTATUS)
sqlite3_uint64 sqlite3Hwtime(void);
#endif
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
# define IS_STMT_SCANSTATUS(db) (db->flags & SQLITE_StmtScanStatus)
#else
# define IS_STMT_SCANSTATUS(db) 0
#endif
#endif