📄 vdbeint.h
字号:
*/struct sqlite3_context { FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */ VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */ Mem s; /* The return value is stored here */ Mem *pMem; /* Memory cell used to store aggregate context */ u8 isError; /* Set to true for an error */ CollSeq *pColl; /* Collating sequence */};/*** A Set structure is used for quick testing to see if a value** is part of a small set. Sets are used to implement code like** this:** x.y IN ('hi','hoo','hum')*/typedef struct Set Set;struct Set { Hash hash; /* A set is just a hash table */ HashElem *prev; /* Previously accessed hash elemen */};/*** A FifoPage structure holds a single page of valves. Pages are arranged** in a list.*/typedef struct FifoPage FifoPage;struct FifoPage { int nSlot; /* Number of entries aSlot[] */ int iWrite; /* Push the next value into this entry in aSlot[] */ int iRead; /* Read the next value from this entry in aSlot[] */ FifoPage *pNext; /* Next page in the fifo */ i64 aSlot[1]; /* One or more slots for rowid values */};/*** The Fifo structure is typedef-ed in vdbeInt.h. But the implementation** of that structure is private to this file.**** The Fifo structure describes the entire fifo. */typedef struct Fifo Fifo;struct Fifo { int nEntry; /* Total number of entries */ FifoPage *pFirst; /* First page on the list */ FifoPage *pLast; /* Last page on the list */};/*** A Context stores the last insert rowid, the last statement change count,** and the current statement change count (i.e. changes since last statement).** The current keylist is also stored in the context.** Elements of Context structure type make up the ContextStack, which is** updated by the ContextPush and ContextPop opcodes (used by triggers).** The context is pushed before executing a trigger a popped when the** trigger finishes.*/typedef struct Context Context;struct Context { i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ int nChange; /* Statement changes (Vdbe.nChanges) */ Fifo sFifo; /* Records that will participate in a DELETE or UPDATE */};/*** 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_compile()** is really a pointer to an instance of this structure.**** The Vdbe.inVtabMethod variable is set to non-zero for the duration of** any virtual table method invocations made by the vdbe program. It is** set to 2 for xDestroy method calls and 1 for all other methods. This** variable is used for two purposes: to allow xDestroy methods to execute** "DROP TABLE" statements and to prevent some nasty side effects of** malloc failure when SQLite is invoked recursively by a virtual table ** method function.*/struct Vdbe { sqlite3 *db; /* The whole database */ Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ FILE *trace; /* Write an execution trace here, if not NULL */ int nOp; /* Number of instructions in the program */ int nOpAlloc; /* Number of slots allocated for aOp[] */ Op *aOp; /* Space to hold the virtual machine's program */ int nLabel; /* Number of labels used */ int nLabelAlloc; /* Number of slots allocated in aLabel[] */ int *aLabel; /* Space to hold the labels */ Mem *aStack; /* The operand stack, except string values */ Mem *pTos; /* Top entry in the operand stack */ Mem **apArg; /* Arguments to currently executing user function */ Mem *aColName; /* Column names to return */ int nCursor; /* Number of slots in apCsr[] */ Cursor **apCsr; /* One element of this array for each open cursor */ int nVar; /* Number of entries in aVar[] */ Mem *aVar; /* Values for the OP_Variable opcode. */ char **azVar; /* Name of variables */ int okVar; /* True if azVar[] has been initialized */ int magic; /* Magic number for sanity checking */ int nMem; /* Number of memory locations currently allocated */ Mem *aMem; /* The memory locations */ int nCallback; /* Number of callbacks invoked so far */ int cacheCtr; /* Cursor row cache generation counter */ Fifo sFifo; /* A list of ROWIDs */ int contextStackTop; /* Index of top element in the context stack */ int contextStackDepth; /* The size of the "context" stack */ Context *contextStack; /* Stack used by opcodes ContextPush & ContextPop*/ int pc; /* The program counter */ int rc; /* Value to return */ unsigned uniqueCnt; /* Used by OP_MakeRecord when P2!=0 */ int errorAction; /* Recovery action to do in case of an error */ int inTempTrans; /* True if temp database is transactioned */ int returnStack[100]; /* Return address stack for OP_Gosub & OP_Return */ int returnDepth; /* Next unused element in returnStack[] */ int nResColumn; /* Number of columns in one row of the result set */ char **azResColumn; /* Values for one row of result */ int popStack; /* Pop the stack this much on entry to VdbeExec() */ char *zErrMsg; /* Error message written here */ u8 resOnStack; /* True if there are result values on the stack */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 aborted; /* True if ROLLBACK in another VM causes an abort */ u8 expired; /* True if the VM needs to be recompiled */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ int nChange; /* Number of db changes made since last reset */ i64 startTime; /* Time when query started - used for profiling */#ifdef SQLITE_SSE int fetchId; /* Statement number used by sqlite3_fetch_statement */ int lru; /* Counter used for LRU cache replacement */#endif};/*** The following are allowed values for Vdbe.magic*/#define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */#define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated *//*** Function prototypes*/void sqlite3VdbeFreeCursor(Vdbe *, Cursor*);void sqliteVdbePopStack(Vdbe*,int);int sqlite3VdbeCursorMoveto(Cursor*);#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)void sqlite3VdbePrintOp(FILE*, int, Op*);#endif#ifdef SQLITE_DEBUGvoid sqlite3VdbePrintSql(Vdbe*);#endifint sqlite3VdbeSerialTypeLen(u32);u32 sqlite3VdbeSerialType(Mem*, int);int sqlite3VdbeSerialPut(unsigned char*, Mem*, int);int sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);int sqlite3VdbeIdxKeyCompare(Cursor*, int , const unsigned char*, int*);int sqlite3VdbeIdxRowid(BtCursor *, i64 *);int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);int sqlite3VdbeRecordCompare(void*,int,const void*,int, const void*);int sqlite3VdbeIdxRowidLen(const u8*);int sqlite3VdbeExec(Vdbe*);int sqlite3VdbeList(Vdbe*);int sqlite3VdbeHalt(Vdbe*);int sqlite3VdbeChangeEncoding(Mem *, int);int sqlite3VdbeMemCopy(Mem*, const Mem*);void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);int sqlite3VdbeMemMove(Mem*, Mem*);int sqlite3VdbeMemNulTerminate(Mem*);int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));void sqlite3VdbeMemSetInt64(Mem*, i64);void sqlite3VdbeMemSetDouble(Mem*, double);void sqlite3VdbeMemSetNull(Mem*);int sqlite3VdbeMemMakeWriteable(Mem*);int sqlite3VdbeMemDynamicify(Mem*);int sqlite3VdbeMemStringify(Mem*, int);i64 sqlite3VdbeIntValue(Mem*);int sqlite3VdbeMemIntegerify(Mem*);double sqlite3VdbeRealValue(Mem*);void sqlite3VdbeIntegerAffinity(Mem*);int sqlite3VdbeMemRealify(Mem*);int sqlite3VdbeMemNumerify(Mem*);int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);void sqlite3VdbeMemRelease(Mem *p);int sqlite3VdbeMemFinalize(Mem*, FuncDef*);#ifndef NDEBUGvoid sqlite3VdbeMemSanity(Mem*);int sqlite3VdbeOpcodeNoPush(u8);#endifint sqlite3VdbeMemTranslate(Mem*, u8);void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);int sqlite3VdbeMemHandleBom(Mem *pMem);void sqlite3VdbeFifoInit(Fifo*);int sqlite3VdbeFifoPush(Fifo*, i64);int sqlite3VdbeFifoPop(Fifo*, i64*);void sqlite3VdbeFifoClear(Fifo*);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -