vdbeInt.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*
  2. ** 2003 September 6
  3. **
  4. ** The author disclaims copyright to this source code. In place of
  5. ** a legal notice, here is a blessing:
  6. **
  7. ** May you do good and not evil.
  8. ** May you find forgiveness for yourself and forgive others.
  9. ** May you share freely, never taking more than you give.
  10. **
  11. *************************************************************************
  12. ** This is the header file for information that is private to the
  13. ** VDBE. This information used to all be at the top of the single
  14. ** source code file "vdbe.c". When that file became too big (over
  15. ** 6000 lines long) it was split up into several smaller files and
  16. ** this header information was factored out.
  17. */
  18. #ifndef _VDBEINT_H_
  19. #define _VDBEINT_H_
  20. /*
  21. ** The maximum number of times that a statement will try to reparse
  22. ** itself before giving up and returning SQLITE_SCHEMA.
  23. */
  24. #ifndef SQLITE_MAX_SCHEMA_RETRY
  25. # define SQLITE_MAX_SCHEMA_RETRY 50
  26. #endif
  27. /*
  28. ** SQL is translated into a sequence of instructions to be
  29. ** executed by a virtual machine. Each instruction is an instance
  30. ** of the following structure.
  31. */
  32. typedef struct VdbeOp Op;
  33. /*
  34. ** Boolean values
  35. */
  36. typedef unsigned char Bool;
  37. /* Opaque type used by code in vdbesort.c */
  38. typedef struct VdbeSorter VdbeSorter;
  39. /* Opaque type used by the explainer */
  40. typedef struct Explain Explain;
  41. /* Elements of the linked list at Vdbe.pAuxData */
  42. typedef struct AuxData AuxData;
  43. /*
  44. ** A cursor is a pointer into a single BTree within a database file.
  45. ** The cursor can seek to a BTree entry with a particular key, or
  46. ** loop over all entries of the Btree. You can also insert new BTree
  47. ** entries or retrieve the key or data from the entry that the cursor
  48. ** is currently pointing to.
  49. **
  50. ** Every cursor that the virtual machine has open is represented by an
  51. ** instance of the following structure.
  52. */
  53. struct VdbeCursor {
  54. BtCursor *pCursor; /* The cursor structure of the backend */
  55. Btree *pBt; /* Separate file holding temporary table */
  56. KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */
  57. int iDb; /* Index of cursor database in db->aDb[] (or -1) */
  58. int pseudoTableReg; /* Register holding pseudotable content. */
  59. int nField; /* Number of fields in the header */
  60. Bool zeroed; /* True if zeroed out and ready for reuse */
  61. Bool rowidIsValid; /* True if lastRowid is valid */
  62. Bool atFirst; /* True if pointing to first entry */
  63. Bool useRandomRowid; /* Generate new record numbers semi-randomly */
  64. Bool nullRow; /* True if pointing to a row with no data */
  65. Bool deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */
  66. Bool isTable; /* True if a table requiring integer keys */
  67. Bool isIndex; /* True if an index containing keys only - no data */
  68. Bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */
  69. Bool isSorter; /* True if a new-style sorter */
  70. Bool multiPseudo; /* Multi-register pseudo-cursor */
  71. sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */
  72. const sqlite3_module *pModule; /* Module for cursor pVtabCursor */
  73. i64 seqCount; /* Sequence counter */
  74. i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */
  75. i64 lastRowid; /* Last rowid from a Next or NextIdx operation */
  76. VdbeSorter *pSorter; /* Sorter object for OP_SorterOpen cursors */
  77. /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or
  78. ** OP_IsUnique opcode on this cursor. */
  79. int seekResult;
  80. /* Cached information about the header for the data record that the
  81. ** cursor is currently pointing to. Only valid if cacheStatus matches
  82. ** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of
  83. ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that
  84. ** the cache is out of date.
  85. **
  86. ** aRow might point to (ephemeral) data for the current row, or it might
  87. ** be NULL.
  88. */
  89. u32 cacheStatus; /* Cache is valid if this matches Vdbe.cacheCtr */
  90. int payloadSize; /* Total number of bytes in the record */
  91. u32 *aType; /* Type values for all entries in the record */
  92. u32 *aOffset; /* Cached offsets to the start of each columns data */
  93. u8 *aRow; /* Data for the current row, if all on one page */
  94. };
  95. typedef struct VdbeCursor VdbeCursor;
  96. /*
  97. ** When a sub-program is executed (OP_Program), a structure of this type
  98. ** is allocated to store the current value of the program counter, as
  99. ** well as the current memory cell array and various other frame specific
  100. ** values stored in the Vdbe struct. When the sub-program is finished,
  101. ** these values are copied back to the Vdbe from the VdbeFrame structure,
  102. ** restoring the state of the VM to as it was before the sub-program
  103. ** began executing.
  104. **
  105. ** The memory for a VdbeFrame object is allocated and managed by a memory
  106. ** cell in the parent (calling) frame. When the memory cell is deleted or
  107. ** overwritten, the VdbeFrame object is not freed immediately. Instead, it
  108. ** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame
  109. ** list is deleted when the VM is reset in VdbeHalt(). The reason for doing
  110. ** this instead of deleting the VdbeFrame immediately is to avoid recursive
  111. ** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the
  112. ** child frame are released.
  113. **
  114. ** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is
  115. ** set to NULL if the currently executing frame is the main program.
  116. */
  117. typedef struct VdbeFrame VdbeFrame;
  118. struct VdbeFrame {
  119. Vdbe *v; /* VM this frame belongs to */
  120. VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */
  121. Op *aOp; /* Program instructions for parent frame */
  122. Mem *aMem; /* Array of memory cells for parent frame */
  123. u8 *aOnceFlag; /* Array of OP_Once flags for parent frame */
  124. VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */
  125. void *token; /* Copy of SubProgram.token */
  126. i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */
  127. int nCursor; /* Number of entries in apCsr */
  128. int pc; /* Program Counter in parent (calling) frame */
  129. int nOp; /* Size of aOp array */
  130. int nMem; /* Number of entries in aMem */
  131. int nOnceFlag; /* Number of entries in aOnceFlag */
  132. int nChildMem; /* Number of memory cells for child frame */
  133. int nChildCsr; /* Number of cursors for child frame */
  134. int nChange; /* Statement changes (Vdbe.nChanges) */
  135. };
  136. #define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
  137. /*
  138. ** A value for VdbeCursor.cacheValid that means the cache is always invalid.
  139. */
  140. #define CACHE_STALE 0
  141. /*
  142. ** Internally, the vdbe manipulates nearly all SQL values as Mem
  143. ** structures. Each Mem struct may cache multiple representations (string,
  144. ** integer etc.) of the same value.
  145. */
  146. struct Mem {
  147. sqlite3 *db; /* The associated database connection */
  148. char *z; /* String or BLOB value */
  149. double r; /* Real value */
  150. union {
  151. i64 i; /* Integer value used when MEM_Int is set in flags */
  152. int nZero; /* Used when bit MEM_Zero is set in flags */
  153. FuncDef *pDef; /* Used only when flags==MEM_Agg */
  154. RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
  155. VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
  156. } u;
  157. int n; /* Number of characters in string value, excluding '\0' */
  158. u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
  159. u8 type; /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */
  160. u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
  161. #ifdef SQLITE_DEBUG
  162. Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
  163. void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */
  164. #endif
  165. void (*xDel)(void *); /* If not null, call this function to delete Mem.z */
  166. char *zMalloc; /* Dynamic buffer allocated by sqlite3_malloc() */
  167. };
  168. /* One or more of the following flags are set to indicate the validOK
  169. ** representations of the value stored in the Mem struct.
  170. **
  171. ** If the MEM_Null flag is set, then the value is an SQL NULL value.
  172. ** No other flags may be set in this case.
  173. **
  174. ** If the MEM_Str flag is set then Mem.z points at a string representation.
  175. ** Usually this is encoded in the same unicode encoding as the main
  176. ** database (see below for exceptions). If the MEM_Term flag is also
  177. ** set, then the string is nul terminated. The MEM_Int and MEM_Real
  178. ** flags may coexist with the MEM_Str flag.
  179. */
  180. #define MEM_Null 0x0001 /* Value is NULL */
  181. #define MEM_Str 0x0002 /* Value is a string */
  182. #define MEM_Int 0x0004 /* Value is an integer */
  183. #define MEM_Real 0x0008 /* Value is a real number */
  184. #define MEM_Blob 0x0010 /* Value is a BLOB */
  185. #define MEM_RowSet 0x0020 /* Value is a RowSet object */
  186. #define MEM_Frame 0x0040 /* Value is a VdbeFrame object */
  187. #define MEM_Invalid 0x0080 /* Value is undefined */
  188. #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
  189. #define MEM_TypeMask 0x01ff /* Mask of type bits */
  190. /* Whenever Mem contains a valid string or blob representation, one of
  191. ** the following flags must be set to determine the memory management
  192. ** policy for Mem.z. The MEM_Term flag tells us whether or not the
  193. ** string is \000 or \u0000 terminated
  194. */
  195. #define MEM_Term 0x0200 /* String rep is nul terminated */
  196. #define MEM_Dyn 0x0400 /* Need to call sqliteFree() on Mem.z */
  197. #define MEM_Static 0x0800 /* Mem.z points to a static string */
  198. #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */
  199. #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */
  200. #define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */
  201. #ifdef SQLITE_OMIT_INCRBLOB
  202. #undef MEM_Zero
  203. #define MEM_Zero 0x0000
  204. #endif
  205. /*
  206. ** Clear any existing type flags from a Mem and replace them with f
  207. */
  208. #define MemSetTypeFlag(p, f) \
  209. ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)
  210. /*
  211. ** Return true if a memory cell is not marked as invalid. This macro
  212. ** is for use inside assert() statements only.
  213. */
  214. #ifdef SQLITE_DEBUG
  215. #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
  216. #endif
  217. /*
  218. ** Each auxilliary data pointer stored by a user defined function
  219. ** implementation calling sqlite3_set_auxdata() is stored in an instance
  220. ** of this structure. All such structures associated with a single VM
  221. ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
  222. ** when the VM is halted (if not before).
  223. */
  224. struct AuxData {
  225. int iOp; /* Instruction number of OP_Function opcode */
  226. int iArg; /* Index of function argument. */
  227. void *pAux; /* Aux data pointer */
  228. void (*xDelete)(void *); /* Destructor for the aux data */
  229. AuxData *pNext; /* Next element in list */
  230. };
  231. /*
  232. ** The "context" argument for a installable function. A pointer to an
  233. ** instance of this structure is the first argument to the routines used
  234. ** implement the SQL functions.
  235. **
  236. ** There is a typedef for this structure in sqlite.h. So all routines,
  237. ** even the public interface to SQLite, can use a pointer to this structure.
  238. ** But this file is the only place where the internal details of this
  239. ** structure are known.
  240. **
  241. ** This structure is defined inside of vdbeInt.h because it uses substructures
  242. ** (Mem) which are only defined there.
  243. */
  244. struct sqlite3_context {
  245. FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
  246. Mem s; /* The return value is stored here */
  247. Mem *pMem; /* Memory cell used to store aggregate context */
  248. CollSeq *pColl; /* Collating sequence */
  249. Vdbe *pVdbe; /* The VM that owns this context */
  250. int iOp; /* Instruction number of OP_Function */
  251. int isError; /* Error code returned by the function. */
  252. u8 skipFlag; /* Skip skip accumulator loading if true */
  253. u8 fErrorOrAux; /* isError!=0 or pVdbe->pAuxData modified */
  254. };
  255. /*
  256. ** An Explain object accumulates indented output which is helpful
  257. ** in describing recursive data structures.
  258. */
  259. struct Explain {
  260. Vdbe *pVdbe; /* Attach the explanation to this Vdbe */
  261. StrAccum str; /* The string being accumulated */
  262. int nIndent; /* Number of elements in aIndent */
  263. u16 aIndent[100]; /* Levels of indentation */
  264. char zBase[100]; /* Initial space */
  265. };
  266. /* A bitfield type for use inside of structures. Always follow with :N where
  267. ** N is the number of bits.
  268. */
  269. typedef unsigned bft; /* Bit Field Type */
  270. /*
  271. ** An instance of the virtual machine. This structure contains the complete
  272. ** state of the virtual machine.
  273. **
  274. ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare()
  275. ** is really a pointer to an instance of this structure.
  276. **
  277. ** The Vdbe.inVtabMethod variable is set to non-zero for the duration of
  278. ** any virtual table method invocations made by the vdbe program. It is
  279. ** set to 2 for xDestroy method calls and 1 for all other methods. This
  280. ** variable is used for two purposes: to allow xDestroy methods to execute
  281. ** "DROP TABLE" statements and to prevent some nasty side effects of
  282. ** malloc failure when SQLite is invoked recursively by a virtual table
  283. ** method function.
  284. */
  285. struct Vdbe {
  286. sqlite3 *db; /* The database connection that owns this statement */
  287. Op *aOp; /* Space to hold the virtual machine's program */
  288. Mem *aMem; /* The memory locations */
  289. Mem **apArg; /* Arguments to currently executing user function */
  290. Mem *aColName; /* Column names to return */
  291. Mem *pResultSet; /* Pointer to an array of results */
  292. int nMem; /* Number of memory locations currently allocated */
  293. int nOp; /* Number of instructions in the program */
  294. int nOpAlloc; /* Number of slots allocated for aOp[] */
  295. int nLabel; /* Number of labels used */
  296. int *aLabel; /* Space to hold the labels */
  297. u16 nResColumn; /* Number of columns in one row of the result set */
  298. int nCursor; /* Number of slots in apCsr[] */
  299. u32 magic; /* Magic number for sanity checking */
  300. char *zErrMsg; /* Error message written here */
  301. Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */
  302. VdbeCursor **apCsr; /* One element of this array for each open cursor */
  303. Mem *aVar; /* Values for the OP_Variable opcode. */
  304. char **azVar; /* Name of variables */
  305. ynVar nVar; /* Number of entries in aVar[] */
  306. ynVar nzVar; /* Number of entries in azVar[] */
  307. u32 cacheCtr; /* VdbeCursor row cache generation counter */
  308. int pc; /* The program counter */
  309. int rc; /* Value to return */
  310. u8 errorAction; /* Recovery action to do in case of an error */
  311. u8 minWriteFileFormat; /* Minimum file format for writable database files */
  312. bft explain:2; /* True if EXPLAIN present on SQL command */
  313. bft inVtabMethod:2; /* See comments above */
  314. bft changeCntOn:1; /* True to update the change-counter */
  315. bft expired:1; /* True if the VM needs to be recompiled */
  316. bft runOnlyOnce:1; /* Automatically expire on reset */
  317. bft usesStmtJournal:1; /* True if uses a statement journal */
  318. bft readOnly:1; /* True for statements that do not write */
  319. bft bIsReader:1; /* True for statements that read */
  320. bft isPrepareV2:1; /* True if prepared with prepare_v2() */
  321. bft doingRerun:1; /* True if rerunning after an auto-reprepare */
  322. int nChange; /* Number of db changes made since last reset */
  323. yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
  324. yDbMask lockMask; /* Subset of btreeMask that requires a lock */
  325. int iStatement; /* Statement number (or 0 if has not opened stmt) */
  326. u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */
  327. #ifndef SQLITE_OMIT_TRACE
  328. i64 startTime; /* Time when query started - used for profiling */
  329. #endif
  330. i64 iCurrentTime; /* Value of julianday('now') for this statement */
  331. i64 nFkConstraint; /* Number of imm. FK constraints this VM */
  332. i64 nStmtDefCons; /* Number of def. constraints when stmt started */
  333. i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
  334. char *zSql; /* Text of the SQL statement that generated this */
  335. void *pFree; /* Free this when deleting the vdbe */
  336. #ifdef SQLITE_DEBUG
  337. FILE *trace; /* Write an execution trace here, if not NULL */
  338. #endif
  339. #ifdef SQLITE_ENABLE_TREE_EXPLAIN
  340. Explain *pExplain; /* The explainer */
  341. char *zExplain; /* Explanation of data structures */
  342. #endif
  343. VdbeFrame *pFrame; /* Parent frame */
  344. VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
  345. int nFrame; /* Number of frames in pFrame list */
  346. u32 expmask; /* Binding to these vars invalidates VM */
  347. SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
  348. int nOnceFlag; /* Size of array aOnceFlag[] */
  349. u8 *aOnceFlag; /* Flags for OP_Once */
  350. AuxData *pAuxData; /* Linked list of auxdata allocations */
  351. };
  352. /*
  353. ** The following are allowed values for Vdbe.magic
  354. */
  355. #define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */
  356. #define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */
  357. #define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */
  358. #define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */
  359. /*
  360. ** Function prototypes
  361. */
  362. void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
  363. void sqliteVdbePopStack(Vdbe*,int);
  364. int sqlite3VdbeCursorMoveto(VdbeCursor*);
  365. #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
  366. void sqlite3VdbePrintOp(FILE*, int, Op*);
  367. #endif
  368. u32 sqlite3VdbeSerialTypeLen(u32);
  369. u32 sqlite3VdbeSerialType(Mem*, int);
  370. u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
  371. u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
  372. void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
  373. int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
  374. int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
  375. int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
  376. int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
  377. int sqlite3VdbeExec(Vdbe*);
  378. int sqlite3VdbeList(Vdbe*);
  379. int sqlite3VdbeHalt(Vdbe*);
  380. int sqlite3VdbeChangeEncoding(Mem *, int);
  381. int sqlite3VdbeMemTooBig(Mem*);
  382. int sqlite3VdbeMemCopy(Mem*, const Mem*);
  383. void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
  384. void sqlite3VdbeMemMove(Mem*, Mem*);
  385. int sqlite3VdbeMemNulTerminate(Mem*);
  386. int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
  387. void sqlite3VdbeMemSetInt64(Mem*, i64);
  388. #ifdef SQLITE_OMIT_FLOATING_POINT
  389. # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
  390. #else
  391. void sqlite3VdbeMemSetDouble(Mem*, double);
  392. #endif
  393. void sqlite3VdbeMemSetNull(Mem*);
  394. void sqlite3VdbeMemSetZeroBlob(Mem*,int);
  395. void sqlite3VdbeMemSetRowSet(Mem*);
  396. int sqlite3VdbeMemMakeWriteable(Mem*);
  397. int sqlite3VdbeMemStringify(Mem*, int);
  398. i64 sqlite3VdbeIntValue(Mem*);
  399. int sqlite3VdbeMemIntegerify(Mem*);
  400. double sqlite3VdbeRealValue(Mem*);
  401. void sqlite3VdbeIntegerAffinity(Mem*);
  402. int sqlite3VdbeMemRealify(Mem*);
  403. int sqlite3VdbeMemNumerify(Mem*);
  404. int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
  405. void sqlite3VdbeMemRelease(Mem *p);
  406. void sqlite3VdbeMemReleaseExternal(Mem *p);
  407. #define VdbeMemRelease(X) \
  408. if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \
  409. sqlite3VdbeMemReleaseExternal(X);
  410. int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
  411. const char *sqlite3OpcodeName(int);
  412. int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
  413. int sqlite3VdbeCloseStatement(Vdbe *, int);
  414. void sqlite3VdbeFrameDelete(VdbeFrame*);
  415. int sqlite3VdbeFrameRestore(VdbeFrame *);
  416. void sqlite3VdbeMemStoreType(Mem *pMem);
  417. int sqlite3VdbeTransferError(Vdbe *p);
  418. int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);
  419. void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
  420. int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
  421. int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *);
  422. int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *);
  423. int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *);
  424. int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *);
  425. #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0
  426. void sqlite3VdbeEnter(Vdbe*);
  427. void sqlite3VdbeLeave(Vdbe*);
  428. #else
  429. # define sqlite3VdbeEnter(X)
  430. # define sqlite3VdbeLeave(X)
  431. #endif
  432. #ifdef SQLITE_DEBUG
  433. void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);
  434. #endif
  435. #ifndef SQLITE_OMIT_FOREIGN_KEY
  436. int sqlite3VdbeCheckFk(Vdbe *, int);
  437. #else
  438. # define sqlite3VdbeCheckFk(p,i) 0
  439. #endif
  440. int sqlite3VdbeMemTranslate(Mem*, u8);
  441. #ifdef SQLITE_DEBUG
  442. void sqlite3VdbePrintSql(Vdbe*);
  443. void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
  444. #endif
  445. int sqlite3VdbeMemHandleBom(Mem *pMem);
  446. #ifndef SQLITE_OMIT_INCRBLOB
  447. int sqlite3VdbeMemExpandBlob(Mem *);
  448. #define ExpandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0)
  449. #else
  450. #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
  451. #define ExpandBlob(P) SQLITE_OK
  452. #endif
  453. #endif /* !defined(_VDBEINT_H_) */