2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A** The author disclaims copyright to this source code. In place of 2N/A** a legal notice, here is a blessing: 2N/A** May you do good and not evil. 2N/A** May you find forgiveness for yourself and forgive others. 2N/A** May you share freely, never taking more than you give. 2N/A************************************************************************* 2N/A** This is the header file for information that is private to the 2N/A** VDBE. This information used to all be at the top of the single 2N/A** source code file "vdbe.c". When that file became too big (over 2N/A** 6000 lines long) it was split up into several smaller files and 2N/A** this header information was factored out. 2N/A** When converting from the native format to the key format and back 2N/A** again, in addition to changing the byte order we invert the high-order 2N/A** bit of the most significant byte. This causes negative numbers to 2N/A** sort before positive numbers in the memcmp() function. 2N/A** The makefile scans this source file and creates the following 2N/A** array of string constants which are the names of all VDBE opcodes. 2N/A** This array is defined in a separate source code file named opcode.c 2N/A** which is automatically generated by the makefile. 2N/A** SQL is translated into a sequence of instructions to be 2N/A** executed by a virtual machine. Each instruction is an instance 2N/A** of the following structure. 2N/A** A cursor is a pointer into a single BTree within a database file. 2N/A** The cursor can seek to a BTree entry with a particular key, or 2N/A** loop over all entries of the Btree. You can also insert new BTree 2N/A** entries or retrieve the key or data from the entry that the cursor 2N/A** is currently pointing to. 2N/A** Every cursor that the virtual machine has open is represented by an 2N/A** instance of the following structure. 2N/A** If the Cursor.isTriggerRow flag is set it means that this cursor is 2N/A** really a single row that represents the NEW or OLD pseudo-table of 2N/A** a row trigger. The data for the row is stored in Cursor.pData and 2N/A** the rowid is in Cursor.iKey. 2N/A int lastRecno;
/* Last recno from a Next or NextIdx operation */ 2N/A Btree *
pBt;
/* Separate file holding temporary table */ 2N/A int nData;
/* Number of bytes in pData */ 2N/A char *
pData;
/* Data for a NEW or OLD pseudo-table */ 2N/A int iKey;
/* Key for the NEW or OLD pseudo-table row */ 2N/A** A sorter builds a list of elements to be sorted. Each element of 2N/A** the list is an instance of the following structure. 2N/A int nKey;
/* Number of bytes in the key */ 2N/A char *
zKey;
/* The key by which we will sort */ 2N/A int nData;
/* Number of bytes in the data */ 2N/A char *
pData;
/* The data associated with this key */ 2N/A** Number of buckets used for merge-sort. 2N/A** Number of bytes of string storage space available to each stack 2N/A** layer without having to malloc. NBFS is short for Number of Bytes 2N/A** A single level of the stack or a single memory cell 2N/A** is an instance of the following structure. 2N/A int i;
/* Integer value */ 2N/A int n;
/* Number of characters in string value, including '\0' */ 2N/A int flags;
/* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ 2N/A double r;
/* Real value */ 2N/A char *z;
/* String value */ 2N/A** Allowed values for Mem.flags 2N/A#
define MEM_Dyn 0x0010 /* Need to call sqliteFree() on Mem.z */ 2N/A#
define MEM_Ephem 0x0040 /* Mem.z points to an ephemeral string */ 2N/A** It indicates that the corresponding AggElem.aMem.z points to a 2N/A** aggregate function context that needs to be finalized. 2N/A#
define MEM_AggCtx 0x0100 /* Mem.z points to an agg function context */ 2N/A** The "context" argument for a installable function. A pointer to an 2N/A** instance of this structure is the first argument to the routines used 2N/A** implement the SQL functions. 2N/A** There is a typedef for this structure in sqlite.h. So all routines, 2N/A** even the public interface to SQLite, can use a pointer to this structure. 2N/A** But this file is the only place where the internal details of this 2N/A** structure are known. 2N/A** This structure is defined inside of vdbe.c because it uses substructures 2N/A** (Mem) which are only defined there. 2N/A Mem s;
/* The return value is stored here */ 2N/A void *
pAgg;
/* Aggregate context */ 2N/A int cnt;
/* Number of times that the step function has been called */ 2N/A** An Agg structure describes an Aggregator. Each Agg consists of 2N/A** zero or more Aggregator elements (AggElem). Each AggElem contains 2N/A** a key and one or more values. The values are used in processing 2N/A** aggregate functions in a SELECT. The key is used to implement 2N/A** the GROUP BY clause of a select. 2N/A int nMem;
/* Number of values stored in each AggElem */ 2N/A char *
zKey;
/* The key to this AggElem */ 2N/A int nKey;
/* Number of bytes in the key, including '\0' at end */ 2N/A** A Set structure is used for quick testing to see if a value 2N/A** is part of a small set. Sets are used to implement code like 2N/A** x.y IN ('hi','hoo','hum') 2N/A** A Keylist is a bunch of keys into a table. The keylist can 2N/A** grow without bound. The keylist stores the ROWIDs of database 2N/A** records that need to be deleted or updated. 2N/A int nKey;
/* Number of slots in aKey[] */ 2N/A int nUsed;
/* Next unwritten slot in aKey[] */ 2N/A int nRead;
/* Next unread slot in aKey[] */ 2N/A int aKey[
1];
/* One or more keys. Extra space allocated as needed */ 2N/A** A Context stores the last insert rowid, the last statement change count, 2N/A** and the current statement change count (i.e. changes since last statement). 2N/A** Elements of Context structure type make up the ContextStack, which is 2N/A** updated by the ContextPush and ContextPop opcodes (used by triggers) 2N/A int lsChange;
/* Last statement change count (from db->lsChange) */ 2N/A int csChange;
/* Current statement change count (from db->csChange) */ 2N/A** An instance of the virtual machine. This structure contains the complete 2N/A** state of the virtual machine. 2N/A** The "sqlite_vm" structure pointer that is returned by sqlite_compile() 2N/A** is really a pointer to an instance of this structure. 2N/A FILE *
trace;
/* Write an execution trace here, if not NULL */ 2N/A int nOp;
/* Number of instructions in the program */ 2N/A int nOpAlloc;
/* Number of slots allocated for aOp[] */ 2N/A Op *
aOp;
/* Space to hold the virtual machine's program */ 2N/A char **
zArgv;
/* Text values used by the callback */ 2N/A char **
azColName;
/* Becomes the 4th parameter to callbacks */ 2N/A Cursor *
aCsr;
/* One element of this array for each open cursor */ 2N/A int nVar;
/* Number of entries in azVariable[] */ 2N/A char **
azVar;
/* Values for the OP_Variable opcode */ 2N/A int *
anVar;
/* Length of each value in azVariable[] */ 2N/A u8 *
abVar;
/* TRUE if azVariable[i] needs to be sqliteFree()ed */ 2N/A char *
zLine;
/* A single line from the input file */ 2N/A int magic;
/* Magic number for sanity checking */ 2N/A int nMem;
/* Number of memory locations currently allocated */ 2N/A int nSet;
/* Number of sets allocated */ 2N/A int pc;
/* The program counter */ 2N/A int rc;
/* Value to return */ 2N/A int returnStack[
100];
/* Return address stack for OP_Gosub & OP_Return */ 2N/A int nResColumn;
/* Number of columns in one row of the result set */ 2N/A int popStack;
/* Pop the stack this much on entry to VdbeExec() */ 2N/A** The following are allowed values for Vdbe.magic 2N/A** Function prototypes