📄 vdbeint.h
字号:
/*** 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.*//*** intToKey() and keyToInt() used to transform the rowid. But with** the latest versions of the design they are no-ops.*/#define keyToInt(X) (X)#define intToKey(X) (X)/*** The makefile scans the vdbe.c source file and creates the following** array of string constants which are the names of all VDBE opcodes. This** array is defined in a separate source code file named opcode.c which is** automatically generated by the makefile.*/extern char *sqlite3OpcodeNames[];/*** 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 char Bool;/*** A cursor is a pointer into a single BTree within a database file.** The cursor can seek to a BTree entry with a particular key, or** loop over all entries of the Btree. You can also insert new BTree** entries or retrieve the key or data from the entry that the cursor** is currently pointing to.** ** Every cursor that the virtual machine has open is represented by an** instance of the following structure.**** If the Cursor.isTriggerRow flag is set it means that this cursor is** really a single row that represents the NEW or OLD pseudo-table of** a row trigger. The data for the row is stored in Cursor.pData and** the rowid is in Cursor.iKey.*/struct Cursor { BtCursor *pCursor; /* The cursor structure of the backend */ i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ i64 nextRowid; /* Next rowid returned by OP_NewRowid */ Bool zeroed; /* True if zeroed out and ready for reuse */ Bool rowidIsValid; /* True if lastRowid is valid */ Bool atFirst; /* True if pointing to first entry */ Bool useRandomRowid; /* Generate new record numbers semi-randomly */ Bool nullRow; /* True if pointing to a row with no data */ Bool nextRowidValid; /* True if the nextRowid field is valid */ Bool pseudoTable; /* This is a NEW or OLD pseudo-tables of a trigger */ Bool deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */ Bool isTable; /* True if a table requiring integer keys */ Bool isIndex; /* True if an index containing keys only - no data */ u8 bogusIncrKey; /* Something for pIncrKey to point to if pKeyInfo==0 */ i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ Btree *pBt; /* Separate file holding temporary table */ int nData; /* Number of bytes in pData */ char *pData; /* Data for a NEW or OLD pseudo-table */ i64 iKey; /* Key for the NEW or OLD pseudo-table row */ u8 *pIncrKey; /* Pointer to pKeyInfo->incrKey */ KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */ int nField; /* Number of fields in the header */ /* Cached information about the header for the data record that the ** cursor is currently pointing to. Only valid if cacheValid is true. ** zRow might point to (ephemeral) data for the current row, or it might ** be NULL. */ Bool cacheValid; /* True if the cache is valid */ int payloadSize; /* Total number of bytes in the record */ u32 *aType; /* Type values for all entries in the record */ u32 *aOffset; /* Cached offsets to the start of each columns data */ u8 *aRow; /* Data for the current row, if all on one page */};typedef struct Cursor Cursor;/*** Number of bytes of string storage space available to each stack** layer without having to malloc. NBFS is short for Number of Bytes** For Strings.*/#define NBFS 32/*** 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. A value (and therefore Mem structure)** has the following properties:**** Each value has a manifest type. The manifest type of the value stored** in a Mem struct is returned by the MemType(Mem*) macro. The type is** one of SQLITE_NULL, SQLITE_INTEGER, SQLITE_REAL, SQLITE_TEXT or** SQLITE_BLOB.*/struct Mem { i64 i; /* Integer value */ int n; /* Number of characters in string value, including '\0' */ u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ u8 type; /* One of MEM_Null, MEM_Str, etc. */ u8 enc; /* TEXT_Utf8, TEXT_Utf16le, or TEXT_Utf16be */ double r; /* Real value */ char *z; /* String or BLOB value */ void (*xDel)(void *); /* If not null, call this function to delete Mem.z */ char zShort[NBFS]; /* Space for short strings */};typedef struct Mem Mem;/*** A sorter builds a list of elements to be sorted. Each element of** the list is an instance of the following structure.*/typedef struct Sorter Sorter;struct Sorter { int nKey; /* Number of bytes in the key */ char *zKey; /* The key by which we will sort */ Mem data; Sorter *pNext; /* Next in the list */};/* ** Number of buckets used for merge-sort. */#define NSORT 30/* 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.** No other flags may be set in this case.**** 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.**** Multiple of these values can appear in Mem.flags. But only one** at a time can appear in Mem.type.*/#define MEM_Null 0x0001 /* Value is NULL */#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 *//* 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 0x0020 /* String rep is nul terminated */#define MEM_Dyn 0x0040 /* Need to call sqliteFree() on Mem.z */#define MEM_Static 0x0080 /* Mem.z points to a static string */#define MEM_Ephem 0x0100 /* Mem.z points to an ephemeral string */#define MEM_Short 0x0200 /* Mem.z points to Mem.zShort *//* The following MEM_ value appears only in AggElem.aMem.s.flag fields.** It indicates that the corresponding AggElem.aMem.z points to a** aggregate function context that needs to be finalized.*/#define MEM_AggCtx 0x0400 /* Mem.z points to an agg function context *//* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains** additional information about auxiliary information bound to arguments** of the function. This is used to implement the sqlite3_get_auxdata()** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data** that can be associated with a constant argument to a function. This** allows functions such as "regexp" to compile their constant regular** expression argument once and reused the compiled code for multiple** invocations.*/struct VdbeFunc { FuncDef *pFunc; /* The definition of the function */ int nAux; /* Number of entries allocated for apAux[] */ struct AuxData { void *pAux; /* Aux data for the i-th argument */ void (*xDelete)(void *); /* Destructor for the aux data */ } apAux[1]; /* One slot for each function argument */};typedef struct VdbeFunc VdbeFunc;/*** The "context" argument for a installable function. A pointer to an** instance of this structure is the first argument to the routines used** implement the SQL functions.**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -