mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 16:30:29 +00:00
Add sqlite amalgamation to third_party
View README for upstream source
This commit is contained in:
parent
b9187061a7
commit
ed0ebc7561
36 changed files with 281627 additions and 0 deletions
8
third_party/sqlite3/README.cosmo
vendored
Normal file
8
third_party/sqlite3/README.cosmo
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
This folder contains the single-file SQLite amalgamation sqlite3.c
|
||||
|
||||
SQLite source code obtained from:
|
||||
https://github.com/sqlite/sqlite (commit f83d501, ahead of version 3.35.5)
|
||||
|
||||
SQLite source was configured to obtain sqlite3.c and compile with cosmopolitan.
|
||||
View the superconfigure script at:
|
||||
https://github.com/ahgamut/sqlite/tree/cosmopolitan
|
401
third_party/sqlite3/headers/btree.h
vendored
Normal file
401
third_party/sqlite3/headers/btree.h
vendored
Normal file
|
@ -0,0 +1,401 @@
|
|||
/*
|
||||
** 2001 September 15
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the interface that the sqlite B-Tree file
|
||||
** subsystem. See comments in the source code for a detailed description
|
||||
** of what each interface routine does.
|
||||
*/
|
||||
#ifndef SQLITE_BTREE_H
|
||||
#define SQLITE_BTREE_H
|
||||
|
||||
/* TODO: This definition is just included so other modules compile. It
|
||||
** needs to be revisited.
|
||||
*/
|
||||
#define SQLITE_N_BTREE_META 16
|
||||
|
||||
/*
|
||||
** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
|
||||
** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
|
||||
*/
|
||||
#ifndef SQLITE_DEFAULT_AUTOVACUUM
|
||||
#define SQLITE_DEFAULT_AUTOVACUUM 0
|
||||
#endif
|
||||
|
||||
#define BTREE_AUTOVACUUM_NONE 0 /* Do not do auto-vacuum */
|
||||
#define BTREE_AUTOVACUUM_FULL 1 /* Do full auto-vacuum */
|
||||
#define BTREE_AUTOVACUUM_INCR 2 /* Incremental vacuum */
|
||||
|
||||
/*
|
||||
** Forward declarations of structure
|
||||
*/
|
||||
typedef struct Btree Btree;
|
||||
typedef struct BtCursor BtCursor;
|
||||
typedef struct BtShared BtShared;
|
||||
typedef struct BtreePayload BtreePayload;
|
||||
|
||||
int sqlite3BtreeOpen(sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
|
||||
const char *zFilename, /* Name of database file to open */
|
||||
sqlite3 *db, /* Associated database connection */
|
||||
Btree **ppBtree, /* Return open Btree* here */
|
||||
int flags, /* Flags */
|
||||
int vfsFlags /* Flags passed through to VFS open */
|
||||
);
|
||||
|
||||
/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
|
||||
** following values.
|
||||
**
|
||||
** NOTE: These values must match the corresponding PAGER_ values in
|
||||
** pager.h.
|
||||
*/
|
||||
#define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */
|
||||
#define BTREE_MEMORY 2 /* This is an in-memory DB */
|
||||
#define BTREE_SINGLE 4 /* The file contains at most 1 b-tree */
|
||||
#define BTREE_UNORDERED 8 /* Use of a hash implementation is OK */
|
||||
|
||||
int sqlite3BtreeClose(Btree *);
|
||||
int sqlite3BtreeSetCacheSize(Btree *, int);
|
||||
int sqlite3BtreeSetSpillSize(Btree *, int);
|
||||
#if SQLITE_MAX_MMAP_SIZE > 0
|
||||
int sqlite3BtreeSetMmapLimit(Btree *, sqlite3_int64);
|
||||
#endif
|
||||
int sqlite3BtreeSetPagerFlags(Btree *, unsigned);
|
||||
int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
|
||||
int sqlite3BtreeGetPageSize(Btree *);
|
||||
Pgno sqlite3BtreeMaxPageCount(Btree *, Pgno);
|
||||
Pgno sqlite3BtreeLastPage(Btree *);
|
||||
int sqlite3BtreeSecureDelete(Btree *, int);
|
||||
int sqlite3BtreeGetRequestedReserve(Btree *);
|
||||
int sqlite3BtreeGetReserveNoMutex(Btree *p);
|
||||
int sqlite3BtreeSetAutoVacuum(Btree *, int);
|
||||
int sqlite3BtreeGetAutoVacuum(Btree *);
|
||||
int sqlite3BtreeBeginTrans(Btree *, int, int *);
|
||||
int sqlite3BtreeCommitPhaseOne(Btree *, const char *);
|
||||
int sqlite3BtreeCommitPhaseTwo(Btree *, int);
|
||||
int sqlite3BtreeCommit(Btree *);
|
||||
int sqlite3BtreeRollback(Btree *, int, int);
|
||||
int sqlite3BtreeBeginStmt(Btree *, int);
|
||||
int sqlite3BtreeCreateTable(Btree *, Pgno *, int flags);
|
||||
int sqlite3BtreeTxnState(Btree *);
|
||||
int sqlite3BtreeIsInBackup(Btree *);
|
||||
|
||||
void *sqlite3BtreeSchema(Btree *, int, void (*)(void *));
|
||||
int sqlite3BtreeSchemaLocked(Btree *pBtree);
|
||||
#ifndef SQLITE_OMIT_SHARED_CACHE
|
||||
int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);
|
||||
#endif
|
||||
|
||||
/* Savepoints are named, nestable SQL transactions mostly implemented */
|
||||
/* in vdbe.c and pager.c See https://sqlite.org/lang_savepoint.html */
|
||||
int sqlite3BtreeSavepoint(Btree *, int, int);
|
||||
|
||||
/* "Checkpoint" only refers to WAL. See https://sqlite.org/wal.html#ckpt */
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
int sqlite3BtreeCheckpoint(Btree *, int, int *, int *);
|
||||
#endif
|
||||
|
||||
const char *sqlite3BtreeGetFilename(Btree *);
|
||||
const char *sqlite3BtreeGetJournalname(Btree *);
|
||||
int sqlite3BtreeCopyFile(Btree *, Btree *);
|
||||
|
||||
int sqlite3BtreeIncrVacuum(Btree *);
|
||||
|
||||
/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
|
||||
** of the flags shown below.
|
||||
**
|
||||
** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.
|
||||
** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data
|
||||
** is stored in the leaves. (BTREE_INTKEY is used for SQL tables.) With
|
||||
** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored
|
||||
** anywhere - the key is the content. (BTREE_BLOBKEY is used for SQL
|
||||
** indices.)
|
||||
*/
|
||||
#define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
|
||||
#define BTREE_BLOBKEY 2 /* Table has keys only - no data */
|
||||
|
||||
int sqlite3BtreeDropTable(Btree *, int, int *);
|
||||
int sqlite3BtreeClearTable(Btree *, int, int *);
|
||||
int sqlite3BtreeClearTableOfCursor(BtCursor *);
|
||||
int sqlite3BtreeTripAllCursors(Btree *, int, int);
|
||||
|
||||
void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
|
||||
int sqlite3BtreeUpdateMeta(Btree *, int idx, u32 value);
|
||||
|
||||
int sqlite3BtreeNewDb(Btree *p);
|
||||
|
||||
/*
|
||||
** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
|
||||
** should be one of the following values. The integer values are assigned
|
||||
** to constants so that the offset of the corresponding field in an
|
||||
** SQLite database header may be found using the following formula:
|
||||
**
|
||||
** offset = 36 + (idx * 4)
|
||||
**
|
||||
** For example, the free-page-count field is located at byte offset 36 of
|
||||
** the database file header. The incr-vacuum-flag field is located at
|
||||
** byte offset 64 (== 36+4*7).
|
||||
**
|
||||
** The BTREE_DATA_VERSION value is not really a value stored in the header.
|
||||
** It is a read-only number computed by the pager. But we merge it with
|
||||
** the header value access routines since its access pattern is the same.
|
||||
** Call it a "virtual meta value".
|
||||
*/
|
||||
#define BTREE_FREE_PAGE_COUNT 0
|
||||
#define BTREE_SCHEMA_VERSION 1
|
||||
#define BTREE_FILE_FORMAT 2
|
||||
#define BTREE_DEFAULT_CACHE_SIZE 3
|
||||
#define BTREE_LARGEST_ROOT_PAGE 4
|
||||
#define BTREE_TEXT_ENCODING 5
|
||||
#define BTREE_USER_VERSION 6
|
||||
#define BTREE_INCR_VACUUM 7
|
||||
#define BTREE_APPLICATION_ID 8
|
||||
#define BTREE_DATA_VERSION 15 /* A virtual meta-value */
|
||||
|
||||
/*
|
||||
** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()
|
||||
** interface.
|
||||
**
|
||||
** BTREE_HINT_RANGE (arguments: Expr*, Mem*)
|
||||
**
|
||||
** The first argument is an Expr* (which is guaranteed to be constant for
|
||||
** the lifetime of the cursor) that defines constraints on which rows
|
||||
** might be fetched with this cursor. The Expr* tree may contain
|
||||
** TK_REGISTER nodes that refer to values stored in the array of registers
|
||||
** passed as the second parameter. In other words, if Expr.op==TK_REGISTER
|
||||
** then the value of the node is the value in Mem[pExpr.iTable]. Any
|
||||
** TK_COLUMN node in the expression tree refers to the Expr.iColumn-th
|
||||
** column of the b-tree of the cursor. The Expr tree will not contain
|
||||
** any function calls nor subqueries nor references to b-trees other than
|
||||
** the cursor being hinted.
|
||||
**
|
||||
** The design of the _RANGE hint is aid b-tree implementations that try
|
||||
** to prefetch content from remote machines - to provide those
|
||||
** implementations with limits on what needs to be prefetched and thereby
|
||||
** reduce network bandwidth.
|
||||
**
|
||||
** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by
|
||||
** standard SQLite. The other hints are provided for extentions that use
|
||||
** the SQLite parser and code generator but substitute their own storage
|
||||
** engine.
|
||||
*/
|
||||
#define BTREE_HINT_RANGE 0 /* Range constraints on queries */
|
||||
|
||||
/*
|
||||
** Values that may be OR'd together to form the argument to the
|
||||
** BTREE_HINT_FLAGS hint for sqlite3BtreeCursorHint():
|
||||
**
|
||||
** The BTREE_BULKLOAD flag is set on index cursors when the index is going
|
||||
** to be filled with content that is already in sorted order.
|
||||
**
|
||||
** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
|
||||
** OP_SeekLE opcodes for a range search, but where the range of entries
|
||||
** selected will all have the same key. In other words, the cursor will
|
||||
** be used only for equality key searches.
|
||||
**
|
||||
*/
|
||||
#define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */
|
||||
#define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */
|
||||
|
||||
/*
|
||||
** Flags passed as the third argument to sqlite3BtreeCursor().
|
||||
**
|
||||
** For read-only cursors the wrFlag argument is always zero. For read-write
|
||||
** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just
|
||||
** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will
|
||||
** only be used by SQLite for the following:
|
||||
**
|
||||
** * to seek to and then delete specific entries, and/or
|
||||
**
|
||||
** * to read values that will be used to create keys that other
|
||||
** BTREE_FORDELETE cursors will seek to and delete.
|
||||
**
|
||||
** The BTREE_FORDELETE flag is an optimization hint. It is not used by
|
||||
** by this, the native b-tree engine of SQLite, but it is available to
|
||||
** alternative storage engines that might be substituted in place of this
|
||||
** b-tree system. For alternative storage engines in which a delete of
|
||||
** the main table row automatically deletes corresponding index rows,
|
||||
** the FORDELETE flag hint allows those alternative storage engines to
|
||||
** skip a lot of work. Namely: FORDELETE cursors may treat all SEEK
|
||||
** and DELETE operations as no-ops, and any READ operation against a
|
||||
** FORDELETE cursor may return a null row: 0x01 0x00.
|
||||
*/
|
||||
#define BTREE_WRCSR 0x00000004 /* read-write cursor */
|
||||
#define BTREE_FORDELETE 0x00000008 /* Cursor is for seek/delete only */
|
||||
|
||||
int sqlite3BtreeCursor(
|
||||
Btree *, /* BTree containing table to open */
|
||||
Pgno iTable, /* Index of root page */
|
||||
int wrFlag, /* 1 for writing. 0 for read-only */
|
||||
struct KeyInfo *, /* First argument to compare function */
|
||||
BtCursor *pCursor /* Space to write cursor structure */
|
||||
);
|
||||
BtCursor *sqlite3BtreeFakeValidCursor(void);
|
||||
int sqlite3BtreeCursorSize(void);
|
||||
void sqlite3BtreeCursorZero(BtCursor *);
|
||||
void sqlite3BtreeCursorHintFlags(BtCursor *, unsigned);
|
||||
#ifdef SQLITE_ENABLE_CURSOR_HINTS
|
||||
void sqlite3BtreeCursorHint(BtCursor *, int, ...);
|
||||
#endif
|
||||
|
||||
int sqlite3BtreeCloseCursor(BtCursor *);
|
||||
int sqlite3BtreeMovetoUnpacked(BtCursor *, UnpackedRecord *pUnKey, i64 intKey,
|
||||
int bias, int *pRes);
|
||||
int sqlite3BtreeCursorHasMoved(BtCursor *);
|
||||
int sqlite3BtreeCursorRestore(BtCursor *, int *);
|
||||
int sqlite3BtreeDelete(BtCursor *, u8 flags);
|
||||
|
||||
/* Allowed flags for sqlite3BtreeDelete() and sqlite3BtreeInsert() */
|
||||
#define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */
|
||||
#define BTREE_AUXDELETE 0x04 /* not the primary delete operation */
|
||||
#define BTREE_APPEND 0x08 /* Insert is likely an append */
|
||||
#define BTREE_PREFORMAT 0x80 /* Inserted data is a preformated cell */
|
||||
|
||||
/* An instance of the BtreePayload object describes the content of a single
|
||||
** entry in either an index or table btree.
|
||||
**
|
||||
** Index btrees (used for indexes and also WITHOUT ROWID tables) contain
|
||||
** an arbitrary key and no data. These btrees have pKey,nKey set to the
|
||||
** key and the pData,nData,nZero fields are uninitialized. The aMem,nMem
|
||||
** fields give an array of Mem objects that are a decomposition of the key.
|
||||
** The nMem field might be zero, indicating that no decomposition is available.
|
||||
**
|
||||
** Table btrees (used for rowid tables) contain an integer rowid used as
|
||||
** the key and passed in the nKey field. The pKey field is zero.
|
||||
** pData,nData hold the content of the new entry. nZero extra zero bytes
|
||||
** are appended to the end of the content when constructing the entry.
|
||||
** The aMem,nMem fields are uninitialized for table btrees.
|
||||
**
|
||||
** Field usage summary:
|
||||
**
|
||||
** Table BTrees Index Btrees
|
||||
**
|
||||
** pKey always NULL encoded key
|
||||
** nKey the ROWID length of pKey
|
||||
** pData data not used
|
||||
** aMem not used decomposed key value
|
||||
** nMem not used entries in aMem
|
||||
** nData length of pData not used
|
||||
** nZero extra zeros after pData not used
|
||||
**
|
||||
** This object is used to pass information into sqlite3BtreeInsert(). The
|
||||
** same information used to be passed as five separate parameters. But placing
|
||||
** the information into this object helps to keep the interface more
|
||||
** organized and understandable, and it also helps the resulting code to
|
||||
** run a little faster by using fewer registers for parameter passing.
|
||||
*/
|
||||
struct BtreePayload {
|
||||
const void *pKey; /* Key content for indexes. NULL for tables */
|
||||
sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */
|
||||
const void *pData; /* Data for tables. */
|
||||
sqlite3_value *aMem; /* First of nMem value in the unpacked pKey */
|
||||
u16 nMem; /* Number of aMem[] value. Might be zero */
|
||||
int nData; /* Size of pData. 0 if none. */
|
||||
int nZero; /* Extra zero data appended after pData,nData */
|
||||
};
|
||||
|
||||
int sqlite3BtreeInsert(BtCursor *, const BtreePayload *pPayload, int flags,
|
||||
int seekResult);
|
||||
int sqlite3BtreeFirst(BtCursor *, int *pRes);
|
||||
int sqlite3BtreeLast(BtCursor *, int *pRes);
|
||||
int sqlite3BtreeNext(BtCursor *, int flags);
|
||||
int sqlite3BtreeEof(BtCursor *);
|
||||
int sqlite3BtreePrevious(BtCursor *, int flags);
|
||||
i64 sqlite3BtreeIntegerKey(BtCursor *);
|
||||
void sqlite3BtreeCursorPin(BtCursor *);
|
||||
void sqlite3BtreeCursorUnpin(BtCursor *);
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
i64 sqlite3BtreeOffset(BtCursor *);
|
||||
#endif
|
||||
int sqlite3BtreePayload(BtCursor *, u32 offset, u32 amt, void *);
|
||||
const void *sqlite3BtreePayloadFetch(BtCursor *, u32 *pAmt);
|
||||
u32 sqlite3BtreePayloadSize(BtCursor *);
|
||||
sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor *);
|
||||
|
||||
char *sqlite3BtreeIntegrityCheck(sqlite3 *, Btree *, Pgno *aRoot, int nRoot,
|
||||
int, int *);
|
||||
struct Pager *sqlite3BtreePager(Btree *);
|
||||
i64 sqlite3BtreeRowCountEst(BtCursor *);
|
||||
|
||||
#ifndef SQLITE_OMIT_INCRBLOB
|
||||
int sqlite3BtreePayloadChecked(BtCursor *, u32 offset, u32 amt, void *);
|
||||
int sqlite3BtreePutData(BtCursor *, u32 offset, u32 amt, void *);
|
||||
void sqlite3BtreeIncrblobCursor(BtCursor *);
|
||||
#endif
|
||||
void sqlite3BtreeClearCursor(BtCursor *);
|
||||
int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
|
||||
int sqlite3BtreeCursorHasHint(BtCursor *, unsigned int mask);
|
||||
int sqlite3BtreeIsReadonly(Btree *pBt);
|
||||
int sqlite3HeaderSizeBtree(void);
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
sqlite3_uint64 sqlite3BtreeSeekCount(Btree *);
|
||||
#else
|
||||
#define sqlite3BtreeSeekCount(X) 0
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
int sqlite3BtreeCursorIsValid(BtCursor *);
|
||||
#endif
|
||||
int sqlite3BtreeCursorIsValidNN(BtCursor *);
|
||||
|
||||
int sqlite3BtreeCount(sqlite3 *, BtCursor *, i64 *);
|
||||
|
||||
#ifdef SQLITE_TEST
|
||||
int sqlite3BtreeCursorInfo(BtCursor *, int *, int);
|
||||
void sqlite3BtreeCursorList(Btree *);
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
int sqlite3BtreeCheckpoint(Btree *, int, int *, int *);
|
||||
#endif
|
||||
|
||||
int sqlite3BtreeTransferRow(BtCursor *, BtCursor *, i64);
|
||||
|
||||
/*
|
||||
** If we are not using shared cache, then there is no need to
|
||||
** use mutexes to access the BtShared structures. So make the
|
||||
** Enter and Leave procedures no-ops.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_SHARED_CACHE
|
||||
void sqlite3BtreeEnter(Btree *);
|
||||
void sqlite3BtreeEnterAll(sqlite3 *);
|
||||
int sqlite3BtreeSharable(Btree *);
|
||||
void sqlite3BtreeEnterCursor(BtCursor *);
|
||||
int sqlite3BtreeConnectionCount(Btree *);
|
||||
#else
|
||||
#define sqlite3BtreeEnter(X)
|
||||
#define sqlite3BtreeEnterAll(X)
|
||||
#define sqlite3BtreeSharable(X) 0
|
||||
#define sqlite3BtreeEnterCursor(X)
|
||||
#define sqlite3BtreeConnectionCount(X) 1
|
||||
#endif
|
||||
|
||||
#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
|
||||
void sqlite3BtreeLeave(Btree *);
|
||||
void sqlite3BtreeLeaveCursor(BtCursor *);
|
||||
void sqlite3BtreeLeaveAll(sqlite3 *);
|
||||
#ifndef NDEBUG
|
||||
/* These routines are used inside assert() statements only. */
|
||||
int sqlite3BtreeHoldsMutex(Btree *);
|
||||
int sqlite3BtreeHoldsAllMutexes(sqlite3 *);
|
||||
int sqlite3SchemaMutexHeld(sqlite3 *, int, Schema *);
|
||||
#endif
|
||||
#else
|
||||
|
||||
#define sqlite3BtreeLeave(X)
|
||||
#define sqlite3BtreeLeaveCursor(X)
|
||||
#define sqlite3BtreeLeaveAll(X)
|
||||
|
||||
#define sqlite3BtreeHoldsMutex(X) 1
|
||||
#define sqlite3BtreeHoldsAllMutexes(X) 1
|
||||
#define sqlite3SchemaMutexHeld(X, Y, Z) 1
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_BTREE_H */
|
727
third_party/sqlite3/headers/btreeInt.h
vendored
Normal file
727
third_party/sqlite3/headers/btreeInt.h
vendored
Normal file
|
@ -0,0 +1,727 @@
|
|||
/*
|
||||
** 2004 April 6
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file implements an external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
**
|
||||
** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
|
||||
** "Sorting And Searching", pages 473-480. Addison-Wesley
|
||||
** Publishing Company, Reading, Massachusetts.
|
||||
**
|
||||
** The basic idea is that each page of the file contains N database
|
||||
** entries and N+1 pointers to subpages.
|
||||
**
|
||||
** ----------------------------------------------------------------
|
||||
** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) |
|
||||
** ----------------------------------------------------------------
|
||||
**
|
||||
** All of the keys on the page that Ptr(0) points to have values less
|
||||
** than Key(0). All of the keys on page Ptr(1) and its subpages have
|
||||
** values greater than Key(0) and less than Key(1). All of the keys
|
||||
** on Ptr(N) and its subpages have values greater than Key(N-1). And
|
||||
** so forth.
|
||||
**
|
||||
** Finding a particular key requires reading O(log(M)) pages from the
|
||||
** disk where M is the number of entries in the tree.
|
||||
**
|
||||
** In this implementation, a single file can hold one or more separate
|
||||
** BTrees. Each BTree is identified by the index of its root page. The
|
||||
** key and data for any entry are combined to form the "payload". A
|
||||
** fixed amount of payload can be carried directly on the database
|
||||
** page. If the payload is larger than the preset amount then surplus
|
||||
** bytes are stored on overflow pages. The payload for an entry
|
||||
** and the preceding pointer are combined to form a "Cell". Each
|
||||
** page has a small header which contains the Ptr(N) pointer and other
|
||||
** information such as the size of key and data.
|
||||
**
|
||||
** FORMAT DETAILS
|
||||
**
|
||||
** The file is divided into pages. The first page is called page 1,
|
||||
** the second is page 2, and so forth. A page number of zero indicates
|
||||
** "no such page". The page size can be any power of 2 between 512 and 65536.
|
||||
** Each page can be either a btree page, a freelist page, an overflow
|
||||
** page, or a pointer-map page.
|
||||
**
|
||||
** The first page is always a btree page. The first 100 bytes of the first
|
||||
** page contain a special header (the "file header") that describes the file.
|
||||
** The format of the file header is as follows:
|
||||
**
|
||||
** OFFSET SIZE DESCRIPTION
|
||||
** 0 16 Header string: "SQLite format 3\000"
|
||||
** 16 2 Page size in bytes. (1 means 65536)
|
||||
** 18 1 File format write version
|
||||
** 19 1 File format read version
|
||||
** 20 1 Bytes of unused space at the end of each page
|
||||
** 21 1 Max embedded payload fraction (must be 64)
|
||||
** 22 1 Min embedded payload fraction (must be 32)
|
||||
** 23 1 Min leaf payload fraction (must be 32)
|
||||
** 24 4 File change counter
|
||||
** 28 4 Reserved for future use
|
||||
** 32 4 First freelist page
|
||||
** 36 4 Number of freelist pages in the file
|
||||
** 40 60 15 4-byte meta values passed to higher layers
|
||||
**
|
||||
** 40 4 Schema cookie
|
||||
** 44 4 File format of schema layer
|
||||
** 48 4 Size of page cache
|
||||
** 52 4 Largest root-page (auto/incr_vacuum)
|
||||
** 56 4 1=UTF-8 2=UTF16le 3=UTF16be
|
||||
** 60 4 User version
|
||||
** 64 4 Incremental vacuum mode
|
||||
** 68 4 Application-ID
|
||||
** 72 20 unused
|
||||
** 92 4 The version-valid-for number
|
||||
** 96 4 SQLITE_VERSION_NUMBER
|
||||
**
|
||||
** All of the integer values are big-endian (most significant byte first).
|
||||
**
|
||||
** The file change counter is incremented when the database is changed
|
||||
** This counter allows other processes to know when the file has changed
|
||||
** and thus when they need to flush their cache.
|
||||
**
|
||||
** The max embedded payload fraction is the amount of the total usable
|
||||
** space in a page that can be consumed by a single cell for standard
|
||||
** B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default
|
||||
** is to limit the maximum cell size so that at least 4 cells will fit
|
||||
** on one page. Thus the default max embedded payload fraction is 64.
|
||||
**
|
||||
** If the payload for a cell is larger than the max payload, then extra
|
||||
** payload is spilled to overflow pages. Once an overflow page is allocated,
|
||||
** as many bytes as possible are moved into the overflow pages without letting
|
||||
** the cell size drop below the min embedded payload fraction.
|
||||
**
|
||||
** The min leaf payload fraction is like the min embedded payload fraction
|
||||
** except that it applies to leaf nodes in a LEAFDATA tree. The maximum
|
||||
** payload fraction for a LEAFDATA tree is always 100% (or 255) and it
|
||||
** not specified in the header.
|
||||
**
|
||||
** Each btree pages is divided into three sections: The header, the
|
||||
** cell pointer array, and the cell content area. Page 1 also has a 100-byte
|
||||
** file header that occurs before the page header.
|
||||
**
|
||||
** |----------------|
|
||||
** | file header | 100 bytes. Page 1 only.
|
||||
** |----------------|
|
||||
** | page header | 8 bytes for leaves. 12 bytes for interior nodes
|
||||
** |----------------|
|
||||
** | cell pointer | | 2 bytes per cell. Sorted order.
|
||||
** | array | | Grows downward
|
||||
** | | v
|
||||
** |----------------|
|
||||
** | unallocated |
|
||||
** | space |
|
||||
** |----------------| ^ Grows upwards
|
||||
** | cell content | | Arbitrary order interspersed with freeblocks.
|
||||
** | area | | and free space fragments.
|
||||
** |----------------|
|
||||
**
|
||||
** The page headers looks like this:
|
||||
**
|
||||
** OFFSET SIZE DESCRIPTION
|
||||
** 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf
|
||||
** 1 2 byte offset to the first freeblock
|
||||
** 3 2 number of cells on this page
|
||||
** 5 2 first byte of the cell content area
|
||||
** 7 1 number of fragmented free bytes
|
||||
** 8 4 Right child (the Ptr(N) value). Omitted on leaves.
|
||||
**
|
||||
** The flags define the format of this btree page. The leaf flag means that
|
||||
** this page has no children. The zerodata flag means that this page carries
|
||||
** only keys and no data. The intkey flag means that the key is an integer
|
||||
** which is stored in the key size entry of the cell header rather than in
|
||||
** the payload area.
|
||||
**
|
||||
** The cell pointer array begins on the first byte after the page header.
|
||||
** The cell pointer array contains zero or more 2-byte numbers which are
|
||||
** offsets from the beginning of the page to the cell content in the cell
|
||||
** content area. The cell pointers occur in sorted order. The system strives
|
||||
** to keep free space after the last cell pointer so that new cells can
|
||||
** be easily added without having to defragment the page.
|
||||
**
|
||||
** Cell content is stored at the very end of the page and grows toward the
|
||||
** beginning of the page.
|
||||
**
|
||||
** Unused space within the cell content area is collected into a linked list of
|
||||
** freeblocks. Each freeblock is at least 4 bytes in size. The byte offset
|
||||
** to the first freeblock is given in the header. Freeblocks occur in
|
||||
** increasing order. Because a freeblock must be at least 4 bytes in size,
|
||||
** any group of 3 or fewer unused bytes in the cell content area cannot
|
||||
** exist on the freeblock chain. A group of 3 or fewer free bytes is called
|
||||
** a fragment. The total number of bytes in all fragments is recorded.
|
||||
** in the page header at offset 7.
|
||||
**
|
||||
** SIZE DESCRIPTION
|
||||
** 2 Byte offset of the next freeblock
|
||||
** 2 Bytes in this freeblock
|
||||
**
|
||||
** Cells are of variable length. Cells are stored in the cell content area at
|
||||
** the end of the page. Pointers to the cells are in the cell pointer array
|
||||
** that immediately follows the page header. Cells is not necessarily
|
||||
** contiguous or in order, but cell pointers are contiguous and in order.
|
||||
**
|
||||
** Cell content makes use of variable length integers. A variable
|
||||
** length integer is 1 to 9 bytes where the lower 7 bits of each
|
||||
** byte are used. The integer consists of all bytes that have bit 8 set and
|
||||
** the first byte with bit 8 clear. The most significant byte of the integer
|
||||
** appears first. A variable-length integer may not be more than 9 bytes long.
|
||||
** As a special case, all 8 bytes of the 9th byte are used as data. This
|
||||
** allows a 64-bit integer to be encoded in 9 bytes.
|
||||
**
|
||||
** 0x00 becomes 0x00000000
|
||||
** 0x7f becomes 0x0000007f
|
||||
** 0x81 0x00 becomes 0x00000080
|
||||
** 0x82 0x00 becomes 0x00000100
|
||||
** 0x80 0x7f becomes 0x0000007f
|
||||
** 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678
|
||||
** 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081
|
||||
**
|
||||
** Variable length integers are used for rowids and to hold the number of
|
||||
** bytes of key and data in a btree cell.
|
||||
**
|
||||
** The content of a cell looks like this:
|
||||
**
|
||||
** SIZE DESCRIPTION
|
||||
** 4 Page number of the left child. Omitted if leaf flag is set.
|
||||
** var Number of bytes of data. Omitted if the zerodata flag is set.
|
||||
** var Number of bytes of key. Or the key itself if intkey flag is set.
|
||||
** * Payload
|
||||
** 4 First page of the overflow chain. Omitted if no overflow
|
||||
**
|
||||
** Overflow pages form a linked list. Each page except the last is completely
|
||||
** filled with data (pagesize - 4 bytes). The last page can have as little
|
||||
** as 1 byte of data.
|
||||
**
|
||||
** SIZE DESCRIPTION
|
||||
** 4 Page number of next overflow page
|
||||
** * Data
|
||||
**
|
||||
** Freelist pages come in two subtypes: trunk pages and leaf pages. The
|
||||
** file header points to the first in a linked list of trunk page. Each trunk
|
||||
** page points to multiple leaf pages. The content of a leaf page is
|
||||
** unspecified. A trunk page looks like this:
|
||||
**
|
||||
** SIZE DESCRIPTION
|
||||
** 4 Page number of next trunk page
|
||||
** 4 Number of leaf pointers on this page
|
||||
** * zero or more pages numbers of leaves
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
/* The following value is the maximum cell size assuming a maximum page
|
||||
** size give above.
|
||||
*/
|
||||
#define MX_CELL_SIZE(pBt) ((int)(pBt->pageSize - 8))
|
||||
|
||||
/* The maximum number of cells on a single page of the database. This
|
||||
** assumes a minimum cell size of 6 bytes (4 bytes for the cell itself
|
||||
** plus 2 bytes for the index to the cell in the page header). Such
|
||||
** small cells will be rare, but they are possible.
|
||||
*/
|
||||
#define MX_CELL(pBt) ((pBt->pageSize - 8) / 6)
|
||||
|
||||
/* Forward declarations */
|
||||
typedef struct MemPage MemPage;
|
||||
typedef struct BtLock BtLock;
|
||||
typedef struct CellInfo CellInfo;
|
||||
|
||||
/*
|
||||
** This is a magic string that appears at the beginning of every
|
||||
** SQLite database in order to identify the file as a real database.
|
||||
**
|
||||
** You can change this value at compile-time by specifying a
|
||||
** -DSQLITE_FILE_HEADER="..." on the compiler command-line. The
|
||||
** header must be exactly 16 bytes including the zero-terminator so
|
||||
** the string itself should be 15 characters long. If you change
|
||||
** the header, then your custom library will not be able to read
|
||||
** databases generated by the standard tools and the standard tools
|
||||
** will not be able to read databases created by your custom library.
|
||||
*/
|
||||
#ifndef SQLITE_FILE_HEADER /* 123456789 123456 */
|
||||
#define SQLITE_FILE_HEADER "SQLite format 3"
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Page type flags. An ORed combination of these flags appear as the
|
||||
** first byte of on-disk image of every BTree page.
|
||||
*/
|
||||
#define PTF_INTKEY 0x01
|
||||
#define PTF_ZERODATA 0x02
|
||||
#define PTF_LEAFDATA 0x04
|
||||
#define PTF_LEAF 0x08
|
||||
|
||||
/*
|
||||
** An instance of this object stores information about each a single database
|
||||
** page that has been loaded into memory. The information in this object
|
||||
** is derived from the raw on-disk page content.
|
||||
**
|
||||
** As each database page is loaded into memory, the pager allocats an
|
||||
** instance of this object and zeros the first 8 bytes. (This is the
|
||||
** "extra" information associated with each page of the pager.)
|
||||
**
|
||||
** Access to all fields of this structure is controlled by the mutex
|
||||
** stored in MemPage.pBt->mutex.
|
||||
*/
|
||||
struct MemPage {
|
||||
u8 isInit; /* True if previously initialized. MUST BE FIRST! */
|
||||
u8 bBusy; /* Prevent endless loops on corrupt database files */
|
||||
u8 intKey; /* True if table b-trees. False for index b-trees */
|
||||
u8 intKeyLeaf; /* True if the leaf of an intKey table */
|
||||
Pgno pgno; /* Page number for this page */
|
||||
/* Only the first 8 bytes (above) are zeroed by pager.c when a new page
|
||||
** is allocated. All fields that follow must be initialized before use */
|
||||
u8 leaf; /* True if a leaf page */
|
||||
u8 hdrOffset; /* 100 for page 1. 0 otherwise */
|
||||
u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */
|
||||
u8 max1bytePayload; /* min(maxLocal,127) */
|
||||
u8 nOverflow; /* Number of overflow cell bodies in aCell[] */
|
||||
u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
|
||||
u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */
|
||||
u16 cellOffset; /* Index in aData of first cell pointer */
|
||||
int nFree; /* Number of free bytes on the page. -1 for unknown */
|
||||
u16 nCell; /* Number of cells on this page, local and ovfl */
|
||||
u16 maskPage; /* Mask for page offset */
|
||||
u16 aiOvfl[4]; /* Insert the i-th overflow cell before the aiOvfl-th
|
||||
** non-overflow cell */
|
||||
u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
|
||||
BtShared *pBt; /* Pointer to BtShared that this page is part of */
|
||||
u8 *aData; /* Pointer to disk image of the page data */
|
||||
u8 *aDataEnd; /* One byte past the end of usable data */
|
||||
u8 *aCellIdx; /* The cell index area */
|
||||
u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
|
||||
DbPage *pDbPage; /* Pager page handle */
|
||||
u16 (*xCellSize)(MemPage *, u8 *); /* cellSizePtr method */
|
||||
void (*xParseCell)(MemPage *, u8 *, CellInfo *); /* btreeParseCell method */
|
||||
};
|
||||
|
||||
/*
|
||||
** A linked list of the following structures is stored at BtShared.pLock.
|
||||
** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor
|
||||
** is opened on the table with root page BtShared.iTable. Locks are removed
|
||||
** from this list when a transaction is committed or rolled back, or when
|
||||
** a btree handle is closed.
|
||||
*/
|
||||
struct BtLock {
|
||||
Btree *pBtree; /* Btree handle holding this lock */
|
||||
Pgno iTable; /* Root page of table */
|
||||
u8 eLock; /* READ_LOCK or WRITE_LOCK */
|
||||
BtLock *pNext; /* Next in BtShared.pLock list */
|
||||
};
|
||||
|
||||
/* Candidate values for BtLock.eLock */
|
||||
#define READ_LOCK 1
|
||||
#define WRITE_LOCK 2
|
||||
|
||||
/* A Btree handle
|
||||
**
|
||||
** A database connection contains a pointer to an instance of
|
||||
** this object for every database file that it has open. This structure
|
||||
** is opaque to the database connection. The database connection cannot
|
||||
** see the internals of this structure and only deals with pointers to
|
||||
** this structure.
|
||||
**
|
||||
** For some database files, the same underlying database cache might be
|
||||
** shared between multiple connections. In that case, each connection
|
||||
** has it own instance of this object. But each instance of this object
|
||||
** points to the same BtShared object. The database cache and the
|
||||
** schema associated with the database file are all contained within
|
||||
** the BtShared object.
|
||||
**
|
||||
** All fields in this structure are accessed under sqlite3.mutex.
|
||||
** The pBt pointer itself may not be changed while there exists cursors
|
||||
** in the referenced BtShared that point back to this Btree since those
|
||||
** cursors have to go through this Btree to find their BtShared and
|
||||
** they often do so without holding sqlite3.mutex.
|
||||
*/
|
||||
struct Btree {
|
||||
sqlite3 *db; /* The database connection holding this btree */
|
||||
BtShared *pBt; /* Sharable content of this btree */
|
||||
u8 inTrans; /* TRANS_NONE, TRANS_READ or TRANS_WRITE */
|
||||
u8 sharable; /* True if we can share pBt with another db */
|
||||
u8 locked; /* True if db currently has pBt locked */
|
||||
u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */
|
||||
int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
|
||||
int nBackup; /* Number of backup operations reading this btree */
|
||||
u32 iBDataVersion; /* Combines with pBt->pPager->iDataVersion */
|
||||
Btree *pNext; /* List of other sharable Btrees from the same db */
|
||||
Btree *pPrev; /* Back pointer of the same list */
|
||||
#ifdef SQLITE_DEBUG
|
||||
u64 nSeek; /* Calls to sqlite3BtreeMovetoUnpacked() */
|
||||
#endif
|
||||
#ifndef SQLITE_OMIT_SHARED_CACHE
|
||||
BtLock lock; /* Object used to lock page 1 */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
** Btree.inTrans may take one of the following values.
|
||||
**
|
||||
** If the shared-data extension is enabled, there may be multiple users
|
||||
** of the Btree structure. At most one of these may open a write transaction,
|
||||
** but any number may have active read transactions.
|
||||
**
|
||||
** These values must match SQLITE_TXN_NONE, SQLITE_TXN_READ, and
|
||||
** SQLITE_TXN_WRITE
|
||||
*/
|
||||
#define TRANS_NONE 0
|
||||
#define TRANS_READ 1
|
||||
#define TRANS_WRITE 2
|
||||
|
||||
#if TRANS_NONE != SQLITE_TXN_NONE
|
||||
#error wrong numeric code for no-transaction
|
||||
#endif
|
||||
#if TRANS_READ != SQLITE_TXN_READ
|
||||
#error wrong numeric code for read-transaction
|
||||
#endif
|
||||
#if TRANS_WRITE != SQLITE_TXN_WRITE
|
||||
#error wrong numeric code for write-transaction
|
||||
#endif
|
||||
|
||||
/*
|
||||
** An instance of this object represents a single database file.
|
||||
**
|
||||
** A single database file can be in use at the same time by two
|
||||
** or more database connections. When two or more connections are
|
||||
** sharing the same database file, each connection has it own
|
||||
** private Btree object for the file and each of those Btrees points
|
||||
** to this one BtShared object. BtShared.nRef is the number of
|
||||
** connections currently sharing this database file.
|
||||
**
|
||||
** Fields in this structure are accessed under the BtShared.mutex
|
||||
** mutex, except for nRef and pNext which are accessed under the
|
||||
** global SQLITE_MUTEX_STATIC_MAIN mutex. The pPager field
|
||||
** may not be modified once it is initially set as long as nRef>0.
|
||||
** The pSchema field may be set once under BtShared.mutex and
|
||||
** thereafter is unchanged as long as nRef>0.
|
||||
**
|
||||
** isPending:
|
||||
**
|
||||
** If a BtShared client fails to obtain a write-lock on a database
|
||||
** table (because there exists one or more read-locks on the table),
|
||||
** the shared-cache enters 'pending-lock' state and isPending is
|
||||
** set to true.
|
||||
**
|
||||
** The shared-cache leaves the 'pending lock' state when either of
|
||||
** the following occur:
|
||||
**
|
||||
** 1) The current writer (BtShared.pWriter) concludes its transaction, OR
|
||||
** 2) The number of locks held by other connections drops to zero.
|
||||
**
|
||||
** while in the 'pending-lock' state, no connection may start a new
|
||||
** transaction.
|
||||
**
|
||||
** This feature is included to help prevent writer-starvation.
|
||||
*/
|
||||
struct BtShared {
|
||||
Pager *pPager; /* The page cache */
|
||||
sqlite3 *db; /* Database connection currently using this Btree */
|
||||
BtCursor *pCursor; /* A list of all open cursors */
|
||||
MemPage *pPage1; /* First page of the database */
|
||||
u8 openFlags; /* Flags to sqlite3BtreeOpen() */
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
u8 autoVacuum; /* True if auto-vacuum is enabled */
|
||||
u8 incrVacuum; /* True if incr-vacuum is enabled */
|
||||
u8 bDoTruncate; /* True to truncate db on commit */
|
||||
#endif
|
||||
u8 inTransaction; /* Transaction state */
|
||||
u8 max1bytePayload; /* Maximum first byte of cell for a 1-byte payload */
|
||||
u8 nReserveWanted; /* Desired number of extra bytes per page */
|
||||
u16 btsFlags; /* Boolean parameters. See BTS_* macros below */
|
||||
u16 maxLocal; /* Maximum local payload in non-LEAFDATA tables */
|
||||
u16 minLocal; /* Minimum local payload in non-LEAFDATA tables */
|
||||
u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */
|
||||
u16 minLeaf; /* Minimum local payload in a LEAFDATA table */
|
||||
u32 pageSize; /* Total number of bytes on a page */
|
||||
u32 usableSize; /* Number of usable bytes on each page */
|
||||
int nTransaction; /* Number of open transactions (read + write) */
|
||||
u32 nPage; /* Number of pages in the database */
|
||||
void *pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */
|
||||
void (*xFreeSchema)(void *); /* Destructor for BtShared.pSchema */
|
||||
sqlite3_mutex *mutex; /* Non-recursive mutex required to access this object */
|
||||
Bitvec *pHasContent; /* Set of pages moved to free-list this transaction */
|
||||
#ifndef SQLITE_OMIT_SHARED_CACHE
|
||||
int nRef; /* Number of references to this structure */
|
||||
BtShared *pNext; /* Next on a list of sharable BtShared structs */
|
||||
BtLock *pLock; /* List of locks held on this shared-btree struct */
|
||||
Btree *pWriter; /* Btree with currently open write transaction */
|
||||
#endif
|
||||
u8 *pTmpSpace; /* Temp space sufficient to hold a single cell */
|
||||
int nPreformatSize; /* Size of last cell written by TransferRow() */
|
||||
};
|
||||
|
||||
/*
|
||||
** Allowed values for BtShared.btsFlags
|
||||
*/
|
||||
#define BTS_READ_ONLY 0x0001 /* Underlying file is readonly */
|
||||
#define BTS_PAGESIZE_FIXED 0x0002 /* Page size can no longer be changed */
|
||||
#define BTS_SECURE_DELETE 0x0004 /* PRAGMA secure_delete is enabled */
|
||||
#define BTS_OVERWRITE 0x0008 /* Overwrite deleted content with zeros */
|
||||
#define BTS_FAST_SECURE 0x000c /* Combination of the previous two */
|
||||
#define BTS_INITIALLY_EMPTY 0x0010 /* Database was empty at trans start */
|
||||
#define BTS_NO_WAL 0x0020 /* Do not open write-ahead-log files */
|
||||
#define BTS_EXCLUSIVE 0x0040 /* pWriter has an exclusive lock */
|
||||
#define BTS_PENDING 0x0080 /* Waiting for read-locks to clear */
|
||||
|
||||
/*
|
||||
** An instance of the following structure is used to hold information
|
||||
** about a cell. The parseCellPtr() function fills in this structure
|
||||
** based on information extract from the raw disk page.
|
||||
*/
|
||||
struct CellInfo {
|
||||
i64 nKey; /* The key for INTKEY tables, or nPayload otherwise */
|
||||
u8 *pPayload; /* Pointer to the start of payload */
|
||||
u32 nPayload; /* Bytes of payload */
|
||||
u16 nLocal; /* Amount of payload held locally, not on overflow */
|
||||
u16 nSize; /* Size of the cell content on the main b-tree page */
|
||||
};
|
||||
|
||||
/*
|
||||
** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
|
||||
** this will be declared corrupt. This value is calculated based on a
|
||||
** maximum database size of 2^31 pages a minimum fanout of 2 for a
|
||||
** root-node and 3 for all other internal nodes.
|
||||
**
|
||||
** If a tree that appears to be taller than this is encountered, it is
|
||||
** assumed that the database is corrupt.
|
||||
*/
|
||||
#define BTCURSOR_MAX_DEPTH 20
|
||||
|
||||
/*
|
||||
** A cursor is a pointer to a particular entry within a particular
|
||||
** b-tree within a database file.
|
||||
**
|
||||
** The entry is identified by its MemPage and the index in
|
||||
** MemPage.aCell[] of the entry.
|
||||
**
|
||||
** A single database file can be shared by two more database connections,
|
||||
** but cursors cannot be shared. Each cursor is associated with a
|
||||
** particular database connection identified BtCursor.pBtree.db.
|
||||
**
|
||||
** Fields in this structure are accessed under the BtShared.mutex
|
||||
** found at self->pBt->mutex.
|
||||
**
|
||||
** skipNext meaning:
|
||||
** The meaning of skipNext depends on the value of eState:
|
||||
**
|
||||
** eState Meaning of skipNext
|
||||
** VALID skipNext is meaningless and is ignored
|
||||
** INVALID skipNext is meaningless and is ignored
|
||||
** SKIPNEXT sqlite3BtreeNext() is a no-op if skipNext>0 and
|
||||
** sqlite3BtreePrevious() is no-op if skipNext<0.
|
||||
** REQUIRESEEK restoreCursorPosition() restores the cursor to
|
||||
** eState=SKIPNEXT if skipNext!=0
|
||||
** FAULT skipNext holds the cursor fault error code.
|
||||
*/
|
||||
struct BtCursor {
|
||||
u8 eState; /* One of the CURSOR_XXX constants (see below) */
|
||||
u8 curFlags; /* zero or more BTCF_* flags defined below */
|
||||
u8 curPagerFlags; /* Flags to send to sqlite3PagerGet() */
|
||||
u8 hints; /* As configured by CursorSetHints() */
|
||||
int skipNext; /* Prev() is noop if negative. Next() is noop if positive.
|
||||
** Error code if eState==CURSOR_FAULT */
|
||||
Btree *pBtree; /* The Btree to which this cursor belongs */
|
||||
Pgno *aOverflow; /* Cache of overflow page locations */
|
||||
void *pKey; /* Saved key that was cursor last known position */
|
||||
/* All fields above are zeroed when the cursor is allocated. See
|
||||
** sqlite3BtreeCursorZero(). Fields that follow must be manually
|
||||
** initialized. */
|
||||
#define BTCURSOR_FIRST_UNINIT pBt /* Name of first uninitialized field */
|
||||
BtShared *pBt; /* The BtShared this cursor points to */
|
||||
BtCursor *pNext; /* Forms a linked list of all cursors */
|
||||
CellInfo info; /* A parse of the cell we are pointing at */
|
||||
i64 nKey; /* Size of pKey, or last integer key */
|
||||
Pgno pgnoRoot; /* The root page of this tree */
|
||||
i8 iPage; /* Index of current page in apPage */
|
||||
u8 curIntKey; /* Value of apPage[0]->intKey */
|
||||
u16 ix; /* Current index for apPage[iPage] */
|
||||
u16 aiIdx[BTCURSOR_MAX_DEPTH - 1]; /* Current index in apPage[i] */
|
||||
struct KeyInfo *pKeyInfo; /* Arg passed to comparison function */
|
||||
MemPage *pPage; /* Current page */
|
||||
MemPage
|
||||
*apPage[BTCURSOR_MAX_DEPTH - 1]; /* Stack of parents of current page */
|
||||
};
|
||||
|
||||
/*
|
||||
** Legal values for BtCursor.curFlags
|
||||
*/
|
||||
#define BTCF_WriteFlag 0x01 /* True if a write cursor */
|
||||
#define BTCF_ValidNKey 0x02 /* True if info.nKey is valid */
|
||||
#define BTCF_ValidOvfl 0x04 /* True if aOverflow is valid */
|
||||
#define BTCF_AtLast 0x08 /* Cursor is pointing ot the last entry */
|
||||
#define BTCF_Incrblob 0x10 /* True if an incremental I/O handle */
|
||||
#define BTCF_Multiple 0x20 /* Maybe another cursor on the same btree */
|
||||
#define BTCF_Pinned 0x40 /* Cursor is busy and cannot be moved */
|
||||
|
||||
/*
|
||||
** Potential values for BtCursor.eState.
|
||||
**
|
||||
** CURSOR_INVALID:
|
||||
** Cursor does not point to a valid entry. This can happen (for example)
|
||||
** because the table is empty or because BtreeCursorFirst() has not been
|
||||
** called.
|
||||
**
|
||||
** CURSOR_VALID:
|
||||
** Cursor points to a valid entry. getPayload() etc. may be called.
|
||||
**
|
||||
** CURSOR_SKIPNEXT:
|
||||
** Cursor is valid except that the Cursor.skipNext field is non-zero
|
||||
** indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious()
|
||||
** operation should be a no-op.
|
||||
**
|
||||
** CURSOR_REQUIRESEEK:
|
||||
** The table that this cursor was opened on still exists, but has been
|
||||
** modified since the cursor was last used. The cursor position is saved
|
||||
** in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in
|
||||
** this state, restoreCursorPosition() can be called to attempt to
|
||||
** seek the cursor to the saved position.
|
||||
**
|
||||
** CURSOR_FAULT:
|
||||
** An unrecoverable error (an I/O error or a malloc failure) has occurred
|
||||
** on a different connection that shares the BtShared cache with this
|
||||
** cursor. The error has left the cache in an inconsistent state.
|
||||
** Do nothing else with this cursor. Any attempt to use the cursor
|
||||
** should return the error code stored in BtCursor.skipNext
|
||||
*/
|
||||
#define CURSOR_VALID 0
|
||||
#define CURSOR_INVALID 1
|
||||
#define CURSOR_SKIPNEXT 2
|
||||
#define CURSOR_REQUIRESEEK 3
|
||||
#define CURSOR_FAULT 4
|
||||
|
||||
/*
|
||||
** The database page the PENDING_BYTE occupies. This page is never used.
|
||||
*/
|
||||
#define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)
|
||||
|
||||
/*
|
||||
** These macros define the location of the pointer-map entry for a
|
||||
** database page. The first argument to each is the number of usable
|
||||
** bytes on each page of the database (often 1024). The second is the
|
||||
** page number to look up in the pointer map.
|
||||
**
|
||||
** PTRMAP_PAGENO returns the database page number of the pointer-map
|
||||
** page that stores the required pointer. PTRMAP_PTROFFSET returns
|
||||
** the offset of the requested map entry.
|
||||
**
|
||||
** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page,
|
||||
** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be
|
||||
** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements
|
||||
** this test.
|
||||
*/
|
||||
#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno)
|
||||
#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5 * (pgno - pgptrmap - 1))
|
||||
#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt), (pgno)) == (pgno))
|
||||
|
||||
/*
|
||||
** The pointer map is a lookup table that identifies the parent page for
|
||||
** each child page in the database file. The parent page is the page that
|
||||
** contains a pointer to the child. Every page in the database contains
|
||||
** 0 or 1 parent pages. (In this context 'database page' refers
|
||||
** to any page that is not part of the pointer map itself.) Each pointer map
|
||||
** entry consists of a single byte 'type' and a 4 byte parent page number.
|
||||
** The PTRMAP_XXX identifiers below are the valid types.
|
||||
**
|
||||
** The purpose of the pointer map is to facility moving pages from one
|
||||
** position in the file to another as part of autovacuum. When a page
|
||||
** is moved, the pointer in its parent must be updated to point to the
|
||||
** new location. The pointer map is used to locate the parent page quickly.
|
||||
**
|
||||
** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not
|
||||
** used in this case.
|
||||
**
|
||||
** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
|
||||
** is not used in this case.
|
||||
**
|
||||
** PTRMAP_OVERFLOW1: The database page is the first page in a list of
|
||||
** overflow pages. The page number identifies the page that
|
||||
** contains the cell with a pointer to this overflow page.
|
||||
**
|
||||
** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of
|
||||
** overflow pages. The page-number identifies the previous
|
||||
** page in the overflow page list.
|
||||
**
|
||||
** PTRMAP_BTREE: The database page is a non-root btree page. The page number
|
||||
** identifies the parent page in the btree.
|
||||
*/
|
||||
#define PTRMAP_ROOTPAGE 1
|
||||
#define PTRMAP_FREEPAGE 2
|
||||
#define PTRMAP_OVERFLOW1 3
|
||||
#define PTRMAP_OVERFLOW2 4
|
||||
#define PTRMAP_BTREE 5
|
||||
|
||||
/* A bunch of assert() statements to check the transaction state variables
|
||||
** of handle p (type Btree*) are internally consistent.
|
||||
*/
|
||||
#define btreeIntegrity(p) \
|
||||
assert(p->pBt->inTransaction != TRANS_NONE || p->pBt->nTransaction == 0); \
|
||||
assert(p->pBt->inTransaction >= p->inTrans);
|
||||
|
||||
/*
|
||||
** The ISAUTOVACUUM macro is used within balance_nonroot() to determine
|
||||
** if the database supports auto-vacuum or not. Because it is used
|
||||
** within an expression that is an argument to another macro
|
||||
** (sqliteMallocRaw), it is not possible to use conditional compilation.
|
||||
** So, this macro is defined instead.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
#define ISAUTOVACUUM (pBt->autoVacuum)
|
||||
#else
|
||||
#define ISAUTOVACUUM 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** This structure is passed around through all the sanity checking routines
|
||||
** in order to keep track of some global state information.
|
||||
**
|
||||
** The aRef[] array is allocated so that there is 1 bit for each page in
|
||||
** the database. As the integrity-check proceeds, for each page used in
|
||||
** the database the corresponding bit is set. This allows integrity-check to
|
||||
** detect pages that are used twice and orphaned pages (both of which
|
||||
** indicate corruption).
|
||||
*/
|
||||
typedef struct IntegrityCk IntegrityCk;
|
||||
struct IntegrityCk {
|
||||
BtShared *pBt; /* The tree being checked out */
|
||||
Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */
|
||||
u8 *aPgRef; /* 1 bit per page in the db (see above) */
|
||||
Pgno nPage; /* Number of pages in the database */
|
||||
int mxErr; /* Stop accumulating errors when this reaches zero */
|
||||
int nErr; /* Number of messages written to zErrMsg so far */
|
||||
int bOomFault; /* A memory allocation error has occurred */
|
||||
const char *zPfx; /* Error message prefix */
|
||||
Pgno v1; /* Value for first %u substitution in zPfx */
|
||||
int v2; /* Value for second %d substitution in zPfx */
|
||||
StrAccum errMsg; /* Accumulate the error message text here */
|
||||
u32 *heap; /* Min-heap used for analyzing cell coverage */
|
||||
sqlite3 *db; /* Database connection running the check */
|
||||
};
|
||||
|
||||
/*
|
||||
** Routines to read or write a two- and four-byte big-endian integer values.
|
||||
*/
|
||||
#define get2byte(x) ((x)[0] << 8 | (x)[1])
|
||||
#define put2byte(p, v) ((p)[0] = (u8)((v) >> 8), (p)[1] = (u8)(v))
|
||||
#define get4byte sqlite3Get4byte
|
||||
#define put4byte sqlite3Put4byte
|
||||
|
||||
/*
|
||||
** get2byteAligned(), unlike get2byte(), requires that its argument point to a
|
||||
** two-byte aligned address. get2bytea() is only used for accessing the
|
||||
** cell addresses in a btree header.
|
||||
*/
|
||||
#if SQLITE_BYTEORDER == 4321
|
||||
#define get2byteAligned(x) (*(u16 *)(x))
|
||||
#elif SQLITE_BYTEORDER == 1234 && GCC_VERSION >= 4008000
|
||||
#define get2byteAligned(x) __builtin_bswap16(*(u16 *)(x))
|
||||
#elif SQLITE_BYTEORDER == 1234 && MSVC_VERSION >= 1300
|
||||
#define get2byteAligned(x) _byteswap_ushort(*(u16 *)(x))
|
||||
#else
|
||||
#define get2byteAligned(x) ((x)[0] << 8 | (x)[1])
|
||||
#endif
|
132
third_party/sqlite3/headers/config.h
vendored
Normal file
132
third_party/sqlite3/headers/config.h
vendored
Normal file
|
@ -0,0 +1,132 @@
|
|||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `fdatasync' function. */
|
||||
#define HAVE_FDATASYNC 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
#define HAVE_GMTIME_R 1
|
||||
|
||||
/* Define to 1 if the system has the type `int16_t'. */
|
||||
#define HAVE_INT16_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `int32_t'. */
|
||||
#define HAVE_INT32_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `int64_t'. */
|
||||
#define HAVE_INT64_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `int8_t'. */
|
||||
#define HAVE_INT8_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `intptr_t'. */
|
||||
#define HAVE_INTPTR_T 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `isnan' function. */
|
||||
/* #undef HAVE_ISNAN */
|
||||
|
||||
/* Define to 1 if you have the `localtime_r' function. */
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
|
||||
/* Define to 1 if you have the `localtime_s' function. */
|
||||
/* #undef HAVE_LOCALTIME_S */
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the `malloc_usable_size' function. */
|
||||
#define HAVE_MALLOC_USABLE_SIZE 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the pread() function. */
|
||||
#define HAVE_PREAD 1
|
||||
|
||||
/* Define to 1 if you have the pread64() function. */
|
||||
/* #undef HAVE_PREAD64 */
|
||||
|
||||
/* Define to 1 if you have the pwrite() function. */
|
||||
#define HAVE_PWRITE 1
|
||||
|
||||
/* Define to 1 if you have the pwrite64() function. */
|
||||
/* #undef HAVE_PWRITE64 */
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strchrnul() function */
|
||||
#define HAVE_STRCHRNUL 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if the system has the type `uint16_t'. */
|
||||
#define HAVE_UINT16_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `uint32_t'. */
|
||||
#define HAVE_UINT32_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `uint64_t'. */
|
||||
#define HAVE_UINT64_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `uint8_t'. */
|
||||
#define HAVE_UINT8_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `uintptr_t'. */
|
||||
#define HAVE_UINTPTR_T 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `usleep' function. */
|
||||
#define HAVE_USLEEP 1
|
||||
|
||||
/* Define to 1 if you have the utime() library function. */
|
||||
#define HAVE_UTIME 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "sqlite"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "sqlite 3.36.0"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "sqlite"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "3.36.0"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
561
third_party/sqlite3/headers/fts5.h
vendored
Normal file
561
third_party/sqlite3/headers/fts5.h
vendored
Normal file
|
@ -0,0 +1,561 @@
|
|||
/*
|
||||
** 2014 May 31
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** Interfaces to extend FTS5. Using the interfaces defined in this file,
|
||||
** FTS5 may be extended with:
|
||||
**
|
||||
** * custom tokenizers, and
|
||||
** * custom auxiliary functions.
|
||||
*/
|
||||
|
||||
#ifndef _FTS5_H
|
||||
#define _FTS5_H
|
||||
|
||||
#include "sqlite3.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
** CUSTOM AUXILIARY FUNCTIONS
|
||||
**
|
||||
** Virtual table implementations may overload SQL functions by implementing
|
||||
** the sqlite3_module.xFindFunction() method.
|
||||
*/
|
||||
|
||||
typedef struct Fts5ExtensionApi Fts5ExtensionApi;
|
||||
typedef struct Fts5Context Fts5Context;
|
||||
typedef struct Fts5PhraseIter Fts5PhraseIter;
|
||||
|
||||
typedef void (*fts5_extension_function)(
|
||||
const Fts5ExtensionApi *pApi, /* API offered by current FTS version */
|
||||
Fts5Context *pFts, /* First arg to pass to pApi functions */
|
||||
sqlite3_context *pCtx, /* Context for returning result/error */
|
||||
int nVal, /* Number of values in apVal[] array */
|
||||
sqlite3_value **apVal /* Array of trailing arguments */
|
||||
);
|
||||
|
||||
struct Fts5PhraseIter {
|
||||
const unsigned char *a;
|
||||
const unsigned char *b;
|
||||
};
|
||||
|
||||
/*
|
||||
** EXTENSION API FUNCTIONS
|
||||
**
|
||||
** xUserData(pFts):
|
||||
** Return a copy of the context pointer the extension function was
|
||||
** registered with.
|
||||
**
|
||||
** xColumnTotalSize(pFts, iCol, pnToken):
|
||||
** If parameter iCol is less than zero, set output variable *pnToken
|
||||
** to the total number of tokens in the FTS5 table. Or, if iCol is
|
||||
** non-negative but less than the number of columns in the table, return
|
||||
** the total number of tokens in column iCol, considering all rows in
|
||||
** the FTS5 table.
|
||||
**
|
||||
** If parameter iCol is greater than or equal to the number of columns
|
||||
** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
|
||||
** an OOM condition or IO error), an appropriate SQLite error code is
|
||||
** returned.
|
||||
**
|
||||
** xColumnCount(pFts):
|
||||
** Return the number of columns in the table.
|
||||
**
|
||||
** xColumnSize(pFts, iCol, pnToken):
|
||||
** If parameter iCol is less than zero, set output variable *pnToken
|
||||
** to the total number of tokens in the current row. Or, if iCol is
|
||||
** non-negative but less than the number of columns in the table, set
|
||||
** *pnToken to the number of tokens in column iCol of the current row.
|
||||
**
|
||||
** If parameter iCol is greater than or equal to the number of columns
|
||||
** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
|
||||
** an OOM condition or IO error), an appropriate SQLite error code is
|
||||
** returned.
|
||||
**
|
||||
** This function may be quite inefficient if used with an FTS5 table
|
||||
** created with the "columnsize=0" option.
|
||||
**
|
||||
** xColumnText:
|
||||
** This function attempts to retrieve the text of column iCol of the
|
||||
** current document. If successful, (*pz) is set to point to a buffer
|
||||
** containing the text in utf-8 encoding, (*pn) is set to the size in bytes
|
||||
** (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
|
||||
** if an error occurs, an SQLite error code is returned and the final values
|
||||
** of (*pz) and (*pn) are undefined.
|
||||
**
|
||||
** xPhraseCount:
|
||||
** Returns the number of phrases in the current query expression.
|
||||
**
|
||||
** xPhraseSize:
|
||||
** Returns the number of tokens in phrase iPhrase of the query. Phrases
|
||||
** are numbered starting from zero.
|
||||
**
|
||||
** xInstCount:
|
||||
** Set *pnInst to the total number of occurrences of all phrases within
|
||||
** the query within the current row. Return SQLITE_OK if successful, or
|
||||
** an error code (i.e. SQLITE_NOMEM) if an error occurs.
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" or "detail=column" option. If the FTS5 table is created
|
||||
** with either "detail=none" or "detail=column" and "content=" option
|
||||
** (i.e. if it is a contentless table), then this API always returns 0.
|
||||
**
|
||||
** xInst:
|
||||
** Query for the details of phrase match iIdx within the current row.
|
||||
** Phrase matches are numbered starting from zero, so the iIdx argument
|
||||
** should be greater than or equal to zero and smaller than the value
|
||||
** output by xInstCount().
|
||||
**
|
||||
** Usually, output parameter *piPhrase is set to the phrase number, *piCol
|
||||
** to the column in which it occurs and *piOff the token offset of the
|
||||
** first token of the phrase. Returns SQLITE_OK if successful, or an error
|
||||
** code (i.e. SQLITE_NOMEM) if an error occurs.
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" or "detail=column" option.
|
||||
**
|
||||
** xRowid:
|
||||
** Returns the rowid of the current row.
|
||||
**
|
||||
** xTokenize:
|
||||
** Tokenize text using the tokenizer belonging to the FTS5 table.
|
||||
**
|
||||
** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):
|
||||
** This API function is used to query the FTS table for phrase iPhrase
|
||||
** of the current query. Specifically, a query equivalent to:
|
||||
**
|
||||
** ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
|
||||
**
|
||||
** with $p set to a phrase equivalent to the phrase iPhrase of the
|
||||
** current query is executed. Any column filter that applies to
|
||||
** phrase iPhrase of the current query is included in $p. For each
|
||||
** row visited, the callback function passed as the fourth argument
|
||||
** is invoked. The context and API objects passed to the callback
|
||||
** function may be used to access the properties of each matched row.
|
||||
** Invoking Api.xUserData() returns a copy of the pointer passed as
|
||||
** the third argument to pUserData.
|
||||
**
|
||||
** If the callback function returns any value other than SQLITE_OK, the
|
||||
** query is abandoned and the xQueryPhrase function returns immediately.
|
||||
** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
|
||||
** Otherwise, the error code is propagated upwards.
|
||||
**
|
||||
** If the query runs to completion without incident, SQLITE_OK is returned.
|
||||
** Or, if some error occurs before the query completes or is aborted by
|
||||
** the callback, an SQLite error code is returned.
|
||||
**
|
||||
**
|
||||
** xSetAuxdata(pFts5, pAux, xDelete)
|
||||
**
|
||||
** Save the pointer passed as the second argument as the extension function's
|
||||
** "auxiliary data". The pointer may then be retrieved by the current or any
|
||||
** future invocation of the same fts5 extension function made as part of
|
||||
** the same MATCH query using the xGetAuxdata() API.
|
||||
**
|
||||
** Each extension function is allocated a single auxiliary data slot for
|
||||
** each FTS query (MATCH expression). If the extension function is invoked
|
||||
** more than once for a single FTS query, then all invocations share a
|
||||
** single auxiliary data context.
|
||||
**
|
||||
** If there is already an auxiliary data pointer when this function is
|
||||
** invoked, then it is replaced by the new pointer. If an xDelete callback
|
||||
** was specified along with the original pointer, it is invoked at this
|
||||
** point.
|
||||
**
|
||||
** The xDelete callback, if one is specified, is also invoked on the
|
||||
** auxiliary data pointer after the FTS5 query has finished.
|
||||
**
|
||||
** If an error (e.g. an OOM condition) occurs within this function,
|
||||
** the auxiliary data is set to NULL and an error code returned. If the
|
||||
** xDelete parameter was not NULL, it is invoked on the auxiliary data
|
||||
** pointer before returning.
|
||||
**
|
||||
**
|
||||
** xGetAuxdata(pFts5, bClear)
|
||||
**
|
||||
** Returns the current auxiliary data pointer for the fts5 extension
|
||||
** function. See the xSetAuxdata() method for details.
|
||||
**
|
||||
** If the bClear argument is non-zero, then the auxiliary data is cleared
|
||||
** (set to NULL) before this function returns. In this case the xDelete,
|
||||
** if any, is not invoked.
|
||||
**
|
||||
**
|
||||
** xRowCount(pFts5, pnRow)
|
||||
**
|
||||
** This function is used to retrieve the total number of rows in the table.
|
||||
** In other words, the same value that would be returned by:
|
||||
**
|
||||
** SELECT count(*) FROM ftstable;
|
||||
**
|
||||
** xPhraseFirst()
|
||||
** This function is used, along with type Fts5PhraseIter and the xPhraseNext
|
||||
** method, to iterate through all instances of a single query phrase within
|
||||
** the current row. This is the same information as is accessible via the
|
||||
** xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient
|
||||
** to use, this API may be faster under some circumstances. To iterate
|
||||
** through instances of phrase iPhrase, use the following code:
|
||||
**
|
||||
** Fts5PhraseIter iter;
|
||||
** int iCol, iOff;
|
||||
** for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);
|
||||
** iCol>=0;
|
||||
** pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)
|
||||
** ){
|
||||
** // An instance of phrase iPhrase at offset iOff of column iCol
|
||||
** }
|
||||
**
|
||||
** The Fts5PhraseIter structure is defined above. Applications should not
|
||||
** modify this structure directly - it should only be used as shown above
|
||||
** with the xPhraseFirst() and xPhraseNext() API methods (and by
|
||||
** xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" or "detail=column" option. If the FTS5 table is created
|
||||
** with either "detail=none" or "detail=column" and "content=" option
|
||||
** (i.e. if it is a contentless table), then this API always iterates
|
||||
** through an empty set (all calls to xPhraseFirst() set iCol to -1).
|
||||
**
|
||||
** xPhraseNext()
|
||||
** See xPhraseFirst above.
|
||||
**
|
||||
** xPhraseFirstColumn()
|
||||
** This function and xPhraseNextColumn() are similar to the xPhraseFirst()
|
||||
** and xPhraseNext() APIs described above. The difference is that instead
|
||||
** of iterating through all instances of a phrase in the current row, these
|
||||
** APIs are used to iterate through the set of columns in the current row
|
||||
** that contain one or more instances of a specified phrase. For example:
|
||||
**
|
||||
** Fts5PhraseIter iter;
|
||||
** int iCol;
|
||||
** for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);
|
||||
** iCol>=0;
|
||||
** pApi->xPhraseNextColumn(pFts, &iter, &iCol)
|
||||
** ){
|
||||
** // Column iCol contains at least one instance of phrase iPhrase
|
||||
** }
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" option. If the FTS5 table is created with either
|
||||
** "detail=none" "content=" option (i.e. if it is a contentless table),
|
||||
** then this API always iterates through an empty set (all calls to
|
||||
** xPhraseFirstColumn() set iCol to -1).
|
||||
**
|
||||
** The information accessed using this API and its companion
|
||||
** xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext
|
||||
** (or xInst/xInstCount). The chief advantage of this API is that it is
|
||||
** significantly more efficient than those alternatives when used with
|
||||
** "detail=column" tables.
|
||||
**
|
||||
** xPhraseNextColumn()
|
||||
** See xPhraseFirstColumn above.
|
||||
*/
|
||||
struct Fts5ExtensionApi {
|
||||
int iVersion; /* Currently always set to 3 */
|
||||
|
||||
void *(*xUserData)(Fts5Context *);
|
||||
|
||||
int (*xColumnCount)(Fts5Context *);
|
||||
int (*xRowCount)(Fts5Context *, sqlite3_int64 *pnRow);
|
||||
int (*xColumnTotalSize)(Fts5Context *, int iCol, sqlite3_int64 *pnToken);
|
||||
|
||||
int (*xTokenize)(Fts5Context *, const char *pText,
|
||||
int nText, /* Text to tokenize */
|
||||
void *pCtx, /* Context passed to xToken() */
|
||||
int (*xToken)(void *, int, const char *, int, int,
|
||||
int) /* Callback */
|
||||
);
|
||||
|
||||
int (*xPhraseCount)(Fts5Context *);
|
||||
int (*xPhraseSize)(Fts5Context *, int iPhrase);
|
||||
|
||||
int (*xInstCount)(Fts5Context *, int *pnInst);
|
||||
int (*xInst)(Fts5Context *, int iIdx, int *piPhrase, int *piCol, int *piOff);
|
||||
|
||||
sqlite3_int64 (*xRowid)(Fts5Context *);
|
||||
int (*xColumnText)(Fts5Context *, int iCol, const char **pz, int *pn);
|
||||
int (*xColumnSize)(Fts5Context *, int iCol, int *pnToken);
|
||||
|
||||
int (*xQueryPhrase)(Fts5Context *, int iPhrase, void *pUserData,
|
||||
int (*)(const Fts5ExtensionApi *, Fts5Context *, void *));
|
||||
int (*xSetAuxdata)(Fts5Context *, void *pAux, void (*xDelete)(void *));
|
||||
void *(*xGetAuxdata)(Fts5Context *, int bClear);
|
||||
|
||||
int (*xPhraseFirst)(Fts5Context *, int iPhrase, Fts5PhraseIter *, int *,
|
||||
int *);
|
||||
void (*xPhraseNext)(Fts5Context *, Fts5PhraseIter *, int *piCol, int *piOff);
|
||||
|
||||
int (*xPhraseFirstColumn)(Fts5Context *, int iPhrase, Fts5PhraseIter *,
|
||||
int *);
|
||||
void (*xPhraseNextColumn)(Fts5Context *, Fts5PhraseIter *, int *piCol);
|
||||
};
|
||||
|
||||
/*
|
||||
** CUSTOM AUXILIARY FUNCTIONS
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
** CUSTOM TOKENIZERS
|
||||
**
|
||||
** Applications may also register custom tokenizer types. A tokenizer
|
||||
** is registered by providing fts5 with a populated instance of the
|
||||
** following structure. All structure methods must be defined, setting
|
||||
** any member of the fts5_tokenizer struct to NULL leads to undefined
|
||||
** behaviour. The structure methods are expected to function as follows:
|
||||
**
|
||||
** xCreate:
|
||||
** This function is used to allocate and initialize a tokenizer instance.
|
||||
** A tokenizer instance is required to actually tokenize text.
|
||||
**
|
||||
** The first argument passed to this function is a copy of the (void*)
|
||||
** pointer provided by the application when the fts5_tokenizer object
|
||||
** was registered with FTS5 (the third argument to xCreateTokenizer()).
|
||||
** The second and third arguments are an array of nul-terminated strings
|
||||
** containing the tokenizer arguments, if any, specified following the
|
||||
** tokenizer name as part of the CREATE VIRTUAL TABLE statement used
|
||||
** to create the FTS5 table.
|
||||
**
|
||||
** The final argument is an output variable. If successful, (*ppOut)
|
||||
** should be set to point to the new tokenizer handle and SQLITE_OK
|
||||
** returned. If an error occurs, some value other than SQLITE_OK should
|
||||
** be returned. In this case, fts5 assumes that the final value of *ppOut
|
||||
** is undefined.
|
||||
**
|
||||
** xDelete:
|
||||
** This function is invoked to delete a tokenizer handle previously
|
||||
** allocated using xCreate(). Fts5 guarantees that this function will
|
||||
** be invoked exactly once for each successful call to xCreate().
|
||||
**
|
||||
** xTokenize:
|
||||
** This function is expected to tokenize the nText byte string indicated
|
||||
** by argument pText. pText may or may not be nul-terminated. The first
|
||||
** argument passed to this function is a pointer to an Fts5Tokenizer object
|
||||
** returned by an earlier call to xCreate().
|
||||
**
|
||||
** The second argument indicates the reason that FTS5 is requesting
|
||||
** tokenization of the supplied text. This is always one of the following
|
||||
** four values:
|
||||
**
|
||||
** <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into
|
||||
** or removed from the FTS table. The tokenizer is being invoked to
|
||||
** determine the set of tokens to add to (or delete from) the
|
||||
** FTS index.
|
||||
**
|
||||
** <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed
|
||||
** against the FTS index. The tokenizer is being called to tokenize
|
||||
** a bareword or quoted string specified as part of the query.
|
||||
**
|
||||
** <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as
|
||||
** FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is
|
||||
** followed by a "*" character, indicating that the last token
|
||||
** returned by the tokenizer will be treated as a token prefix.
|
||||
**
|
||||
** <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to
|
||||
** satisfy an fts5_api.xTokenize() request made by an auxiliary
|
||||
** function. Or an fts5_api.xColumnSize() request made by the same
|
||||
** on a columnsize=0 database.
|
||||
** </ul>
|
||||
**
|
||||
** For each token in the input string, the supplied callback xToken() must
|
||||
** be invoked. The first argument to it should be a copy of the pointer
|
||||
** passed as the second argument to xTokenize(). The third and fourth
|
||||
** arguments are a pointer to a buffer containing the token text, and the
|
||||
** size of the token in bytes. The 4th and 5th arguments are the byte offsets
|
||||
** of the first byte of and first byte immediately following the text from
|
||||
** which the token is derived within the input.
|
||||
**
|
||||
** The second argument passed to the xToken() callback ("tflags") should
|
||||
** normally be set to 0. The exception is if the tokenizer supports
|
||||
** synonyms. In this case see the discussion below for details.
|
||||
**
|
||||
** FTS5 assumes the xToken() callback is invoked for each token in the
|
||||
** order that they occur within the input text.
|
||||
**
|
||||
** If an xToken() callback returns any value other than SQLITE_OK, then
|
||||
** the tokenization should be abandoned and the xTokenize() method should
|
||||
** immediately return a copy of the xToken() return value. Or, if the
|
||||
** input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,
|
||||
** if an error occurs with the xTokenize() implementation itself, it
|
||||
** may abandon the tokenization and return any error code other than
|
||||
** SQLITE_OK or SQLITE_DONE.
|
||||
**
|
||||
** SYNONYM SUPPORT
|
||||
**
|
||||
** Custom tokenizers may also support synonyms. Consider a case in which a
|
||||
** user wishes to query for a phrase such as "first place". Using the
|
||||
** built-in tokenizers, the FTS5 query 'first + place' will match instances
|
||||
** of "first place" within the document set, but not alternative forms
|
||||
** such as "1st place". In some applications, it would be better to match
|
||||
** all instances of "first place" or "1st place" regardless of which form
|
||||
** the user specified in the MATCH query text.
|
||||
**
|
||||
** There are several ways to approach this in FTS5:
|
||||
**
|
||||
** <ol><li> By mapping all synonyms to a single token. In this case, using
|
||||
** the above example, this means that the tokenizer returns the
|
||||
** same token for inputs "first" and "1st". Say that token is in
|
||||
** fact "first", so that when the user inserts the document "I won
|
||||
** 1st place" entries are added to the index for tokens "i", "won",
|
||||
** "first" and "place". If the user then queries for '1st + place',
|
||||
** the tokenizer substitutes "first" for "1st" and the query works
|
||||
** as expected.
|
||||
**
|
||||
** <li> By querying the index for all synonyms of each query term
|
||||
** separately. In this case, when tokenizing query text, the
|
||||
** tokenizer may provide multiple synonyms for a single term
|
||||
** within the document. FTS5 then queries the index for each
|
||||
** synonym individually. For example, faced with the query:
|
||||
**
|
||||
** <codeblock>
|
||||
** ... MATCH 'first place'</codeblock>
|
||||
**
|
||||
** the tokenizer offers both "1st" and "first" as synonyms for the
|
||||
** first token in the MATCH query and FTS5 effectively runs a query
|
||||
** similar to:
|
||||
**
|
||||
** <codeblock>
|
||||
** ... MATCH '(first OR 1st) place'</codeblock>
|
||||
**
|
||||
** except that, for the purposes of auxiliary functions, the query
|
||||
** still appears to contain just two phrases - "(first OR 1st)"
|
||||
** being treated as a single phrase.
|
||||
**
|
||||
** <li> By adding multiple synonyms for a single term to the FTS index.
|
||||
** Using this method, when tokenizing document text, the tokenizer
|
||||
** provides multiple synonyms for each token. So that when a
|
||||
** document such as "I won first place" is tokenized, entries are
|
||||
** added to the FTS index for "i", "won", "first", "1st" and
|
||||
** "place".
|
||||
**
|
||||
** This way, even if the tokenizer does not provide synonyms
|
||||
** when tokenizing query text (it should not - to do so would be
|
||||
** inefficient), it doesn't matter if the user queries for
|
||||
** 'first + place' or '1st + place', as there are entries in the
|
||||
** FTS index corresponding to both forms of the first token.
|
||||
** </ol>
|
||||
**
|
||||
** Whether it is parsing document or query text, any call to xToken that
|
||||
** specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit
|
||||
** is considered to supply a synonym for the previous token. For example,
|
||||
** when parsing the document "I won first place", a tokenizer that supports
|
||||
** synonyms would call xToken() 5 times, as follows:
|
||||
**
|
||||
** <codeblock>
|
||||
** xToken(pCtx, 0, "i", 1, 0, 1);
|
||||
** xToken(pCtx, 0, "won", 3, 2, 5);
|
||||
** xToken(pCtx, 0, "first", 5, 6, 11);
|
||||
** xToken(pCtx, FTS5_TOKEN_COLOCATED, "1st", 3, 6, 11);
|
||||
** xToken(pCtx, 0, "place", 5, 12, 17);
|
||||
**</codeblock>
|
||||
**
|
||||
** It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time
|
||||
** xToken() is called. Multiple synonyms may be specified for a single token
|
||||
** by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence.
|
||||
** There is no limit to the number of synonyms that may be provided for a
|
||||
** single token.
|
||||
**
|
||||
** In many cases, method (1) above is the best approach. It does not add
|
||||
** extra data to the FTS index or require FTS5 to query for multiple terms,
|
||||
** so it is efficient in terms of disk space and query speed. However, it
|
||||
** does not support prefix queries very well. If, as suggested above, the
|
||||
** token "first" is substituted for "1st" by the tokenizer, then the query:
|
||||
**
|
||||
** <codeblock>
|
||||
** ... MATCH '1s*'</codeblock>
|
||||
**
|
||||
** will not match documents that contain the token "1st" (as the tokenizer
|
||||
** will probably not map "1s" to any prefix of "first").
|
||||
**
|
||||
** For full prefix support, method (3) may be preferred. In this case,
|
||||
** because the index contains entries for both "first" and "1st", prefix
|
||||
** queries such as 'fi*' or '1s*' will match correctly. However, because
|
||||
** extra entries are added to the FTS index, this method uses more space
|
||||
** within the database.
|
||||
**
|
||||
** Method (2) offers a midpoint between (1) and (3). Using this method,
|
||||
** a query such as '1s*' will match documents that contain the literal
|
||||
** token "1st", but not "first" (assuming the tokenizer is not able to
|
||||
** provide synonyms for prefixes). However, a non-prefix query like '1st'
|
||||
** will match against "1st" and "first". This method does not require
|
||||
** extra disk space, as no extra entries are added to the FTS index.
|
||||
** On the other hand, it may require more CPU cycles to run MATCH queries,
|
||||
** as separate queries of the FTS index are required for each synonym.
|
||||
**
|
||||
** When using methods (2) or (3), it is important that the tokenizer only
|
||||
** provide synonyms when tokenizing document text (method (2)) or query
|
||||
** text (method (3)), not both. Doing so will not cause any errors, but is
|
||||
** inefficient.
|
||||
*/
|
||||
typedef struct Fts5Tokenizer Fts5Tokenizer;
|
||||
typedef struct fts5_tokenizer fts5_tokenizer;
|
||||
struct fts5_tokenizer {
|
||||
int (*xCreate)(void *, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
|
||||
void (*xDelete)(Fts5Tokenizer *);
|
||||
int (*xTokenize)(
|
||||
Fts5Tokenizer *, void *pCtx,
|
||||
int flags, /* Mask of FTS5_TOKENIZE_* flags */
|
||||
const char *pText, int nText,
|
||||
int (*xToken)(void *pCtx, /* Copy of 2nd argument to xTokenize() */
|
||||
int tflags, /* Mask of FTS5_TOKEN_* flags */
|
||||
const char *pToken, /* Pointer to buffer containing token */
|
||||
int nToken, /* Size of token in bytes */
|
||||
int iStart, /* Byte offset of token within input text */
|
||||
int iEnd /* Byte offset of end of token within input text */
|
||||
));
|
||||
};
|
||||
|
||||
/* Flags that may be passed as the third argument to xTokenize() */
|
||||
#define FTS5_TOKENIZE_QUERY 0x0001
|
||||
#define FTS5_TOKENIZE_PREFIX 0x0002
|
||||
#define FTS5_TOKENIZE_DOCUMENT 0x0004
|
||||
#define FTS5_TOKENIZE_AUX 0x0008
|
||||
|
||||
/* Flags that may be passed by the tokenizer implementation back to FTS5
|
||||
** as the third argument to the supplied xToken callback. */
|
||||
#define FTS5_TOKEN_COLOCATED 0x0001 /* Same position as prev. token */
|
||||
|
||||
/*
|
||||
** END OF CUSTOM TOKENIZERS
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
** FTS5 EXTENSION REGISTRATION API
|
||||
*/
|
||||
typedef struct fts5_api fts5_api;
|
||||
struct fts5_api {
|
||||
int iVersion; /* Currently always set to 2 */
|
||||
|
||||
/* Create a new tokenizer */
|
||||
int (*xCreateTokenizer)(fts5_api *pApi, const char *zName, void *pContext,
|
||||
fts5_tokenizer *pTokenizer, void (*xDestroy)(void *));
|
||||
|
||||
/* Find an existing tokenizer */
|
||||
int (*xFindTokenizer)(fts5_api *pApi, const char *zName, void **ppContext,
|
||||
fts5_tokenizer *pTokenizer);
|
||||
|
||||
/* Create a new auxiliary function */
|
||||
int (*xCreateFunction)(fts5_api *pApi, const char *zName, void *pContext,
|
||||
fts5_extension_function xFunction,
|
||||
void (*xDestroy)(void *));
|
||||
};
|
||||
|
||||
/*
|
||||
** END OF REGISTRATION API
|
||||
*************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of the 'extern "C"' block */
|
||||
#endif
|
||||
|
||||
#endif /* _FTS5_H */
|
15
third_party/sqlite3/headers/fts5parse.h
vendored
Normal file
15
third_party/sqlite3/headers/fts5parse.h
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
#define FTS5_OR 1
|
||||
#define FTS5_AND 2
|
||||
#define FTS5_NOT 3
|
||||
#define FTS5_TERM 4
|
||||
#define FTS5_COLON 5
|
||||
#define FTS5_MINUS 6
|
||||
#define FTS5_LCP 7
|
||||
#define FTS5_RCP 8
|
||||
#define FTS5_STRING 9
|
||||
#define FTS5_LP 10
|
||||
#define FTS5_RP 11
|
||||
#define FTS5_CARET 12
|
||||
#define FTS5_COMMA 13
|
||||
#define FTS5_PLUS 14
|
||||
#define FTS5_STAR 15
|
96
third_party/sqlite3/headers/hash.h
vendored
Normal file
96
third_party/sqlite3/headers/hash.h
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
** 2001 September 22
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This is the header file for the generic hash-table implementation
|
||||
** used in SQLite.
|
||||
*/
|
||||
#ifndef SQLITE_HASH_H
|
||||
#define SQLITE_HASH_H
|
||||
|
||||
/* Forward declarations of structures. */
|
||||
typedef struct Hash Hash;
|
||||
typedef struct HashElem HashElem;
|
||||
|
||||
/* A complete hash table is an instance of the following structure.
|
||||
** The internals of this structure are intended to be opaque -- client
|
||||
** code should not attempt to access or modify the fields of this structure
|
||||
** directly. Change this structure only by using the routines below.
|
||||
** However, some of the "procedures" and "functions" for modifying and
|
||||
** accessing this structure are really macros, so we can't really make
|
||||
** this structure opaque.
|
||||
**
|
||||
** All elements of the hash table are on a single doubly-linked list.
|
||||
** Hash.first points to the head of this list.
|
||||
**
|
||||
** There are Hash.htsize buckets. Each bucket points to a spot in
|
||||
** the global doubly-linked list. The contents of the bucket are the
|
||||
** element pointed to plus the next _ht.count-1 elements in the list.
|
||||
**
|
||||
** Hash.htsize and Hash.ht may be zero. In that case lookup is done
|
||||
** by a linear search of the global list. For small tables, the
|
||||
** Hash.ht table is never allocated because if there are few elements
|
||||
** in the table, it is faster to do a linear search than to manage
|
||||
** the hash table.
|
||||
*/
|
||||
struct Hash {
|
||||
unsigned int htsize; /* Number of buckets in the hash table */
|
||||
unsigned int count; /* Number of entries in this table */
|
||||
HashElem *first; /* The first element of the array */
|
||||
struct _ht { /* the hash table */
|
||||
unsigned int count; /* Number of entries with this hash */
|
||||
HashElem *chain; /* Pointer to first entry with this hash */
|
||||
} * ht;
|
||||
};
|
||||
|
||||
/* Each element in the hash table is an instance of the following
|
||||
** structure. All elements are stored on a single doubly-linked list.
|
||||
**
|
||||
** Again, this structure is intended to be opaque, but it can't really
|
||||
** be opaque because it is used by macros.
|
||||
*/
|
||||
struct HashElem {
|
||||
HashElem *next, *prev; /* Next and previous elements in the table */
|
||||
void *data; /* Data associated with this element */
|
||||
const char *pKey; /* Key associated with this element */
|
||||
};
|
||||
|
||||
/*
|
||||
** Access routines. To delete, insert a NULL pointer.
|
||||
*/
|
||||
void sqlite3HashInit(Hash *);
|
||||
void *sqlite3HashInsert(Hash *, const char *pKey, void *pData);
|
||||
void *sqlite3HashFind(const Hash *, const char *pKey);
|
||||
void sqlite3HashClear(Hash *);
|
||||
|
||||
/*
|
||||
** Macros for looping over all elements of a hash table. The idiom is
|
||||
** like this:
|
||||
**
|
||||
** Hash h;
|
||||
** HashElem *p;
|
||||
** ...
|
||||
** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){
|
||||
** SomeStructure *pData = sqliteHashData(p);
|
||||
** // do something with pData
|
||||
** }
|
||||
*/
|
||||
#define sqliteHashFirst(H) ((H)->first)
|
||||
#define sqliteHashNext(E) ((E)->next)
|
||||
#define sqliteHashData(E) ((E)->data)
|
||||
/* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */
|
||||
/* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */
|
||||
|
||||
/*
|
||||
** Number of entries in a hash table
|
||||
*/
|
||||
/* #define sqliteHashCount(H) ((H)->count) // NOT USED */
|
||||
|
||||
#endif /* SQLITE_HASH_H */
|
86
third_party/sqlite3/headers/hwtime.h
vendored
Normal file
86
third_party/sqlite3/headers/hwtime.h
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
** 2008 May 27
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This file contains inline asm code for retrieving "high-performance"
|
||||
** counters for x86 and x86_64 class CPUs.
|
||||
*/
|
||||
#ifndef SQLITE_HWTIME_H
|
||||
#define SQLITE_HWTIME_H
|
||||
|
||||
/*
|
||||
** The following routine only works on pentium-class (or newer) processors.
|
||||
** It uses the RDTSC opcode to read the cycle count value out of the
|
||||
** processor and returns that value. This can be used for high-res
|
||||
** profiling.
|
||||
*/
|
||||
#if !defined(__STRICT_ANSI__) && (defined(__GNUC__) || defined(_MSC_VER)) && \
|
||||
(defined(i386) || defined(__i386__) || defined(_M_IX86))
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
||||
__inline__ sqlite_uint64 sqlite3Hwtime(void) {
|
||||
unsigned int lo, hi;
|
||||
__asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi));
|
||||
return (sqlite_uint64)hi << 32 | lo;
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
__declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void) {
|
||||
__asm {
|
||||
rdtsc
|
||||
ret ; return value at EDX:EAX
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
|
||||
|
||||
__inline__ sqlite_uint64 sqlite3Hwtime(void) {
|
||||
unsigned long val;
|
||||
__asm__ __volatile__("rdtsc" : "=A"(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
|
||||
|
||||
__inline__ sqlite_uint64 sqlite3Hwtime(void) {
|
||||
unsigned long long retval;
|
||||
unsigned long junk;
|
||||
__asm__ __volatile__("\n\
|
||||
1: mftbu %1\n\
|
||||
mftb %L0\n\
|
||||
mftbu %0\n\
|
||||
cmpw %0,%1\n\
|
||||
bne 1b"
|
||||
: "=r"(retval), "=r"(junk));
|
||||
return retval;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
** asm() is needed for hardware timing support. Without asm(),
|
||||
** disable the sqlite3Hwtime() routine.
|
||||
**
|
||||
** sqlite3Hwtime() is only used for some obscure debugging
|
||||
** and analysis configurations, not in any deliverable, so this
|
||||
** should not be a great loss.
|
||||
*/
|
||||
sqlite_uint64 sqlite3Hwtime(void) {
|
||||
return ((sqlite_uint64)0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !defined(SQLITE_HWTIME_H) */
|
486
third_party/sqlite3/headers/keywordhash.h
vendored
Normal file
486
third_party/sqlite3/headers/keywordhash.h
vendored
Normal file
|
@ -0,0 +1,486 @@
|
|||
/***** This file contains automatically generated code ******
|
||||
**
|
||||
** The code in this file has been automatically generated by
|
||||
**
|
||||
** sqlite/tool/mkkeywordhash.c
|
||||
**
|
||||
** The code in this file implements a function that determines whether
|
||||
** or not a given identifier is really an SQL keyword. The same thing
|
||||
** might be implemented more directly using a hand-written hash table.
|
||||
** But by using this automatically generated code, the size of the code
|
||||
** is substantially reduced. This is important for embedded applications
|
||||
** on platforms with limited memory.
|
||||
*/
|
||||
/* Hash score: 231 */
|
||||
/* zKWText[] encodes 1007 bytes of keyword text in 667 bytes */
|
||||
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
|
||||
/* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */
|
||||
/* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */
|
||||
/* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */
|
||||
/* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */
|
||||
/* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */
|
||||
/* PRAGMATERIALIZEDEFERREDISTINCTUPDATEVALUESVIRTUALWAYSWHENWHERE */
|
||||
/* CURSIVEABORTAFTERENAMEANDROPARTITIONAUTOINCREMENTCASTCOLUMN */
|
||||
/* COMMITCONFLICTCROSSCURRENT_TIMESTAMPRECEDINGFAILASTFILTER */
|
||||
/* EPLACEFIRSTFOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVER */
|
||||
/* ETURNINGRIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBY */
|
||||
/* INITIALLYPRIMARY */
|
||||
static const char zKWText[666] = {
|
||||
'R', 'E', 'I', 'N', 'D', 'E', 'X', 'E', 'D', 'E', 'S', 'C', 'A', 'P', 'E',
|
||||
'A', 'C', 'H', 'E', 'C', 'K', 'E', 'Y', 'B', 'E', 'F', 'O', 'R', 'E', 'I',
|
||||
'G', 'N', 'O', 'R', 'E', 'G', 'E', 'X', 'P', 'L', 'A', 'I', 'N', 'S', 'T',
|
||||
'E', 'A', 'D', 'D', 'A', 'T', 'A', 'B', 'A', 'S', 'E', 'L', 'E', 'C', 'T',
|
||||
'A', 'B', 'L', 'E', 'F', 'T', 'H', 'E', 'N', 'D', 'E', 'F', 'E', 'R', 'R',
|
||||
'A', 'B', 'L', 'E', 'L', 'S', 'E', 'X', 'C', 'L', 'U', 'D', 'E', 'L', 'E',
|
||||
'T', 'E', 'M', 'P', 'O', 'R', 'A', 'R', 'Y', 'I', 'S', 'N', 'U', 'L', 'L',
|
||||
'S', 'A', 'V', 'E', 'P', 'O', 'I', 'N', 'T', 'E', 'R', 'S', 'E', 'C', 'T',
|
||||
'I', 'E', 'S', 'N', 'O', 'T', 'N', 'U', 'L', 'L', 'I', 'K', 'E', 'X', 'C',
|
||||
'E', 'P', 'T', 'R', 'A', 'N', 'S', 'A', 'C', 'T', 'I', 'O', 'N', 'A', 'T',
|
||||
'U', 'R', 'A', 'L', 'T', 'E', 'R', 'A', 'I', 'S', 'E', 'X', 'C', 'L', 'U',
|
||||
'S', 'I', 'V', 'E', 'X', 'I', 'S', 'T', 'S', 'C', 'O', 'N', 'S', 'T', 'R',
|
||||
'A', 'I', 'N', 'T', 'O', 'F', 'F', 'S', 'E', 'T', 'R', 'I', 'G', 'G', 'E',
|
||||
'R', 'A', 'N', 'G', 'E', 'N', 'E', 'R', 'A', 'T', 'E', 'D', 'E', 'T', 'A',
|
||||
'C', 'H', 'A', 'V', 'I', 'N', 'G', 'L', 'O', 'B', 'E', 'G', 'I', 'N', 'N',
|
||||
'E', 'R', 'E', 'F', 'E', 'R', 'E', 'N', 'C', 'E', 'S', 'U', 'N', 'I', 'Q',
|
||||
'U', 'E', 'R', 'Y', 'W', 'I', 'T', 'H', 'O', 'U', 'T', 'E', 'R', 'E', 'L',
|
||||
'E', 'A', 'S', 'E', 'A', 'T', 'T', 'A', 'C', 'H', 'B', 'E', 'T', 'W', 'E',
|
||||
'E', 'N', 'O', 'T', 'H', 'I', 'N', 'G', 'R', 'O', 'U', 'P', 'S', 'C', 'A',
|
||||
'S', 'C', 'A', 'D', 'E', 'F', 'A', 'U', 'L', 'T', 'C', 'A', 'S', 'E', 'C',
|
||||
'O', 'L', 'L', 'A', 'T', 'E', 'C', 'R', 'E', 'A', 'T', 'E', 'C', 'U', 'R',
|
||||
'R', 'E', 'N', 'T', '_', 'D', 'A', 'T', 'E', 'I', 'M', 'M', 'E', 'D', 'I',
|
||||
'A', 'T', 'E', 'J', 'O', 'I', 'N', 'S', 'E', 'R', 'T', 'M', 'A', 'T', 'C',
|
||||
'H', 'P', 'L', 'A', 'N', 'A', 'L', 'Y', 'Z', 'E', 'P', 'R', 'A', 'G', 'M',
|
||||
'A', 'T', 'E', 'R', 'I', 'A', 'L', 'I', 'Z', 'E', 'D', 'E', 'F', 'E', 'R',
|
||||
'R', 'E', 'D', 'I', 'S', 'T', 'I', 'N', 'C', 'T', 'U', 'P', 'D', 'A', 'T',
|
||||
'E', 'V', 'A', 'L', 'U', 'E', 'S', 'V', 'I', 'R', 'T', 'U', 'A', 'L', 'W',
|
||||
'A', 'Y', 'S', 'W', 'H', 'E', 'N', 'W', 'H', 'E', 'R', 'E', 'C', 'U', 'R',
|
||||
'S', 'I', 'V', 'E', 'A', 'B', 'O', 'R', 'T', 'A', 'F', 'T', 'E', 'R', 'E',
|
||||
'N', 'A', 'M', 'E', 'A', 'N', 'D', 'R', 'O', 'P', 'A', 'R', 'T', 'I', 'T',
|
||||
'I', 'O', 'N', 'A', 'U', 'T', 'O', 'I', 'N', 'C', 'R', 'E', 'M', 'E', 'N',
|
||||
'T', 'C', 'A', 'S', 'T', 'C', 'O', 'L', 'U', 'M', 'N', 'C', 'O', 'M', 'M',
|
||||
'I', 'T', 'C', 'O', 'N', 'F', 'L', 'I', 'C', 'T', 'C', 'R', 'O', 'S', 'S',
|
||||
'C', 'U', 'R', 'R', 'E', 'N', 'T', '_', 'T', 'I', 'M', 'E', 'S', 'T', 'A',
|
||||
'M', 'P', 'R', 'E', 'C', 'E', 'D', 'I', 'N', 'G', 'F', 'A', 'I', 'L', 'A',
|
||||
'S', 'T', 'F', 'I', 'L', 'T', 'E', 'R', 'E', 'P', 'L', 'A', 'C', 'E', 'F',
|
||||
'I', 'R', 'S', 'T', 'F', 'O', 'L', 'L', 'O', 'W', 'I', 'N', 'G', 'F', 'R',
|
||||
'O', 'M', 'F', 'U', 'L', 'L', 'I', 'M', 'I', 'T', 'I', 'F', 'O', 'R', 'D',
|
||||
'E', 'R', 'E', 'S', 'T', 'R', 'I', 'C', 'T', 'O', 'T', 'H', 'E', 'R', 'S',
|
||||
'O', 'V', 'E', 'R', 'E', 'T', 'U', 'R', 'N', 'I', 'N', 'G', 'R', 'I', 'G',
|
||||
'H', 'T', 'R', 'O', 'L', 'L', 'B', 'A', 'C', 'K', 'R', 'O', 'W', 'S', 'U',
|
||||
'N', 'B', 'O', 'U', 'N', 'D', 'E', 'D', 'U', 'N', 'I', 'O', 'N', 'U', 'S',
|
||||
'I', 'N', 'G', 'V', 'A', 'C', 'U', 'U', 'M', 'V', 'I', 'E', 'W', 'I', 'N',
|
||||
'D', 'O', 'W', 'B', 'Y', 'I', 'N', 'I', 'T', 'I', 'A', 'L', 'L', 'Y', 'P',
|
||||
'R', 'I', 'M', 'A', 'R', 'Y',
|
||||
};
|
||||
/* aKWHash[i] is the hash value for the i-th keyword */
|
||||
static const unsigned char aKWHash[127] = {
|
||||
84, 92, 134, 82, 105, 29, 0, 0, 94, 0, 85, 72, 0, 53, 35,
|
||||
86, 15, 0, 42, 97, 54, 89, 135, 19, 0, 0, 140, 0, 40, 129,
|
||||
0, 22, 107, 0, 9, 0, 0, 123, 80, 0, 78, 6, 0, 65, 103,
|
||||
147, 0, 136, 115, 0, 0, 48, 0, 90, 24, 0, 17, 0, 27, 70,
|
||||
23, 26, 5, 60, 142, 110, 122, 0, 73, 91, 71, 145, 61, 120, 74,
|
||||
0, 49, 0, 11, 41, 0, 113, 0, 0, 0, 109, 10, 111, 116, 125,
|
||||
14, 50, 124, 0, 100, 0, 18, 121, 144, 56, 130, 139, 88, 83, 37,
|
||||
30, 126, 0, 0, 108, 51, 131, 128, 0, 34, 0, 0, 132, 0, 98,
|
||||
38, 39, 0, 20, 45, 117, 93,
|
||||
};
|
||||
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
|
||||
** then the i-th keyword has no more hash collisions. Otherwise,
|
||||
** the next keyword with the same hash is aKWHash[i]-1. */
|
||||
static const unsigned char aKWNext[147] = {
|
||||
0, 0, 0, 0, 4, 0, 43, 0, 0, 106, 114, 0, 0, 0, 2,
|
||||
0, 0, 143, 0, 0, 0, 13, 0, 0, 0, 0, 141, 0, 0, 119,
|
||||
52, 0, 0, 137, 12, 0, 0, 62, 0, 138, 0, 133, 0, 0, 36,
|
||||
0, 0, 28, 77, 0, 0, 0, 0, 59, 0, 47, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 0, 146, 3, 0,
|
||||
58, 0, 1, 75, 0, 0, 0, 31, 0, 0, 0, 0, 0, 127, 0,
|
||||
104, 0, 64, 66, 63, 0, 0, 0, 0, 0, 46, 0, 16, 8, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 101, 0, 112, 21, 7,
|
||||
67, 0, 79, 96, 118, 0, 0, 68, 0, 0, 99, 44, 0, 55, 0,
|
||||
76, 0, 95, 32, 33, 57, 25, 0, 102, 0, 0, 87,
|
||||
};
|
||||
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
|
||||
static const unsigned char aKWLen[147] = {
|
||||
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, 7, 7, 3, 8, 2, 6, 5, 4,
|
||||
4, 3, 10, 4, 7, 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4, 4, 6, 11,
|
||||
6, 2, 7, 5, 5, 9, 6, 10, 4, 6, 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10,
|
||||
6, 5, 7, 4, 5, 7, 6, 7, 7, 6, 5, 7, 3, 7, 4, 7, 6, 12, 9, 4, 6,
|
||||
5, 4, 7, 6, 12, 8, 8, 2, 6, 6, 7, 6, 4, 5, 9, 5, 5, 6, 3, 4, 9,
|
||||
13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 9, 4, 4, 6, 7, 5, 9, 4, 4, 5,
|
||||
2, 5, 8, 6, 4, 9, 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
|
||||
};
|
||||
/* aKWOffset[i] is the index into zKWText[] of the start of
|
||||
** the text for the i-th keyword. */
|
||||
static const unsigned short int aKWOffset[147] = {
|
||||
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, 36, 41,
|
||||
46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, 86, 90, 90, 94,
|
||||
99, 101, 105, 111, 119, 123, 123, 123, 126, 129, 132, 137, 142, 146, 147,
|
||||
152, 156, 160, 168, 174, 181, 184, 184, 187, 189, 195, 198, 206, 211, 216,
|
||||
219, 222, 226, 236, 239, 244, 244, 248, 252, 259, 265, 271, 277, 277, 283,
|
||||
284, 288, 295, 299, 306, 312, 324, 333, 335, 341, 346, 348, 355, 359, 370,
|
||||
377, 378, 385, 391, 397, 402, 408, 412, 415, 424, 429, 433, 439, 441, 444,
|
||||
453, 455, 457, 466, 470, 476, 482, 490, 495, 495, 495, 511, 520, 523, 527,
|
||||
532, 539, 544, 553, 557, 560, 565, 567, 571, 579, 585, 588, 597, 602, 610,
|
||||
610, 614, 623, 628, 633, 639, 642, 645, 648, 650, 655, 659,
|
||||
};
|
||||
/* aKWCode[i] is the parser symbol code for the i-th keyword */
|
||||
static const unsigned char aKWCode[147] = {
|
||||
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
|
||||
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
|
||||
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
|
||||
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
|
||||
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
|
||||
TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR,
|
||||
TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES,
|
||||
TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
|
||||
TK_EXCEPT, TK_TRANSACTION, TK_ACTION, TK_ON, TK_JOIN_KW,
|
||||
TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT,
|
||||
TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER,
|
||||
TK_RANGE, TK_GENERATED, TK_DETACH, TK_HAVING, TK_LIKE_KW,
|
||||
TK_BEGIN, TK_JOIN_KW, TK_REFERENCES, TK_UNIQUE, TK_QUERY,
|
||||
TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_ATTACH,
|
||||
TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE,
|
||||
TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE,
|
||||
TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH,
|
||||
TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_MATERIALIZED, TK_DEFERRED,
|
||||
TK_DISTINCT, TK_IS, TK_UPDATE, TK_VALUES, TK_VIRTUAL,
|
||||
TK_ALWAYS, TK_WHEN, TK_WHERE, TK_RECURSIVE, TK_ABORT,
|
||||
TK_AFTER, TK_RENAME, TK_AND, TK_DROP, TK_PARTITION,
|
||||
TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW,
|
||||
TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW,
|
||||
TK_CURRENT, TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER,
|
||||
TK_REPLACE, TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW,
|
||||
TK_LIMIT, TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS,
|
||||
TK_OVER, TK_RETURNING, TK_JOIN_KW, TK_ROLLBACK, TK_ROWS,
|
||||
TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, TK_VACUUM,
|
||||
TK_VIEW, TK_WINDOW, TK_DO, TK_BY, TK_INITIALLY,
|
||||
TK_ALL, TK_PRIMARY,
|
||||
};
|
||||
/* Hash table decoded:
|
||||
** 0: INSERT
|
||||
** 1: IS
|
||||
** 2: ROLLBACK TRIGGER
|
||||
** 3: IMMEDIATE
|
||||
** 4: PARTITION
|
||||
** 5: TEMP
|
||||
** 6:
|
||||
** 7:
|
||||
** 8: VALUES WITHOUT
|
||||
** 9:
|
||||
** 10: MATCH
|
||||
** 11: NOTHING
|
||||
** 12:
|
||||
** 13: OF
|
||||
** 14: TIES IGNORE
|
||||
** 15: PLAN
|
||||
** 16: INSTEAD INDEXED
|
||||
** 17:
|
||||
** 18: TRANSACTION RIGHT
|
||||
** 19: WHEN
|
||||
** 20: SET HAVING
|
||||
** 21: MATERIALIZED IF
|
||||
** 22: ROWS
|
||||
** 23: SELECT
|
||||
** 24:
|
||||
** 25:
|
||||
** 26: VACUUM SAVEPOINT
|
||||
** 27:
|
||||
** 28: LIKE UNION VIRTUAL REFERENCES
|
||||
** 29: RESTRICT
|
||||
** 30:
|
||||
** 31: THEN REGEXP
|
||||
** 32: TO
|
||||
** 33:
|
||||
** 34: BEFORE
|
||||
** 35:
|
||||
** 36:
|
||||
** 37: FOLLOWING COLLATE CASCADE
|
||||
** 38: CREATE
|
||||
** 39:
|
||||
** 40: CASE REINDEX
|
||||
** 41: EACH
|
||||
** 42:
|
||||
** 43: QUERY
|
||||
** 44: AND ADD
|
||||
** 45: PRIMARY ANALYZE
|
||||
** 46:
|
||||
** 47: ROW ASC DETACH
|
||||
** 48: CURRENT_TIME CURRENT_DATE
|
||||
** 49:
|
||||
** 50:
|
||||
** 51: EXCLUSIVE TEMPORARY
|
||||
** 52:
|
||||
** 53: DEFERRED
|
||||
** 54: DEFERRABLE
|
||||
** 55:
|
||||
** 56: DATABASE
|
||||
** 57:
|
||||
** 58: DELETE VIEW GENERATED
|
||||
** 59: ATTACH
|
||||
** 60: END
|
||||
** 61: EXCLUDE
|
||||
** 62: ESCAPE DESC
|
||||
** 63: GLOB
|
||||
** 64: WINDOW ELSE
|
||||
** 65: COLUMN
|
||||
** 66: FIRST
|
||||
** 67:
|
||||
** 68: GROUPS ALL
|
||||
** 69: DISTINCT DROP KEY
|
||||
** 70: BETWEEN
|
||||
** 71: INITIALLY
|
||||
** 72: BEGIN
|
||||
** 73: FILTER CHECK ACTION
|
||||
** 74: GROUP INDEX
|
||||
** 75:
|
||||
** 76: EXISTS DEFAULT
|
||||
** 77:
|
||||
** 78: FOR CURRENT_TIMESTAMP
|
||||
** 79: EXCEPT
|
||||
** 80:
|
||||
** 81: CROSS
|
||||
** 82:
|
||||
** 83:
|
||||
** 84:
|
||||
** 85: CAST
|
||||
** 86: FOREIGN AUTOINCREMENT
|
||||
** 87: COMMIT
|
||||
** 88: CURRENT AFTER ALTER
|
||||
** 89: FULL FAIL CONFLICT
|
||||
** 90: EXPLAIN
|
||||
** 91: CONSTRAINT
|
||||
** 92: FROM ALWAYS
|
||||
** 93:
|
||||
** 94: ABORT
|
||||
** 95:
|
||||
** 96: AS DO
|
||||
** 97: REPLACE WITH RELEASE
|
||||
** 98: BY RENAME
|
||||
** 99: RANGE RAISE
|
||||
** 100: OTHERS
|
||||
** 101: USING NULLS
|
||||
** 102: PRAGMA
|
||||
** 103: JOIN ISNULL OFFSET
|
||||
** 104: NOT
|
||||
** 105: OR LAST LEFT
|
||||
** 106: LIMIT
|
||||
** 107:
|
||||
** 108:
|
||||
** 109: IN
|
||||
** 110: INTO
|
||||
** 111: OVER RECURSIVE
|
||||
** 112: ORDER OUTER
|
||||
** 113:
|
||||
** 114: INTERSECT UNBOUNDED
|
||||
** 115:
|
||||
** 116:
|
||||
** 117: RETURNING ON
|
||||
** 118:
|
||||
** 119: WHERE
|
||||
** 120: NO INNER
|
||||
** 121: NULL
|
||||
** 122:
|
||||
** 123: TABLE
|
||||
** 124: NATURAL NOTNULL
|
||||
** 125: PRECEDING
|
||||
** 126: UPDATE UNIQUE
|
||||
*/
|
||||
/* Check to see if z[0..n-1] is a keyword. If it is, write the
|
||||
** parser symbol code for that keyword into *pType. Always
|
||||
** return the integer n (the length of the token). */
|
||||
static int keywordCode(const char *z, int n, int *pType) {
|
||||
int i, j;
|
||||
const char *zKW;
|
||||
if (n >= 2) {
|
||||
i = ((charMap(z[0]) * 4) ^ (charMap(z[n - 1]) * 3) ^ n * 1) % 127;
|
||||
for (i = ((int)aKWHash[i]) - 1; i >= 0; i = ((int)aKWNext[i]) - 1) {
|
||||
if (aKWLen[i] != n) continue;
|
||||
zKW = &zKWText[aKWOffset[i]];
|
||||
#ifdef SQLITE_ASCII
|
||||
if ((z[0] & ~0x20) != zKW[0]) continue;
|
||||
if ((z[1] & ~0x20) != zKW[1]) continue;
|
||||
j = 2;
|
||||
while (j < n && (z[j] & ~0x20) == zKW[j]) {
|
||||
j++;
|
||||
}
|
||||
#endif
|
||||
#ifdef SQLITE_EBCDIC
|
||||
if (toupper(z[0]) != zKW[0]) continue;
|
||||
if (toupper(z[1]) != zKW[1]) continue;
|
||||
j = 2;
|
||||
while (j < n && toupper(z[j]) == zKW[j]) {
|
||||
j++;
|
||||
}
|
||||
#endif
|
||||
if (j < n) continue;
|
||||
testcase(i == 0); /* REINDEX */
|
||||
testcase(i == 1); /* INDEXED */
|
||||
testcase(i == 2); /* INDEX */
|
||||
testcase(i == 3); /* DESC */
|
||||
testcase(i == 4); /* ESCAPE */
|
||||
testcase(i == 5); /* EACH */
|
||||
testcase(i == 6); /* CHECK */
|
||||
testcase(i == 7); /* KEY */
|
||||
testcase(i == 8); /* BEFORE */
|
||||
testcase(i == 9); /* FOREIGN */
|
||||
testcase(i == 10); /* FOR */
|
||||
testcase(i == 11); /* IGNORE */
|
||||
testcase(i == 12); /* REGEXP */
|
||||
testcase(i == 13); /* EXPLAIN */
|
||||
testcase(i == 14); /* INSTEAD */
|
||||
testcase(i == 15); /* ADD */
|
||||
testcase(i == 16); /* DATABASE */
|
||||
testcase(i == 17); /* AS */
|
||||
testcase(i == 18); /* SELECT */
|
||||
testcase(i == 19); /* TABLE */
|
||||
testcase(i == 20); /* LEFT */
|
||||
testcase(i == 21); /* THEN */
|
||||
testcase(i == 22); /* END */
|
||||
testcase(i == 23); /* DEFERRABLE */
|
||||
testcase(i == 24); /* ELSE */
|
||||
testcase(i == 25); /* EXCLUDE */
|
||||
testcase(i == 26); /* DELETE */
|
||||
testcase(i == 27); /* TEMPORARY */
|
||||
testcase(i == 28); /* TEMP */
|
||||
testcase(i == 29); /* OR */
|
||||
testcase(i == 30); /* ISNULL */
|
||||
testcase(i == 31); /* NULLS */
|
||||
testcase(i == 32); /* SAVEPOINT */
|
||||
testcase(i == 33); /* INTERSECT */
|
||||
testcase(i == 34); /* TIES */
|
||||
testcase(i == 35); /* NOTNULL */
|
||||
testcase(i == 36); /* NOT */
|
||||
testcase(i == 37); /* NO */
|
||||
testcase(i == 38); /* NULL */
|
||||
testcase(i == 39); /* LIKE */
|
||||
testcase(i == 40); /* EXCEPT */
|
||||
testcase(i == 41); /* TRANSACTION */
|
||||
testcase(i == 42); /* ACTION */
|
||||
testcase(i == 43); /* ON */
|
||||
testcase(i == 44); /* NATURAL */
|
||||
testcase(i == 45); /* ALTER */
|
||||
testcase(i == 46); /* RAISE */
|
||||
testcase(i == 47); /* EXCLUSIVE */
|
||||
testcase(i == 48); /* EXISTS */
|
||||
testcase(i == 49); /* CONSTRAINT */
|
||||
testcase(i == 50); /* INTO */
|
||||
testcase(i == 51); /* OFFSET */
|
||||
testcase(i == 52); /* OF */
|
||||
testcase(i == 53); /* SET */
|
||||
testcase(i == 54); /* TRIGGER */
|
||||
testcase(i == 55); /* RANGE */
|
||||
testcase(i == 56); /* GENERATED */
|
||||
testcase(i == 57); /* DETACH */
|
||||
testcase(i == 58); /* HAVING */
|
||||
testcase(i == 59); /* GLOB */
|
||||
testcase(i == 60); /* BEGIN */
|
||||
testcase(i == 61); /* INNER */
|
||||
testcase(i == 62); /* REFERENCES */
|
||||
testcase(i == 63); /* UNIQUE */
|
||||
testcase(i == 64); /* QUERY */
|
||||
testcase(i == 65); /* WITHOUT */
|
||||
testcase(i == 66); /* WITH */
|
||||
testcase(i == 67); /* OUTER */
|
||||
testcase(i == 68); /* RELEASE */
|
||||
testcase(i == 69); /* ATTACH */
|
||||
testcase(i == 70); /* BETWEEN */
|
||||
testcase(i == 71); /* NOTHING */
|
||||
testcase(i == 72); /* GROUPS */
|
||||
testcase(i == 73); /* GROUP */
|
||||
testcase(i == 74); /* CASCADE */
|
||||
testcase(i == 75); /* ASC */
|
||||
testcase(i == 76); /* DEFAULT */
|
||||
testcase(i == 77); /* CASE */
|
||||
testcase(i == 78); /* COLLATE */
|
||||
testcase(i == 79); /* CREATE */
|
||||
testcase(i == 80); /* CURRENT_DATE */
|
||||
testcase(i == 81); /* IMMEDIATE */
|
||||
testcase(i == 82); /* JOIN */
|
||||
testcase(i == 83); /* INSERT */
|
||||
testcase(i == 84); /* MATCH */
|
||||
testcase(i == 85); /* PLAN */
|
||||
testcase(i == 86); /* ANALYZE */
|
||||
testcase(i == 87); /* PRAGMA */
|
||||
testcase(i == 88); /* MATERIALIZED */
|
||||
testcase(i == 89); /* DEFERRED */
|
||||
testcase(i == 90); /* DISTINCT */
|
||||
testcase(i == 91); /* IS */
|
||||
testcase(i == 92); /* UPDATE */
|
||||
testcase(i == 93); /* VALUES */
|
||||
testcase(i == 94); /* VIRTUAL */
|
||||
testcase(i == 95); /* ALWAYS */
|
||||
testcase(i == 96); /* WHEN */
|
||||
testcase(i == 97); /* WHERE */
|
||||
testcase(i == 98); /* RECURSIVE */
|
||||
testcase(i == 99); /* ABORT */
|
||||
testcase(i == 100); /* AFTER */
|
||||
testcase(i == 101); /* RENAME */
|
||||
testcase(i == 102); /* AND */
|
||||
testcase(i == 103); /* DROP */
|
||||
testcase(i == 104); /* PARTITION */
|
||||
testcase(i == 105); /* AUTOINCREMENT */
|
||||
testcase(i == 106); /* TO */
|
||||
testcase(i == 107); /* IN */
|
||||
testcase(i == 108); /* CAST */
|
||||
testcase(i == 109); /* COLUMN */
|
||||
testcase(i == 110); /* COMMIT */
|
||||
testcase(i == 111); /* CONFLICT */
|
||||
testcase(i == 112); /* CROSS */
|
||||
testcase(i == 113); /* CURRENT_TIMESTAMP */
|
||||
testcase(i == 114); /* CURRENT_TIME */
|
||||
testcase(i == 115); /* CURRENT */
|
||||
testcase(i == 116); /* PRECEDING */
|
||||
testcase(i == 117); /* FAIL */
|
||||
testcase(i == 118); /* LAST */
|
||||
testcase(i == 119); /* FILTER */
|
||||
testcase(i == 120); /* REPLACE */
|
||||
testcase(i == 121); /* FIRST */
|
||||
testcase(i == 122); /* FOLLOWING */
|
||||
testcase(i == 123); /* FROM */
|
||||
testcase(i == 124); /* FULL */
|
||||
testcase(i == 125); /* LIMIT */
|
||||
testcase(i == 126); /* IF */
|
||||
testcase(i == 127); /* ORDER */
|
||||
testcase(i == 128); /* RESTRICT */
|
||||
testcase(i == 129); /* OTHERS */
|
||||
testcase(i == 130); /* OVER */
|
||||
testcase(i == 131); /* RETURNING */
|
||||
testcase(i == 132); /* RIGHT */
|
||||
testcase(i == 133); /* ROLLBACK */
|
||||
testcase(i == 134); /* ROWS */
|
||||
testcase(i == 135); /* ROW */
|
||||
testcase(i == 136); /* UNBOUNDED */
|
||||
testcase(i == 137); /* UNION */
|
||||
testcase(i == 138); /* USING */
|
||||
testcase(i == 139); /* VACUUM */
|
||||
testcase(i == 140); /* VIEW */
|
||||
testcase(i == 141); /* WINDOW */
|
||||
testcase(i == 142); /* DO */
|
||||
testcase(i == 143); /* BY */
|
||||
testcase(i == 144); /* INITIALLY */
|
||||
testcase(i == 145); /* ALL */
|
||||
testcase(i == 146); /* PRIMARY */
|
||||
*pType = aKWCode[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
int sqlite3KeywordCode(const unsigned char *z, int n) {
|
||||
int id = TK_ID;
|
||||
keywordCode((char *)z, n, &id);
|
||||
return id;
|
||||
}
|
||||
#define SQLITE_N_KEYWORD 147
|
||||
int sqlite3_keyword_name(int i, const char **pzName, int *pnName) {
|
||||
if (i < 0 || i >= SQLITE_N_KEYWORD) return SQLITE_ERROR;
|
||||
*pzName = zKWText + aKWOffset[i];
|
||||
*pnName = aKWLen[i];
|
||||
return SQLITE_OK;
|
||||
}
|
||||
int sqlite3_keyword_count(void) {
|
||||
return SQLITE_N_KEYWORD;
|
||||
}
|
||||
int sqlite3_keyword_check(const char *zName, int nName) {
|
||||
return TK_ID != sqlite3KeywordCode((const u8 *)zName, nName);
|
||||
}
|
41
third_party/sqlite3/headers/msvc.h
vendored
Normal file
41
third_party/sqlite3/headers/msvc.h
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
** 2015 January 12
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This file contains code that is specific to MSVC.
|
||||
*/
|
||||
#ifndef SQLITE_MSVC_H
|
||||
#define SQLITE_MSVC_H
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable : 4054)
|
||||
#pragma warning(disable : 4055)
|
||||
#pragma warning(disable : 4100)
|
||||
#pragma warning(disable : 4127)
|
||||
#pragma warning(disable : 4130)
|
||||
#pragma warning(disable : 4152)
|
||||
#pragma warning(disable : 4189)
|
||||
#pragma warning(disable : 4206)
|
||||
#pragma warning(disable : 4210)
|
||||
#pragma warning(disable : 4232)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4305)
|
||||
#pragma warning(disable : 4306)
|
||||
#pragma warning(disable : 4702)
|
||||
#pragma warning(disable : 4706)
|
||||
#endif /* defined(_MSC_VER) */
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN64)
|
||||
#undef SQLITE_4_BYTE_ALIGNED_MALLOC
|
||||
#define SQLITE_4_BYTE_ALIGNED_MALLOC
|
||||
#endif /* defined(_MSC_VER) && !defined(_WIN64) */
|
||||
|
||||
#endif /* SQLITE_MSVC_H */
|
70
third_party/sqlite3/headers/mutex.h
vendored
Normal file
70
third_party/sqlite3/headers/mutex.h
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
** 2007 August 28
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This file contains the common header for all mutex implementations.
|
||||
** The sqliteInt.h header #includes this file so that it is available
|
||||
** to all source files. We break it out in an effort to keep the code
|
||||
** better organized.
|
||||
**
|
||||
** NOTE: source files should *not* #include this header file directly.
|
||||
** Source files should #include the sqliteInt.h file and let that file
|
||||
** include this one indirectly.
|
||||
*/
|
||||
|
||||
/*
|
||||
** Figure out what version of the code to use. The choices are
|
||||
**
|
||||
** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The
|
||||
** mutexes implementation cannot be overridden
|
||||
** at start-time.
|
||||
**
|
||||
** SQLITE_MUTEX_NOOP For single-threaded applications. No
|
||||
** mutual exclusion is provided. But this
|
||||
** implementation can be overridden at
|
||||
** start-time.
|
||||
**
|
||||
** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix.
|
||||
**
|
||||
** SQLITE_MUTEX_W32 For multi-threaded applications on Win32.
|
||||
*/
|
||||
#if !SQLITE_THREADSAFE
|
||||
#define SQLITE_MUTEX_OMIT
|
||||
#endif
|
||||
#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)
|
||||
#if SQLITE_OS_UNIX
|
||||
#define SQLITE_MUTEX_PTHREADS
|
||||
#elif SQLITE_OS_WIN
|
||||
#define SQLITE_MUTEX_W32
|
||||
#else
|
||||
#define SQLITE_MUTEX_NOOP
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_MUTEX_OMIT
|
||||
/*
|
||||
** If this is a no-op implementation, implement everything as macros.
|
||||
*/
|
||||
#define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8)
|
||||
#define sqlite3_mutex_free(X)
|
||||
#define sqlite3_mutex_enter(X)
|
||||
#define sqlite3_mutex_try(X) SQLITE_OK
|
||||
#define sqlite3_mutex_leave(X)
|
||||
#define sqlite3_mutex_held(X) ((void)(X), 1)
|
||||
#define sqlite3_mutex_notheld(X) ((void)(X), 1)
|
||||
#define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8)
|
||||
#define sqlite3MutexInit() SQLITE_OK
|
||||
#define sqlite3MutexEnd()
|
||||
#define MUTEX_LOGIC(X)
|
||||
#else
|
||||
#define MUTEX_LOGIC(X) X
|
||||
int sqlite3_mutex_held(sqlite3_mutex*);
|
||||
#endif /* defined(SQLITE_MUTEX_OMIT) */
|
28
third_party/sqlite3/headers/opcodes.h
vendored
Normal file
28
third_party/sqlite3/headers/opcodes.h
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* Automatically generated. Do not edit */
|
||||
/* See the tool/mkopcodeh.tcl script for details */
|
||||
#define OP_Noop 0
|
||||
#define OP_Explain 1
|
||||
#define OP_Abortable 2
|
||||
|
||||
/* Properties such as "out2" or "jump" that are specified in
|
||||
** comments following the "case" for each opcode in the vdbe.c
|
||||
** are encoded into bitvectors as follows:
|
||||
*/
|
||||
#define OPFLG_JUMP 0x01 /* jump: P2 holds jmp target */
|
||||
#define OPFLG_IN1 0x02 /* in1: P1 is an input */
|
||||
#define OPFLG_IN2 0x04 /* in2: P2 is an input */
|
||||
#define OPFLG_IN3 0x08 /* in3: P3 is an input */
|
||||
#define OPFLG_OUT2 0x10 /* out2: P2 is an output */
|
||||
#define OPFLG_OUT3 0x20 /* out3: P3 is an output */
|
||||
#define OPFLG_INITIALIZER \
|
||||
{ /* 0 */ \
|
||||
0x00, 0x00, 0x00, \
|
||||
}
|
||||
|
||||
/* The sqlite3P2Values() routine is able to run faster if it knows
|
||||
** the value of the largest JUMP opcode. The smaller the maximum
|
||||
** JUMP opcode the better, so the mkopcodeh.tcl script that
|
||||
** generated this include file strives to group all JUMP opcodes
|
||||
** together near the beginning of the list.
|
||||
*/
|
||||
#define SQLITE_MX_JUMP_OPCODE -1 /* Maximum JUMP opcode */
|
212
third_party/sqlite3/headers/os.h
vendored
Normal file
212
third_party/sqlite3/headers/os.h
vendored
Normal file
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
** 2001 September 16
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This header file (together with is companion C source-code file
|
||||
** "os.c") attempt to abstract the underlying operating system so that
|
||||
** the SQLite library will work on both POSIX and windows systems.
|
||||
**
|
||||
** This header file is #include-ed by sqliteInt.h and thus ends up
|
||||
** being included by every source file.
|
||||
*/
|
||||
#ifndef _SQLITE_OS_H_
|
||||
#define _SQLITE_OS_H_
|
||||
|
||||
/*
|
||||
** Attempt to automatically detect the operating system and setup the
|
||||
** necessary pre-processor macros for it.
|
||||
*/
|
||||
#include "os_setup.h"
|
||||
|
||||
/* If the SET_FULLSYNC macro is not defined above, then make it
|
||||
** a no-op
|
||||
*/
|
||||
#ifndef SET_FULLSYNC
|
||||
#define SET_FULLSYNC(x, y)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The default size of a disk sector
|
||||
*/
|
||||
#ifndef SQLITE_DEFAULT_SECTOR_SIZE
|
||||
#define SQLITE_DEFAULT_SECTOR_SIZE 4096
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Temporary files are named starting with this prefix followed by 16 random
|
||||
** alphanumeric characters, and no file extension. They are stored in the
|
||||
** OS's standard temporary file directory, and are deleted prior to exit.
|
||||
** If sqlite is being embedded in another program, you may wish to change the
|
||||
** prefix to reflect your program's name, so that if your program exits
|
||||
** prematurely, old temporary files can be easily identified. This can be done
|
||||
** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line.
|
||||
**
|
||||
** 2006-10-31: The default prefix used to be "sqlite_". But then
|
||||
** Mcafee started using SQLite in their anti-virus product and it
|
||||
** started putting files with the "sqlite" name in the c:/temp folder.
|
||||
** This annoyed many windows users. Those users would then do a
|
||||
** Google search for "sqlite", find the telephone numbers of the
|
||||
** developers and call to wake them up at night and complain.
|
||||
** For this reason, the default name prefix is changed to be "sqlite"
|
||||
** spelled backwards. So the temp files are still identified, but
|
||||
** anybody smart enough to figure out the code is also likely smart
|
||||
** enough to know that calling the developer will not help get rid
|
||||
** of the file.
|
||||
*/
|
||||
#ifndef SQLITE_TEMP_FILE_PREFIX
|
||||
#define SQLITE_TEMP_FILE_PREFIX "etilqs_"
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The following values may be passed as the second argument to
|
||||
** sqlite3OsLock(). The various locks exhibit the following semantics:
|
||||
**
|
||||
** SHARED: Any number of processes may hold a SHARED lock simultaneously.
|
||||
** RESERVED: A single process may hold a RESERVED lock on a file at
|
||||
** any time. Other processes may hold and obtain new SHARED locks.
|
||||
** PENDING: A single process may hold a PENDING lock on a file at
|
||||
** any one time. Existing SHARED locks may persist, but no new
|
||||
** SHARED locks may be obtained by other processes.
|
||||
** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks.
|
||||
**
|
||||
** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a
|
||||
** process that requests an EXCLUSIVE lock may actually obtain a PENDING
|
||||
** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to
|
||||
** sqlite3OsLock().
|
||||
*/
|
||||
#define NO_LOCK 0
|
||||
#define SHARED_LOCK 1
|
||||
#define RESERVED_LOCK 2
|
||||
#define PENDING_LOCK 3
|
||||
#define EXCLUSIVE_LOCK 4
|
||||
|
||||
/*
|
||||
** File Locking Notes: (Mostly about windows but also some info for Unix)
|
||||
**
|
||||
** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because
|
||||
** those functions are not available. So we use only LockFile() and
|
||||
** UnlockFile().
|
||||
**
|
||||
** LockFile() prevents not just writing but also reading by other processes.
|
||||
** A SHARED_LOCK is obtained by locking a single randomly-chosen
|
||||
** byte out of a specific range of bytes. The lock byte is obtained at
|
||||
** random so two separate readers can probably access the file at the
|
||||
** same time, unless they are unlucky and choose the same lock byte.
|
||||
** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range.
|
||||
** There can only be one writer. A RESERVED_LOCK is obtained by locking
|
||||
** a single byte of the file that is designated as the reserved lock byte.
|
||||
** A PENDING_LOCK is obtained by locking a designated byte different from
|
||||
** the RESERVED_LOCK byte.
|
||||
**
|
||||
** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available,
|
||||
** which means we can use reader/writer locks. When reader/writer locks
|
||||
** are used, the lock is placed on the same range of bytes that is used
|
||||
** for probabilistic locking in Win95/98/ME. Hence, the locking scheme
|
||||
** will support two or more Win95 readers or two or more WinNT readers.
|
||||
** But a single Win95 reader will lock out all WinNT readers and a single
|
||||
** WinNT reader will lock out all other Win95 readers.
|
||||
**
|
||||
** The following #defines specify the range of bytes used for locking.
|
||||
** SHARED_SIZE is the number of bytes available in the pool from which
|
||||
** a random byte is selected for a shared lock. The pool of bytes for
|
||||
** shared locks begins at SHARED_FIRST.
|
||||
**
|
||||
** The same locking strategy and
|
||||
** byte ranges are used for Unix. This leaves open the possibility of having
|
||||
** clients on win95, winNT, and unix all talking to the same shared file
|
||||
** and all locking correctly. To do so would require that samba (or whatever
|
||||
** tool is being used for file sharing) implements locks correctly between
|
||||
** windows and unix. I'm guessing that isn't likely to happen, but by
|
||||
** using the same locking range we are at least open to the possibility.
|
||||
**
|
||||
** Locking in windows is manditory. For this reason, we cannot store
|
||||
** actual data in the bytes used for locking. The pager never allocates
|
||||
** the pages involved in locking therefore. SHARED_SIZE is selected so
|
||||
** that all locks will fit on a single page even at the minimum page size.
|
||||
** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE
|
||||
** is set high so that we don't have to allocate an unused page except
|
||||
** for very large databases. But one should test the page skipping logic
|
||||
** by setting PENDING_BYTE low and running the entire regression suite.
|
||||
**
|
||||
** Changing the value of PENDING_BYTE results in a subtly incompatible
|
||||
** file format. Depending on how it is changed, you might not notice
|
||||
** the incompatibility right away, even running a full regression test.
|
||||
** The default location of PENDING_BYTE is the first byte past the
|
||||
** 1GB boundary.
|
||||
**
|
||||
*/
|
||||
#ifdef SQLITE_OMIT_WSD
|
||||
#define PENDING_BYTE (0x40000000)
|
||||
#else
|
||||
#define PENDING_BYTE sqlite3PendingByte
|
||||
#endif
|
||||
#define RESERVED_BYTE (PENDING_BYTE + 1)
|
||||
#define SHARED_FIRST (PENDING_BYTE + 2)
|
||||
#define SHARED_SIZE 510
|
||||
|
||||
/*
|
||||
** Wrapper around OS specific sqlite3_os_init() function.
|
||||
*/
|
||||
int sqlite3OsInit(void);
|
||||
|
||||
/*
|
||||
** Functions for accessing sqlite3_file methods
|
||||
*/
|
||||
void sqlite3OsClose(sqlite3_file *);
|
||||
int sqlite3OsRead(sqlite3_file *, void *, int amt, i64 offset);
|
||||
int sqlite3OsWrite(sqlite3_file *, const void *, int amt, i64 offset);
|
||||
int sqlite3OsTruncate(sqlite3_file *, i64 size);
|
||||
int sqlite3OsSync(sqlite3_file *, int);
|
||||
int sqlite3OsFileSize(sqlite3_file *, i64 *pSize);
|
||||
int sqlite3OsLock(sqlite3_file *, int);
|
||||
int sqlite3OsUnlock(sqlite3_file *, int);
|
||||
int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);
|
||||
int sqlite3OsFileControl(sqlite3_file *, int, void *);
|
||||
void sqlite3OsFileControlHint(sqlite3_file *, int, void *);
|
||||
#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0
|
||||
int sqlite3OsSectorSize(sqlite3_file *id);
|
||||
int sqlite3OsDeviceCharacteristics(sqlite3_file *id);
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
int sqlite3OsShmMap(sqlite3_file *, int, int, int, void volatile **);
|
||||
int sqlite3OsShmLock(sqlite3_file *id, int, int, int);
|
||||
void sqlite3OsShmBarrier(sqlite3_file *id);
|
||||
int sqlite3OsShmUnmap(sqlite3_file *id, int);
|
||||
#endif /* SQLITE_OMIT_WAL */
|
||||
int sqlite3OsFetch(sqlite3_file *id, i64, int, void **);
|
||||
int sqlite3OsUnfetch(sqlite3_file *, i64, void *);
|
||||
|
||||
/*
|
||||
** Functions for accessing sqlite3_vfs methods
|
||||
*/
|
||||
int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int *);
|
||||
int sqlite3OsDelete(sqlite3_vfs *, const char *, int);
|
||||
int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut);
|
||||
int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *);
|
||||
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
||||
void *sqlite3OsDlOpen(sqlite3_vfs *, const char *);
|
||||
void sqlite3OsDlError(sqlite3_vfs *, int, char *);
|
||||
void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void);
|
||||
void sqlite3OsDlClose(sqlite3_vfs *, void *);
|
||||
#endif /* SQLITE_OMIT_LOAD_EXTENSION */
|
||||
int sqlite3OsRandomness(sqlite3_vfs *, int, char *);
|
||||
int sqlite3OsSleep(sqlite3_vfs *, int);
|
||||
int sqlite3OsGetLastError(sqlite3_vfs *);
|
||||
int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64 *);
|
||||
|
||||
/*
|
||||
** Convenience functions for opening and closing files using
|
||||
** sqlite3_malloc() to obtain space for the file-handle structure.
|
||||
*/
|
||||
int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,
|
||||
int *);
|
||||
void sqlite3OsCloseFree(sqlite3_file *);
|
||||
|
||||
#endif /* _SQLITE_OS_H_ */
|
107
third_party/sqlite3/headers/os_common.h
vendored
Normal file
107
third_party/sqlite3/headers/os_common.h
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
** 2004 May 22
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This file contains macros and a little bit of code that is common to
|
||||
** all of the platform-specific files (os_*.c) and is #included into those
|
||||
** files.
|
||||
**
|
||||
** This file should be #included by the os_*.c files only. It is not a
|
||||
** general purpose header file.
|
||||
*/
|
||||
#ifndef _OS_COMMON_H_
|
||||
#define _OS_COMMON_H_
|
||||
|
||||
/*
|
||||
** At least two bugs have slipped in because we changed the MEMORY_DEBUG
|
||||
** macro to SQLITE_DEBUG and some older makefiles have not yet made the
|
||||
** switch. The following code should catch this problem at compile-time.
|
||||
*/
|
||||
#ifdef MEMORY_DEBUG
|
||||
#error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Macros for performance tracing. Normally turned off. Only works
|
||||
** on i486 hardware.
|
||||
*/
|
||||
#ifdef SQLITE_PERFORMANCE_TRACE
|
||||
|
||||
/*
|
||||
** hwtime.h contains inline assembler code for implementing
|
||||
** high-performance timing routines.
|
||||
*/
|
||||
#include "hwtime.h"
|
||||
|
||||
static sqlite_uint64 g_start;
|
||||
static sqlite_uint64 g_elapsed;
|
||||
#define TIMER_START g_start = sqlite3Hwtime()
|
||||
#define TIMER_END g_elapsed = sqlite3Hwtime() - g_start
|
||||
#define TIMER_ELAPSED g_elapsed
|
||||
#else
|
||||
#define TIMER_START
|
||||
#define TIMER_END
|
||||
#define TIMER_ELAPSED ((sqlite_uint64)0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** If we compile with the SQLITE_TEST macro set, then the following block
|
||||
** of code will give us the ability to simulate a disk I/O error. This
|
||||
** is used for testing the I/O recovery logic.
|
||||
*/
|
||||
#if defined(SQLITE_TEST)
|
||||
extern int sqlite3_io_error_hit;
|
||||
extern int sqlite3_io_error_hardhit;
|
||||
extern int sqlite3_io_error_pending;
|
||||
extern int sqlite3_io_error_persist;
|
||||
extern int sqlite3_io_error_benign;
|
||||
extern int sqlite3_diskfull_pending;
|
||||
extern int sqlite3_diskfull;
|
||||
#define SimulateIOErrorBenign(X) sqlite3_io_error_benign = (X)
|
||||
#define SimulateIOError(CODE) \
|
||||
if ((sqlite3_io_error_persist && sqlite3_io_error_hit) || \
|
||||
sqlite3_io_error_pending-- == 1) { \
|
||||
local_ioerr(); \
|
||||
CODE; \
|
||||
}
|
||||
static void local_ioerr() {
|
||||
IOTRACE(("IOERR\n"));
|
||||
sqlite3_io_error_hit++;
|
||||
if (!sqlite3_io_error_benign) sqlite3_io_error_hardhit++;
|
||||
}
|
||||
#define SimulateDiskfullError(CODE) \
|
||||
if (sqlite3_diskfull_pending) { \
|
||||
if (sqlite3_diskfull_pending == 1) { \
|
||||
local_ioerr(); \
|
||||
sqlite3_diskfull = 1; \
|
||||
sqlite3_io_error_hit = 1; \
|
||||
CODE; \
|
||||
} else { \
|
||||
sqlite3_diskfull_pending--; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define SimulateIOErrorBenign(X)
|
||||
#define SimulateIOError(A)
|
||||
#define SimulateDiskfullError(A)
|
||||
#endif /* defined(SQLITE_TEST) */
|
||||
|
||||
/*
|
||||
** When testing, keep a count of the number of open files.
|
||||
*/
|
||||
#if defined(SQLITE_TEST)
|
||||
extern int sqlite3_open_file_count;
|
||||
#define OpenCounter(X) sqlite3_open_file_count += (X)
|
||||
#else
|
||||
#define OpenCounter(X)
|
||||
#endif /* defined(SQLITE_TEST) */
|
||||
|
||||
#endif /* !defined(_OS_COMMON_H_) */
|
57
third_party/sqlite3/headers/os_setup.h
vendored
Normal file
57
third_party/sqlite3/headers/os_setup.h
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
** 2013 November 25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This file contains pre-processor directives related to operating system
|
||||
** detection and/or setup.
|
||||
*/
|
||||
#ifndef SQLITE_OS_SETUP_H
|
||||
#define SQLITE_OS_SETUP_H
|
||||
|
||||
/*
|
||||
** Figure out if we are dealing with Unix, Windows, or some other operating
|
||||
** system.
|
||||
**
|
||||
** After the following block of preprocess macros, all of SQLITE_OS_UNIX,
|
||||
** SQLITE_OS_WIN, and SQLITE_OS_OTHER will defined to either 1 or 0. One of
|
||||
** the three will be 1. The other two will be 0.
|
||||
*/
|
||||
#if defined(SQLITE_OS_OTHER)
|
||||
#if SQLITE_OS_OTHER == 1
|
||||
#undef SQLITE_OS_UNIX
|
||||
#define SQLITE_OS_UNIX 0
|
||||
#undef SQLITE_OS_WIN
|
||||
#define SQLITE_OS_WIN 0
|
||||
#else
|
||||
#undef SQLITE_OS_OTHER
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER)
|
||||
#define SQLITE_OS_OTHER 0
|
||||
#ifndef SQLITE_OS_WIN
|
||||
#if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || \
|
||||
defined(__MINGW32__) || defined(__BORLANDC__)
|
||||
#define SQLITE_OS_WIN 1
|
||||
#define SQLITE_OS_UNIX 0
|
||||
#else
|
||||
#define SQLITE_OS_WIN 0
|
||||
#define SQLITE_OS_UNIX 1
|
||||
#endif
|
||||
#else
|
||||
#define SQLITE_OS_UNIX 0
|
||||
#endif
|
||||
#else
|
||||
#ifndef SQLITE_OS_WIN
|
||||
#define SQLITE_OS_WIN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_OS_SETUP_H */
|
88
third_party/sqlite3/headers/os_win.h
vendored
Normal file
88
third_party/sqlite3/headers/os_win.h
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
** 2013 November 25
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This file contains code that is specific to Windows.
|
||||
*/
|
||||
#ifndef SQLITE_OS_WIN_H
|
||||
#define SQLITE_OS_WIN_H
|
||||
|
||||
/*
|
||||
** Include the primary Windows SDK header file.
|
||||
*/
|
||||
#include "windows.h"
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#include <errno.h> /* amalgamator: dontcache */
|
||||
#include <sys/cygwin.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Determine if we are dealing with Windows NT.
|
||||
**
|
||||
** We ought to be able to determine if we are compiling for Windows 9x or
|
||||
** Windows NT using the _WIN32_WINNT macro as follows:
|
||||
**
|
||||
** #if defined(_WIN32_WINNT)
|
||||
** # define SQLITE_OS_WINNT 1
|
||||
** #else
|
||||
** # define SQLITE_OS_WINNT 0
|
||||
** #endif
|
||||
**
|
||||
** However, Visual Studio 2005 does not set _WIN32_WINNT by default, as
|
||||
** it ought to, so the above test does not work. We'll just assume that
|
||||
** everything is Windows NT unless the programmer explicitly says otherwise
|
||||
** by setting SQLITE_OS_WINNT to 0.
|
||||
*/
|
||||
#if SQLITE_OS_WIN && !defined(SQLITE_OS_WINNT)
|
||||
#define SQLITE_OS_WINNT 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Determine if we are dealing with Windows CE - which has a much reduced
|
||||
** API.
|
||||
*/
|
||||
#if defined(_WIN32_WCE)
|
||||
#define SQLITE_OS_WINCE 1
|
||||
#else
|
||||
#define SQLITE_OS_WINCE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Determine if we are dealing with WinRT, which provides only a subset of
|
||||
** the full Win32 API.
|
||||
*/
|
||||
#if !defined(SQLITE_OS_WINRT)
|
||||
#define SQLITE_OS_WINRT 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** For WinCE, some API function parameters do not appear to be declared as
|
||||
** volatile.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE
|
||||
#define SQLITE_WIN32_VOLATILE
|
||||
#else
|
||||
#define SQLITE_WIN32_VOLATILE volatile
|
||||
#endif
|
||||
|
||||
/*
|
||||
** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()
|
||||
** functions are not available (e.g. those not using MSVC, Cygwin, etc).
|
||||
*/
|
||||
#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
|
||||
SQLITE_THREADSAFE > 0 && !defined(__CYGWIN__)
|
||||
#define SQLITE_OS_WIN_THREADS 1
|
||||
#else
|
||||
#define SQLITE_OS_WIN_THREADS 0
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_OS_WIN_H */
|
235
third_party/sqlite3/headers/pager.h
vendored
Normal file
235
third_party/sqlite3/headers/pager.h
vendored
Normal file
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
** 2001 September 15
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the interface that the sqlite page cache
|
||||
** subsystem. The page cache subsystem reads and writes a file a page
|
||||
** at a time and provides a journal for rollback.
|
||||
*/
|
||||
|
||||
#ifndef SQLITE_PAGER_H
|
||||
#define SQLITE_PAGER_H
|
||||
|
||||
/*
|
||||
** Default maximum size for persistent journal files. A negative
|
||||
** value means no limit. This value may be overridden using the
|
||||
** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
|
||||
*/
|
||||
#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
|
||||
#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The type used to represent a page number. The first page in a file
|
||||
** is called page 1. 0 is used to represent "not a page".
|
||||
*/
|
||||
typedef u32 Pgno;
|
||||
|
||||
/*
|
||||
** Each open file is managed by a separate instance of the "Pager" structure.
|
||||
*/
|
||||
typedef struct Pager Pager;
|
||||
|
||||
/*
|
||||
** Handle type for pages.
|
||||
*/
|
||||
typedef struct PgHdr DbPage;
|
||||
|
||||
/*
|
||||
** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
|
||||
** reserved for working around a windows/posix incompatibility). It is
|
||||
** used in the journal to signify that the remainder of the journal file
|
||||
** is devoted to storing a super-journal name - there are no more pages to
|
||||
** roll back. See comments for function writeSuperJournal() in pager.c
|
||||
** for details.
|
||||
*/
|
||||
#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE / ((x)->pageSize)) + 1))
|
||||
|
||||
/*
|
||||
** Allowed values for the flags parameter to sqlite3PagerOpen().
|
||||
**
|
||||
** NOTE: These values must match the corresponding BTREE_ values in btree.h.
|
||||
*/
|
||||
#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */
|
||||
#define PAGER_MEMORY 0x0002 /* In-memory database */
|
||||
|
||||
/*
|
||||
** Valid values for the second argument to sqlite3PagerLockingMode().
|
||||
*/
|
||||
#define PAGER_LOCKINGMODE_QUERY -1
|
||||
#define PAGER_LOCKINGMODE_NORMAL 0
|
||||
#define PAGER_LOCKINGMODE_EXCLUSIVE 1
|
||||
|
||||
/*
|
||||
** Numeric constants that encode the journalmode.
|
||||
**
|
||||
** The numeric values encoded here (other than PAGER_JOURNALMODE_QUERY)
|
||||
** are exposed in the API via the "PRAGMA journal_mode" command and
|
||||
** therefore cannot be changed without a compatibility break.
|
||||
*/
|
||||
#define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */
|
||||
#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */
|
||||
#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */
|
||||
#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */
|
||||
#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */
|
||||
#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
|
||||
#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */
|
||||
|
||||
/*
|
||||
** Flags that make up the mask passed to sqlite3PagerGet().
|
||||
*/
|
||||
#define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */
|
||||
#define PAGER_GET_READONLY 0x02 /* Read-only page is acceptable */
|
||||
|
||||
/*
|
||||
** Flags for sqlite3PagerSetFlags()
|
||||
**
|
||||
** Value constraints (enforced via assert()):
|
||||
** PAGER_FULLFSYNC == SQLITE_FullFSync
|
||||
** PAGER_CKPT_FULLFSYNC == SQLITE_CkptFullFSync
|
||||
** PAGER_CACHE_SPILL == SQLITE_CacheSpill
|
||||
*/
|
||||
#define PAGER_SYNCHRONOUS_OFF 0x01 /* PRAGMA synchronous=OFF */
|
||||
#define PAGER_SYNCHRONOUS_NORMAL 0x02 /* PRAGMA synchronous=NORMAL */
|
||||
#define PAGER_SYNCHRONOUS_FULL 0x03 /* PRAGMA synchronous=FULL */
|
||||
#define PAGER_SYNCHRONOUS_EXTRA 0x04 /* PRAGMA synchronous=EXTRA */
|
||||
#define PAGER_SYNCHRONOUS_MASK 0x07 /* Mask for four values above */
|
||||
#define PAGER_FULLFSYNC 0x08 /* PRAGMA fullfsync=ON */
|
||||
#define PAGER_CKPT_FULLFSYNC 0x10 /* PRAGMA checkpoint_fullfsync=ON */
|
||||
#define PAGER_CACHESPILL 0x20 /* PRAGMA cache_spill=ON */
|
||||
#define PAGER_FLAGS_MASK 0x38 /* All above except SYNCHRONOUS */
|
||||
|
||||
/*
|
||||
** The remainder of this file contains the declarations of the functions
|
||||
** that make up the Pager sub-system API. See source code comments for
|
||||
** a detailed description of each routine.
|
||||
*/
|
||||
|
||||
/* Open and close a Pager connection. */
|
||||
int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char *, int, int,
|
||||
int, void (*)(DbPage *));
|
||||
int sqlite3PagerClose(Pager *pPager, sqlite3 *);
|
||||
int sqlite3PagerReadFileheader(Pager *, int, unsigned char *);
|
||||
|
||||
/* Functions used to configure a Pager object. */
|
||||
void sqlite3PagerSetBusyHandler(Pager *, int (*)(void *), void *);
|
||||
int sqlite3PagerSetPagesize(Pager *, u32 *, int);
|
||||
Pgno sqlite3PagerMaxPageCount(Pager *, Pgno);
|
||||
void sqlite3PagerSetCachesize(Pager *, int);
|
||||
int sqlite3PagerSetSpillsize(Pager *, int);
|
||||
void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);
|
||||
void sqlite3PagerShrink(Pager *);
|
||||
void sqlite3PagerSetFlags(Pager *, unsigned);
|
||||
int sqlite3PagerLockingMode(Pager *, int);
|
||||
int sqlite3PagerSetJournalMode(Pager *, int);
|
||||
int sqlite3PagerGetJournalMode(Pager *);
|
||||
int sqlite3PagerOkToChangeJournalMode(Pager *);
|
||||
i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
|
||||
sqlite3_backup **sqlite3PagerBackupPtr(Pager *);
|
||||
int sqlite3PagerFlush(Pager *);
|
||||
|
||||
/* Functions used to obtain and release page references. */
|
||||
int sqlite3PagerGet(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
|
||||
DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
|
||||
void sqlite3PagerRef(DbPage *);
|
||||
void sqlite3PagerUnref(DbPage *);
|
||||
void sqlite3PagerUnrefNotNull(DbPage *);
|
||||
void sqlite3PagerUnrefPageOne(DbPage *);
|
||||
|
||||
/* Operations on page references. */
|
||||
int sqlite3PagerWrite(DbPage *);
|
||||
void sqlite3PagerDontWrite(DbPage *);
|
||||
int sqlite3PagerMovepage(Pager *, DbPage *, Pgno, int);
|
||||
int sqlite3PagerPageRefcount(DbPage *);
|
||||
void *sqlite3PagerGetData(DbPage *);
|
||||
void *sqlite3PagerGetExtra(DbPage *);
|
||||
|
||||
/* Functions used to manage pager transactions and savepoints. */
|
||||
void sqlite3PagerPagecount(Pager *, int *);
|
||||
int sqlite3PagerBegin(Pager *, int exFlag, int);
|
||||
int sqlite3PagerCommitPhaseOne(Pager *, const char *zSuper, int);
|
||||
int sqlite3PagerExclusiveLock(Pager *);
|
||||
int sqlite3PagerSync(Pager *pPager, const char *zSuper);
|
||||
int sqlite3PagerCommitPhaseTwo(Pager *);
|
||||
int sqlite3PagerRollback(Pager *);
|
||||
int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
|
||||
int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
|
||||
int sqlite3PagerSharedLock(Pager *pPager);
|
||||
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
int sqlite3PagerCheckpoint(Pager *pPager, sqlite3 *, int, int *, int *);
|
||||
int sqlite3PagerWalSupported(Pager *pPager);
|
||||
int sqlite3PagerWalCallback(Pager *pPager);
|
||||
int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
|
||||
int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *);
|
||||
#ifdef SQLITE_ENABLE_SNAPSHOT
|
||||
int sqlite3PagerSnapshotGet(Pager *, sqlite3_snapshot **ppSnapshot);
|
||||
int sqlite3PagerSnapshotOpen(Pager *, sqlite3_snapshot *pSnapshot);
|
||||
int sqlite3PagerSnapshotRecover(Pager *pPager);
|
||||
int sqlite3PagerSnapshotCheck(Pager *pPager, sqlite3_snapshot *pSnapshot);
|
||||
void sqlite3PagerSnapshotUnlock(Pager *pPager);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(SQLITE_OMIT_WAL) && defined(SQLITE_ENABLE_SETLK_TIMEOUT)
|
||||
int sqlite3PagerWalWriteLock(Pager *, int);
|
||||
void sqlite3PagerWalDb(Pager *, sqlite3 *);
|
||||
#else
|
||||
#define sqlite3PagerWalWriteLock(y, z) SQLITE_OK
|
||||
#define sqlite3PagerWalDb(x, y)
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
||||
int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_ENABLE_ZIPVFS
|
||||
int sqlite3PagerWalFramesize(Pager *pPager);
|
||||
#endif
|
||||
|
||||
/* Functions used to query pager state and configuration. */
|
||||
u8 sqlite3PagerIsreadonly(Pager *);
|
||||
u32 sqlite3PagerDataVersion(Pager *);
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3PagerRefcount(Pager *);
|
||||
#endif
|
||||
int sqlite3PagerMemUsed(Pager *);
|
||||
const char *sqlite3PagerFilename(const Pager *, int);
|
||||
sqlite3_vfs *sqlite3PagerVfs(Pager *);
|
||||
sqlite3_file *sqlite3PagerFile(Pager *);
|
||||
sqlite3_file *sqlite3PagerJrnlFile(Pager *);
|
||||
const char *sqlite3PagerJournalname(Pager *);
|
||||
void *sqlite3PagerTempSpace(Pager *);
|
||||
int sqlite3PagerIsMemdb(Pager *);
|
||||
void sqlite3PagerCacheStat(Pager *, int, int, int *);
|
||||
void sqlite3PagerClearCache(Pager *);
|
||||
int sqlite3SectorSize(sqlite3_file *);
|
||||
|
||||
/* Functions used to truncate the database file. */
|
||||
void sqlite3PagerTruncateImage(Pager *, Pgno);
|
||||
|
||||
void sqlite3PagerRekey(DbPage *, Pgno, u16);
|
||||
|
||||
/* Functions to support testing and debugging. */
|
||||
#if !defined(NDEBUG) || defined(SQLITE_TEST)
|
||||
Pgno sqlite3PagerPagenumber(DbPage *);
|
||||
int sqlite3PagerIswriteable(DbPage *);
|
||||
#endif
|
||||
#ifdef SQLITE_TEST
|
||||
int *sqlite3PagerStats(Pager *);
|
||||
void sqlite3PagerRefdump(Pager *);
|
||||
void disable_simulated_io_errors(void);
|
||||
void enable_simulated_io_errors(void);
|
||||
#else
|
||||
#define disable_simulated_io_errors()
|
||||
#define enable_simulated_io_errors()
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_PAGER_H */
|
182
third_party/sqlite3/headers/parse.h
vendored
Normal file
182
third_party/sqlite3/headers/parse.h
vendored
Normal file
|
@ -0,0 +1,182 @@
|
|||
#define TK_SEMI 1
|
||||
#define TK_EXPLAIN 2
|
||||
#define TK_QUERY 3
|
||||
#define TK_PLAN 4
|
||||
#define TK_BEGIN 5
|
||||
#define TK_TRANSACTION 6
|
||||
#define TK_DEFERRED 7
|
||||
#define TK_IMMEDIATE 8
|
||||
#define TK_EXCLUSIVE 9
|
||||
#define TK_COMMIT 10
|
||||
#define TK_END 11
|
||||
#define TK_ROLLBACK 12
|
||||
#define TK_SAVEPOINT 13
|
||||
#define TK_RELEASE 14
|
||||
#define TK_TO 15
|
||||
#define TK_TABLE 16
|
||||
#define TK_CREATE 17
|
||||
#define TK_IF 18
|
||||
#define TK_NOT 19
|
||||
#define TK_EXISTS 20
|
||||
#define TK_TEMP 21
|
||||
#define TK_LP 22
|
||||
#define TK_RP 23
|
||||
#define TK_AS 24
|
||||
#define TK_WITHOUT 25
|
||||
#define TK_COMMA 26
|
||||
#define TK_ABORT 27
|
||||
#define TK_ACTION 28
|
||||
#define TK_AFTER 29
|
||||
#define TK_ANALYZE 30
|
||||
#define TK_ASC 31
|
||||
#define TK_ATTACH 32
|
||||
#define TK_BEFORE 33
|
||||
#define TK_BY 34
|
||||
#define TK_CASCADE 35
|
||||
#define TK_CAST 36
|
||||
#define TK_CONFLICT 37
|
||||
#define TK_DATABASE 38
|
||||
#define TK_DESC 39
|
||||
#define TK_DETACH 40
|
||||
#define TK_EACH 41
|
||||
#define TK_FAIL 42
|
||||
#define TK_OR 43
|
||||
#define TK_AND 44
|
||||
#define TK_IS 45
|
||||
#define TK_MATCH 46
|
||||
#define TK_LIKE_KW 47
|
||||
#define TK_BETWEEN 48
|
||||
#define TK_IN 49
|
||||
#define TK_ISNULL 50
|
||||
#define TK_NOTNULL 51
|
||||
#define TK_NE 52
|
||||
#define TK_EQ 53
|
||||
#define TK_GT 54
|
||||
#define TK_LE 55
|
||||
#define TK_LT 56
|
||||
#define TK_GE 57
|
||||
#define TK_ESCAPE 58
|
||||
#define TK_ID 59
|
||||
#define TK_COLUMNKW 60
|
||||
#define TK_DO 61
|
||||
#define TK_FOR 62
|
||||
#define TK_IGNORE 63
|
||||
#define TK_INITIALLY 64
|
||||
#define TK_INSTEAD 65
|
||||
#define TK_NO 66
|
||||
#define TK_KEY 67
|
||||
#define TK_OF 68
|
||||
#define TK_OFFSET 69
|
||||
#define TK_PRAGMA 70
|
||||
#define TK_RAISE 71
|
||||
#define TK_RECURSIVE 72
|
||||
#define TK_REPLACE 73
|
||||
#define TK_RESTRICT 74
|
||||
#define TK_ROW 75
|
||||
#define TK_ROWS 76
|
||||
#define TK_TRIGGER 77
|
||||
#define TK_VACUUM 78
|
||||
#define TK_VIEW 79
|
||||
#define TK_VIRTUAL 80
|
||||
#define TK_WITH 81
|
||||
#define TK_NULLS 82
|
||||
#define TK_FIRST 83
|
||||
#define TK_LAST 84
|
||||
#define TK_CURRENT 85
|
||||
#define TK_FOLLOWING 86
|
||||
#define TK_PARTITION 87
|
||||
#define TK_PRECEDING 88
|
||||
#define TK_RANGE 89
|
||||
#define TK_UNBOUNDED 90
|
||||
#define TK_EXCLUDE 91
|
||||
#define TK_GROUPS 92
|
||||
#define TK_OTHERS 93
|
||||
#define TK_TIES 94
|
||||
#define TK_GENERATED 95
|
||||
#define TK_ALWAYS 96
|
||||
#define TK_MATERIALIZED 97
|
||||
#define TK_REINDEX 98
|
||||
#define TK_RENAME 99
|
||||
#define TK_CTIME_KW 100
|
||||
#define TK_ANY 101
|
||||
#define TK_BITAND 102
|
||||
#define TK_BITOR 103
|
||||
#define TK_LSHIFT 104
|
||||
#define TK_RSHIFT 105
|
||||
#define TK_PLUS 106
|
||||
#define TK_MINUS 107
|
||||
#define TK_STAR 108
|
||||
#define TK_SLASH 109
|
||||
#define TK_REM 110
|
||||
#define TK_CONCAT 111
|
||||
#define TK_COLLATE 112
|
||||
#define TK_BITNOT 113
|
||||
#define TK_ON 114
|
||||
#define TK_INDEXED 115
|
||||
#define TK_STRING 116
|
||||
#define TK_JOIN_KW 117
|
||||
#define TK_CONSTRAINT 118
|
||||
#define TK_DEFAULT 119
|
||||
#define TK_NULL 120
|
||||
#define TK_PRIMARY 121
|
||||
#define TK_UNIQUE 122
|
||||
#define TK_CHECK 123
|
||||
#define TK_REFERENCES 124
|
||||
#define TK_AUTOINCR 125
|
||||
#define TK_INSERT 126
|
||||
#define TK_DELETE 127
|
||||
#define TK_UPDATE 128
|
||||
#define TK_SET 129
|
||||
#define TK_DEFERRABLE 130
|
||||
#define TK_FOREIGN 131
|
||||
#define TK_DROP 132
|
||||
#define TK_UNION 133
|
||||
#define TK_ALL 134
|
||||
#define TK_EXCEPT 135
|
||||
#define TK_INTERSECT 136
|
||||
#define TK_SELECT 137
|
||||
#define TK_VALUES 138
|
||||
#define TK_DISTINCT 139
|
||||
#define TK_DOT 140
|
||||
#define TK_FROM 141
|
||||
#define TK_JOIN 142
|
||||
#define TK_USING 143
|
||||
#define TK_ORDER 144
|
||||
#define TK_GROUP 145
|
||||
#define TK_HAVING 146
|
||||
#define TK_LIMIT 147
|
||||
#define TK_WHERE 148
|
||||
#define TK_RETURNING 149
|
||||
#define TK_INTO 150
|
||||
#define TK_NOTHING 151
|
||||
#define TK_FLOAT 152
|
||||
#define TK_BLOB 153
|
||||
#define TK_INTEGER 154
|
||||
#define TK_VARIABLE 155
|
||||
#define TK_CASE 156
|
||||
#define TK_WHEN 157
|
||||
#define TK_THEN 158
|
||||
#define TK_ELSE 159
|
||||
#define TK_INDEX 160
|
||||
#define TK_ALTER 161
|
||||
#define TK_ADD 162
|
||||
#define TK_WINDOW 163
|
||||
#define TK_OVER 164
|
||||
#define TK_FILTER 165
|
||||
#define TK_COLUMN 166
|
||||
#define TK_AGG_FUNCTION 167
|
||||
#define TK_AGG_COLUMN 168
|
||||
#define TK_TRUEFALSE 169
|
||||
#define TK_ISNOT 170
|
||||
#define TK_FUNCTION 171
|
||||
#define TK_UMINUS 172
|
||||
#define TK_UPLUS 173
|
||||
#define TK_TRUTH 174
|
||||
#define TK_REGISTER 175
|
||||
#define TK_VECTOR 176
|
||||
#define TK_SELECT_COLUMN 177
|
||||
#define TK_IF_NULL_ROW 178
|
||||
#define TK_ASTERISK 179
|
||||
#define TK_SPAN 180
|
||||
#define TK_SPACE 181
|
||||
#define TK_ILLEGAL 182
|
191
third_party/sqlite3/headers/pcache.h
vendored
Normal file
191
third_party/sqlite3/headers/pcache.h
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
** 2008 August 05
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the interface that the sqlite page cache
|
||||
** subsystem.
|
||||
*/
|
||||
|
||||
#ifndef _PCACHE_H_
|
||||
|
||||
typedef struct PgHdr PgHdr;
|
||||
typedef struct PCache PCache;
|
||||
|
||||
/*
|
||||
** Every page in the cache is controlled by an instance of the following
|
||||
** structure.
|
||||
*/
|
||||
struct PgHdr {
|
||||
sqlite3_pcache_page *pPage; /* Pcache object page handle */
|
||||
void *pData; /* Page data */
|
||||
void *pExtra; /* Extra content */
|
||||
PCache *pCache; /* PRIVATE: Cache that owns this page */
|
||||
PgHdr *pDirty; /* Transient list of dirty sorted by pgno */
|
||||
Pager *pPager; /* The pager this page is part of */
|
||||
Pgno pgno; /* Page number for this page */
|
||||
#ifdef SQLITE_CHECK_PAGES
|
||||
u32 pageHash; /* Hash of page content */
|
||||
#endif
|
||||
u16 flags; /* PGHDR flags defined below */
|
||||
|
||||
/**********************************************************************
|
||||
** Elements above, except pCache, are public. All that follow are
|
||||
** private to pcache.c and should not be accessed by other modules.
|
||||
** pCache is grouped with the public elements for efficiency.
|
||||
*/
|
||||
i16 nRef; /* Number of users of this page */
|
||||
PgHdr *pDirtyNext; /* Next element in list of dirty pages */
|
||||
PgHdr *pDirtyPrev; /* Previous element in list of dirty pages */
|
||||
/* NB: pDirtyNext and pDirtyPrev are undefined if the
|
||||
** PgHdr object is not dirty */
|
||||
};
|
||||
|
||||
/* Bit values for PgHdr.flags */
|
||||
#define PGHDR_CLEAN 0x001 /* Page not on the PCache.pDirty list */
|
||||
#define PGHDR_DIRTY 0x002 /* Page is on the PCache.pDirty list */
|
||||
#define PGHDR_WRITEABLE 0x004 /* Journaled and ready to modify */
|
||||
#define PGHDR_NEED_SYNC \
|
||||
0x008 /* Fsync the rollback journal before \
|
||||
** writing this page to the database */
|
||||
#define PGHDR_DONT_WRITE 0x010 /* Do not write content to disk */
|
||||
#define PGHDR_MMAP 0x020 /* This is an mmap page object */
|
||||
|
||||
#define PGHDR_WAL_APPEND 0x040 /* Appended to wal file */
|
||||
|
||||
/* Initialize and shutdown the page cache subsystem */
|
||||
int sqlite3PcacheInitialize(void);
|
||||
void sqlite3PcacheShutdown(void);
|
||||
|
||||
/* Page cache buffer management:
|
||||
** These routines implement SQLITE_CONFIG_PAGECACHE.
|
||||
*/
|
||||
void sqlite3PCacheBufferSetup(void *, int sz, int n);
|
||||
|
||||
/* Create a new pager cache.
|
||||
** Under memory stress, invoke xStress to try to make pages clean.
|
||||
** Only clean and unpinned pages can be reclaimed.
|
||||
*/
|
||||
int sqlite3PcacheOpen(
|
||||
int szPage, /* Size of every page */
|
||||
int szExtra, /* Extra space associated with each page */
|
||||
int bPurgeable, /* True if pages are on backing store */
|
||||
int (*xStress)(void *, PgHdr *), /* Call to try to make pages clean */
|
||||
void *pStress, /* Argument to xStress */
|
||||
PCache *pToInit /* Preallocated space for the PCache */
|
||||
);
|
||||
|
||||
/* Modify the page-size after the cache has been created. */
|
||||
int sqlite3PcacheSetPageSize(PCache *, int);
|
||||
|
||||
/* Return the size in bytes of a PCache object. Used to preallocate
|
||||
** storage space.
|
||||
*/
|
||||
int sqlite3PcacheSize(void);
|
||||
|
||||
/* One release per successful fetch. Page is pinned until released.
|
||||
** Reference counted.
|
||||
*/
|
||||
sqlite3_pcache_page *sqlite3PcacheFetch(PCache *, Pgno, int createFlag);
|
||||
int sqlite3PcacheFetchStress(PCache *, Pgno, sqlite3_pcache_page **);
|
||||
PgHdr *sqlite3PcacheFetchFinish(PCache *, Pgno, sqlite3_pcache_page *pPage);
|
||||
void sqlite3PcacheRelease(PgHdr *);
|
||||
|
||||
void sqlite3PcacheDrop(PgHdr *); /* Remove page from cache */
|
||||
void sqlite3PcacheMakeDirty(PgHdr *); /* Make sure page is marked dirty */
|
||||
void sqlite3PcacheMakeClean(PgHdr *); /* Mark a single page as clean */
|
||||
void sqlite3PcacheCleanAll(PCache *); /* Mark all dirty list pages as clean */
|
||||
void sqlite3PcacheClearWritable(PCache *);
|
||||
|
||||
/* Change a page number. Used by incr-vacuum. */
|
||||
void sqlite3PcacheMove(PgHdr *, Pgno);
|
||||
|
||||
/* Remove all pages with pgno>x. Reset the cache if x==0 */
|
||||
void sqlite3PcacheTruncate(PCache *, Pgno x);
|
||||
|
||||
/* Get a list of all dirty pages in the cache, sorted by page number */
|
||||
PgHdr *sqlite3PcacheDirtyList(PCache *);
|
||||
|
||||
/* Reset and close the cache object */
|
||||
void sqlite3PcacheClose(PCache *);
|
||||
|
||||
/* Clear flags from pages of the page cache */
|
||||
void sqlite3PcacheClearSyncFlags(PCache *);
|
||||
|
||||
/* Discard the contents of the cache */
|
||||
void sqlite3PcacheClear(PCache *);
|
||||
|
||||
/* Return the total number of outstanding page references */
|
||||
int sqlite3PcacheRefCount(PCache *);
|
||||
|
||||
/* Increment the reference count of an existing page */
|
||||
void sqlite3PcacheRef(PgHdr *);
|
||||
|
||||
int sqlite3PcachePageRefcount(PgHdr *);
|
||||
|
||||
/* Return the total number of pages stored in the cache */
|
||||
int sqlite3PcachePagecount(PCache *);
|
||||
|
||||
#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)
|
||||
/* Iterate through all dirty pages currently stored in the cache. This
|
||||
** interface is only available if SQLITE_CHECK_PAGES is defined when the
|
||||
** library is built.
|
||||
*/
|
||||
void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *));
|
||||
#endif
|
||||
|
||||
#if defined(SQLITE_DEBUG)
|
||||
/* Check invariants on a PgHdr object */
|
||||
int sqlite3PcachePageSanity(PgHdr *);
|
||||
#endif
|
||||
|
||||
/* Set and get the suggested cache-size for the specified pager-cache.
|
||||
**
|
||||
** If no global maximum is configured, then the system attempts to limit
|
||||
** the total number of pages cached by purgeable pager-caches to the sum
|
||||
** of the suggested cache-sizes.
|
||||
*/
|
||||
void sqlite3PcacheSetCachesize(PCache *, int);
|
||||
#ifdef SQLITE_TEST
|
||||
int sqlite3PcacheGetCachesize(PCache *);
|
||||
#endif
|
||||
|
||||
/* Set or get the suggested spill-size for the specified pager-cache.
|
||||
**
|
||||
** The spill-size is the minimum number of pages in cache before the cache
|
||||
** will attempt to spill dirty pages by calling xStress.
|
||||
*/
|
||||
int sqlite3PcacheSetSpillsize(PCache *, int);
|
||||
|
||||
/* Free up as much memory as possible from the page cache */
|
||||
void sqlite3PcacheShrink(PCache *);
|
||||
|
||||
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
|
||||
/* Try to return memory used by the pcache module to the main memory heap */
|
||||
int sqlite3PcacheReleaseMemory(int);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_TEST
|
||||
void sqlite3PcacheStats(int *, int *, int *, int *);
|
||||
#endif
|
||||
|
||||
void sqlite3PCacheSetDefault(void);
|
||||
|
||||
/* Return the header size */
|
||||
int sqlite3HeaderSizePcache(void);
|
||||
int sqlite3HeaderSizePcache1(void);
|
||||
|
||||
/* Number of dirty pages as a percentage of the configured cache size */
|
||||
int sqlite3PCachePercentDirty(PCache *);
|
||||
|
||||
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
||||
int sqlite3PCacheIsDirty(PCache *pCache);
|
||||
#endif
|
||||
|
||||
#endif /* _PCACHE_H_ */
|
653
third_party/sqlite3/headers/pragma.h
vendored
Normal file
653
third_party/sqlite3/headers/pragma.h
vendored
Normal file
|
@ -0,0 +1,653 @@
|
|||
/* DO NOT EDIT!
|
||||
** This file is automatically generated by the script at
|
||||
** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit
|
||||
** that script and rerun it.
|
||||
*/
|
||||
|
||||
/* The various pragma types */
|
||||
#define PragTyp_ACTIVATE_EXTENSIONS 0
|
||||
#define PragTyp_ANALYSIS_LIMIT 1
|
||||
#define PragTyp_HEADER_VALUE 2
|
||||
#define PragTyp_AUTO_VACUUM 3
|
||||
#define PragTyp_FLAG 4
|
||||
#define PragTyp_BUSY_TIMEOUT 5
|
||||
#define PragTyp_CACHE_SIZE 6
|
||||
#define PragTyp_CACHE_SPILL 7
|
||||
#define PragTyp_CASE_SENSITIVE_LIKE 8
|
||||
#define PragTyp_COLLATION_LIST 9
|
||||
#define PragTyp_COMPILE_OPTIONS 10
|
||||
#define PragTyp_DATA_STORE_DIRECTORY 11
|
||||
#define PragTyp_DATABASE_LIST 12
|
||||
#define PragTyp_DEFAULT_CACHE_SIZE 13
|
||||
#define PragTyp_ENCODING 14
|
||||
#define PragTyp_FOREIGN_KEY_CHECK 15
|
||||
#define PragTyp_FOREIGN_KEY_LIST 16
|
||||
#define PragTyp_FUNCTION_LIST 17
|
||||
#define PragTyp_HARD_HEAP_LIMIT 18
|
||||
#define PragTyp_INCREMENTAL_VACUUM 19
|
||||
#define PragTyp_INDEX_INFO 20
|
||||
#define PragTyp_INDEX_LIST 21
|
||||
#define PragTyp_INTEGRITY_CHECK 22
|
||||
#define PragTyp_JOURNAL_MODE 23
|
||||
#define PragTyp_JOURNAL_SIZE_LIMIT 24
|
||||
#define PragTyp_LOCK_PROXY_FILE 25
|
||||
#define PragTyp_LOCKING_MODE 26
|
||||
#define PragTyp_PAGE_COUNT 27
|
||||
#define PragTyp_MMAP_SIZE 28
|
||||
#define PragTyp_MODULE_LIST 29
|
||||
#define PragTyp_OPTIMIZE 30
|
||||
#define PragTyp_PAGE_SIZE 31
|
||||
#define PragTyp_PRAGMA_LIST 32
|
||||
#define PragTyp_SECURE_DELETE 33
|
||||
#define PragTyp_SHRINK_MEMORY 34
|
||||
#define PragTyp_SOFT_HEAP_LIMIT 35
|
||||
#define PragTyp_SYNCHRONOUS 36
|
||||
#define PragTyp_TABLE_INFO 37
|
||||
#define PragTyp_TEMP_STORE 38
|
||||
#define PragTyp_TEMP_STORE_DIRECTORY 39
|
||||
#define PragTyp_THREADS 40
|
||||
#define PragTyp_WAL_AUTOCHECKPOINT 41
|
||||
#define PragTyp_WAL_CHECKPOINT 42
|
||||
#define PragTyp_LOCK_STATUS 43
|
||||
#define PragTyp_STATS 44
|
||||
|
||||
/* Property flags associated with various pragma. */
|
||||
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
|
||||
#define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
|
||||
#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
|
||||
#define PragFlg_ReadOnly 0x08 /* Read-only HEADER_VALUE */
|
||||
#define PragFlg_Result0 0x10 /* Acts as query when no argument */
|
||||
#define PragFlg_Result1 0x20 /* Acts as query when has one argument */
|
||||
#define PragFlg_SchemaOpt 0x40 /* Schema restricts name search if present */
|
||||
#define PragFlg_SchemaReq 0x80 /* Schema required - "main" is default */
|
||||
|
||||
/* Names of columns for pragmas that return multi-column result
|
||||
** or that return single-column results where the name of the
|
||||
** result column is different from the name of the pragma
|
||||
*/
|
||||
static const char *const pragCName[] = {
|
||||
/* 0 */ "id", /* Used by: foreign_key_list */
|
||||
/* 1 */ "seq",
|
||||
/* 2 */ "table",
|
||||
/* 3 */ "from",
|
||||
/* 4 */ "to",
|
||||
/* 5 */ "on_update",
|
||||
/* 6 */ "on_delete",
|
||||
/* 7 */ "match",
|
||||
/* 8 */ "cid", /* Used by: table_xinfo */
|
||||
/* 9 */ "name",
|
||||
/* 10 */ "type",
|
||||
/* 11 */ "notnull",
|
||||
/* 12 */ "dflt_value",
|
||||
/* 13 */ "pk",
|
||||
/* 14 */ "hidden",
|
||||
/* table_info reuses 8 */
|
||||
/* 15 */ "seqno", /* Used by: index_xinfo */
|
||||
/* 16 */ "cid",
|
||||
/* 17 */ "name",
|
||||
/* 18 */ "desc",
|
||||
/* 19 */ "coll",
|
||||
/* 20 */ "key",
|
||||
/* 21 */ "name", /* Used by: function_list */
|
||||
/* 22 */ "builtin",
|
||||
/* 23 */ "type",
|
||||
/* 24 */ "enc",
|
||||
/* 25 */ "narg",
|
||||
/* 26 */ "flags",
|
||||
/* 27 */ "tbl", /* Used by: stats */
|
||||
/* 28 */ "idx",
|
||||
/* 29 */ "wdth",
|
||||
/* 30 */ "hght",
|
||||
/* 31 */ "flgs",
|
||||
/* 32 */ "seq", /* Used by: index_list */
|
||||
/* 33 */ "name",
|
||||
/* 34 */ "unique",
|
||||
/* 35 */ "origin",
|
||||
/* 36 */ "partial",
|
||||
/* 37 */ "table", /* Used by: foreign_key_check */
|
||||
/* 38 */ "rowid",
|
||||
/* 39 */ "parent",
|
||||
/* 40 */ "fkid",
|
||||
/* index_info reuses 15 */
|
||||
/* 41 */ "seq", /* Used by: database_list */
|
||||
/* 42 */ "name",
|
||||
/* 43 */ "file",
|
||||
/* 44 */ "busy", /* Used by: wal_checkpoint */
|
||||
/* 45 */ "log",
|
||||
/* 46 */ "checkpointed",
|
||||
/* collation_list reuses 32 */
|
||||
/* 47 */ "database", /* Used by: lock_status */
|
||||
/* 48 */ "status",
|
||||
/* 49 */ "cache_size", /* Used by: default_cache_size */
|
||||
/* module_list pragma_list reuses 9 */
|
||||
/* 50 */ "timeout", /* Used by: busy_timeout */
|
||||
};
|
||||
|
||||
/* Definitions of all built-in pragmas */
|
||||
typedef struct PragmaName {
|
||||
const char *const zName; /* Name of pragma */
|
||||
u8 ePragTyp; /* PragTyp_XXX value */
|
||||
u8 mPragFlg; /* Zero or more PragFlg_XXX values */
|
||||
u8 iPragCName; /* Start of column names in pragCName[] */
|
||||
u8 nPragCName; /* Num of col names. 0 means use pragma name */
|
||||
u64 iArg; /* Extra argument */
|
||||
} PragmaName;
|
||||
static const PragmaName aPragmaName[] = {
|
||||
#if defined(SQLITE_ENABLE_CEROD)
|
||||
{/* zName: */ "activate_extensions",
|
||||
/* ePragTyp: */ PragTyp_ACTIVATE_EXTENSIONS,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
{/* zName: */ "analysis_limit",
|
||||
/* ePragTyp: */ PragTyp_ANALYSIS_LIMIT,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "application_id",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1 | PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_APPLICATION_ID},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_AUTOVACUUM)
|
||||
{/* zName: */ "auto_vacuum",
|
||||
/* ePragTyp: */ PragTyp_AUTO_VACUUM,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq |
|
||||
PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
|
||||
{/* zName: */ "automatic_index",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_AutoIndex},
|
||||
#endif
|
||||
#endif
|
||||
{/* zName: */ "busy_timeout",
|
||||
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 50, 1,
|
||||
/* iArg: */ 0},
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "cache_size",
|
||||
/* ePragTyp: */ PragTyp_CACHE_SIZE,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq |
|
||||
PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "cache_spill",
|
||||
/* ePragTyp: */ PragTyp_CACHE_SPILL,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_CASE_SENSITIVE_LIKE_PRAGMA)
|
||||
{/* zName: */ "case_sensitive_like",
|
||||
/* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE,
|
||||
/* ePragFlg: */ PragFlg_NoColumns,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
{/* zName: */ "cell_size_check",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_CellSizeCk},
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "checkpoint_fullfsync",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_CkptFullFSync},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
{/* zName: */ "collation_list",
|
||||
/* ePragTyp: */ PragTyp_COLLATION_LIST,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 32, 2,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
|
||||
{/* zName: */ "compile_options",
|
||||
/* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "count_changes",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_CountRows},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
|
||||
{/* zName: */ "data_store_directory",
|
||||
/* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "data_version",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_ReadOnly | PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_DATA_VERSION},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
{/* zName: */ "database_list",
|
||||
/* ePragTyp: */ PragTyp_DATABASE_LIST,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0,
|
||||
/* ColNames: */ 41, 3,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
|
||||
{/* zName: */ "default_cache_size",
|
||||
/* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq |
|
||||
PragFlg_NoColumns1,
|
||||
/* ColNames: */ 49, 1,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
|
||||
{/* zName: */ "defer_foreign_keys",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_DeferFKs},
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "empty_result_callbacks",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_NullCallback},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_UTF16)
|
||||
{/* zName: */ "encoding",
|
||||
/* ePragTyp: */ PragTyp_ENCODING,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
|
||||
{/* zName: */ "foreign_key_check",
|
||||
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_Result1 |
|
||||
PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 37, 4,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
|
||||
{/* zName: */ "foreign_key_list",
|
||||
/* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 0, 8,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
|
||||
{/* zName: */ "foreign_keys",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ForeignKeys},
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "freelist_count",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_ReadOnly | PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_FREE_PAGE_COUNT},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "full_column_names",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_FullColNames},
|
||||
{/* zName: */ "fullfsync",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_FullFSync},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
#if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
|
||||
{/* zName: */ "function_list",
|
||||
/* ePragTyp: */ PragTyp_FUNCTION_LIST,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 21, 6,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#endif
|
||||
{/* zName: */ "hard_heap_limit",
|
||||
/* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if !defined(SQLITE_OMIT_CHECK)
|
||||
{/* zName: */ "ignore_check_constraints",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_IgnoreChecks},
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_AUTOVACUUM)
|
||||
{/* zName: */ "incremental_vacuum",
|
||||
/* ePragTyp: */ PragTyp_INCREMENTAL_VACUUM,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_NoColumns,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
{/* zName: */ "index_info",
|
||||
/* ePragTyp: */ PragTyp_INDEX_INFO,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 15, 3,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "index_list",
|
||||
/* ePragTyp: */ PragTyp_INDEX_LIST,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 32, 5,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "index_xinfo",
|
||||
/* ePragTyp: */ PragTyp_INDEX_INFO,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 15, 6,
|
||||
/* iArg: */ 1},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
|
||||
{/* zName: */ "integrity_check",
|
||||
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_Result1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "journal_mode",
|
||||
/* ePragTyp: */ PragTyp_JOURNAL_MODE,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "journal_size_limit",
|
||||
/* ePragTyp: */ PragTyp_JOURNAL_SIZE_LIMIT,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_SchemaReq,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "legacy_alter_table",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_LegacyAlter},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
|
||||
{/* zName: */ "lock_proxy_file",
|
||||
/* ePragTyp: */ PragTyp_LOCK_PROXY_FILE,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
|
||||
{/* zName: */ "lock_status",
|
||||
/* ePragTyp: */ PragTyp_LOCK_STATUS,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 47, 2,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "locking_mode",
|
||||
/* ePragTyp: */ PragTyp_LOCKING_MODE,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_SchemaReq,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "max_page_count",
|
||||
/* ePragTyp: */ PragTyp_PAGE_COUNT,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "mmap_size",
|
||||
/* ePragTyp: */ PragTyp_MMAP_SIZE,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
#if !defined(SQLITE_OMIT_VIRTUALTABLE)
|
||||
#if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
|
||||
{/* zName: */ "module_list",
|
||||
/* ePragTyp: */ PragTyp_MODULE_LIST,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 9, 1,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
{/* zName: */ "optimize",
|
||||
/* ePragTyp: */ PragTyp_OPTIMIZE,
|
||||
/* ePragFlg: */ PragFlg_Result1 | PragFlg_NeedSchema,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "page_count",
|
||||
/* ePragTyp: */ PragTyp_PAGE_COUNT,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "page_size",
|
||||
/* ePragTyp: */ PragTyp_PAGE_SIZE,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if defined(SQLITE_DEBUG)
|
||||
{/* zName: */ "parser_trace",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ParserTrace},
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
|
||||
{/* zName: */ "pragma_list",
|
||||
/* ePragTyp: */ PragTyp_PRAGMA_LIST,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 9, 1,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "query_only",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_QueryOnly},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
|
||||
{/* zName: */ "quick_check",
|
||||
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_Result1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "read_uncommitted",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ReadUncommit},
|
||||
{/* zName: */ "recursive_triggers",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_RecTriggers},
|
||||
{/* zName: */ "reverse_unordered_selects",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ReverseOrder},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "schema_version",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1 | PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_SCHEMA_VERSION},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "secure_delete",
|
||||
/* ePragTyp: */ PragTyp_SECURE_DELETE,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "short_column_names",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ShortColNames},
|
||||
#endif
|
||||
{/* zName: */ "shrink_memory",
|
||||
/* ePragTyp: */ PragTyp_SHRINK_MEMORY,
|
||||
/* ePragFlg: */ PragFlg_NoColumns,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "soft_heap_limit",
|
||||
/* ePragTyp: */ PragTyp_SOFT_HEAP_LIMIT,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if defined(SQLITE_DEBUG)
|
||||
{/* zName: */ "sql_trace",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_SqlTrace},
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
|
||||
{/* zName: */ "stats",
|
||||
/* ePragTyp: */ PragTyp_STATS,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq,
|
||||
/* ColNames: */ 27, 5,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "synchronous",
|
||||
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq |
|
||||
PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
{/* zName: */ "table_info",
|
||||
/* ePragTyp: */ PragTyp_TABLE_INFO,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 8, 6,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "table_xinfo",
|
||||
/* ePragTyp: */ PragTyp_TABLE_INFO,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 8, 7,
|
||||
/* iArg: */ 1},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "temp_store",
|
||||
/* ePragTyp: */ PragTyp_TEMP_STORE,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "temp_store_directory",
|
||||
/* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
{/* zName: */ "threads",
|
||||
/* ePragTyp: */ PragTyp_THREADS,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "trusted_schema",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_TrustedSchema},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "user_version",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1 | PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_USER_VERSION},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if defined(SQLITE_DEBUG)
|
||||
{/* zName: */ "vdbe_addoptrace",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeAddopTrace},
|
||||
{/* zName: */ "vdbe_debug",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_SqlTrace | SQLITE_VdbeListing | SQLITE_VdbeTrace},
|
||||
{/* zName: */ "vdbe_eqp",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeEQP},
|
||||
{/* zName: */ "vdbe_listing",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeListing},
|
||||
{/* zName: */ "vdbe_trace",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeTrace},
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_WAL)
|
||||
{/* zName: */ "wal_autocheckpoint",
|
||||
/* ePragTyp: */ PragTyp_WAL_AUTOCHECKPOINT,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0},
|
||||
{/* zName: */ "wal_checkpoint",
|
||||
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema,
|
||||
/* ColNames: */ 44, 3,
|
||||
/* iArg: */ 0},
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "writable_schema",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_WriteSchema | SQLITE_NoSchemaError},
|
||||
#endif
|
||||
};
|
||||
/* Number of pragmas: 67 on by default, 77 total. */
|
12237
third_party/sqlite3/headers/sqlite3.h
vendored
Normal file
12237
third_party/sqlite3/headers/sqlite3.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
687
third_party/sqlite3/headers/sqlite3ext.h
vendored
Normal file
687
third_party/sqlite3/headers/sqlite3ext.h
vendored
Normal file
|
@ -0,0 +1,687 @@
|
|||
/*
|
||||
** 2006 June 7
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the SQLite interface for use by
|
||||
** shared libraries that want to be imported as extensions into
|
||||
** an SQLite instance. Shared libraries that intend to be loaded
|
||||
** as extensions by SQLite should #include this file instead of
|
||||
** sqlite3.h.
|
||||
*/
|
||||
#ifndef SQLITE3EXT_H
|
||||
#define SQLITE3EXT_H
|
||||
#include "sqlite3.h"
|
||||
|
||||
/*
|
||||
** The following structure holds pointers to all of the SQLite API
|
||||
** routines.
|
||||
**
|
||||
** WARNING: In order to maintain backwards compatibility, add new
|
||||
** interfaces to the end of this structure only. If you insert new
|
||||
** interfaces in the middle of this structure, then older different
|
||||
** versions of SQLite will not be able to load each other's shared
|
||||
** libraries!
|
||||
*/
|
||||
struct sqlite3_api_routines {
|
||||
void *(*aggregate_context)(sqlite3_context *, int nBytes);
|
||||
int (*aggregate_count)(sqlite3_context *);
|
||||
int (*bind_blob)(sqlite3_stmt *, int, const void *, int n, void (*)(void *));
|
||||
int (*bind_double)(sqlite3_stmt *, int, double);
|
||||
int (*bind_int)(sqlite3_stmt *, int, int);
|
||||
int (*bind_int64)(sqlite3_stmt *, int, sqlite_int64);
|
||||
int (*bind_null)(sqlite3_stmt *, int);
|
||||
int (*bind_parameter_count)(sqlite3_stmt *);
|
||||
int (*bind_parameter_index)(sqlite3_stmt *, const char *zName);
|
||||
const char *(*bind_parameter_name)(sqlite3_stmt *, int);
|
||||
int (*bind_text)(sqlite3_stmt *, int, const char *, int n, void (*)(void *));
|
||||
int (*bind_text16)(sqlite3_stmt *, int, const void *, int, void (*)(void *));
|
||||
int (*bind_value)(sqlite3_stmt *, int, const sqlite3_value *);
|
||||
int (*busy_handler)(sqlite3 *, int (*)(void *, int), void *);
|
||||
int (*busy_timeout)(sqlite3 *, int ms);
|
||||
int (*changes)(sqlite3 *);
|
||||
int (*close)(sqlite3 *);
|
||||
int (*collation_needed)(sqlite3 *, void *,
|
||||
void (*)(void *, sqlite3 *, int eTextRep,
|
||||
const char *));
|
||||
int (*collation_needed16)(sqlite3 *, void *,
|
||||
void (*)(void *, sqlite3 *, int eTextRep,
|
||||
const void *));
|
||||
const void *(*column_blob)(sqlite3_stmt *, int iCol);
|
||||
int (*column_bytes)(sqlite3_stmt *, int iCol);
|
||||
int (*column_bytes16)(sqlite3_stmt *, int iCol);
|
||||
int (*column_count)(sqlite3_stmt *pStmt);
|
||||
const char *(*column_database_name)(sqlite3_stmt *, int);
|
||||
const void *(*column_database_name16)(sqlite3_stmt *, int);
|
||||
const char *(*column_decltype)(sqlite3_stmt *, int i);
|
||||
const void *(*column_decltype16)(sqlite3_stmt *, int);
|
||||
double (*column_double)(sqlite3_stmt *, int iCol);
|
||||
int (*column_int)(sqlite3_stmt *, int iCol);
|
||||
sqlite_int64 (*column_int64)(sqlite3_stmt *, int iCol);
|
||||
const char *(*column_name)(sqlite3_stmt *, int);
|
||||
const void *(*column_name16)(sqlite3_stmt *, int);
|
||||
const char *(*column_origin_name)(sqlite3_stmt *, int);
|
||||
const void *(*column_origin_name16)(sqlite3_stmt *, int);
|
||||
const char *(*column_table_name)(sqlite3_stmt *, int);
|
||||
const void *(*column_table_name16)(sqlite3_stmt *, int);
|
||||
const unsigned char *(*column_text)(sqlite3_stmt *, int iCol);
|
||||
const void *(*column_text16)(sqlite3_stmt *, int iCol);
|
||||
int (*column_type)(sqlite3_stmt *, int iCol);
|
||||
sqlite3_value *(*column_value)(sqlite3_stmt *, int iCol);
|
||||
void *(*commit_hook)(sqlite3 *, int (*)(void *), void *);
|
||||
int (*complete)(const char *sql);
|
||||
int (*complete16)(const void *sql);
|
||||
int (*create_collation)(sqlite3 *, const char *, int, void *,
|
||||
int (*)(void *, int, const void *, int,
|
||||
const void *));
|
||||
int (*create_collation16)(sqlite3 *, const void *, int, void *,
|
||||
int (*)(void *, int, const void *, int,
|
||||
const void *));
|
||||
int (*create_function)(sqlite3 *, const char *, int, int, void *,
|
||||
void (*xFunc)(sqlite3_context *, int,
|
||||
sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context *, int,
|
||||
sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context *));
|
||||
int (*create_function16)(sqlite3 *, const void *, int, int, void *,
|
||||
void (*xFunc)(sqlite3_context *, int,
|
||||
sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context *, int,
|
||||
sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context *));
|
||||
int (*create_module)(sqlite3 *, const char *, const sqlite3_module *, void *);
|
||||
int (*data_count)(sqlite3_stmt *pStmt);
|
||||
sqlite3 *(*db_handle)(sqlite3_stmt *);
|
||||
int (*declare_vtab)(sqlite3 *, const char *);
|
||||
int (*enable_shared_cache)(int);
|
||||
int (*errcode)(sqlite3 *db);
|
||||
const char *(*errmsg)(sqlite3 *);
|
||||
const void *(*errmsg16)(sqlite3 *);
|
||||
int (*exec)(sqlite3 *, const char *, sqlite3_callback, void *, char **);
|
||||
int (*expired)(sqlite3_stmt *);
|
||||
int (*finalize)(sqlite3_stmt *pStmt);
|
||||
void (*free)(void *);
|
||||
void (*free_table)(char **result);
|
||||
int (*get_autocommit)(sqlite3 *);
|
||||
void *(*get_auxdata)(sqlite3_context *, int);
|
||||
int (*get_table)(sqlite3 *, const char *, char ***, int *, int *, char **);
|
||||
int (*global_recover)(void);
|
||||
void (*interruptx)(sqlite3 *);
|
||||
sqlite_int64 (*last_insert_rowid)(sqlite3 *);
|
||||
const char *(*libversion)(void);
|
||||
int (*libversion_number)(void);
|
||||
void *(*malloc)(int);
|
||||
char *(*mprintf)(const char *, ...);
|
||||
int (*open)(const char *, sqlite3 **);
|
||||
int (*open16)(const void *, sqlite3 **);
|
||||
int (*prepare)(sqlite3 *, const char *, int, sqlite3_stmt **, const char **);
|
||||
int (*prepare16)(sqlite3 *, const void *, int, sqlite3_stmt **,
|
||||
const void **);
|
||||
void *(*profile)(sqlite3 *, void (*)(void *, const char *, sqlite_uint64),
|
||||
void *);
|
||||
void (*progress_handler)(sqlite3 *, int, int (*)(void *), void *);
|
||||
void *(*realloc)(void *, int);
|
||||
int (*reset)(sqlite3_stmt *pStmt);
|
||||
void (*result_blob)(sqlite3_context *, const void *, int, void (*)(void *));
|
||||
void (*result_double)(sqlite3_context *, double);
|
||||
void (*result_error)(sqlite3_context *, const char *, int);
|
||||
void (*result_error16)(sqlite3_context *, const void *, int);
|
||||
void (*result_int)(sqlite3_context *, int);
|
||||
void (*result_int64)(sqlite3_context *, sqlite_int64);
|
||||
void (*result_null)(sqlite3_context *);
|
||||
void (*result_text)(sqlite3_context *, const char *, int, void (*)(void *));
|
||||
void (*result_text16)(sqlite3_context *, const void *, int, void (*)(void *));
|
||||
void (*result_text16be)(sqlite3_context *, const void *, int,
|
||||
void (*)(void *));
|
||||
void (*result_text16le)(sqlite3_context *, const void *, int,
|
||||
void (*)(void *));
|
||||
void (*result_value)(sqlite3_context *, sqlite3_value *);
|
||||
void *(*rollback_hook)(sqlite3 *, void (*)(void *), void *);
|
||||
int (*set_authorizer)(sqlite3 *,
|
||||
int (*)(void *, int, const char *, const char *,
|
||||
const char *, const char *),
|
||||
void *);
|
||||
void (*set_auxdata)(sqlite3_context *, int, void *, void (*)(void *));
|
||||
char *(*xsnprintf)(int, char *, const char *, ...);
|
||||
int (*step)(sqlite3_stmt *);
|
||||
int (*table_column_metadata)(sqlite3 *, const char *, const char *,
|
||||
const char *, char const **, char const **,
|
||||
int *, int *, int *);
|
||||
void (*thread_cleanup)(void);
|
||||
int (*total_changes)(sqlite3 *);
|
||||
void *(*trace)(sqlite3 *, void (*xTrace)(void *, const char *), void *);
|
||||
int (*transfer_bindings)(sqlite3_stmt *, sqlite3_stmt *);
|
||||
void *(*update_hook)(sqlite3 *,
|
||||
void (*)(void *, int, char const *, char const *,
|
||||
sqlite_int64),
|
||||
void *);
|
||||
void *(*user_data)(sqlite3_context *);
|
||||
const void *(*value_blob)(sqlite3_value *);
|
||||
int (*value_bytes)(sqlite3_value *);
|
||||
int (*value_bytes16)(sqlite3_value *);
|
||||
double (*value_double)(sqlite3_value *);
|
||||
int (*value_int)(sqlite3_value *);
|
||||
sqlite_int64 (*value_int64)(sqlite3_value *);
|
||||
int (*value_numeric_type)(sqlite3_value *);
|
||||
const unsigned char *(*value_text)(sqlite3_value *);
|
||||
const void *(*value_text16)(sqlite3_value *);
|
||||
const void *(*value_text16be)(sqlite3_value *);
|
||||
const void *(*value_text16le)(sqlite3_value *);
|
||||
int (*value_type)(sqlite3_value *);
|
||||
char *(*vmprintf)(const char *, va_list);
|
||||
/* Added ??? */
|
||||
int (*overload_function)(sqlite3 *, const char *zFuncName, int nArg);
|
||||
/* Added by 3.3.13 */
|
||||
int (*prepare_v2)(sqlite3 *, const char *, int, sqlite3_stmt **,
|
||||
const char **);
|
||||
int (*prepare16_v2)(sqlite3 *, const void *, int, sqlite3_stmt **,
|
||||
const void **);
|
||||
int (*clear_bindings)(sqlite3_stmt *);
|
||||
/* Added by 3.4.1 */
|
||||
int (*create_module_v2)(sqlite3 *, const char *, const sqlite3_module *,
|
||||
void *, void (*xDestroy)(void *));
|
||||
/* Added by 3.5.0 */
|
||||
int (*bind_zeroblob)(sqlite3_stmt *, int, int);
|
||||
int (*blob_bytes)(sqlite3_blob *);
|
||||
int (*blob_close)(sqlite3_blob *);
|
||||
int (*blob_open)(sqlite3 *, const char *, const char *, const char *,
|
||||
sqlite3_int64, int, sqlite3_blob **);
|
||||
int (*blob_read)(sqlite3_blob *, void *, int, int);
|
||||
int (*blob_write)(sqlite3_blob *, const void *, int, int);
|
||||
int (*create_collation_v2)(sqlite3 *, const char *, int, void *,
|
||||
int (*)(void *, int, const void *, int,
|
||||
const void *),
|
||||
void (*)(void *));
|
||||
int (*file_control)(sqlite3 *, const char *, int, void *);
|
||||
sqlite3_int64 (*memory_highwater)(int);
|
||||
sqlite3_int64 (*memory_used)(void);
|
||||
sqlite3_mutex *(*mutex_alloc)(int);
|
||||
void (*mutex_enter)(sqlite3_mutex *);
|
||||
void (*mutex_free)(sqlite3_mutex *);
|
||||
void (*mutex_leave)(sqlite3_mutex *);
|
||||
int (*mutex_try)(sqlite3_mutex *);
|
||||
int (*open_v2)(const char *, sqlite3 **, int, const char *);
|
||||
int (*release_memory)(int);
|
||||
void (*result_error_nomem)(sqlite3_context *);
|
||||
void (*result_error_toobig)(sqlite3_context *);
|
||||
int (*sleep)(int);
|
||||
void (*soft_heap_limit)(int);
|
||||
sqlite3_vfs *(*vfs_find)(const char *);
|
||||
int (*vfs_register)(sqlite3_vfs *, int);
|
||||
int (*vfs_unregister)(sqlite3_vfs *);
|
||||
int (*xthreadsafe)(void);
|
||||
void (*result_zeroblob)(sqlite3_context *, int);
|
||||
void (*result_error_code)(sqlite3_context *, int);
|
||||
int (*test_control)(int, ...);
|
||||
void (*randomness)(int, void *);
|
||||
sqlite3 *(*context_db_handle)(sqlite3_context *);
|
||||
int (*extended_result_codes)(sqlite3 *, int);
|
||||
int (*limit)(sqlite3 *, int, int);
|
||||
sqlite3_stmt *(*next_stmt)(sqlite3 *, sqlite3_stmt *);
|
||||
const char *(*sql)(sqlite3_stmt *);
|
||||
int (*status)(int, int *, int *, int);
|
||||
int (*backup_finish)(sqlite3_backup *);
|
||||
sqlite3_backup *(*backup_init)(sqlite3 *, const char *, sqlite3 *,
|
||||
const char *);
|
||||
int (*backup_pagecount)(sqlite3_backup *);
|
||||
int (*backup_remaining)(sqlite3_backup *);
|
||||
int (*backup_step)(sqlite3_backup *, int);
|
||||
const char *(*compileoption_get)(int);
|
||||
int (*compileoption_used)(const char *);
|
||||
int (*create_function_v2)(
|
||||
sqlite3 *, const char *, int, int, void *,
|
||||
void (*xFunc)(sqlite3_context *, int, sqlite3_value **),
|
||||
void (*xStep)(sqlite3_context *, int, sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context *), void (*xDestroy)(void *));
|
||||
int (*db_config)(sqlite3 *, int, ...);
|
||||
sqlite3_mutex *(*db_mutex)(sqlite3 *);
|
||||
int (*db_status)(sqlite3 *, int, int *, int *, int);
|
||||
int (*extended_errcode)(sqlite3 *);
|
||||
void (*log)(int, const char *, ...);
|
||||
sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
|
||||
const char *(*sourceid)(void);
|
||||
int (*stmt_status)(sqlite3_stmt *, int, int);
|
||||
int (*strnicmp)(const char *, const char *, int);
|
||||
int (*unlock_notify)(sqlite3 *, void (*)(void **, int), void *);
|
||||
int (*wal_autocheckpoint)(sqlite3 *, int);
|
||||
int (*wal_checkpoint)(sqlite3 *, const char *);
|
||||
void *(*wal_hook)(sqlite3 *, int (*)(void *, sqlite3 *, const char *, int),
|
||||
void *);
|
||||
int (*blob_reopen)(sqlite3_blob *, sqlite3_int64);
|
||||
int (*vtab_config)(sqlite3 *, int op, ...);
|
||||
int (*vtab_on_conflict)(sqlite3 *);
|
||||
/* Version 3.7.16 and later */
|
||||
int (*close_v2)(sqlite3 *);
|
||||
const char *(*db_filename)(sqlite3 *, const char *);
|
||||
int (*db_readonly)(sqlite3 *, const char *);
|
||||
int (*db_release_memory)(sqlite3 *);
|
||||
const char *(*errstr)(int);
|
||||
int (*stmt_busy)(sqlite3_stmt *);
|
||||
int (*stmt_readonly)(sqlite3_stmt *);
|
||||
int (*stricmp)(const char *, const char *);
|
||||
int (*uri_boolean)(const char *, const char *, int);
|
||||
sqlite3_int64 (*uri_int64)(const char *, const char *, sqlite3_int64);
|
||||
const char *(*uri_parameter)(const char *, const char *);
|
||||
char *(*xvsnprintf)(int, char *, const char *, va_list);
|
||||
int (*wal_checkpoint_v2)(sqlite3 *, const char *, int, int *, int *);
|
||||
/* Version 3.8.7 and later */
|
||||
int (*auto_extension)(void (*)(void));
|
||||
int (*bind_blob64)(sqlite3_stmt *, int, const void *, sqlite3_uint64,
|
||||
void (*)(void *));
|
||||
int (*bind_text64)(sqlite3_stmt *, int, const char *, sqlite3_uint64,
|
||||
void (*)(void *), unsigned char);
|
||||
int (*cancel_auto_extension)(void (*)(void));
|
||||
int (*load_extension)(sqlite3 *, const char *, const char *, char **);
|
||||
void *(*malloc64)(sqlite3_uint64);
|
||||
sqlite3_uint64 (*msize)(void *);
|
||||
void *(*realloc64)(void *, sqlite3_uint64);
|
||||
void (*reset_auto_extension)(void);
|
||||
void (*result_blob64)(sqlite3_context *, const void *, sqlite3_uint64,
|
||||
void (*)(void *));
|
||||
void (*result_text64)(sqlite3_context *, const char *, sqlite3_uint64,
|
||||
void (*)(void *), unsigned char);
|
||||
int (*strglob)(const char *, const char *);
|
||||
/* Version 3.8.11 and later */
|
||||
sqlite3_value *(*value_dup)(const sqlite3_value *);
|
||||
void (*value_free)(sqlite3_value *);
|
||||
int (*result_zeroblob64)(sqlite3_context *, sqlite3_uint64);
|
||||
int (*bind_zeroblob64)(sqlite3_stmt *, int, sqlite3_uint64);
|
||||
/* Version 3.9.0 and later */
|
||||
unsigned int (*value_subtype)(sqlite3_value *);
|
||||
void (*result_subtype)(sqlite3_context *, unsigned int);
|
||||
/* Version 3.10.0 and later */
|
||||
int (*status64)(int, sqlite3_int64 *, sqlite3_int64 *, int);
|
||||
int (*strlike)(const char *, const char *, unsigned int);
|
||||
int (*db_cacheflush)(sqlite3 *);
|
||||
/* Version 3.12.0 and later */
|
||||
int (*system_errno)(sqlite3 *);
|
||||
/* Version 3.14.0 and later */
|
||||
int (*trace_v2)(sqlite3 *, unsigned,
|
||||
int (*)(unsigned, void *, void *, void *), void *);
|
||||
char *(*expanded_sql)(sqlite3_stmt *);
|
||||
/* Version 3.18.0 and later */
|
||||
void (*set_last_insert_rowid)(sqlite3 *, sqlite3_int64);
|
||||
/* Version 3.20.0 and later */
|
||||
int (*prepare_v3)(sqlite3 *, const char *, int, unsigned int, sqlite3_stmt **,
|
||||
const char **);
|
||||
int (*prepare16_v3)(sqlite3 *, const void *, int, unsigned int,
|
||||
sqlite3_stmt **, const void **);
|
||||
int (*bind_pointer)(sqlite3_stmt *, int, void *, const char *,
|
||||
void (*)(void *));
|
||||
void (*result_pointer)(sqlite3_context *, void *, const char *,
|
||||
void (*)(void *));
|
||||
void *(*value_pointer)(sqlite3_value *, const char *);
|
||||
int (*vtab_nochange)(sqlite3_context *);
|
||||
int (*value_nochange)(sqlite3_value *);
|
||||
const char *(*vtab_collation)(sqlite3_index_info *, int);
|
||||
/* Version 3.24.0 and later */
|
||||
int (*keyword_count)(void);
|
||||
int (*keyword_name)(int, const char **, int *);
|
||||
int (*keyword_check)(const char *, int);
|
||||
sqlite3_str *(*str_new)(sqlite3 *);
|
||||
char *(*str_finish)(sqlite3_str *);
|
||||
void (*str_appendf)(sqlite3_str *, const char *zFormat, ...);
|
||||
void (*str_vappendf)(sqlite3_str *, const char *zFormat, va_list);
|
||||
void (*str_append)(sqlite3_str *, const char *zIn, int N);
|
||||
void (*str_appendall)(sqlite3_str *, const char *zIn);
|
||||
void (*str_appendchar)(sqlite3_str *, int N, char C);
|
||||
void (*str_reset)(sqlite3_str *);
|
||||
int (*str_errcode)(sqlite3_str *);
|
||||
int (*str_length)(sqlite3_str *);
|
||||
char *(*str_value)(sqlite3_str *);
|
||||
/* Version 3.25.0 and later */
|
||||
int (*create_window_function)(
|
||||
sqlite3 *, const char *, int, int, void *,
|
||||
void (*xStep)(sqlite3_context *, int, sqlite3_value **),
|
||||
void (*xFinal)(sqlite3_context *), void (*xValue)(sqlite3_context *),
|
||||
void (*xInv)(sqlite3_context *, int, sqlite3_value **),
|
||||
void (*xDestroy)(void *));
|
||||
/* Version 3.26.0 and later */
|
||||
const char *(*normalized_sql)(sqlite3_stmt *);
|
||||
/* Version 3.28.0 and later */
|
||||
int (*stmt_isexplain)(sqlite3_stmt *);
|
||||
int (*value_frombind)(sqlite3_value *);
|
||||
/* Version 3.30.0 and later */
|
||||
int (*drop_modules)(sqlite3 *, const char **);
|
||||
/* Version 3.31.0 and later */
|
||||
sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
|
||||
const char *(*uri_key)(const char *, int);
|
||||
const char *(*filename_database)(const char *);
|
||||
const char *(*filename_journal)(const char *);
|
||||
const char *(*filename_wal)(const char *);
|
||||
/* Version 3.32.0 and later */
|
||||
char *(*create_filename)(const char *, const char *, const char *, int,
|
||||
const char **);
|
||||
void (*free_filename)(char *);
|
||||
sqlite3_file *(*database_file_object)(const char *);
|
||||
/* Version 3.34.0 and later */
|
||||
int (*txn_state)(sqlite3 *, const char *);
|
||||
};
|
||||
|
||||
/*
|
||||
** This is the function signature used for all extension entry points. It
|
||||
** is also defined in the file "loadext.c".
|
||||
*/
|
||||
typedef int (*sqlite3_loadext_entry)(
|
||||
sqlite3 *db, /* Handle to the database. */
|
||||
char **pzErrMsg, /* Used to set error string on failure. */
|
||||
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
|
||||
);
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected through the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
** it can get access to the sqlite3_api_routines structure
|
||||
** definition. But the main library does not want to redefine
|
||||
** the API. So the redefinition macros are only valid if the
|
||||
** SQLITE_CORE macros is undefined.
|
||||
*/
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
|
||||
#endif
|
||||
#define sqlite3_bind_blob sqlite3_api->bind_blob
|
||||
#define sqlite3_bind_double sqlite3_api->bind_double
|
||||
#define sqlite3_bind_int sqlite3_api->bind_int
|
||||
#define sqlite3_bind_int64 sqlite3_api->bind_int64
|
||||
#define sqlite3_bind_null sqlite3_api->bind_null
|
||||
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
|
||||
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
|
||||
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
|
||||
#define sqlite3_bind_text sqlite3_api->bind_text
|
||||
#define sqlite3_bind_text16 sqlite3_api->bind_text16
|
||||
#define sqlite3_bind_value sqlite3_api->bind_value
|
||||
#define sqlite3_busy_handler sqlite3_api->busy_handler
|
||||
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
|
||||
#define sqlite3_changes sqlite3_api->changes
|
||||
#define sqlite3_close sqlite3_api->close
|
||||
#define sqlite3_collation_needed sqlite3_api->collation_needed
|
||||
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
|
||||
#define sqlite3_column_blob sqlite3_api->column_blob
|
||||
#define sqlite3_column_bytes sqlite3_api->column_bytes
|
||||
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
|
||||
#define sqlite3_column_count sqlite3_api->column_count
|
||||
#define sqlite3_column_database_name sqlite3_api->column_database_name
|
||||
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
|
||||
#define sqlite3_column_decltype sqlite3_api->column_decltype
|
||||
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
|
||||
#define sqlite3_column_double sqlite3_api->column_double
|
||||
#define sqlite3_column_int sqlite3_api->column_int
|
||||
#define sqlite3_column_int64 sqlite3_api->column_int64
|
||||
#define sqlite3_column_name sqlite3_api->column_name
|
||||
#define sqlite3_column_name16 sqlite3_api->column_name16
|
||||
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
|
||||
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
|
||||
#define sqlite3_column_table_name sqlite3_api->column_table_name
|
||||
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
|
||||
#define sqlite3_column_text sqlite3_api->column_text
|
||||
#define sqlite3_column_text16 sqlite3_api->column_text16
|
||||
#define sqlite3_column_type sqlite3_api->column_type
|
||||
#define sqlite3_column_value sqlite3_api->column_value
|
||||
#define sqlite3_commit_hook sqlite3_api->commit_hook
|
||||
#define sqlite3_complete sqlite3_api->complete
|
||||
#define sqlite3_complete16 sqlite3_api->complete16
|
||||
#define sqlite3_create_collation sqlite3_api->create_collation
|
||||
#define sqlite3_create_collation16 sqlite3_api->create_collation16
|
||||
#define sqlite3_create_function sqlite3_api->create_function
|
||||
#define sqlite3_create_function16 sqlite3_api->create_function16
|
||||
#define sqlite3_create_module sqlite3_api->create_module
|
||||
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
|
||||
#define sqlite3_data_count sqlite3_api->data_count
|
||||
#define sqlite3_db_handle sqlite3_api->db_handle
|
||||
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
|
||||
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
|
||||
#define sqlite3_errcode sqlite3_api->errcode
|
||||
#define sqlite3_errmsg sqlite3_api->errmsg
|
||||
#define sqlite3_errmsg16 sqlite3_api->errmsg16
|
||||
#define sqlite3_exec sqlite3_api->exec
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_expired sqlite3_api->expired
|
||||
#endif
|
||||
#define sqlite3_finalize sqlite3_api->finalize
|
||||
#define sqlite3_free sqlite3_api->free
|
||||
#define sqlite3_free_table sqlite3_api->free_table
|
||||
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
|
||||
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
|
||||
#define sqlite3_get_table sqlite3_api->get_table
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_global_recover sqlite3_api->global_recover
|
||||
#endif
|
||||
#define sqlite3_interrupt sqlite3_api->interruptx
|
||||
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
|
||||
#define sqlite3_libversion sqlite3_api->libversion
|
||||
#define sqlite3_libversion_number sqlite3_api->libversion_number
|
||||
#define sqlite3_malloc sqlite3_api->malloc
|
||||
#define sqlite3_mprintf sqlite3_api->mprintf
|
||||
#define sqlite3_open sqlite3_api->open
|
||||
#define sqlite3_open16 sqlite3_api->open16
|
||||
#define sqlite3_prepare sqlite3_api->prepare
|
||||
#define sqlite3_prepare16 sqlite3_api->prepare16
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_profile sqlite3_api->profile
|
||||
#define sqlite3_progress_handler sqlite3_api->progress_handler
|
||||
#define sqlite3_realloc sqlite3_api->realloc
|
||||
#define sqlite3_reset sqlite3_api->reset
|
||||
#define sqlite3_result_blob sqlite3_api->result_blob
|
||||
#define sqlite3_result_double sqlite3_api->result_double
|
||||
#define sqlite3_result_error sqlite3_api->result_error
|
||||
#define sqlite3_result_error16 sqlite3_api->result_error16
|
||||
#define sqlite3_result_int sqlite3_api->result_int
|
||||
#define sqlite3_result_int64 sqlite3_api->result_int64
|
||||
#define sqlite3_result_null sqlite3_api->result_null
|
||||
#define sqlite3_result_text sqlite3_api->result_text
|
||||
#define sqlite3_result_text16 sqlite3_api->result_text16
|
||||
#define sqlite3_result_text16be sqlite3_api->result_text16be
|
||||
#define sqlite3_result_text16le sqlite3_api->result_text16le
|
||||
#define sqlite3_result_value sqlite3_api->result_value
|
||||
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
|
||||
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
|
||||
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
|
||||
#define sqlite3_snprintf sqlite3_api->xsnprintf
|
||||
#define sqlite3_step sqlite3_api->step
|
||||
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
|
||||
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
|
||||
#define sqlite3_total_changes sqlite3_api->total_changes
|
||||
#define sqlite3_trace sqlite3_api->trace
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
|
||||
#endif
|
||||
#define sqlite3_update_hook sqlite3_api->update_hook
|
||||
#define sqlite3_user_data sqlite3_api->user_data
|
||||
#define sqlite3_value_blob sqlite3_api->value_blob
|
||||
#define sqlite3_value_bytes sqlite3_api->value_bytes
|
||||
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
|
||||
#define sqlite3_value_double sqlite3_api->value_double
|
||||
#define sqlite3_value_int sqlite3_api->value_int
|
||||
#define sqlite3_value_int64 sqlite3_api->value_int64
|
||||
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
|
||||
#define sqlite3_value_text sqlite3_api->value_text
|
||||
#define sqlite3_value_text16 sqlite3_api->value_text16
|
||||
#define sqlite3_value_text16be sqlite3_api->value_text16be
|
||||
#define sqlite3_value_text16le sqlite3_api->value_text16le
|
||||
#define sqlite3_value_type sqlite3_api->value_type
|
||||
#define sqlite3_vmprintf sqlite3_api->vmprintf
|
||||
#define sqlite3_vsnprintf sqlite3_api->xvsnprintf
|
||||
#define sqlite3_overload_function sqlite3_api->overload_function
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
|
||||
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
|
||||
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
|
||||
#define sqlite3_blob_close sqlite3_api->blob_close
|
||||
#define sqlite3_blob_open sqlite3_api->blob_open
|
||||
#define sqlite3_blob_read sqlite3_api->blob_read
|
||||
#define sqlite3_blob_write sqlite3_api->blob_write
|
||||
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
|
||||
#define sqlite3_file_control sqlite3_api->file_control
|
||||
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
|
||||
#define sqlite3_memory_used sqlite3_api->memory_used
|
||||
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
|
||||
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
|
||||
#define sqlite3_mutex_free sqlite3_api->mutex_free
|
||||
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
|
||||
#define sqlite3_mutex_try sqlite3_api->mutex_try
|
||||
#define sqlite3_open_v2 sqlite3_api->open_v2
|
||||
#define sqlite3_release_memory sqlite3_api->release_memory
|
||||
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
|
||||
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
|
||||
#define sqlite3_sleep sqlite3_api->sleep
|
||||
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
|
||||
#define sqlite3_vfs_find sqlite3_api->vfs_find
|
||||
#define sqlite3_vfs_register sqlite3_api->vfs_register
|
||||
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
|
||||
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
|
||||
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
|
||||
#define sqlite3_result_error_code sqlite3_api->result_error_code
|
||||
#define sqlite3_test_control sqlite3_api->test_control
|
||||
#define sqlite3_randomness sqlite3_api->randomness
|
||||
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
|
||||
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
|
||||
#define sqlite3_limit sqlite3_api->limit
|
||||
#define sqlite3_next_stmt sqlite3_api->next_stmt
|
||||
#define sqlite3_sql sqlite3_api->sql
|
||||
#define sqlite3_status sqlite3_api->status
|
||||
#define sqlite3_backup_finish sqlite3_api->backup_finish
|
||||
#define sqlite3_backup_init sqlite3_api->backup_init
|
||||
#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
|
||||
#define sqlite3_backup_remaining sqlite3_api->backup_remaining
|
||||
#define sqlite3_backup_step sqlite3_api->backup_step
|
||||
#define sqlite3_compileoption_get sqlite3_api->compileoption_get
|
||||
#define sqlite3_compileoption_used sqlite3_api->compileoption_used
|
||||
#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
|
||||
#define sqlite3_db_config sqlite3_api->db_config
|
||||
#define sqlite3_db_mutex sqlite3_api->db_mutex
|
||||
#define sqlite3_db_status sqlite3_api->db_status
|
||||
#define sqlite3_extended_errcode sqlite3_api->extended_errcode
|
||||
#define sqlite3_log sqlite3_api->log
|
||||
#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
|
||||
#define sqlite3_sourceid sqlite3_api->sourceid
|
||||
#define sqlite3_stmt_status sqlite3_api->stmt_status
|
||||
#define sqlite3_strnicmp sqlite3_api->strnicmp
|
||||
#define sqlite3_unlock_notify sqlite3_api->unlock_notify
|
||||
#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
|
||||
#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
|
||||
#define sqlite3_wal_hook sqlite3_api->wal_hook
|
||||
#define sqlite3_blob_reopen sqlite3_api->blob_reopen
|
||||
#define sqlite3_vtab_config sqlite3_api->vtab_config
|
||||
#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
|
||||
/* Version 3.7.16 and later */
|
||||
#define sqlite3_close_v2 sqlite3_api->close_v2
|
||||
#define sqlite3_db_filename sqlite3_api->db_filename
|
||||
#define sqlite3_db_readonly sqlite3_api->db_readonly
|
||||
#define sqlite3_db_release_memory sqlite3_api->db_release_memory
|
||||
#define sqlite3_errstr sqlite3_api->errstr
|
||||
#define sqlite3_stmt_busy sqlite3_api->stmt_busy
|
||||
#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
|
||||
#define sqlite3_stricmp sqlite3_api->stricmp
|
||||
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
|
||||
#define sqlite3_uri_int64 sqlite3_api->uri_int64
|
||||
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
|
||||
#define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf
|
||||
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
|
||||
/* Version 3.8.7 and later */
|
||||
#define sqlite3_auto_extension sqlite3_api->auto_extension
|
||||
#define sqlite3_bind_blob64 sqlite3_api->bind_blob64
|
||||
#define sqlite3_bind_text64 sqlite3_api->bind_text64
|
||||
#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
|
||||
#define sqlite3_load_extension sqlite3_api->load_extension
|
||||
#define sqlite3_malloc64 sqlite3_api->malloc64
|
||||
#define sqlite3_msize sqlite3_api->msize
|
||||
#define sqlite3_realloc64 sqlite3_api->realloc64
|
||||
#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
|
||||
#define sqlite3_result_blob64 sqlite3_api->result_blob64
|
||||
#define sqlite3_result_text64 sqlite3_api->result_text64
|
||||
#define sqlite3_strglob sqlite3_api->strglob
|
||||
/* Version 3.8.11 and later */
|
||||
#define sqlite3_value_dup sqlite3_api->value_dup
|
||||
#define sqlite3_value_free sqlite3_api->value_free
|
||||
#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
|
||||
#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
|
||||
/* Version 3.9.0 and later */
|
||||
#define sqlite3_value_subtype sqlite3_api->value_subtype
|
||||
#define sqlite3_result_subtype sqlite3_api->result_subtype
|
||||
/* Version 3.10.0 and later */
|
||||
#define sqlite3_status64 sqlite3_api->status64
|
||||
#define sqlite3_strlike sqlite3_api->strlike
|
||||
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
|
||||
/* Version 3.12.0 and later */
|
||||
#define sqlite3_system_errno sqlite3_api->system_errno
|
||||
/* Version 3.14.0 and later */
|
||||
#define sqlite3_trace_v2 sqlite3_api->trace_v2
|
||||
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
|
||||
/* Version 3.18.0 and later */
|
||||
#define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
|
||||
/* Version 3.20.0 and later */
|
||||
#define sqlite3_prepare_v3 sqlite3_api->prepare_v3
|
||||
#define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
|
||||
#define sqlite3_bind_pointer sqlite3_api->bind_pointer
|
||||
#define sqlite3_result_pointer sqlite3_api->result_pointer
|
||||
#define sqlite3_value_pointer sqlite3_api->value_pointer
|
||||
/* Version 3.22.0 and later */
|
||||
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
|
||||
#define sqlite3_value_nochange sqlite3_api->value_nochange
|
||||
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
|
||||
/* Version 3.24.0 and later */
|
||||
#define sqlite3_keyword_count sqlite3_api->keyword_count
|
||||
#define sqlite3_keyword_name sqlite3_api->keyword_name
|
||||
#define sqlite3_keyword_check sqlite3_api->keyword_check
|
||||
#define sqlite3_str_new sqlite3_api->str_new
|
||||
#define sqlite3_str_finish sqlite3_api->str_finish
|
||||
#define sqlite3_str_appendf sqlite3_api->str_appendf
|
||||
#define sqlite3_str_vappendf sqlite3_api->str_vappendf
|
||||
#define sqlite3_str_append sqlite3_api->str_append
|
||||
#define sqlite3_str_appendall sqlite3_api->str_appendall
|
||||
#define sqlite3_str_appendchar sqlite3_api->str_appendchar
|
||||
#define sqlite3_str_reset sqlite3_api->str_reset
|
||||
#define sqlite3_str_errcode sqlite3_api->str_errcode
|
||||
#define sqlite3_str_length sqlite3_api->str_length
|
||||
#define sqlite3_str_value sqlite3_api->str_value
|
||||
/* Version 3.25.0 and later */
|
||||
#define sqlite3_create_window_function sqlite3_api->create_window_function
|
||||
/* Version 3.26.0 and later */
|
||||
#define sqlite3_normalized_sql sqlite3_api->normalized_sql
|
||||
/* Version 3.28.0 and later */
|
||||
#define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
|
||||
#define sqlite3_value_frombind sqlite3_api->value_frombind
|
||||
/* Version 3.30.0 and later */
|
||||
#define sqlite3_drop_modules sqlite3_api->drop_modules
|
||||
/* Version 3.31.0 and later */
|
||||
#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
|
||||
#define sqlite3_uri_key sqlite3_api->uri_key
|
||||
#define sqlite3_filename_database sqlite3_api->filename_database
|
||||
#define sqlite3_filename_journal sqlite3_api->filename_journal
|
||||
#define sqlite3_filename_wal sqlite3_api->filename_wal
|
||||
/* Version 3.32.0 and later */
|
||||
#define sqlite3_create_filename sqlite3_api->create_filename
|
||||
#define sqlite3_free_filename sqlite3_api->free_filename
|
||||
#define sqlite3_database_file_object sqlite3_api->database_file_object
|
||||
/* Version 3.34.0 and later */
|
||||
#define sqlite3_txn_state sqlite3_api->txn_state
|
||||
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
||||
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
/* This case when the file really is being compiled as a loadable
|
||||
** extension */
|
||||
#define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0;
|
||||
#define SQLITE_EXTENSION_INIT2(v) sqlite3_api = v;
|
||||
#define SQLITE_EXTENSION_INIT3 extern const sqlite3_api_routines *sqlite3_api;
|
||||
#else
|
||||
/* This case when the file is being statically linked into the
|
||||
** application */
|
||||
#define SQLITE_EXTENSION_INIT1 /*no-op*/
|
||||
#define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
|
||||
#define SQLITE_EXTENSION_INIT3 /*no-op*/
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE3EXT_H */
|
1684
third_party/sqlite3/headers/sqlite3session.h
vendored
Normal file
1684
third_party/sqlite3/headers/sqlite3session.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
5249
third_party/sqlite3/headers/sqliteInt.h
vendored
Normal file
5249
third_party/sqlite3/headers/sqliteInt.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
207
third_party/sqlite3/headers/sqliteLimit.h
vendored
Normal file
207
third_party/sqlite3/headers/sqliteLimit.h
vendored
Normal file
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
** 2007 May 7
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This file defines various limits of what SQLite can process.
|
||||
*/
|
||||
|
||||
/*
|
||||
** The maximum length of a TEXT or BLOB in bytes. This also
|
||||
** limits the size of a row in a table or index.
|
||||
**
|
||||
** The hard limit is the ability of a 32-bit signed integer
|
||||
** to count the size: 2^31-1 or 2147483647.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_LENGTH
|
||||
#define SQLITE_MAX_LENGTH 1000000000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** This is the maximum number of
|
||||
**
|
||||
** * Columns in a table
|
||||
** * Columns in an index
|
||||
** * Columns in a view
|
||||
** * Terms in the SET clause of an UPDATE statement
|
||||
** * Terms in the result set of a SELECT statement
|
||||
** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
|
||||
** * Terms in the VALUES clause of an INSERT statement
|
||||
**
|
||||
** The hard upper limit here is 32676. Most database people will
|
||||
** tell you that in a well-normalized database, you usually should
|
||||
** not have more than a dozen or so columns in any table. And if
|
||||
** that is the case, there is no point in having more than a few
|
||||
** dozen values in any of the other situations described above.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_COLUMN
|
||||
#define SQLITE_MAX_COLUMN 2000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The maximum length of a single SQL statement in bytes.
|
||||
**
|
||||
** It used to be the case that setting this value to zero would
|
||||
** turn the limit off. That is no longer true. It is not possible
|
||||
** to turn this limit off.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_SQL_LENGTH
|
||||
#define SQLITE_MAX_SQL_LENGTH 1000000000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The maximum depth of an expression tree. This is limited to
|
||||
** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
|
||||
** want to place more severe limits on the complexity of an
|
||||
** expression. A value of 0 means that there is no limit.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_EXPR_DEPTH
|
||||
#define SQLITE_MAX_EXPR_DEPTH 1000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The maximum number of terms in a compound SELECT statement.
|
||||
** The code generator for compound SELECT statements does one
|
||||
** level of recursion for each term. A stack overflow can result
|
||||
** if the number of terms is too large. In practice, most SQL
|
||||
** never has more than 3 or 4 terms. Use a value of 0 to disable
|
||||
** any limit on the number of terms in a compount SELECT.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_COMPOUND_SELECT
|
||||
#define SQLITE_MAX_COMPOUND_SELECT 500
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The maximum number of opcodes in a VDBE program.
|
||||
** Not currently enforced.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_VDBE_OP
|
||||
#define SQLITE_MAX_VDBE_OP 250000000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The maximum number of arguments to an SQL function.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_FUNCTION_ARG
|
||||
#define SQLITE_MAX_FUNCTION_ARG 127
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The suggested maximum number of in-memory pages to use for
|
||||
** the main database table and for temporary tables.
|
||||
**
|
||||
** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,
|
||||
** which means the cache size is limited to 2048000 bytes of memory.
|
||||
** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
|
||||
** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
|
||||
*/
|
||||
#ifndef SQLITE_DEFAULT_CACHE_SIZE
|
||||
#define SQLITE_DEFAULT_CACHE_SIZE -2000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The default number of frames to accumulate in the log file before
|
||||
** checkpointing the database in WAL mode.
|
||||
*/
|
||||
#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
|
||||
#define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The maximum number of attached databases. This must be between 0
|
||||
** and 125. The upper bound of 125 is because the attached databases are
|
||||
** counted using a signed 8-bit integer which has a maximum value of 127
|
||||
** and we have to allow 2 extra counts for the "main" and "temp" databases.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_ATTACHED
|
||||
#define SQLITE_MAX_ATTACHED 10
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The maximum value of a ?nnn wildcard that the parser will accept.
|
||||
** If the value exceeds 32767 then extra space is required for the Expr
|
||||
** structure. But otherwise, we believe that the number can be as large
|
||||
** as a signed 32-bit integer can hold.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_VARIABLE_NUMBER
|
||||
#define SQLITE_MAX_VARIABLE_NUMBER 32766
|
||||
#endif
|
||||
|
||||
/* Maximum page size. The upper bound on this value is 65536. This a limit
|
||||
** imposed by the use of 16-bit offsets within each page.
|
||||
**
|
||||
** Earlier versions of SQLite allowed the user to change this value at
|
||||
** compile time. This is no longer permitted, on the grounds that it creates
|
||||
** a library that is technically incompatible with an SQLite library
|
||||
** compiled with a different limit. If a process operating on a database
|
||||
** with a page-size of 65536 bytes crashes, then an instance of SQLite
|
||||
** compiled with the default page-size limit will not be able to rollback
|
||||
** the aborted transaction. This could lead to database corruption.
|
||||
*/
|
||||
#ifdef SQLITE_MAX_PAGE_SIZE
|
||||
#undef SQLITE_MAX_PAGE_SIZE
|
||||
#endif
|
||||
#define SQLITE_MAX_PAGE_SIZE 65536
|
||||
|
||||
/*
|
||||
** The default size of a database page.
|
||||
*/
|
||||
#ifndef SQLITE_DEFAULT_PAGE_SIZE
|
||||
#define SQLITE_DEFAULT_PAGE_SIZE 4096
|
||||
#endif
|
||||
#if SQLITE_DEFAULT_PAGE_SIZE > SQLITE_MAX_PAGE_SIZE
|
||||
#undef SQLITE_DEFAULT_PAGE_SIZE
|
||||
#define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Ordinarily, if no value is explicitly provided, SQLite creates databases
|
||||
** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
|
||||
** device characteristics (sector-size and atomic write() support),
|
||||
** SQLite may choose a larger value. This constant is the maximum value
|
||||
** SQLite will choose on its own.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
|
||||
#define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
|
||||
#endif
|
||||
#if SQLITE_MAX_DEFAULT_PAGE_SIZE > SQLITE_MAX_PAGE_SIZE
|
||||
#undef SQLITE_MAX_DEFAULT_PAGE_SIZE
|
||||
#define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Maximum number of pages in one database file.
|
||||
**
|
||||
** This is really just the default value for the max_page_count pragma.
|
||||
** This value can be lowered (or raised) at run-time using that the
|
||||
** max_page_count macro.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_PAGE_COUNT
|
||||
#define SQLITE_MAX_PAGE_COUNT 1073741823
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Maximum length (in bytes) of the pattern in a LIKE or GLOB
|
||||
** operator.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
|
||||
#define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Maximum depth of recursion for triggers.
|
||||
**
|
||||
** A value of 1 means that a trigger program will not be able to itself
|
||||
** fire any triggers. A value of 0 means that no trigger programs at all
|
||||
** may be executed.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_TRIGGER_DEPTH
|
||||
#define SQLITE_MAX_TRIGGER_DEPTH 1000
|
||||
#endif
|
132
third_party/sqlite3/headers/test_intarray.h
vendored
Normal file
132
third_party/sqlite3/headers/test_intarray.h
vendored
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
** 2009 November 10
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This is the C-language interface definition for the "intarray" or
|
||||
** integer array virtual table for SQLite.
|
||||
**
|
||||
** This virtual table is used for internal testing of SQLite only. It is
|
||||
** not recommended for use in production. For a similar virtual table that
|
||||
** is production-ready, see the "carray" virtual table over in ext/misc.
|
||||
**
|
||||
** The intarray virtual table is designed to facilitate using an
|
||||
** array of integers as the right-hand side of an IN operator. So
|
||||
** instead of doing a prepared statement like this:
|
||||
**
|
||||
** SELECT * FROM table WHERE x IN (?,?,?,...,?);
|
||||
**
|
||||
** And then binding indivdual integers to each of ? slots, a C-language
|
||||
** application can create an intarray object (named "ex1" in the following
|
||||
** example), prepare a statement like this:
|
||||
**
|
||||
** SELECT * FROM table WHERE x IN ex1;
|
||||
**
|
||||
** Then bind an ordinary C/C++ array of integer values to the ex1 object
|
||||
** to run the statement.
|
||||
**
|
||||
** USAGE:
|
||||
**
|
||||
** One or more intarray objects can be created as follows:
|
||||
**
|
||||
** sqlite3_intarray *p1, *p2, *p3;
|
||||
** sqlite3_intarray_create(db, "ex1", &p1);
|
||||
** sqlite3_intarray_create(db, "ex2", &p2);
|
||||
** sqlite3_intarray_create(db, "ex3", &p3);
|
||||
**
|
||||
** Each call to sqlite3_intarray_create() generates a new virtual table
|
||||
** module and a singleton of that virtual table module in the TEMP
|
||||
** database. Both the module and the virtual table instance use the
|
||||
** name given by the second parameter. The virtual tables can then be
|
||||
** used in prepared statements:
|
||||
**
|
||||
** SELECT * FROM t1, t2, t3
|
||||
** WHERE t1.x IN ex1
|
||||
** AND t2.y IN ex2
|
||||
** AND t3.z IN ex3;
|
||||
**
|
||||
** Each integer array is initially empty. New arrays can be bound to
|
||||
** an integer array as follows:
|
||||
**
|
||||
** sqlite3_int64 a1[] = { 1, 2, 3, 4 };
|
||||
** sqlite3_int64 a2[] = { 5, 6, 7, 8, 9, 10, 11 };
|
||||
** sqlite3_int64 *a3 = sqlite3_malloc( 100*sizeof(sqlite3_int64) );
|
||||
** // Fill in content of a3[]
|
||||
** sqlite3_intarray_bind(p1, 4, a1, 0);
|
||||
** sqlite3_intarray_bind(p2, 7, a2, 0);
|
||||
** sqlite3_intarray_bind(p3, 100, a3, sqlite3_free);
|
||||
**
|
||||
** A single intarray object can be rebound multiple times. But do not
|
||||
** attempt to change the bindings of an intarray while it is in the middle
|
||||
** of a query.
|
||||
**
|
||||
** The array that holds the integers is automatically freed by the function
|
||||
** in the fourth parameter to sqlite3_intarray_bind() when the array is no
|
||||
** longer needed. The application must not change the intarray values
|
||||
** while an intarray is in the middle of a query.
|
||||
**
|
||||
** The intarray object is automatically destroyed when its corresponding
|
||||
** virtual table is dropped. Since the virtual tables are created in the
|
||||
** TEMP database, they are automatically dropped when the database connection
|
||||
** closes so the application does not normally need to take any special
|
||||
** action to free the intarray objects. Because of the way virtual tables
|
||||
** work and the (somewhat goofy) way that the intarray virtual table is
|
||||
** implemented, it is not allowed to invoke sqlite3_intarray_create(D,N,P)
|
||||
** more than once with the same D and N values.
|
||||
*/
|
||||
#include "sqlite3.h"
|
||||
#ifndef SQLITE_INTARRAY_H
|
||||
#define SQLITE_INTARRAY_H
|
||||
|
||||
/*
|
||||
** Make sure we can call this stuff from C++.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** An sqlite3_intarray is an abstract type to stores an instance of
|
||||
** an integer array.
|
||||
*/
|
||||
typedef struct sqlite3_intarray sqlite3_intarray;
|
||||
|
||||
/*
|
||||
** Invoke this routine to create a specific instance of an intarray object.
|
||||
** The new intarray object is returned by the 3rd parameter.
|
||||
**
|
||||
** Each intarray object corresponds to a virtual table in the TEMP table
|
||||
** with a name of zName.
|
||||
**
|
||||
** Destroy the intarray object by dropping the virtual table. If not done
|
||||
** explicitly by the application, the virtual table will be dropped implicitly
|
||||
** by the system when the database connection is closed.
|
||||
*/
|
||||
SQLITE_API int sqlite3_intarray_create(sqlite3 *db, const char *zName,
|
||||
sqlite3_intarray **ppReturn);
|
||||
|
||||
/*
|
||||
** Bind a new array array of integers to a specific intarray object.
|
||||
**
|
||||
** The array of integers bound must be unchanged for the duration of
|
||||
** any query against the corresponding virtual table. If the integer
|
||||
** array does change or is deallocated undefined behavior will result.
|
||||
*/
|
||||
SQLITE_API int sqlite3_intarray_bind(
|
||||
sqlite3_intarray *pIntArray, /* The intarray object to bind to */
|
||||
int nElements, /* Number of elements in the intarray */
|
||||
sqlite3_int64 *aElements, /* Content of the intarray */
|
||||
void (*xFree)(void *) /* How to dispose of the intarray when done */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* End of the 'extern "C"' block */
|
||||
#endif
|
||||
#endif /* SQLITE_INTARRAY_H */
|
101
third_party/sqlite3/headers/test_multiplex.h
vendored
Normal file
101
third_party/sqlite3/headers/test_multiplex.h
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
** 2011 March 18
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This file contains a VFS "shim" - a layer that sits in between the
|
||||
** pager and the real VFS.
|
||||
**
|
||||
** This particular shim enforces a multiplex system on DB files.
|
||||
** This shim shards/partitions a single DB file into smaller
|
||||
** "chunks" such that the total DB file size may exceed the maximum
|
||||
** file size of the underlying file system.
|
||||
**
|
||||
*/
|
||||
|
||||
#ifndef SQLITE_TEST_MULTIPLEX_H
|
||||
#define SQLITE_TEST_MULTIPLEX_H
|
||||
|
||||
/*
|
||||
** CAPI: File-control Operations Supported by Multiplex VFS
|
||||
**
|
||||
** Values interpreted by the xFileControl method of a Multiplex VFS db
|
||||
*file-handle.
|
||||
**
|
||||
** MULTIPLEX_CTRL_ENABLE:
|
||||
** This file control is used to enable or disable the multiplex
|
||||
** shim.
|
||||
**
|
||||
** MULTIPLEX_CTRL_SET_CHUNK_SIZE:
|
||||
** This file control is used to set the maximum allowed chunk
|
||||
** size for a multiplex file set. The chunk size should be
|
||||
** a multiple of SQLITE_MAX_PAGE_SIZE, and will be rounded up
|
||||
** if not.
|
||||
**
|
||||
** MULTIPLEX_CTRL_SET_MAX_CHUNKS:
|
||||
** This file control is used to set the maximum number of chunks
|
||||
** allowed to be used for a mutliplex file set.
|
||||
*/
|
||||
#define MULTIPLEX_CTRL_ENABLE 214014
|
||||
#define MULTIPLEX_CTRL_SET_CHUNK_SIZE 214015
|
||||
#define MULTIPLEX_CTRL_SET_MAX_CHUNKS 214016
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** CAPI: Initialize the multiplex VFS shim - sqlite3_multiplex_initialize()
|
||||
**
|
||||
** Use the VFS named zOrigVfsName as the VFS that does the actual work.
|
||||
** Use the default if zOrigVfsName==NULL.
|
||||
**
|
||||
** The multiplex VFS shim is named "multiplex". It will become the default
|
||||
** VFS if makeDefault is non-zero.
|
||||
**
|
||||
** An auto-extension is registered which will make the function
|
||||
** multiplex_control() available to database connections. This
|
||||
** function gives access to the xFileControl interface of the
|
||||
** multiplex VFS shim.
|
||||
**
|
||||
** SELECT multiplex_control(<op>,<val>);
|
||||
**
|
||||
** <op>=1 MULTIPLEX_CTRL_ENABLE
|
||||
** <val>=0 disable
|
||||
** <val>=1 enable
|
||||
**
|
||||
** <op>=2 MULTIPLEX_CTRL_SET_CHUNK_SIZE
|
||||
** <val> int, chunk size
|
||||
**
|
||||
** <op>=3 MULTIPLEX_CTRL_SET_MAX_CHUNKS
|
||||
** <val> int, max chunks
|
||||
**
|
||||
** THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once
|
||||
** during start-up.
|
||||
*/
|
||||
extern int sqlite3_multiplex_initialize(const char *zOrigVfsName,
|
||||
int makeDefault);
|
||||
|
||||
/*
|
||||
** CAPI: Shutdown the multiplex system - sqlite3_multiplex_shutdown()
|
||||
**
|
||||
** All SQLite database connections must be closed before calling this
|
||||
** routine.
|
||||
**
|
||||
** THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once while
|
||||
** shutting down in order to free all remaining multiplex groups.
|
||||
*/
|
||||
extern int sqlite3_multiplex_shutdown(int eForce);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* End of the 'extern "C"' block */
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_TEST_MULTIPLEX_H */
|
271
third_party/sqlite3/headers/test_quota.h
vendored
Normal file
271
third_party/sqlite3/headers/test_quota.h
vendored
Normal file
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
** 2011 December 1
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This file contains the interface definition for the quota a VFS shim.
|
||||
**
|
||||
** This particular shim enforces a quota system on files. One or more
|
||||
** database files are in a "quota group" that is defined by a GLOB
|
||||
** pattern. A quota is set for the combined size of all files in the
|
||||
** the group. A quota of zero means "no limit". If the total size
|
||||
** of all files in the quota group is greater than the limit, then
|
||||
** write requests that attempt to enlarge a file fail with SQLITE_FULL.
|
||||
**
|
||||
** However, before returning SQLITE_FULL, the write requests invoke
|
||||
** a callback function that is configurable for each quota group.
|
||||
** This callback has the opportunity to enlarge the quota. If the
|
||||
** callback does enlarge the quota such that the total size of all
|
||||
** files within the group is less than the new quota, then the write
|
||||
** continues as if nothing had happened.
|
||||
*/
|
||||
#ifndef _QUOTA_H_
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "sqlite3.h"
|
||||
|
||||
/* Make this callable from C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Initialize the quota VFS shim. Use the VFS named zOrigVfsName
|
||||
** as the VFS that does the actual work. Use the default if
|
||||
** zOrigVfsName==NULL.
|
||||
**
|
||||
** The quota VFS shim is named "quota". It will become the default
|
||||
** VFS if makeDefault is non-zero.
|
||||
**
|
||||
** THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once
|
||||
** during start-up.
|
||||
*/
|
||||
int sqlite3_quota_initialize(const char *zOrigVfsName, int makeDefault);
|
||||
|
||||
/*
|
||||
** Shutdown the quota system.
|
||||
**
|
||||
** All SQLite database connections must be closed before calling this
|
||||
** routine.
|
||||
**
|
||||
** THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once while
|
||||
** shutting down in order to free all remaining quota groups.
|
||||
*/
|
||||
int sqlite3_quota_shutdown(void);
|
||||
|
||||
/*
|
||||
** Create or destroy a quota group.
|
||||
**
|
||||
** The quota group is defined by the zPattern. When calling this routine
|
||||
** with a zPattern for a quota group that already exists, this routine
|
||||
** merely updates the iLimit, xCallback, and pArg values for that quota
|
||||
** group. If zPattern is new, then a new quota group is created.
|
||||
**
|
||||
** The zPattern is always compared against the full pathname of the file.
|
||||
** Even if APIs are called with relative pathnames, SQLite converts the
|
||||
** name to a full pathname before comparing it against zPattern. zPattern
|
||||
** is a glob pattern with the following matching rules:
|
||||
**
|
||||
** '*' Matches any sequence of zero or more characters.
|
||||
**
|
||||
** '?' Matches exactly one character.
|
||||
**
|
||||
** [...] Matches one character from the enclosed list of
|
||||
** characters. "]" can be part of the list if it is
|
||||
** the first character. Within the list "X-Y" matches
|
||||
** characters X or Y or any character in between the
|
||||
** two. Ex: "[0-9]" matches any digit.
|
||||
**
|
||||
** [^...] Matches one character not in the enclosed list.
|
||||
**
|
||||
** / Matches either / or \. This allows glob patterns
|
||||
** containing / to work on both unix and windows.
|
||||
**
|
||||
** Note that, unlike unix shell globbing, the directory separator "/"
|
||||
** can match a wildcard. So, for example, the pattern "/abc/xyz/" "*"
|
||||
** matches any files anywhere in the directory hierarchy beneath
|
||||
** /abc/xyz.
|
||||
**
|
||||
** The glob algorithm works on bytes. Multi-byte UTF8 characters are
|
||||
** matched as if each byte were a separate character.
|
||||
**
|
||||
** If the iLimit for a quota group is set to zero, then the quota group
|
||||
** is disabled and will be deleted when the last database connection using
|
||||
** the quota group is closed.
|
||||
**
|
||||
** Calling this routine on a zPattern that does not exist and with a
|
||||
** zero iLimit is a no-op.
|
||||
**
|
||||
** A quota group must exist with a non-zero iLimit prior to opening
|
||||
** database connections if those connections are to participate in the
|
||||
** quota group. Creating a quota group does not affect database connections
|
||||
** that are already open.
|
||||
**
|
||||
** The patterns that define the various quota groups should be distinct.
|
||||
** If the same filename matches more than one quota group pattern, then
|
||||
** the behavior of this package is undefined.
|
||||
*/
|
||||
int sqlite3_quota_set(
|
||||
const char *zPattern, /* The filename pattern */
|
||||
sqlite3_int64 iLimit, /* New quota to set for this quota group */
|
||||
void (*xCallback)( /* Callback invoked when going over quota */
|
||||
const char
|
||||
*zFilename, /* Name of file whose size increases */
|
||||
sqlite3_int64 *piLimit, /* IN/OUT: The current limit */
|
||||
sqlite3_int64
|
||||
iSize, /* Total size of all files in the group */
|
||||
void *pArg /* Client data */
|
||||
),
|
||||
void *pArg, /* client data passed thru to callback */
|
||||
void (*xDestroy)(void *) /* Optional destructor for pArg */
|
||||
);
|
||||
|
||||
/*
|
||||
** Bring the named file under quota management, assuming its name matches
|
||||
** the glob pattern of some quota group. Or if it is already under
|
||||
** management, update its size. If zFilename does not match the glob
|
||||
** pattern of any quota group, this routine is a no-op.
|
||||
*/
|
||||
int sqlite3_quota_file(const char *zFilename);
|
||||
|
||||
/*
|
||||
** The following object serves the same role as FILE in the standard C
|
||||
** library. It represents an open connection to a file on disk for I/O.
|
||||
**
|
||||
** A single quota_FILE should not be used by two or more threads at the
|
||||
** same time. Multiple threads can be using different quota_FILE objects
|
||||
** simultaneously, but not the same quota_FILE object.
|
||||
*/
|
||||
typedef struct quota_FILE quota_FILE;
|
||||
|
||||
/*
|
||||
** Create a new quota_FILE object used to read and/or write to the
|
||||
** file zFilename. The zMode parameter is as with standard library zMode.
|
||||
*/
|
||||
quota_FILE *sqlite3_quota_fopen(const char *zFilename, const char *zMode);
|
||||
|
||||
/*
|
||||
** Perform I/O against a quota_FILE object. When doing writes, the
|
||||
** quota mechanism may result in a short write, in order to prevent
|
||||
** the sum of sizes of all files from going over quota.
|
||||
*/
|
||||
size_t sqlite3_quota_fread(void *, size_t, size_t, quota_FILE *);
|
||||
size_t sqlite3_quota_fwrite(const void *, size_t, size_t, quota_FILE *);
|
||||
|
||||
/*
|
||||
** Flush all written content held in memory buffers out to disk.
|
||||
** This is the equivalent of fflush() in the standard library.
|
||||
**
|
||||
** If the hardSync parameter is true (non-zero) then this routine
|
||||
** also forces OS buffers to disk - the equivalent of fsync().
|
||||
**
|
||||
** This routine return zero on success and non-zero if something goes
|
||||
** wrong.
|
||||
*/
|
||||
int sqlite3_quota_fflush(quota_FILE *, int hardSync);
|
||||
|
||||
/*
|
||||
** Close a quota_FILE object and free all associated resources. The
|
||||
** file remains under quota management.
|
||||
*/
|
||||
int sqlite3_quota_fclose(quota_FILE *);
|
||||
|
||||
/*
|
||||
** Move the read/write pointer for a quota_FILE object. Or tell the
|
||||
** current location of the read/write pointer.
|
||||
*/
|
||||
int sqlite3_quota_fseek(quota_FILE *, long, int);
|
||||
void sqlite3_quota_rewind(quota_FILE *);
|
||||
long sqlite3_quota_ftell(quota_FILE *);
|
||||
|
||||
/*
|
||||
** Test the error indicator for the given file.
|
||||
**
|
||||
** Return non-zero if the error indicator is set.
|
||||
*/
|
||||
int sqlite3_quota_ferror(quota_FILE *);
|
||||
|
||||
/*
|
||||
** Truncate a file previously opened by sqlite3_quota_fopen(). Return
|
||||
** zero on success and non-zero on any kind of failure.
|
||||
**
|
||||
** The newSize argument must be less than or equal to the current file size.
|
||||
** Any attempt to "truncate" a file to a larger size results in
|
||||
** undefined behavior.
|
||||
*/
|
||||
int sqlite3_quota_ftruncate(quota_FILE *, sqlite3_int64 newSize);
|
||||
|
||||
/*
|
||||
** Return the last modification time of the opened file, in seconds
|
||||
** since 1970.
|
||||
*/
|
||||
int sqlite3_quota_file_mtime(quota_FILE *, time_t *pTime);
|
||||
|
||||
/*
|
||||
** Return the size of the file as it is known to the quota system.
|
||||
**
|
||||
** This size might be different from the true size of the file on
|
||||
** disk if some outside process has modified the file without using the
|
||||
** quota mechanism, or if calls to sqlite3_quota_fwrite() have occurred
|
||||
** which have increased the file size, but those writes have not yet been
|
||||
** forced to disk using sqlite3_quota_fflush().
|
||||
**
|
||||
** Return -1 if the file is not participating in quota management.
|
||||
*/
|
||||
sqlite3_int64 sqlite3_quota_file_size(quota_FILE *);
|
||||
|
||||
/*
|
||||
** Return the true size of the file.
|
||||
**
|
||||
** The true size should be the same as the size of the file as known
|
||||
** to the quota system, however the sizes might be different if the
|
||||
** file has been extended or truncated via some outside process or if
|
||||
** pending writes have not yet been flushed to disk.
|
||||
**
|
||||
** Return -1 if the file does not exist or if the size of the file
|
||||
** cannot be determined for some reason.
|
||||
*/
|
||||
sqlite3_int64 sqlite3_quota_file_truesize(quota_FILE *);
|
||||
|
||||
/*
|
||||
** Determine the amount of data in bytes available for reading
|
||||
** in the given file.
|
||||
**
|
||||
** Return -1 if the amount cannot be determined for some reason.
|
||||
*/
|
||||
long sqlite3_quota_file_available(quota_FILE *);
|
||||
|
||||
/*
|
||||
** Delete a file from the disk, if that file is under quota management.
|
||||
** Adjust quotas accordingly.
|
||||
**
|
||||
** If zFilename is the name of a directory that matches one of the
|
||||
** quota glob patterns, then all files under quota management that
|
||||
** are contained within that directory are deleted.
|
||||
**
|
||||
** A standard SQLite result code is returned (SQLITE_OK, SQLITE_NOMEM, etc.)
|
||||
** When deleting a directory of files, if the deletion of any one
|
||||
** file fails (for example due to an I/O error), then this routine
|
||||
** returns immediately, with the error code, and does not try to
|
||||
** delete any of the other files in the specified directory.
|
||||
**
|
||||
** All files are removed from quota management and deleted from disk.
|
||||
** However, no attempt is made to remove empty directories.
|
||||
**
|
||||
** This routine is a no-op for files that are not under quota management.
|
||||
*/
|
||||
int sqlite3_quota_remove(const char *zFilename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of the 'extern "C"' block */
|
||||
#endif
|
||||
#endif /* _QUOTA_H_ */
|
160
third_party/sqlite3/headers/test_windirent.h
vendored
Normal file
160
third_party/sqlite3/headers/test_windirent.h
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
** 2015 November 30
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file contains declarations for most of the opendir() family of
|
||||
** POSIX functions on Win32 using the MSVCRT.
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H)
|
||||
#define SQLITE_WINDIRENT_H
|
||||
|
||||
/*
|
||||
** We need several data types from the Windows SDK header.
|
||||
*/
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
/*
|
||||
** We need several support functions from the SQLite core.
|
||||
*/
|
||||
|
||||
#include "sqlite3.h"
|
||||
|
||||
/*
|
||||
** We need several things from the ANSI and MSVCRT headers.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
** We may need several defines that should have been in "sys/stat.h".
|
||||
*/
|
||||
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISLNK
|
||||
#define S_ISLNK(mode) (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** We may need to provide the "mode_t" type.
|
||||
*/
|
||||
|
||||
#ifndef MODE_T_DEFINED
|
||||
#define MODE_T_DEFINED
|
||||
typedef unsigned short mode_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
** We may need to provide the "ino_t" type.
|
||||
*/
|
||||
|
||||
#ifndef INO_T_DEFINED
|
||||
#define INO_T_DEFINED
|
||||
typedef unsigned short ino_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
** We need to define "NAME_MAX" if it was not present in "limits.h".
|
||||
*/
|
||||
|
||||
#ifndef NAME_MAX
|
||||
#ifdef FILENAME_MAX
|
||||
#define NAME_MAX (FILENAME_MAX)
|
||||
#else
|
||||
#define NAME_MAX (260)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
|
||||
*/
|
||||
|
||||
#ifndef NULL_INTPTR_T
|
||||
#define NULL_INTPTR_T ((intptr_t)(0))
|
||||
#endif
|
||||
|
||||
#ifndef BAD_INTPTR_T
|
||||
#define BAD_INTPTR_T ((intptr_t)(-1))
|
||||
#endif
|
||||
|
||||
/*
|
||||
** We need to provide the necessary structures and related types.
|
||||
*/
|
||||
|
||||
#ifndef DIRENT_DEFINED
|
||||
#define DIRENT_DEFINED
|
||||
typedef struct DIRENT DIRENT;
|
||||
typedef DIRENT *LPDIRENT;
|
||||
struct DIRENT {
|
||||
ino_t d_ino; /* Sequence number, do not use. */
|
||||
unsigned d_attributes; /* Win32 file attributes. */
|
||||
char d_name[NAME_MAX + 1]; /* Name within the directory. */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef DIR_DEFINED
|
||||
#define DIR_DEFINED
|
||||
typedef struct DIR DIR;
|
||||
typedef DIR *LPDIR;
|
||||
struct DIR {
|
||||
intptr_t d_handle; /* Value returned by "_findfirst". */
|
||||
DIRENT d_first; /* DIRENT constructed based on "_findfirst". */
|
||||
DIRENT d_next; /* DIRENT constructed based on "_findnext". */
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Provide a macro, for use by the implementation, to determine if a
|
||||
** particular directory entry should be skipped over when searching for
|
||||
** the next directory entry that should be returned by the readdir() or
|
||||
** readdir_r() functions.
|
||||
*/
|
||||
|
||||
#ifndef is_filtered
|
||||
#define is_filtered(a) \
|
||||
((((a).attrib) & _A_HIDDEN) || (((a).attrib) & _A_SYSTEM))
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Provide the function prototype for the POSIX compatiable getenv()
|
||||
** function. This function is not thread-safe.
|
||||
*/
|
||||
|
||||
extern const char *windirent_getenv(const char *name);
|
||||
|
||||
/*
|
||||
** Finally, we can provide the function prototypes for the opendir(),
|
||||
** readdir(), readdir_r(), and closedir() POSIX functions.
|
||||
*/
|
||||
|
||||
extern LPDIR opendir(const char *dirname);
|
||||
extern LPDIRENT readdir(LPDIR dirp);
|
||||
extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);
|
||||
extern INT closedir(LPDIR dirp);
|
||||
|
||||
#endif /* defined(WIN32) && defined(_MSC_VER) */
|
397
third_party/sqlite3/headers/vdbe.h
vendored
Normal file
397
third_party/sqlite3/headers/vdbe.h
vendored
Normal file
|
@ -0,0 +1,397 @@
|
|||
/*
|
||||
** 2001 September 15
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** Header file for the Virtual DataBase Engine (VDBE)
|
||||
**
|
||||
** This header defines the interface to the virtual database engine
|
||||
** or VDBE. The VDBE implements an abstract machine that runs a
|
||||
** simple program to access and modify the underlying database.
|
||||
*/
|
||||
#ifndef SQLITE_VDBE_H
|
||||
#define SQLITE_VDBE_H
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
** A single VDBE is an opaque structure named "Vdbe". Only routines
|
||||
** in the source file sqliteVdbe.c are allowed to see the insides
|
||||
** of this structure.
|
||||
*/
|
||||
typedef struct Vdbe Vdbe;
|
||||
|
||||
/*
|
||||
** The names of the following types declared in vdbeInt.h are required
|
||||
** for the VdbeOp definition.
|
||||
*/
|
||||
typedef struct sqlite3_value Mem;
|
||||
typedef struct SubProgram SubProgram;
|
||||
|
||||
/*
|
||||
** A single instruction of the virtual machine has an opcode
|
||||
** and as many as three operands. The instruction is recorded
|
||||
** as an instance of the following structure:
|
||||
*/
|
||||
struct VdbeOp {
|
||||
u8 opcode; /* What operation to perform */
|
||||
signed char p4type; /* One of the P4_xxx constants for p4 */
|
||||
u16 p5; /* Fifth parameter is an unsigned 16-bit integer */
|
||||
int p1; /* First operand */
|
||||
int p2; /* Second parameter (often the jump destination) */
|
||||
int p3; /* The third parameter */
|
||||
union p4union { /* fourth parameter */
|
||||
int i; /* Integer value if p4type==P4_INT32 */
|
||||
void *p; /* Generic pointer */
|
||||
char *z; /* Pointer to data for string (char array) types */
|
||||
i64 *pI64; /* Used when p4type is P4_INT64 */
|
||||
double *pReal; /* Used when p4type is P4_REAL */
|
||||
FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
|
||||
sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */
|
||||
CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
|
||||
Mem *pMem; /* Used when p4type is P4_MEM */
|
||||
VTable *pVtab; /* Used when p4type is P4_VTAB */
|
||||
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
|
||||
u32 *ai; /* Used when p4type is P4_INTARRAY */
|
||||
SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
|
||||
Table *pTab; /* Used when p4type is P4_TABLE */
|
||||
#ifdef SQLITE_ENABLE_CURSOR_HINTS
|
||||
Expr *pExpr; /* Used when p4type is P4_EXPR */
|
||||
#endif
|
||||
int (*xAdvance)(BtCursor *, int);
|
||||
} p4;
|
||||
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
|
||||
char *zComment; /* Comment to improve readability */
|
||||
#endif
|
||||
#ifdef VDBE_PROFILE
|
||||
u32 cnt; /* Number of times this instruction was executed */
|
||||
u64 cycles; /* Total time spent executing this instruction */
|
||||
#endif
|
||||
#ifdef SQLITE_VDBE_COVERAGE
|
||||
u32 iSrcLine; /* Source-code line that generated this opcode
|
||||
** with flags in the upper 8 bits */
|
||||
#endif
|
||||
};
|
||||
typedef struct VdbeOp VdbeOp;
|
||||
|
||||
/*
|
||||
** A sub-routine used to implement a trigger program.
|
||||
*/
|
||||
struct SubProgram {
|
||||
VdbeOp *aOp; /* Array of opcodes for sub-program */
|
||||
int nOp; /* Elements in aOp[] */
|
||||
int nMem; /* Number of memory cells required */
|
||||
int nCsr; /* Number of cursors required */
|
||||
u8 *aOnce; /* Array of OP_Once flags */
|
||||
void *token; /* id that may be used to recursive triggers */
|
||||
SubProgram *pNext; /* Next sub-program already visited */
|
||||
};
|
||||
|
||||
/*
|
||||
** A smaller version of VdbeOp used for the VdbeAddOpList() function because
|
||||
** it takes up less space.
|
||||
*/
|
||||
struct VdbeOpList {
|
||||
u8 opcode; /* What operation to perform */
|
||||
signed char p1; /* First operand */
|
||||
signed char p2; /* Second parameter (often the jump destination) */
|
||||
signed char p3; /* Third parameter */
|
||||
};
|
||||
typedef struct VdbeOpList VdbeOpList;
|
||||
|
||||
/*
|
||||
** Allowed values of VdbeOp.p4type
|
||||
*/
|
||||
#define P4_NOTUSED 0 /* The P4 parameter is not used */
|
||||
#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
|
||||
#define P4_STATIC (-1) /* Pointer to a static string */
|
||||
#define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
|
||||
#define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
|
||||
#define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
|
||||
#define P4_ADVANCE (-5) /* P4 is a pointer to BtreeNext() or BtreePrev() */
|
||||
#define P4_TABLE (-6) /* P4 is a pointer to a Table structure */
|
||||
/* Above do not own any resources. Must free those below */
|
||||
#define P4_FREE_IF_LE (-7)
|
||||
#define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */
|
||||
#define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */
|
||||
#define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */
|
||||
#define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */
|
||||
#define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */
|
||||
#define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */
|
||||
#define P4_REAL (-13) /* P4 is a 64-bit floating point value */
|
||||
#define P4_INT64 (-14) /* P4 is a 64-bit signed integer */
|
||||
#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
|
||||
#define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
|
||||
#define P4_DYNBLOB (-17) /* Pointer to memory from sqliteMalloc() */
|
||||
|
||||
/* Error message codes for OP_Halt */
|
||||
#define P5_ConstraintNotNull 1
|
||||
#define P5_ConstraintUnique 2
|
||||
#define P5_ConstraintCheck 3
|
||||
#define P5_ConstraintFK 4
|
||||
|
||||
/*
|
||||
** The Vdbe.aColName array contains 5n Mem structures, where n is the
|
||||
** number of columns of data returned by the statement.
|
||||
*/
|
||||
#define COLNAME_NAME 0
|
||||
#define COLNAME_DECLTYPE 1
|
||||
#define COLNAME_DATABASE 2
|
||||
#define COLNAME_TABLE 3
|
||||
#define COLNAME_COLUMN 4
|
||||
#ifdef SQLITE_ENABLE_COLUMN_METADATA
|
||||
#define COLNAME_N 5 /* Number of COLNAME_xxx symbols */
|
||||
#else
|
||||
#ifdef SQLITE_OMIT_DECLTYPE
|
||||
#define COLNAME_N 1 /* Store only the name */
|
||||
#else
|
||||
#define COLNAME_N 2 /* Store the name and decltype */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The following macro converts a label returned by sqlite3VdbeMakeLabel()
|
||||
** into an index into the Parse.aLabel[] array that contains the resolved
|
||||
** address of that label.
|
||||
*/
|
||||
#define ADDR(X) (~(X))
|
||||
|
||||
/*
|
||||
** The makefile scans the vdbe.c source file and creates the "opcodes.h"
|
||||
** header file that defines a number for each opcode used by the VDBE.
|
||||
*/
|
||||
#include "opcodes.h"
|
||||
|
||||
/*
|
||||
** Additional non-public SQLITE_PREPARE_* flags
|
||||
*/
|
||||
#define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */
|
||||
#define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */
|
||||
|
||||
/*
|
||||
** Prototypes for the VDBE interface. See comments on the implementation
|
||||
** for a description of what each of these routines does.
|
||||
*/
|
||||
Vdbe *sqlite3VdbeCreate(Parse *);
|
||||
Parse *sqlite3VdbeParser(Vdbe *);
|
||||
int sqlite3VdbeAddOp0(Vdbe *, int);
|
||||
int sqlite3VdbeAddOp1(Vdbe *, int, int);
|
||||
int sqlite3VdbeAddOp2(Vdbe *, int, int, int);
|
||||
int sqlite3VdbeGoto(Vdbe *, int);
|
||||
int sqlite3VdbeLoadString(Vdbe *, int, const char *);
|
||||
void sqlite3VdbeMultiLoad(Vdbe *, int, const char *, ...);
|
||||
int sqlite3VdbeAddOp3(Vdbe *, int, int, int, int);
|
||||
int sqlite3VdbeAddOp4(Vdbe *, int, int, int, int, const char *zP4, int);
|
||||
int sqlite3VdbeAddOp4Dup8(Vdbe *, int, int, int, int, const u8 *, int);
|
||||
int sqlite3VdbeAddOp4Int(Vdbe *, int, int, int, int, int);
|
||||
int sqlite3VdbeAddFunctionCall(Parse *, int, int, int, int, const FuncDef *,
|
||||
int);
|
||||
void sqlite3VdbeEndCoroutine(Vdbe *, int);
|
||||
#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
|
||||
void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
|
||||
void sqlite3VdbeVerifyNoResultRow(Vdbe *p);
|
||||
#else
|
||||
#define sqlite3VdbeVerifyNoMallocRequired(A, B)
|
||||
#define sqlite3VdbeVerifyNoResultRow(A)
|
||||
#endif
|
||||
#if defined(SQLITE_DEBUG)
|
||||
void sqlite3VdbeVerifyAbortable(Vdbe *p, int);
|
||||
#else
|
||||
#define sqlite3VdbeVerifyAbortable(A, B)
|
||||
#endif
|
||||
VdbeOp *sqlite3VdbeAddOpList(Vdbe *, int nOp, VdbeOpList const *aOp,
|
||||
int iLineno);
|
||||
#ifndef SQLITE_OMIT_EXPLAIN
|
||||
void sqlite3VdbeExplain(Parse *, u8, const char *, ...);
|
||||
void sqlite3VdbeExplainPop(Parse *);
|
||||
int sqlite3VdbeExplainParent(Parse *);
|
||||
#define ExplainQueryPlan(P) sqlite3VdbeExplain P
|
||||
#define ExplainQueryPlanPop(P) sqlite3VdbeExplainPop(P)
|
||||
#define ExplainQueryPlanParent(P) sqlite3VdbeExplainParent(P)
|
||||
#else
|
||||
#define ExplainQueryPlan(P)
|
||||
#define ExplainQueryPlanPop(P)
|
||||
#define ExplainQueryPlanParent(P) 0
|
||||
#define sqlite3ExplainBreakpoint(A, B) /*no-op*/
|
||||
#endif
|
||||
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
|
||||
void sqlite3ExplainBreakpoint(const char *, const char *);
|
||||
#else
|
||||
#define sqlite3ExplainBreakpoint(A, B) /*no-op*/
|
||||
#endif
|
||||
void sqlite3VdbeAddParseSchemaOp(Vdbe *, int, char *, u16);
|
||||
void sqlite3VdbeChangeOpcode(Vdbe *, int addr, u8);
|
||||
void sqlite3VdbeChangeP1(Vdbe *, int addr, int P1);
|
||||
void sqlite3VdbeChangeP2(Vdbe *, int addr, int P2);
|
||||
void sqlite3VdbeChangeP3(Vdbe *, int addr, int P3);
|
||||
void sqlite3VdbeChangeP5(Vdbe *, u16 P5);
|
||||
void sqlite3VdbeJumpHere(Vdbe *, int addr);
|
||||
void sqlite3VdbeJumpHereOrPopInst(Vdbe *, int addr);
|
||||
int sqlite3VdbeChangeToNoop(Vdbe *, int addr);
|
||||
int sqlite3VdbeDeletePriorOpcode(Vdbe *, u8 op);
|
||||
#ifdef SQLITE_DEBUG
|
||||
void sqlite3VdbeReleaseRegisters(Parse *, int addr, int n, u32 mask, int);
|
||||
#else
|
||||
#define sqlite3VdbeReleaseRegisters(P, A, N, M, F)
|
||||
#endif
|
||||
void sqlite3VdbeChangeP4(Vdbe *, int addr, const char *zP4, int N);
|
||||
void sqlite3VdbeAppendP4(Vdbe *, void *pP4, int p4type);
|
||||
void sqlite3VdbeSetP4KeyInfo(Parse *, Index *);
|
||||
void sqlite3VdbeUsesBtree(Vdbe *, int);
|
||||
VdbeOp *sqlite3VdbeGetOp(Vdbe *, int);
|
||||
int sqlite3VdbeMakeLabel(Parse *);
|
||||
void sqlite3VdbeRunOnlyOnce(Vdbe *);
|
||||
void sqlite3VdbeReusable(Vdbe *);
|
||||
void sqlite3VdbeDelete(Vdbe *);
|
||||
void sqlite3VdbeClearObject(sqlite3 *, Vdbe *);
|
||||
void sqlite3VdbeMakeReady(Vdbe *, Parse *);
|
||||
int sqlite3VdbeFinalize(Vdbe *);
|
||||
void sqlite3VdbeResolveLabel(Vdbe *, int);
|
||||
int sqlite3VdbeCurrentAddr(Vdbe *);
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3VdbeAssertMayAbort(Vdbe *, int);
|
||||
#endif
|
||||
void sqlite3VdbeResetStepResult(Vdbe *);
|
||||
void sqlite3VdbeRewind(Vdbe *);
|
||||
int sqlite3VdbeReset(Vdbe *);
|
||||
void sqlite3VdbeSetNumCols(Vdbe *, int);
|
||||
int sqlite3VdbeSetColName(Vdbe *, int, int, const char *, void (*)(void *));
|
||||
void sqlite3VdbeCountChanges(Vdbe *);
|
||||
sqlite3 *sqlite3VdbeDb(Vdbe *);
|
||||
u8 sqlite3VdbePrepareFlags(Vdbe *);
|
||||
void sqlite3VdbeSetSql(Vdbe *, const char *z, int n, u8);
|
||||
#ifdef SQLITE_ENABLE_NORMALIZE
|
||||
void sqlite3VdbeAddDblquoteStr(sqlite3 *, Vdbe *, const char *);
|
||||
int sqlite3VdbeUsesDoubleQuotedString(Vdbe *, const char *);
|
||||
#endif
|
||||
void sqlite3VdbeSwap(Vdbe *, Vdbe *);
|
||||
VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *, int *, int *);
|
||||
sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *, int, u8);
|
||||
void sqlite3VdbeSetVarmask(Vdbe *, int);
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
char *sqlite3VdbeExpandSql(Vdbe *, const char *);
|
||||
#endif
|
||||
int sqlite3MemCompare(const Mem *, const Mem *, const CollSeq *);
|
||||
int sqlite3BlobCompare(const Mem *, const Mem *);
|
||||
|
||||
void sqlite3VdbeRecordUnpack(KeyInfo *, int, const void *, UnpackedRecord *);
|
||||
int sqlite3VdbeRecordCompare(int, const void *, UnpackedRecord *);
|
||||
int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
|
||||
UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *);
|
||||
|
||||
typedef int (*RecordCompare)(int, const void *, UnpackedRecord *);
|
||||
RecordCompare sqlite3VdbeFindCompare(UnpackedRecord *);
|
||||
|
||||
void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
|
||||
int sqlite3VdbeHasSubProgram(Vdbe *);
|
||||
|
||||
int sqlite3NotPureFunc(sqlite3_context *);
|
||||
#ifdef SQLITE_ENABLE_BYTECODE_VTAB
|
||||
int sqlite3VdbeBytecodeVtabInit(sqlite3 *);
|
||||
#endif
|
||||
|
||||
/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
|
||||
** each VDBE opcode.
|
||||
**
|
||||
** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op
|
||||
** comments in VDBE programs that show key decision points in the code
|
||||
** generator.
|
||||
*/
|
||||
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
|
||||
void sqlite3VdbeComment(Vdbe *, const char *, ...);
|
||||
#define VdbeComment(X) sqlite3VdbeComment X
|
||||
void sqlite3VdbeNoopComment(Vdbe *, const char *, ...);
|
||||
#define VdbeNoopComment(X) sqlite3VdbeNoopComment X
|
||||
#ifdef SQLITE_ENABLE_MODULE_COMMENTS
|
||||
#define VdbeModuleComment(X) sqlite3VdbeNoopComment X
|
||||
#else
|
||||
#define VdbeModuleComment(X)
|
||||
#endif
|
||||
#else
|
||||
#define VdbeComment(X)
|
||||
#define VdbeNoopComment(X)
|
||||
#define VdbeModuleComment(X)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The VdbeCoverage macros are used to set a coverage testing point
|
||||
** for VDBE branch instructions. The coverage testing points are line
|
||||
** numbers in the sqlite3.c source file. VDBE branch coverage testing
|
||||
** only works with an amalagmation build. That's ok since a VDBE branch
|
||||
** coverage build designed for testing the test suite only. No application
|
||||
** should ever ship with VDBE branch coverage measuring turned on.
|
||||
**
|
||||
** VdbeCoverage(v) // Mark the previously coded instruction
|
||||
** // as a branch
|
||||
**
|
||||
** VdbeCoverageIf(v, conditional) // Mark previous if conditional true
|
||||
**
|
||||
** VdbeCoverageAlwaysTaken(v) // Previous branch is always taken
|
||||
**
|
||||
** VdbeCoverageNeverTaken(v) // Previous branch is never taken
|
||||
**
|
||||
** VdbeCoverageNeverNull(v) // Previous three-way branch is only
|
||||
** // taken on the first two ways. The
|
||||
** // NULL option is not possible
|
||||
**
|
||||
** VdbeCoverageEqNe(v) // Previous OP_Jump is only interested
|
||||
** // in distingishing equal and not-equal.
|
||||
**
|
||||
** Every VDBE branch operation must be tagged with one of the macros above.
|
||||
** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and
|
||||
** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()
|
||||
** routine in vdbe.c, alerting the developer to the missed tag.
|
||||
**
|
||||
** During testing, the test application will invoke
|
||||
** sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE,...) to set a callback
|
||||
** routine that is invoked as each bytecode branch is taken. The callback
|
||||
** contains the sqlite3.c source line number ov the VdbeCoverage macro and
|
||||
** flags to indicate whether or not the branch was taken. The test application
|
||||
** is responsible for keeping track of this and reporting byte-code branches
|
||||
** that are never taken.
|
||||
**
|
||||
** See the VdbeBranchTaken() macro and vdbeTakeBranch() function in the
|
||||
** vdbe.c source file for additional information.
|
||||
*/
|
||||
#ifdef SQLITE_VDBE_COVERAGE
|
||||
void sqlite3VdbeSetLineNumber(Vdbe *, int);
|
||||
#define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v, __LINE__)
|
||||
#define VdbeCoverageIf(v, x) \
|
||||
if (x) sqlite3VdbeSetLineNumber(v, __LINE__)
|
||||
#define VdbeCoverageAlwaysTaken(v) \
|
||||
sqlite3VdbeSetLineNumber(v, __LINE__ | 0x5000000);
|
||||
#define VdbeCoverageNeverTaken(v) \
|
||||
sqlite3VdbeSetLineNumber(v, __LINE__ | 0x6000000);
|
||||
#define VdbeCoverageNeverNull(v) \
|
||||
sqlite3VdbeSetLineNumber(v, __LINE__ | 0x4000000);
|
||||
#define VdbeCoverageNeverNullIf(v, x) \
|
||||
if (x) sqlite3VdbeSetLineNumber(v, __LINE__ | 0x4000000);
|
||||
#define VdbeCoverageEqNe(v) sqlite3VdbeSetLineNumber(v, __LINE__ | 0x8000000);
|
||||
#define VDBE_OFFSET_LINENO(x) (__LINE__ + x)
|
||||
#else
|
||||
#define VdbeCoverage(v)
|
||||
#define VdbeCoverageIf(v, x)
|
||||
#define VdbeCoverageAlwaysTaken(v)
|
||||
#define VdbeCoverageNeverTaken(v)
|
||||
#define VdbeCoverageNeverNull(v)
|
||||
#define VdbeCoverageNeverNullIf(v, x)
|
||||
#define VdbeCoverageEqNe(v)
|
||||
#define VDBE_OFFSET_LINENO(x) 0
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
||||
void sqlite3VdbeScanStatus(Vdbe *, int, int, int, LogEst, const char *);
|
||||
#else
|
||||
#define sqlite3VdbeScanStatus(a, b, c, d, e)
|
||||
#endif
|
||||
|
||||
#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
|
||||
void sqlite3VdbePrintOp(FILE *, int, VdbeOp *);
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_VDBE_H */
|
624
third_party/sqlite3/headers/vdbeInt.h
vendored
Normal file
624
third_party/sqlite3/headers/vdbeInt.h
vendored
Normal file
|
@ -0,0 +1,624 @@
|
|||
/*
|
||||
** 2003 September 6
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This is the header file for information that is private to the
|
||||
** VDBE. This information used to all be at the top of the single
|
||||
** source code file "vdbe.c". When that file became too big (over
|
||||
** 6000 lines long) it was split up into several smaller files and
|
||||
** this header information was factored out.
|
||||
*/
|
||||
#ifndef SQLITE_VDBEINT_H
|
||||
#define SQLITE_VDBEINT_H
|
||||
|
||||
/*
|
||||
** The maximum number of times that a statement will try to reparse
|
||||
** itself before giving up and returning SQLITE_SCHEMA.
|
||||
*/
|
||||
#ifndef SQLITE_MAX_SCHEMA_RETRY
|
||||
#define SQLITE_MAX_SCHEMA_RETRY 50
|
||||
#endif
|
||||
|
||||
/*
|
||||
** VDBE_DISPLAY_P4 is true or false depending on whether or not the
|
||||
** "explain" P4 display logic is enabled.
|
||||
*/
|
||||
#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || \
|
||||
defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) || \
|
||||
defined(SQLITE_ENABLE_BYTECODE_VTAB)
|
||||
#define VDBE_DISPLAY_P4 1
|
||||
#else
|
||||
#define VDBE_DISPLAY_P4 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** SQL is translated into a sequence of instructions to be
|
||||
** executed by a virtual machine. Each instruction is an instance
|
||||
** of the following structure.
|
||||
*/
|
||||
typedef struct VdbeOp Op;
|
||||
|
||||
/*
|
||||
** Boolean values
|
||||
*/
|
||||
typedef unsigned Bool;
|
||||
|
||||
/* Opaque type used by code in vdbesort.c */
|
||||
typedef struct VdbeSorter VdbeSorter;
|
||||
|
||||
/* Elements of the linked list at Vdbe.pAuxData */
|
||||
typedef struct AuxData AuxData;
|
||||
|
||||
/* Types of VDBE cursors */
|
||||
#define CURTYPE_BTREE 0
|
||||
#define CURTYPE_SORTER 1
|
||||
#define CURTYPE_VTAB 2
|
||||
#define CURTYPE_PSEUDO 3
|
||||
|
||||
/*
|
||||
** A VdbeCursor is an superclass (a wrapper) for various cursor objects:
|
||||
**
|
||||
** * A b-tree cursor
|
||||
** - In the main database or in an ephemeral database
|
||||
** - On either an index or a table
|
||||
** * A sorter
|
||||
** * A virtual table
|
||||
** * A one-row "pseudotable" stored in a single register
|
||||
*/
|
||||
typedef struct VdbeCursor VdbeCursor;
|
||||
struct VdbeCursor {
|
||||
u8 eCurType; /* One of the CURTYPE_* values above */
|
||||
i8 iDb; /* Index of cursor database in db->aDb[] (or -1) */
|
||||
u8 nullRow; /* True if pointing to a row with no data */
|
||||
u8 deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */
|
||||
u8 isTable; /* True for rowid tables. False for indexes */
|
||||
#ifdef SQLITE_DEBUG
|
||||
u8 seekOp; /* Most recent seek operation on this cursor */
|
||||
u8 wrFlag; /* The wrFlag argument to sqlite3BtreeCursor() */
|
||||
#endif
|
||||
Bool isEphemeral : 1; /* True for an ephemeral table */
|
||||
Bool useRandomRowid : 1; /* Generate new record numbers semi-randomly */
|
||||
Bool isOrdered : 1; /* True if the table is not BTREE_UNORDERED */
|
||||
Bool hasBeenDuped : 1; /* This cursor was source or target of OP_OpenDup */
|
||||
u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
|
||||
Btree *pBtx; /* Separate file holding temporary table */
|
||||
i64 seqCount; /* Sequence counter */
|
||||
u32 *aAltMap; /* Mapping from table to index column numbers */
|
||||
|
||||
/* Cached OP_Column parse information is only valid if cacheStatus matches
|
||||
** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of
|
||||
** CACHE_STALE (0) and so setting cacheStatus=CACHE_STALE guarantees that
|
||||
** the cache is out of date. */
|
||||
u32 cacheStatus; /* Cache is valid if this matches Vdbe.cacheCtr */
|
||||
int seekResult; /* Result of previous sqlite3BtreeMoveto() or 0
|
||||
** if there have been no prior seeks on the cursor. */
|
||||
/* seekResult does not distinguish between "no seeks have ever occurred
|
||||
** on this cursor" and "the most recent seek was an exact match".
|
||||
** For CURTYPE_PSEUDO, seekResult is the register holding the record */
|
||||
|
||||
/* When a new VdbeCursor is allocated, only the fields above are zeroed.
|
||||
** The fields that follow are uninitialized, and must be individually
|
||||
** initialized prior to first use. */
|
||||
VdbeCursor *pAltCursor; /* Associated index cursor from which to read */
|
||||
union {
|
||||
BtCursor *pCursor; /* CURTYPE_BTREE or _PSEUDO. Btree cursor */
|
||||
sqlite3_vtab_cursor *pVCur; /* CURTYPE_VTAB. Vtab cursor */
|
||||
VdbeSorter *pSorter; /* CURTYPE_SORTER. Sorter object */
|
||||
} uc;
|
||||
KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */
|
||||
u32 iHdrOffset; /* Offset to next unparsed byte of the header */
|
||||
Pgno pgnoRoot; /* Root page of the open btree cursor */
|
||||
i16 nField; /* Number of fields in the header */
|
||||
u16 nHdrParsed; /* Number of header fields parsed so far */
|
||||
i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */
|
||||
u32 *aOffset; /* Pointer to aType[nField] */
|
||||
const u8 *aRow; /* Data for the current row, if all on one page */
|
||||
u32 payloadSize; /* Total number of bytes in the record */
|
||||
u32 szRow; /* Byte available in aRow */
|
||||
#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
|
||||
u64 maskUsed; /* Mask of columns used by this cursor */
|
||||
#endif
|
||||
|
||||
/* 2*nField extra array elements allocated for aType[], beyond the one
|
||||
** static element declared in the structure. nField total array slots for
|
||||
** aType[] and nField+1 array slots for aOffset[] */
|
||||
u32 aType[1]; /* Type values record decode. MUST BE LAST */
|
||||
};
|
||||
|
||||
/*
|
||||
** A value for VdbeCursor.cacheStatus that means the cache is always invalid.
|
||||
*/
|
||||
#define CACHE_STALE 0
|
||||
|
||||
/*
|
||||
** When a sub-program is executed (OP_Program), a structure of this type
|
||||
** is allocated to store the current value of the program counter, as
|
||||
** well as the current memory cell array and various other frame specific
|
||||
** values stored in the Vdbe struct. When the sub-program is finished,
|
||||
** these values are copied back to the Vdbe from the VdbeFrame structure,
|
||||
** restoring the state of the VM to as it was before the sub-program
|
||||
** began executing.
|
||||
**
|
||||
** The memory for a VdbeFrame object is allocated and managed by a memory
|
||||
** cell in the parent (calling) frame. When the memory cell is deleted or
|
||||
** overwritten, the VdbeFrame object is not freed immediately. Instead, it
|
||||
** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame
|
||||
** list is deleted when the VM is reset in VdbeHalt(). The reason for doing
|
||||
** this instead of deleting the VdbeFrame immediately is to avoid recursive
|
||||
** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the
|
||||
** child frame are released.
|
||||
**
|
||||
** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is
|
||||
** set to NULL if the currently executing frame is the main program.
|
||||
*/
|
||||
typedef struct VdbeFrame VdbeFrame;
|
||||
struct VdbeFrame {
|
||||
Vdbe *v; /* VM this frame belongs to */
|
||||
VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */
|
||||
Op *aOp; /* Program instructions for parent frame */
|
||||
i64 *anExec; /* Event counters from parent frame */
|
||||
Mem *aMem; /* Array of memory cells for parent frame */
|
||||
VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */
|
||||
u8 *aOnce; /* Bitmask used by OP_Once */
|
||||
void *token; /* Copy of SubProgram.token */
|
||||
i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */
|
||||
AuxData *pAuxData; /* Linked list of auxdata allocations */
|
||||
#if SQLITE_DEBUG
|
||||
u32 iFrameMagic; /* magic number for sanity checking */
|
||||
#endif
|
||||
int nCursor; /* Number of entries in apCsr */
|
||||
int pc; /* Program Counter in parent (calling) frame */
|
||||
int nOp; /* Size of aOp array */
|
||||
int nMem; /* Number of entries in aMem */
|
||||
int nChildMem; /* Number of memory cells for child frame */
|
||||
int nChildCsr; /* Number of cursors for child frame */
|
||||
int nChange; /* Statement changes (Vdbe.nChange) */
|
||||
int nDbChange; /* Value of db->nChange */
|
||||
};
|
||||
|
||||
/* Magic number for sanity checking on VdbeFrame objects */
|
||||
#define SQLITE_FRAME_MAGIC 0x879fb71e
|
||||
|
||||
/*
|
||||
** Return a pointer to the array of registers allocated for use
|
||||
** by a VdbeFrame.
|
||||
*/
|
||||
#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
|
||||
|
||||
/*
|
||||
** Internally, the vdbe manipulates nearly all SQL values as Mem
|
||||
** structures. Each Mem struct may cache multiple representations (string,
|
||||
** integer etc.) of the same value.
|
||||
*/
|
||||
struct sqlite3_value {
|
||||
union MemValue {
|
||||
double r; /* Real value used when MEM_Real is set in flags */
|
||||
i64 i; /* Integer value used when MEM_Int is set in flags */
|
||||
int nZero; /* Extra zero bytes when MEM_Zero and MEM_Blob set */
|
||||
const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */
|
||||
FuncDef *pDef; /* Used only when flags==MEM_Agg */
|
||||
} u;
|
||||
u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
|
||||
u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
|
||||
u8 eSubtype; /* Subtype for this value */
|
||||
int n; /* Number of characters in string value, excluding '\0' */
|
||||
char *z; /* String or BLOB value */
|
||||
/* ShallowCopy only needs to copy the information above */
|
||||
char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
|
||||
int szMalloc; /* Size of the zMalloc allocation */
|
||||
u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */
|
||||
sqlite3 *db; /* The associated database connection */
|
||||
void (*xDel)(void *); /* Destructor for Mem.z - only valid if MEM_Dyn */
|
||||
#ifdef SQLITE_DEBUG
|
||||
Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
|
||||
u16 mScopyFlags; /* flags value immediately after the shallow copy */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
** Size of struct Mem not including the Mem.zMalloc member or anything that
|
||||
** follows.
|
||||
*/
|
||||
#define MEMCELLSIZE offsetof(Mem, zMalloc)
|
||||
|
||||
/* One or more of the following flags are set to indicate the validOK
|
||||
** representations of the value stored in the Mem struct.
|
||||
**
|
||||
** If the MEM_Null flag is set, then the value is an SQL NULL value.
|
||||
** For a pointer type created using sqlite3_bind_pointer() or
|
||||
** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.
|
||||
**
|
||||
** If the MEM_Str flag is set then Mem.z points at a string representation.
|
||||
** Usually this is encoded in the same unicode encoding as the main
|
||||
** database (see below for exceptions). If the MEM_Term flag is also
|
||||
** set, then the string is nul terminated. The MEM_Int and MEM_Real
|
||||
** flags may coexist with the MEM_Str flag.
|
||||
*/
|
||||
#define MEM_Null 0x0001 /* Value is NULL (or a pointer) */
|
||||
#define MEM_Str 0x0002 /* Value is a string */
|
||||
#define MEM_Int 0x0004 /* Value is an integer */
|
||||
#define MEM_Real 0x0008 /* Value is a real number */
|
||||
#define MEM_Blob 0x0010 /* Value is a BLOB */
|
||||
#define MEM_IntReal 0x0020 /* MEM_Int that stringifies like MEM_Real */
|
||||
#define MEM_AffMask 0x003f /* Mask of affinity bits */
|
||||
#define MEM_FromBind 0x0040 /* Value originates from sqlite3_bind() */
|
||||
#define MEM_Undefined 0x0080 /* Value is undefined */
|
||||
#define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
|
||||
#define MEM_TypeMask 0xc1bf /* Mask of type bits */
|
||||
|
||||
/* Whenever Mem contains a valid string or blob representation, one of
|
||||
** the following flags must be set to determine the memory management
|
||||
** policy for Mem.z. The MEM_Term flag tells us whether or not the
|
||||
** string is \000 or \u0000 terminated
|
||||
*/
|
||||
#define MEM_Term 0x0200 /* String in Mem.z is zero terminated */
|
||||
#define MEM_Dyn 0x0400 /* Need to call Mem.xDel() on Mem.z */
|
||||
#define MEM_Static 0x0800 /* Mem.z points to a static string */
|
||||
#define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */
|
||||
#define MEM_Agg 0x2000 /* Mem.z points to an agg function context */
|
||||
#define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */
|
||||
#define MEM_Subtype 0x8000 /* Mem.eSubtype is valid */
|
||||
#ifdef SQLITE_OMIT_INCRBLOB
|
||||
#undef MEM_Zero
|
||||
#define MEM_Zero 0x0000
|
||||
#endif
|
||||
|
||||
/* Return TRUE if Mem X contains dynamically allocated content - anything
|
||||
** that needs to be deallocated to avoid a leak.
|
||||
*/
|
||||
#define VdbeMemDynamic(X) (((X)->flags & (MEM_Agg | MEM_Dyn)) != 0)
|
||||
|
||||
/*
|
||||
** Clear any existing type flags from a Mem and replace them with f
|
||||
*/
|
||||
#define MemSetTypeFlag(p, f) \
|
||||
((p)->flags = ((p)->flags & ~(MEM_TypeMask | MEM_Zero)) | f)
|
||||
|
||||
/*
|
||||
** True if Mem X is a NULL-nochng type.
|
||||
*/
|
||||
#define MemNullNochng(X) \
|
||||
(((X)->flags & MEM_TypeMask) == (MEM_Null | MEM_Zero) && (X)->n == 0 && \
|
||||
(X)->u.nZero == 0)
|
||||
|
||||
/*
|
||||
** Return true if a memory cell is not marked as invalid. This macro
|
||||
** is for use inside assert() statements only.
|
||||
*/
|
||||
#ifdef SQLITE_DEBUG
|
||||
#define memIsValid(M) ((M)->flags & MEM_Undefined) == 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Each auxiliary data pointer stored by a user defined function
|
||||
** implementation calling sqlite3_set_auxdata() is stored in an instance
|
||||
** of this structure. All such structures associated with a single VM
|
||||
** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
|
||||
** when the VM is halted (if not before).
|
||||
*/
|
||||
struct AuxData {
|
||||
int iAuxOp; /* Instruction number of OP_Function opcode */
|
||||
int iAuxArg; /* Index of function argument. */
|
||||
void *pAux; /* Aux data pointer */
|
||||
void (*xDeleteAux)(void *); /* Destructor for the aux data */
|
||||
AuxData *pNextAux; /* Next element in list */
|
||||
};
|
||||
|
||||
/*
|
||||
** The "context" argument for an installable function. A pointer to an
|
||||
** instance of this structure is the first argument to the routines used
|
||||
** implement the SQL functions.
|
||||
**
|
||||
** There is a typedef for this structure in sqlite.h. So all routines,
|
||||
** even the public interface to SQLite, can use a pointer to this structure.
|
||||
** But this file is the only place where the internal details of this
|
||||
** structure are known.
|
||||
**
|
||||
** This structure is defined inside of vdbeInt.h because it uses substructures
|
||||
** (Mem) which are only defined there.
|
||||
*/
|
||||
struct sqlite3_context {
|
||||
Mem *pOut; /* The return value is stored here */
|
||||
FuncDef *pFunc; /* Pointer to function information */
|
||||
Mem *pMem; /* Memory cell used to store aggregate context */
|
||||
Vdbe *pVdbe; /* The VM that owns this context */
|
||||
int iOp; /* Instruction number of OP_Function */
|
||||
int isError; /* Error code returned by the function. */
|
||||
u8 skipFlag; /* Skip accumulator loading if true */
|
||||
u8 argc; /* Number of arguments */
|
||||
sqlite3_value *argv[1]; /* Argument set */
|
||||
};
|
||||
|
||||
/* A bitfield type for use inside of structures. Always follow with :N where
|
||||
** N is the number of bits.
|
||||
*/
|
||||
typedef unsigned bft; /* Bit Field Type */
|
||||
|
||||
/* The ScanStatus object holds a single value for the
|
||||
** sqlite3_stmt_scanstatus() interface.
|
||||
*/
|
||||
typedef struct ScanStatus ScanStatus;
|
||||
struct ScanStatus {
|
||||
int addrExplain; /* OP_Explain for loop */
|
||||
int addrLoop; /* Address of "loops" counter */
|
||||
int addrVisit; /* Address of "rows visited" counter */
|
||||
int iSelectID; /* The "Select-ID" for this loop */
|
||||
LogEst nEst; /* Estimated output rows per loop */
|
||||
char *zName; /* Name of table or index */
|
||||
};
|
||||
|
||||
/* The DblquoteStr object holds the text of a double-quoted
|
||||
** string for a prepared statement. A linked list of these objects
|
||||
** is constructed during statement parsing and is held on Vdbe.pDblStr.
|
||||
** When computing a normalized SQL statement for an SQL statement, that
|
||||
** list is consulted for each double-quoted identifier to see if the
|
||||
** identifier should really be a string literal.
|
||||
*/
|
||||
typedef struct DblquoteStr DblquoteStr;
|
||||
struct DblquoteStr {
|
||||
DblquoteStr *pNextStr; /* Next string literal in the list */
|
||||
char z[8]; /* Dequoted value for the string */
|
||||
};
|
||||
|
||||
/*
|
||||
** An instance of the virtual machine. This structure contains the complete
|
||||
** state of the virtual machine.
|
||||
**
|
||||
** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare()
|
||||
** is really a pointer to an instance of this structure.
|
||||
*/
|
||||
struct Vdbe {
|
||||
sqlite3 *db; /* The database connection that owns this statement */
|
||||
Vdbe *pPrev, *pNext; /* Linked list of VDBEs with the same Vdbe.db */
|
||||
Parse *pParse; /* Parsing context used to create this Vdbe */
|
||||
ynVar nVar; /* Number of entries in aVar[] */
|
||||
u32 iVdbeMagic; /* Magic number defining state of the SQL statement */
|
||||
int nMem; /* Number of memory locations currently allocated */
|
||||
int nCursor; /* Number of slots in apCsr[] */
|
||||
u32 cacheCtr; /* VdbeCursor row cache generation counter */
|
||||
int pc; /* The program counter */
|
||||
int rc; /* Value to return */
|
||||
int nChange; /* Number of db changes made since last reset */
|
||||
int iStatement; /* Statement number (or 0 if has no opened stmt) */
|
||||
i64 iCurrentTime; /* Value of julianday('now') for this statement */
|
||||
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
|
||||
i64 nStmtDefCons; /* Number of def. constraints when stmt started */
|
||||
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
|
||||
Mem *aMem; /* The memory locations */
|
||||
Mem **apArg; /* Arguments to currently executing user function */
|
||||
VdbeCursor **apCsr; /* One element of this array for each open cursor */
|
||||
Mem *aVar; /* Values for the OP_Variable opcode. */
|
||||
|
||||
/* When allocating a new Vdbe object, all of the fields below should be
|
||||
** initialized to zero or NULL */
|
||||
|
||||
Op *aOp; /* Space to hold the virtual machine's program */
|
||||
int nOp; /* Number of instructions in the program */
|
||||
int nOpAlloc; /* Slots allocated for aOp[] */
|
||||
Mem *aColName; /* Column names to return */
|
||||
Mem *pResultSet; /* Pointer to an array of results */
|
||||
char *zErrMsg; /* Error message written here */
|
||||
VList *pVList; /* Name of variables */
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
i64 startTime; /* Time when query started - used for profiling */
|
||||
#endif
|
||||
#ifdef SQLITE_DEBUG
|
||||
int rcApp; /* errcode set by sqlite3_result_error_code() */
|
||||
u32 nWrite; /* Number of write operations that have occurred */
|
||||
#endif
|
||||
u16 nResColumn; /* Number of columns in one row of the result set */
|
||||
u8 errorAction; /* Recovery action to do in case of an error */
|
||||
u8 minWriteFileFormat; /* Minimum file format for writable database files */
|
||||
u8 prepFlags; /* SQLITE_PREPARE_* flags */
|
||||
u8 doingRerun; /* True if rerunning after an auto-reprepare */
|
||||
bft expired : 2; /* 1: recompile VM immediately 2: when convenient */
|
||||
bft explain : 2; /* True if EXPLAIN present on SQL command */
|
||||
bft changeCntOn : 1; /* True to update the change-counter */
|
||||
bft runOnlyOnce : 1; /* Automatically expire on reset */
|
||||
bft usesStmtJournal : 1; /* True if uses a statement journal */
|
||||
bft readOnly : 1; /* True for statements that do not write */
|
||||
bft bIsReader : 1; /* True for statements that read */
|
||||
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
|
||||
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
|
||||
u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
|
||||
char *zSql; /* Text of the SQL statement that generated this */
|
||||
#ifdef SQLITE_ENABLE_NORMALIZE
|
||||
char *zNormSql; /* Normalization of the associated SQL statement */
|
||||
DblquoteStr *pDblStr; /* List of double-quoted string literals */
|
||||
#endif
|
||||
void *pFree; /* Free this when deleting the vdbe */
|
||||
VdbeFrame *pFrame; /* Parent frame */
|
||||
VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
|
||||
int nFrame; /* Number of frames in pFrame list */
|
||||
u32 expmask; /* Binding to these vars invalidates VM */
|
||||
SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
|
||||
AuxData *pAuxData; /* Linked list of auxdata allocations */
|
||||
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
||||
i64 *anExec; /* Number of times each op has been executed */
|
||||
int nScan; /* Entries in aScan[] */
|
||||
ScanStatus *aScan; /* Scan definitions for sqlite3_stmt_scanstatus() */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
** The following are allowed values for Vdbe.magic
|
||||
*/
|
||||
#define VDBE_MAGIC_INIT 0x16bceaa5 /* Building a VDBE program */
|
||||
#define VDBE_MAGIC_RUN 0x2df20da3 /* VDBE is ready to execute */
|
||||
#define VDBE_MAGIC_HALT 0x319c2973 /* VDBE has completed execution */
|
||||
#define VDBE_MAGIC_RESET 0x48fa9f76 /* Reset and ready to run again */
|
||||
#define VDBE_MAGIC_DEAD 0x5606c3c8 /* The VDBE has been deallocated */
|
||||
|
||||
/*
|
||||
** Structure used to store the context required by the
|
||||
** sqlite3_preupdate_*() API functions.
|
||||
*/
|
||||
struct PreUpdate {
|
||||
Vdbe *v;
|
||||
VdbeCursor *pCsr; /* Cursor to read old values from */
|
||||
int op; /* One of SQLITE_INSERT, UPDATE, DELETE */
|
||||
u8 *aRecord; /* old.* database record */
|
||||
KeyInfo keyinfo;
|
||||
UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
|
||||
UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
|
||||
int iNewReg; /* Register for new.* values */
|
||||
int iBlobWrite; /* Value returned by preupdate_blobwrite() */
|
||||
i64 iKey1; /* First key value passed to hook */
|
||||
i64 iKey2; /* Second key value passed to hook */
|
||||
Mem *aNew; /* Array of new.* values */
|
||||
Table *pTab; /* Schema object being upated */
|
||||
Index *pPk; /* PK index if pTab is WITHOUT ROWID */
|
||||
};
|
||||
|
||||
/*
|
||||
** Function prototypes
|
||||
*/
|
||||
void sqlite3VdbeError(Vdbe *, const char *, ...);
|
||||
void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor *);
|
||||
void sqliteVdbePopStack(Vdbe *, int);
|
||||
int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor *);
|
||||
int sqlite3VdbeCursorMoveto(VdbeCursor **, u32 *);
|
||||
int sqlite3VdbeCursorRestore(VdbeCursor *);
|
||||
u32 sqlite3VdbeSerialTypeLen(u32);
|
||||
u8 sqlite3VdbeOneByteSerialTypeLen(u8);
|
||||
u32 sqlite3VdbeSerialPut(unsigned char *, Mem *, u32);
|
||||
u32 sqlite3VdbeSerialGet(const unsigned char *, u32, Mem *);
|
||||
void sqlite3VdbeDeleteAuxData(sqlite3 *, AuxData **, int, int);
|
||||
|
||||
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
|
||||
int sqlite3VdbeIdxKeyCompare(sqlite3 *, VdbeCursor *, UnpackedRecord *, int *);
|
||||
int sqlite3VdbeIdxRowid(sqlite3 *, BtCursor *, i64 *);
|
||||
int sqlite3VdbeExec(Vdbe *);
|
||||
#if !defined(SQLITE_OMIT_EXPLAIN) || defined(SQLITE_ENABLE_BYTECODE_VTAB)
|
||||
int sqlite3VdbeNextOpcode(Vdbe *, Mem *, int, int *, int *, Op **);
|
||||
char *sqlite3VdbeDisplayP4(sqlite3 *, Op *);
|
||||
#endif
|
||||
#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS)
|
||||
char *sqlite3VdbeDisplayComment(sqlite3 *, const Op *, const char *);
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_EXPLAIN)
|
||||
int sqlite3VdbeList(Vdbe *);
|
||||
#endif
|
||||
int sqlite3VdbeHalt(Vdbe *);
|
||||
int sqlite3VdbeChangeEncoding(Mem *, int);
|
||||
int sqlite3VdbeMemTooBig(Mem *);
|
||||
int sqlite3VdbeMemCopy(Mem *, const Mem *);
|
||||
void sqlite3VdbeMemShallowCopy(Mem *, const Mem *, int);
|
||||
void sqlite3VdbeMemMove(Mem *, Mem *);
|
||||
int sqlite3VdbeMemNulTerminate(Mem *);
|
||||
int sqlite3VdbeMemSetStr(Mem *, const char *, int, u8, void (*)(void *));
|
||||
void sqlite3VdbeMemSetInt64(Mem *, i64);
|
||||
#ifdef SQLITE_OMIT_FLOATING_POINT
|
||||
#define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
|
||||
#else
|
||||
void sqlite3VdbeMemSetDouble(Mem *, double);
|
||||
#endif
|
||||
void sqlite3VdbeMemSetPointer(Mem *, void *, const char *, void (*)(void *));
|
||||
void sqlite3VdbeMemInit(Mem *, sqlite3 *, u16);
|
||||
void sqlite3VdbeMemSetNull(Mem *);
|
||||
void sqlite3VdbeMemSetZeroBlob(Mem *, int);
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3VdbeMemIsRowSet(const Mem *);
|
||||
#endif
|
||||
int sqlite3VdbeMemSetRowSet(Mem *);
|
||||
int sqlite3VdbeMemMakeWriteable(Mem *);
|
||||
int sqlite3VdbeMemStringify(Mem *, u8, u8);
|
||||
i64 sqlite3VdbeIntValue(Mem *);
|
||||
int sqlite3VdbeMemIntegerify(Mem *);
|
||||
double sqlite3VdbeRealValue(Mem *);
|
||||
int sqlite3VdbeBooleanValue(Mem *, int ifNull);
|
||||
void sqlite3VdbeIntegerAffinity(Mem *);
|
||||
int sqlite3VdbeMemRealify(Mem *);
|
||||
int sqlite3VdbeMemNumerify(Mem *);
|
||||
int sqlite3VdbeMemCast(Mem *, u8, u8);
|
||||
int sqlite3VdbeMemFromBtree(BtCursor *, u32, u32, Mem *);
|
||||
int sqlite3VdbeMemFromBtreeZeroOffset(BtCursor *, u32, Mem *);
|
||||
void sqlite3VdbeMemRelease(Mem *p);
|
||||
int sqlite3VdbeMemFinalize(Mem *, FuncDef *);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
int sqlite3VdbeMemAggValue(Mem *, Mem *, FuncDef *);
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_EXPLAIN) || defined(SQLITE_ENABLE_BYTECODE_VTAB)
|
||||
const char *sqlite3OpcodeName(int);
|
||||
#endif
|
||||
int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
|
||||
int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
|
||||
int sqlite3VdbeCloseStatement(Vdbe *, int);
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3VdbeFrameIsValid(VdbeFrame *);
|
||||
#endif
|
||||
void sqlite3VdbeFrameMemDel(void *); /* Destructor on Mem */
|
||||
void sqlite3VdbeFrameDelete(VdbeFrame *); /* Actually deletes the Frame */
|
||||
int sqlite3VdbeFrameRestore(VdbeFrame *);
|
||||
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
void sqlite3VdbePreUpdateHook(Vdbe *, VdbeCursor *, int, const char *, Table *,
|
||||
i64, int, int);
|
||||
#endif
|
||||
int sqlite3VdbeTransferError(Vdbe *p);
|
||||
|
||||
int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
|
||||
void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
|
||||
void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
|
||||
int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
|
||||
int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);
|
||||
int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
|
||||
int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
|
||||
int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
void sqlite3VdbeIncrWriteCounter(Vdbe *, VdbeCursor *);
|
||||
void sqlite3VdbeAssertAbortable(Vdbe *);
|
||||
#else
|
||||
#define sqlite3VdbeIncrWriteCounter(V, C)
|
||||
#define sqlite3VdbeAssertAbortable(V)
|
||||
#endif
|
||||
|
||||
#if !defined(SQLITE_OMIT_SHARED_CACHE)
|
||||
void sqlite3VdbeEnter(Vdbe *);
|
||||
#else
|
||||
#define sqlite3VdbeEnter(X)
|
||||
#endif
|
||||
|
||||
#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE > 0
|
||||
void sqlite3VdbeLeave(Vdbe *);
|
||||
#else
|
||||
#define sqlite3VdbeLeave(X)
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
void sqlite3VdbeMemAboutToChange(Vdbe *, Mem *);
|
||||
int sqlite3VdbeCheckMemInvariants(Mem *);
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
||||
int sqlite3VdbeCheckFk(Vdbe *, int);
|
||||
#else
|
||||
#define sqlite3VdbeCheckFk(p, i) 0
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
void sqlite3VdbePrintSql(Vdbe *);
|
||||
void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr);
|
||||
#endif
|
||||
#ifndef SQLITE_OMIT_UTF16
|
||||
int sqlite3VdbeMemTranslate(Mem *, u8);
|
||||
int sqlite3VdbeMemHandleBom(Mem *pMem);
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_INCRBLOB
|
||||
int sqlite3VdbeMemExpandBlob(Mem *);
|
||||
#define ExpandBlob(P) \
|
||||
(((P)->flags & MEM_Zero) ? sqlite3VdbeMemExpandBlob(P) : 0)
|
||||
#else
|
||||
#define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
|
||||
#define ExpandBlob(P) SQLITE_OK
|
||||
#endif
|
||||
|
||||
#endif /* !defined(SQLITE_VDBEINT_H) */
|
32
third_party/sqlite3/headers/vxworks.h
vendored
Normal file
32
third_party/sqlite3/headers/vxworks.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
** 2015-03-02
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This file contains code that is specific to Wind River's VxWorks
|
||||
*/
|
||||
#if defined(__RTP__) || defined(_WRS_KERNEL)
|
||||
/* This is VxWorks. Set up things specially for that OS
|
||||
*/
|
||||
#include <pthread.h> /* amalgamator: dontcache */
|
||||
#include <vxWorks.h>
|
||||
#define OS_VXWORKS 1
|
||||
#define SQLITE_OS_OTHER 0
|
||||
#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
|
||||
#define SQLITE_OMIT_LOAD_EXTENSION 1
|
||||
#define SQLITE_ENABLE_LOCKING_STYLE 0
|
||||
#define HAVE_UTIME 1
|
||||
#else
|
||||
/* This is not VxWorks. */
|
||||
#define OS_VXWORKS 0
|
||||
#define HAVE_FCHOWN 1
|
||||
#define HAVE_READLINK 1
|
||||
#define HAVE_LSTAT 1
|
||||
#endif /* defined(_WRS_KERNEL) */
|
156
third_party/sqlite3/headers/wal.h
vendored
Normal file
156
third_party/sqlite3/headers/wal.h
vendored
Normal file
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
** 2010 February 1
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the interface to the write-ahead logging
|
||||
** system. Refer to the comments below and the header comment attached to
|
||||
** the implementation of each function in log.c for further details.
|
||||
*/
|
||||
|
||||
#ifndef SQLITE_WAL_H
|
||||
#define SQLITE_WAL_H
|
||||
|
||||
#include "sqliteInt.h"
|
||||
|
||||
/* Macros for extracting appropriate sync flags for either transaction
|
||||
** commits (WAL_SYNC_FLAGS(X)) or for checkpoint ops (CKPT_SYNC_FLAGS(X)):
|
||||
*/
|
||||
#define WAL_SYNC_FLAGS(X) ((X)&0x03)
|
||||
#define CKPT_SYNC_FLAGS(X) (((X) >> 2) & 0x03)
|
||||
|
||||
#ifdef SQLITE_OMIT_WAL
|
||||
#define sqlite3WalOpen(x, y, z) 0
|
||||
#define sqlite3WalLimit(x, y)
|
||||
#define sqlite3WalClose(v, w, x, y, z) 0
|
||||
#define sqlite3WalBeginReadTransaction(y, z) 0
|
||||
#define sqlite3WalEndReadTransaction(z)
|
||||
#define sqlite3WalDbsize(y) 0
|
||||
#define sqlite3WalBeginWriteTransaction(y) 0
|
||||
#define sqlite3WalEndWriteTransaction(x) 0
|
||||
#define sqlite3WalUndo(x, y, z) 0
|
||||
#define sqlite3WalSavepoint(y, z)
|
||||
#define sqlite3WalSavepointUndo(y, z) 0
|
||||
#define sqlite3WalFrames(u, v, w, x, y, z) 0
|
||||
#define sqlite3WalCheckpoint(q, r, s, t, u, v, w, x, y, z) 0
|
||||
#define sqlite3WalCallback(z) 0
|
||||
#define sqlite3WalExclusiveMode(y, z) 0
|
||||
#define sqlite3WalHeapMemory(z) 0
|
||||
#define sqlite3WalFramesize(z) 0
|
||||
#define sqlite3WalFindFrame(x, y, z) 0
|
||||
#define sqlite3WalFile(x) 0
|
||||
#else
|
||||
|
||||
#define WAL_SAVEPOINT_NDATA 4
|
||||
|
||||
/* Connection to a write-ahead log (WAL) file.
|
||||
** There is one object of this type for each pager.
|
||||
*/
|
||||
typedef struct Wal Wal;
|
||||
|
||||
/* Open and close a connection to a write-ahead log. */
|
||||
int sqlite3WalOpen(sqlite3_vfs *, sqlite3_file *, const char *, int, i64,
|
||||
Wal **);
|
||||
int sqlite3WalClose(Wal *pWal, sqlite3 *, int sync_flags, int, u8 *);
|
||||
|
||||
/* Set the limiting size of a WAL file. */
|
||||
void sqlite3WalLimit(Wal *, i64);
|
||||
|
||||
/* Used by readers to open (lock) and close (unlock) a snapshot. A
|
||||
** snapshot is like a read-transaction. It is the state of the database
|
||||
** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and
|
||||
** preserves the current state even if the other threads or processes
|
||||
** write to or checkpoint the WAL. sqlite3WalCloseSnapshot() closes the
|
||||
** transaction and releases the lock.
|
||||
*/
|
||||
int sqlite3WalBeginReadTransaction(Wal *pWal, int *);
|
||||
void sqlite3WalEndReadTransaction(Wal *pWal);
|
||||
|
||||
/* Read a page from the write-ahead log, if it is present. */
|
||||
int sqlite3WalFindFrame(Wal *, Pgno, u32 *);
|
||||
int sqlite3WalReadFrame(Wal *, u32, int, u8 *);
|
||||
|
||||
/* If the WAL is not empty, return the size of the database. */
|
||||
Pgno sqlite3WalDbsize(Wal *pWal);
|
||||
|
||||
/* Obtain or release the WRITER lock. */
|
||||
int sqlite3WalBeginWriteTransaction(Wal *pWal);
|
||||
int sqlite3WalEndWriteTransaction(Wal *pWal);
|
||||
|
||||
/* Undo any frames written (but not committed) to the log */
|
||||
int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);
|
||||
|
||||
/* Return an integer that records the current (uncommitted) write
|
||||
** position in the WAL */
|
||||
void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData);
|
||||
|
||||
/* Move the write position of the WAL back to iFrame. Called in
|
||||
** response to a ROLLBACK TO command. */
|
||||
int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);
|
||||
|
||||
/* Write a frame or frames to the log. */
|
||||
int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
|
||||
|
||||
/* Copy pages from the log to the database file */
|
||||
int sqlite3WalCheckpoint(
|
||||
Wal *pWal, /* Write-ahead log connection */
|
||||
sqlite3 *db, /* Check this handle's interrupt flag */
|
||||
int eMode, /* One of PASSIVE, FULL and RESTART */
|
||||
int (*xBusy)(void *), /* Function to call when busy */
|
||||
void *pBusyArg, /* Context argument for xBusyHandler */
|
||||
int sync_flags, /* Flags to sync db file with (or 0) */
|
||||
int nBuf, /* Size of buffer nBuf */
|
||||
u8 *zBuf, /* Temporary buffer to use */
|
||||
int *pnLog, /* OUT: Number of frames in WAL */
|
||||
int *pnCkpt /* OUT: Number of backfilled frames in WAL */
|
||||
);
|
||||
|
||||
/* Return the value to pass to a sqlite3_wal_hook callback, the
|
||||
** number of frames in the WAL at the point of the last commit since
|
||||
** sqlite3WalCallback() was called. If no commits have occurred since
|
||||
** the last call, then return 0.
|
||||
*/
|
||||
int sqlite3WalCallback(Wal *pWal);
|
||||
|
||||
/* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)
|
||||
** by the pager layer on the database file.
|
||||
*/
|
||||
int sqlite3WalExclusiveMode(Wal *pWal, int op);
|
||||
|
||||
/* Return true if the argument is non-NULL and the WAL module is using
|
||||
** heap-memory for the wal-index. Otherwise, if the argument is NULL or the
|
||||
** WAL module is using shared-memory, return false.
|
||||
*/
|
||||
int sqlite3WalHeapMemory(Wal *pWal);
|
||||
|
||||
#ifdef SQLITE_ENABLE_SNAPSHOT
|
||||
int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot);
|
||||
void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot);
|
||||
int sqlite3WalSnapshotRecover(Wal *pWal);
|
||||
int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot);
|
||||
void sqlite3WalSnapshotUnlock(Wal *pWal);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_ENABLE_ZIPVFS
|
||||
/* If the WAL file is not empty, return the number of bytes of content
|
||||
** stored in each frame (i.e. the db page-size when the WAL was created).
|
||||
*/
|
||||
int sqlite3WalFramesize(Wal *pWal);
|
||||
#endif
|
||||
|
||||
/* Return the sqlite3_file object for the WAL file */
|
||||
sqlite3_file *sqlite3WalFile(Wal *pWal);
|
||||
|
||||
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
|
||||
int sqlite3WalWriteLock(Wal *pWal, int bLock);
|
||||
void sqlite3WalDb(Wal *pWal, sqlite3 *db);
|
||||
#endif
|
||||
|
||||
#endif /* ifndef SQLITE_OMIT_WAL */
|
||||
#endif /* SQLITE_WAL_H */
|
603
third_party/sqlite3/headers/whereInt.h
vendored
Normal file
603
third_party/sqlite3/headers/whereInt.h
vendored
Normal file
|
@ -0,0 +1,603 @@
|
|||
/*
|
||||
** 2013-11-12
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This file contains structure and macro definitions for the query
|
||||
** planner logic in "where.c". These definitions are broken out into
|
||||
** a separate source file for easier editing.
|
||||
*/
|
||||
#ifndef SQLITE_WHEREINT_H
|
||||
#define SQLITE_WHEREINT_H
|
||||
|
||||
/* Forward references
|
||||
*/
|
||||
typedef struct WhereClause WhereClause;
|
||||
typedef struct WhereMaskSet WhereMaskSet;
|
||||
typedef struct WhereOrInfo WhereOrInfo;
|
||||
typedef struct WhereAndInfo WhereAndInfo;
|
||||
typedef struct WhereLevel WhereLevel;
|
||||
typedef struct WhereLoop WhereLoop;
|
||||
typedef struct WherePath WherePath;
|
||||
typedef struct WhereTerm WhereTerm;
|
||||
typedef struct WhereLoopBuilder WhereLoopBuilder;
|
||||
typedef struct WhereScan WhereScan;
|
||||
typedef struct WhereOrCost WhereOrCost;
|
||||
typedef struct WhereOrSet WhereOrSet;
|
||||
|
||||
/*
|
||||
** This object contains information needed to implement a single nested
|
||||
** loop in WHERE clause.
|
||||
**
|
||||
** Contrast this object with WhereLoop. This object describes the
|
||||
** implementation of the loop. WhereLoop describes the algorithm.
|
||||
** This object contains a pointer to the WhereLoop algorithm as one of
|
||||
** its elements.
|
||||
**
|
||||
** The WhereInfo object contains a single instance of this object for
|
||||
** each term in the FROM clause (which is to say, for each of the
|
||||
** nested loops as implemented). The order of WhereLevel objects determines
|
||||
** the loop nested order, with WhereInfo.a[0] being the outer loop and
|
||||
** WhereInfo.a[WhereInfo.nLevel-1] being the inner loop.
|
||||
*/
|
||||
struct WhereLevel {
|
||||
int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
|
||||
int iTabCur; /* The VDBE cursor used to access the table */
|
||||
int iIdxCur; /* The VDBE cursor used to access pIdx */
|
||||
int addrBrk; /* Jump here to break out of the loop */
|
||||
int addrNxt; /* Jump here to start the next IN combination */
|
||||
int addrSkip; /* Jump here for next iteration of skip-scan */
|
||||
int addrCont; /* Jump here to continue with the next loop cycle */
|
||||
int addrFirst; /* First instruction of interior of the loop */
|
||||
int addrBody; /* Beginning of the body of this loop */
|
||||
int regBignull; /* big-null flag reg. True if a NULL-scan is needed */
|
||||
int addrBignull; /* Jump here for next part of big-null scan */
|
||||
#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
|
||||
u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
|
||||
int addrLikeRep; /* LIKE range processing address */
|
||||
#endif
|
||||
u8 iFrom; /* Which entry in the FROM clause */
|
||||
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
|
||||
int p1, p2; /* Operands of the opcode used to end the loop */
|
||||
union { /* Information that depends on pWLoop->wsFlags */
|
||||
struct {
|
||||
int nIn; /* Number of entries in aInLoop[] */
|
||||
struct InLoop {
|
||||
int iCur; /* The VDBE cursor used by this IN operator */
|
||||
int addrInTop; /* Top of the IN loop */
|
||||
int iBase; /* Base register of multi-key index record */
|
||||
int nPrefix; /* Number of prior entires in the key */
|
||||
u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */
|
||||
} * aInLoop; /* Information about each nested IN operator */
|
||||
} in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */
|
||||
Index *pCovidx; /* Possible covering index for WHERE_MULTI_OR */
|
||||
} u;
|
||||
struct WhereLoop *pWLoop; /* The selected WhereLoop object */
|
||||
Bitmask notReady; /* FROM entries not usable at this level */
|
||||
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
||||
int addrVisit; /* Address at which row is visited */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
** Each instance of this object represents an algorithm for evaluating one
|
||||
** term of a join. Every term of the FROM clause will have at least
|
||||
** one corresponding WhereLoop object (unless INDEXED BY constraints
|
||||
** prevent a query solution - which is an error) and many terms of the
|
||||
** FROM clause will have multiple WhereLoop objects, each describing a
|
||||
** potential way of implementing that FROM-clause term, together with
|
||||
** dependencies and cost estimates for using the chosen algorithm.
|
||||
**
|
||||
** Query planning consists of building up a collection of these WhereLoop
|
||||
** objects, then computing a particular sequence of WhereLoop objects, with
|
||||
** one WhereLoop object per FROM clause term, that satisfy all dependencies
|
||||
** and that minimize the overall cost.
|
||||
*/
|
||||
struct WhereLoop {
|
||||
Bitmask prereq; /* Bitmask of other loops that must run first */
|
||||
Bitmask maskSelf; /* Bitmask identifying table iTab */
|
||||
#ifdef SQLITE_DEBUG
|
||||
char cId; /* Symbolic ID of this loop for debugging use */
|
||||
#endif
|
||||
u8 iTab; /* Position in FROM clause of table for this loop */
|
||||
u8 iSortIdx; /* Sorting index number. 0==None */
|
||||
LogEst rSetup; /* One-time setup cost (ex: create transient index) */
|
||||
LogEst rRun; /* Cost of running each loop */
|
||||
LogEst nOut; /* Estimated number of output rows */
|
||||
union {
|
||||
struct { /* Information for internal btree tables */
|
||||
u16 nEq; /* Number of equality constraints */
|
||||
u16 nBtm; /* Size of BTM vector */
|
||||
u16 nTop; /* Size of TOP vector */
|
||||
u16 nDistinctCol; /* Index columns used to sort for DISTINCT */
|
||||
Index *pIndex; /* Index used, or NULL */
|
||||
} btree;
|
||||
struct { /* Information for virtual tables */
|
||||
int idxNum; /* Index number */
|
||||
u8 needFree; /* True if sqlite3_free(idxStr) is needed */
|
||||
i8 isOrdered; /* True if satisfies ORDER BY */
|
||||
u16 omitMask; /* Terms that may be omitted */
|
||||
char *idxStr; /* Index identifier string */
|
||||
} vtab;
|
||||
} u;
|
||||
u32 wsFlags; /* WHERE_* flags describing the plan */
|
||||
u16 nLTerm; /* Number of entries in aLTerm[] */
|
||||
u16 nSkip; /* Number of NULL aLTerm[] entries */
|
||||
/**** whereLoopXfer() copies fields above ***********************/
|
||||
#define WHERE_LOOP_XFER_SZ offsetof(WhereLoop, nLSlot)
|
||||
u16 nLSlot; /* Number of slots allocated for aLTerm[] */
|
||||
WhereTerm **aLTerm; /* WhereTerms used */
|
||||
WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
|
||||
WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */
|
||||
};
|
||||
|
||||
/* This object holds the prerequisites and the cost of running a
|
||||
** subquery on one operand of an OR operator in the WHERE clause.
|
||||
** See WhereOrSet for additional information
|
||||
*/
|
||||
struct WhereOrCost {
|
||||
Bitmask prereq; /* Prerequisites */
|
||||
LogEst rRun; /* Cost of running this subquery */
|
||||
LogEst nOut; /* Number of outputs for this subquery */
|
||||
};
|
||||
|
||||
/* The WhereOrSet object holds a set of possible WhereOrCosts that
|
||||
** correspond to the subquery(s) of OR-clause processing. Only the
|
||||
** best N_OR_COST elements are retained.
|
||||
*/
|
||||
#define N_OR_COST 3
|
||||
struct WhereOrSet {
|
||||
u16 n; /* Number of valid a[] entries */
|
||||
WhereOrCost a[N_OR_COST]; /* Set of best costs */
|
||||
};
|
||||
|
||||
/*
|
||||
** Each instance of this object holds a sequence of WhereLoop objects
|
||||
** that implement some or all of a query plan.
|
||||
**
|
||||
** Think of each WhereLoop object as a node in a graph with arcs
|
||||
** showing dependencies and costs for travelling between nodes. (That is
|
||||
** not a completely accurate description because WhereLoop costs are a
|
||||
** vector, not a scalar, and because dependencies are many-to-one, not
|
||||
** one-to-one as are graph nodes. But it is a useful visualization aid.)
|
||||
** Then a WherePath object is a path through the graph that visits some
|
||||
** or all of the WhereLoop objects once.
|
||||
**
|
||||
** The "solver" works by creating the N best WherePath objects of length
|
||||
** 1. Then using those as a basis to compute the N best WherePath objects
|
||||
** of length 2. And so forth until the length of WherePaths equals the
|
||||
** number of nodes in the FROM clause. The best (lowest cost) WherePath
|
||||
** at the end is the chosen query plan.
|
||||
*/
|
||||
struct WherePath {
|
||||
Bitmask maskLoop; /* Bitmask of all WhereLoop objects in this path */
|
||||
Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */
|
||||
LogEst nRow; /* Estimated number of rows generated by this path */
|
||||
LogEst rCost; /* Total cost of this path */
|
||||
LogEst rUnsorted; /* Total cost of this path ignoring sorting costs */
|
||||
i8 isOrdered; /* No. of ORDER BY terms satisfied. -1 for unknown */
|
||||
WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */
|
||||
};
|
||||
|
||||
/*
|
||||
** The query generator uses an array of instances of this structure to
|
||||
** help it analyze the subexpressions of the WHERE clause. Each WHERE
|
||||
** clause subexpression is separated from the others by AND operators,
|
||||
** usually, or sometimes subexpressions separated by OR.
|
||||
**
|
||||
** All WhereTerms are collected into a single WhereClause structure.
|
||||
** The following identity holds:
|
||||
**
|
||||
** WhereTerm.pWC->a[WhereTerm.idx] == WhereTerm
|
||||
**
|
||||
** When a term is of the form:
|
||||
**
|
||||
** X <op> <expr>
|
||||
**
|
||||
** where X is a column name and <op> is one of certain operators,
|
||||
** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the
|
||||
** cursor number and column number for X. WhereTerm.eOperator records
|
||||
** the <op> using a bitmask encoding defined by WO_xxx below. The
|
||||
** use of a bitmask encoding for the operator allows us to search
|
||||
** quickly for terms that match any of several different operators.
|
||||
**
|
||||
** A WhereTerm might also be two or more subterms connected by OR:
|
||||
**
|
||||
** (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR ....
|
||||
**
|
||||
** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR
|
||||
** and the WhereTerm.u.pOrInfo field points to auxiliary information that
|
||||
** is collected about the OR clause.
|
||||
**
|
||||
** If a term in the WHERE clause does not match either of the two previous
|
||||
** categories, then eOperator==0. The WhereTerm.pExpr field is still set
|
||||
** to the original subexpression content and wtFlags is set up appropriately
|
||||
** but no other fields in the WhereTerm object are meaningful.
|
||||
**
|
||||
** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers,
|
||||
** but they do so indirectly. A single WhereMaskSet structure translates
|
||||
** cursor number into bits and the translated bit is stored in the prereq
|
||||
** fields. The translation is used in order to maximize the number of
|
||||
** bits that will fit in a Bitmask. The VDBE cursor numbers might be
|
||||
** spread out over the non-negative integers. For example, the cursor
|
||||
** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45. The WhereMaskSet
|
||||
** translates these sparse cursor numbers into consecutive integers
|
||||
** beginning with 0 in order to make the best possible use of the available
|
||||
** bits in the Bitmask. So, in the example above, the cursor numbers
|
||||
** would be mapped into integers 0 through 7.
|
||||
**
|
||||
** The number of terms in a join is limited by the number of bits
|
||||
** in prereqRight and prereqAll. The default is 64 bits, hence SQLite
|
||||
** is only able to process joins with 64 or fewer tables.
|
||||
*/
|
||||
struct WhereTerm {
|
||||
Expr *pExpr; /* Pointer to the subexpression that is this term */
|
||||
WhereClause *pWC; /* The clause this term is part of */
|
||||
LogEst truthProb; /* Probability of truth for this expression */
|
||||
u16 wtFlags; /* TERM_xxx bit flags. See below */
|
||||
u16 eOperator; /* A WO_xx value describing <op> */
|
||||
u8 nChild; /* Number of children that must disable us */
|
||||
u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */
|
||||
int iParent; /* Disable pWC->a[iParent] when this term disabled */
|
||||
int leftCursor; /* Cursor number of X in "X <op> <expr>" */
|
||||
union {
|
||||
struct {
|
||||
int leftColumn; /* Column number of X in "X <op> <expr>" */
|
||||
int iField; /* Field in (?,?,?) IN (SELECT...) vector */
|
||||
} x; /* Opcode other than OP_OR or OP_AND */
|
||||
WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
|
||||
WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
|
||||
} u;
|
||||
Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
|
||||
Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
|
||||
};
|
||||
|
||||
/*
|
||||
** Allowed values of WhereTerm.wtFlags
|
||||
*/
|
||||
#define TERM_DYNAMIC 0x0001 /* Need to call sqlite3ExprDelete(db, pExpr) */
|
||||
#define TERM_VIRTUAL 0x0002 /* Added by the optimizer. Do not code */
|
||||
#define TERM_CODED 0x0004 /* This term is already coded */
|
||||
#define TERM_COPIED 0x0008 /* Has a child */
|
||||
#define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */
|
||||
#define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */
|
||||
#define TERM_OR_OK 0x0040 /* Used during OR-clause processing */
|
||||
#define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
|
||||
#define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */
|
||||
#define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
|
||||
#define TERM_LIKE 0x0400 /* The original LIKE operator */
|
||||
#define TERM_IS 0x0800 /* Term.pExpr is an IS operator */
|
||||
#define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
|
||||
#define TERM_HEURTRUTH 0x2000 /* Heuristic truthProb used */
|
||||
#ifdef SQLITE_ENABLE_STAT4
|
||||
#define TERM_HIGHTRUTH 0x4000 /* Term excludes few rows */
|
||||
#else
|
||||
#define TERM_HIGHTRUTH 0 /* Only used with STAT4 */
|
||||
#endif
|
||||
|
||||
/*
|
||||
** An instance of the WhereScan object is used as an iterator for locating
|
||||
** terms in the WHERE clause that are useful to the query planner.
|
||||
*/
|
||||
struct WhereScan {
|
||||
WhereClause *pOrigWC; /* Original, innermost WhereClause */
|
||||
WhereClause *pWC; /* WhereClause currently being scanned */
|
||||
const char *zCollName; /* Required collating sequence, if not NULL */
|
||||
Expr *pIdxExpr; /* Search for this index expression */
|
||||
char idxaff; /* Must match this affinity, if zCollName!=NULL */
|
||||
unsigned char nEquiv; /* Number of entries in aEquiv[] */
|
||||
unsigned char iEquiv; /* Next unused slot in aEquiv[] */
|
||||
u32 opMask; /* Acceptable operators */
|
||||
int k; /* Resume scanning at this->pWC->a[this->k] */
|
||||
int aiCur[11]; /* Cursors in the equivalence class */
|
||||
i16 aiColumn[11]; /* Corresponding column number in the eq-class */
|
||||
};
|
||||
|
||||
/*
|
||||
** An instance of the following structure holds all information about a
|
||||
** WHERE clause. Mostly this is a container for one or more WhereTerms.
|
||||
**
|
||||
** Explanation of pOuter: For a WHERE clause of the form
|
||||
**
|
||||
** a AND ((b AND c) OR (d AND e)) AND f
|
||||
**
|
||||
** There are separate WhereClause objects for the whole clause and for
|
||||
** the subclauses "(b AND c)" and "(d AND e)". The pOuter field of the
|
||||
** subclauses points to the WhereClause object for the whole clause.
|
||||
*/
|
||||
struct WhereClause {
|
||||
WhereInfo *pWInfo; /* WHERE clause processing context */
|
||||
WhereClause *pOuter; /* Outer conjunction */
|
||||
u8 op; /* Split operator. TK_AND or TK_OR */
|
||||
u8 hasOr; /* True if any a[].eOperator is WO_OR */
|
||||
int nTerm; /* Number of terms */
|
||||
int nSlot; /* Number of entries in a[] */
|
||||
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
|
||||
#if defined(SQLITE_SMALL_STACK)
|
||||
WhereTerm aStatic[1]; /* Initial static space for a[] */
|
||||
#else
|
||||
WhereTerm aStatic[8]; /* Initial static space for a[] */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to
|
||||
** a dynamically allocated instance of the following structure.
|
||||
*/
|
||||
struct WhereOrInfo {
|
||||
WhereClause wc; /* Decomposition into subterms */
|
||||
Bitmask indexable; /* Bitmask of all indexable tables in the clause */
|
||||
};
|
||||
|
||||
/*
|
||||
** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to
|
||||
** a dynamically allocated instance of the following structure.
|
||||
*/
|
||||
struct WhereAndInfo {
|
||||
WhereClause wc; /* The subexpression broken out */
|
||||
};
|
||||
|
||||
/*
|
||||
** An instance of the following structure keeps track of a mapping
|
||||
** between VDBE cursor numbers and bits of the bitmasks in WhereTerm.
|
||||
**
|
||||
** The VDBE cursor numbers are small integers contained in
|
||||
** SrcList_item.iCursor and Expr.iTable fields. For any given WHERE
|
||||
** clause, the cursor numbers might not begin with 0 and they might
|
||||
** contain gaps in the numbering sequence. But we want to make maximum
|
||||
** use of the bits in our bitmasks. This structure provides a mapping
|
||||
** from the sparse cursor numbers into consecutive integers beginning
|
||||
** with 0.
|
||||
**
|
||||
** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask
|
||||
** corresponds VDBE cursor number B. The A-th bit of a bitmask is 1<<A.
|
||||
**
|
||||
** For example, if the WHERE clause expression used these VDBE
|
||||
** cursors: 4, 5, 8, 29, 57, 73. Then the WhereMaskSet structure
|
||||
** would map those cursor numbers into bits 0 through 5.
|
||||
**
|
||||
** Note that the mapping is not necessarily ordered. In the example
|
||||
** above, the mapping might go like this: 4->3, 5->1, 8->2, 29->0,
|
||||
** 57->5, 73->4. Or one of 719 other combinations might be used. It
|
||||
** does not really matter. What is important is that sparse cursor
|
||||
** numbers all get mapped into bit numbers that begin with 0 and contain
|
||||
** no gaps.
|
||||
*/
|
||||
struct WhereMaskSet {
|
||||
int bVarSelect; /* Used by sqlite3WhereExprUsage() */
|
||||
int n; /* Number of assigned cursor values */
|
||||
int ix[BMS]; /* Cursor assigned to each bit */
|
||||
};
|
||||
|
||||
/*
|
||||
** Initialize a WhereMaskSet object
|
||||
*/
|
||||
#define initMaskSet(P) (P)->n = 0
|
||||
|
||||
/*
|
||||
** This object is a convenience wrapper holding all information needed
|
||||
** to construct WhereLoop objects for a particular query.
|
||||
*/
|
||||
struct WhereLoopBuilder {
|
||||
WhereInfo *pWInfo; /* Information about this WHERE */
|
||||
WhereClause *pWC; /* WHERE clause terms */
|
||||
ExprList *pOrderBy; /* ORDER BY clause */
|
||||
WhereLoop *pNew; /* Template WhereLoop */
|
||||
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
|
||||
#ifdef SQLITE_ENABLE_STAT4
|
||||
UnpackedRecord *pRec; /* Probe for stat4 (if required) */
|
||||
int nRecValid; /* Number of valid fields currently in pRec */
|
||||
#endif
|
||||
unsigned char bldFlags1; /* First set of SQLITE_BLDF_* flags */
|
||||
unsigned char bldFlags2; /* Second set of SQLITE_BLDF_* flags */
|
||||
unsigned int iPlanLimit; /* Search limiter */
|
||||
};
|
||||
|
||||
/* Allowed values for WhereLoopBuider.bldFlags */
|
||||
#define SQLITE_BLDF1_INDEXED 0x0001 /* An index is used */
|
||||
#define SQLITE_BLDF1_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
|
||||
|
||||
#define SQLITE_BLDF2_2NDPASS 0x0004 /* Second builder pass needed */
|
||||
|
||||
/* The WhereLoopBuilder.iPlanLimit is used to limit the number of
|
||||
** index+constraint combinations the query planner will consider for a
|
||||
** particular query. If this parameter is unlimited, then certain
|
||||
** pathological queries can spend excess time in the sqlite3WhereBegin()
|
||||
** routine. The limit is high enough that is should not impact real-world
|
||||
** queries.
|
||||
**
|
||||
** SQLITE_QUERY_PLANNER_LIMIT is the baseline limit. The limit is
|
||||
** increased by SQLITE_QUERY_PLANNER_LIMIT_INCR before each term of the FROM
|
||||
** clause is processed, so that every table in a join is guaranteed to be
|
||||
** able to propose a some index+constraint combinations even if the initial
|
||||
** baseline limit was exhausted by prior tables of the join.
|
||||
*/
|
||||
#ifndef SQLITE_QUERY_PLANNER_LIMIT
|
||||
#define SQLITE_QUERY_PLANNER_LIMIT 20000
|
||||
#endif
|
||||
#ifndef SQLITE_QUERY_PLANNER_LIMIT_INCR
|
||||
#define SQLITE_QUERY_PLANNER_LIMIT_INCR 1000
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Each instance of this object records a change to a single node
|
||||
** in an expression tree to cause that node to point to a column
|
||||
** of an index rather than an expression or a virtual column. All
|
||||
** such transformations need to be undone at the end of WHERE clause
|
||||
** processing.
|
||||
*/
|
||||
typedef struct WhereExprMod WhereExprMod;
|
||||
struct WhereExprMod {
|
||||
WhereExprMod *pNext; /* Next translation on a list of them all */
|
||||
Expr *pExpr; /* The Expr node that was transformed */
|
||||
Expr orig; /* Original value of the Expr node */
|
||||
};
|
||||
|
||||
/*
|
||||
** The WHERE clause processing routine has two halves. The
|
||||
** first part does the start of the WHERE loop and the second
|
||||
** half does the tail of the WHERE loop. An instance of
|
||||
** this structure is returned by the first half and passed
|
||||
** into the second half to give some continuity.
|
||||
**
|
||||
** An instance of this object holds the complete state of the query
|
||||
** planner.
|
||||
*/
|
||||
struct WhereInfo {
|
||||
Parse *pParse; /* Parsing and code generating context */
|
||||
SrcList *pTabList; /* List of tables in the join */
|
||||
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
|
||||
ExprList *pResultSet; /* Result set of the query */
|
||||
Expr *pWhere; /* The complete WHERE clause */
|
||||
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
|
||||
int iContinue; /* Jump here to continue with next record */
|
||||
int iBreak; /* Jump here to break out of the loop */
|
||||
int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
|
||||
u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
|
||||
LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */
|
||||
u8 nLevel; /* Number of nested loop */
|
||||
i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
|
||||
u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
|
||||
u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
|
||||
unsigned bDeferredSeek : 1; /* Uses OP_DeferredSeek */
|
||||
unsigned untestedTerms : 1; /* Not all WHERE terms resolved by outer loop */
|
||||
unsigned
|
||||
bOrderedInnerLoop : 1; /* True if only the inner-most loop is ordered */
|
||||
unsigned sorted : 1; /* True if really sorted (not just grouped) */
|
||||
LogEst nRowOut; /* Estimated number of output rows */
|
||||
int iTop; /* The very beginning of the WHERE loop */
|
||||
int iEndWhere; /* End of the WHERE clause itself */
|
||||
WhereLoop *pLoops; /* List of all WhereLoop objects */
|
||||
WhereExprMod *pExprMods; /* Expression modifications */
|
||||
Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
|
||||
WhereClause sWC; /* Decomposition of the WHERE clause */
|
||||
WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */
|
||||
WhereLevel a[1]; /* Information about each nest loop in WHERE */
|
||||
};
|
||||
|
||||
/*
|
||||
** Private interfaces - callable only by other where.c routines.
|
||||
**
|
||||
** where.c:
|
||||
*/
|
||||
Bitmask sqlite3WhereGetMask(WhereMaskSet *, int);
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
void sqlite3WhereClausePrint(WhereClause *pWC);
|
||||
void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm);
|
||||
void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC);
|
||||
#endif
|
||||
WhereTerm *sqlite3WhereFindTerm(
|
||||
WhereClause *pWC, /* The WHERE clause to be searched */
|
||||
int iCur, /* Cursor number of LHS */
|
||||
int iColumn, /* Column number of LHS */
|
||||
Bitmask notReady, /* RHS must not overlap with this mask */
|
||||
u32 op, /* Mask of WO_xx values describing operator */
|
||||
Index *pIdx /* Must be compatible with this index, if not NULL */
|
||||
);
|
||||
|
||||
/* wherecode.c: */
|
||||
#ifndef SQLITE_OMIT_EXPLAIN
|
||||
int sqlite3WhereExplainOneScan(
|
||||
Parse *pParse, /* Parse context */
|
||||
SrcList *pTabList, /* Table list this loop refers to */
|
||||
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
|
||||
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
|
||||
);
|
||||
#else
|
||||
#define sqlite3WhereExplainOneScan(u, v, w, x) 0
|
||||
#endif /* SQLITE_OMIT_EXPLAIN */
|
||||
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
||||
void sqlite3WhereAddScanStatus(
|
||||
Vdbe *v, /* Vdbe to add scanstatus entry to */
|
||||
SrcList *pSrclist, /* FROM clause pLvl reads data from */
|
||||
WhereLevel *pLvl, /* Level to add scanstatus() entry for */
|
||||
int addrExplain /* Address of OP_Explain (or 0) */
|
||||
);
|
||||
#else
|
||||
#define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d)
|
||||
#endif
|
||||
Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
Parse *pParse, /* Parsing context */
|
||||
Vdbe *v, /* Prepared statement under construction */
|
||||
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
|
||||
int iLevel, /* Which level of pWInfo->a[] should be coded */
|
||||
WhereLevel *pLevel, /* The current level pointer */
|
||||
Bitmask notReady /* Which tables are currently available */
|
||||
);
|
||||
|
||||
/* whereexpr.c: */
|
||||
void sqlite3WhereClauseInit(WhereClause *, WhereInfo *);
|
||||
void sqlite3WhereClauseClear(WhereClause *);
|
||||
void sqlite3WhereSplit(WhereClause *, Expr *, u8);
|
||||
Bitmask sqlite3WhereExprUsage(WhereMaskSet *, Expr *);
|
||||
Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *, Expr *);
|
||||
Bitmask sqlite3WhereExprListUsage(WhereMaskSet *, ExprList *);
|
||||
void sqlite3WhereExprAnalyze(SrcList *, WhereClause *);
|
||||
void sqlite3WhereTabFuncArgs(Parse *, SrcItem *, WhereClause *);
|
||||
|
||||
/*
|
||||
** Bitmasks for the operators on WhereTerm objects. These are all
|
||||
** operators that are of interest to the query planner. An
|
||||
** OR-ed combination of these values can be used when searching for
|
||||
** particular WhereTerms within a WhereClause.
|
||||
**
|
||||
** Value constraints:
|
||||
** WO_EQ == SQLITE_INDEX_CONSTRAINT_EQ
|
||||
** WO_LT == SQLITE_INDEX_CONSTRAINT_LT
|
||||
** WO_LE == SQLITE_INDEX_CONSTRAINT_LE
|
||||
** WO_GT == SQLITE_INDEX_CONSTRAINT_GT
|
||||
** WO_GE == SQLITE_INDEX_CONSTRAINT_GE
|
||||
*/
|
||||
#define WO_IN 0x0001
|
||||
#define WO_EQ 0x0002
|
||||
#define WO_LT (WO_EQ << (TK_LT - TK_EQ))
|
||||
#define WO_LE (WO_EQ << (TK_LE - TK_EQ))
|
||||
#define WO_GT (WO_EQ << (TK_GT - TK_EQ))
|
||||
#define WO_GE (WO_EQ << (TK_GE - TK_EQ))
|
||||
#define WO_AUX 0x0040 /* Op useful to virtual tables only */
|
||||
#define WO_IS 0x0080
|
||||
#define WO_ISNULL 0x0100
|
||||
#define WO_OR 0x0200 /* Two or more OR-connected terms */
|
||||
#define WO_AND 0x0400 /* Two or more AND-connected terms */
|
||||
#define WO_EQUIV 0x0800 /* Of the form A==B, both columns */
|
||||
#define WO_NOOP 0x1000 /* This term does not restrict search space */
|
||||
|
||||
#define WO_ALL 0x1fff /* Mask of all possible WO_* values */
|
||||
#define WO_SINGLE 0x01ff /* Mask of all non-compound WO_* values */
|
||||
|
||||
/*
|
||||
** These are definitions of bits in the WhereLoop.wsFlags field.
|
||||
** The particular combination of bits in each WhereLoop help to
|
||||
** determine the algorithm that WhereLoop represents.
|
||||
*/
|
||||
#define WHERE_COLUMN_EQ 0x00000001 /* x=EXPR */
|
||||
#define WHERE_COLUMN_RANGE 0x00000002 /* x<EXPR and/or x>EXPR */
|
||||
#define WHERE_COLUMN_IN 0x00000004 /* x IN (...) */
|
||||
#define WHERE_COLUMN_NULL 0x00000008 /* x IS NULL */
|
||||
#define WHERE_CONSTRAINT 0x0000000f /* Any of the WHERE_COLUMN_xxx values */
|
||||
#define WHERE_TOP_LIMIT 0x00000010 /* x<EXPR or x<=EXPR constraint */
|
||||
#define WHERE_BTM_LIMIT 0x00000020 /* x>EXPR or x>=EXPR constraint */
|
||||
#define WHERE_BOTH_LIMIT 0x00000030 /* Both x>EXPR and x<EXPR */
|
||||
#define WHERE_IDX_ONLY 0x00000040 /* Use index only - omit table */
|
||||
#define WHERE_IPK 0x00000100 /* x is the INTEGER PRIMARY KEY */
|
||||
#define WHERE_INDEXED 0x00000200 /* WhereLoop.u.btree.pIndex is valid */
|
||||
#define WHERE_VIRTUALTABLE 0x00000400 /* WhereLoop.u.vtab is valid */
|
||||
#define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
|
||||
#define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
|
||||
#define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
|
||||
#define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
|
||||
#define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
|
||||
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
|
||||
#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
|
||||
#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
|
||||
#define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
|
||||
#define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
|
||||
|
||||
#endif /* !defined(SQLITE_WHEREINT_H) */
|
21210
third_party/sqlite3/shell.c
vendored
Normal file
21210
third_party/sqlite3/shell.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
233501
third_party/sqlite3/sqlite3.c
vendored
Normal file
233501
third_party/sqlite3/sqlite3.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue