1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/SQLite/vdbe.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,206 @@
1.4 +/*
1.5 +** 2001 September 15
1.6 +**
1.7 +** The author disclaims copyright to this source code. In place of
1.8 +** a legal notice, here is a blessing:
1.9 +**
1.10 +** May you do good and not evil.
1.11 +** May you find forgiveness for yourself and forgive others.
1.12 +** May you share freely, never taking more than you give.
1.13 +**
1.14 +*************************************************************************
1.15 +** Header file for the Virtual DataBase Engine (VDBE)
1.16 +**
1.17 +** This header defines the interface to the virtual database engine
1.18 +** or VDBE. The VDBE implements an abstract machine that runs a
1.19 +** simple program to access and modify the underlying database.
1.20 +**
1.21 +** $Id: vdbe.h,v 1.138 2008/08/20 22:06:48 drh Exp $
1.22 +*/
1.23 +#ifndef _SQLITE_VDBE_H_
1.24 +#define _SQLITE_VDBE_H_
1.25 +#include <stdio.h>
1.26 +
1.27 +/*
1.28 +** A single VDBE is an opaque structure named "Vdbe". Only routines
1.29 +** in the source file sqliteVdbe.c are allowed to see the insides
1.30 +** of this structure.
1.31 +*/
1.32 +typedef struct Vdbe Vdbe;
1.33 +
1.34 +/*
1.35 +** The names of the following types declared in vdbeInt.h are required
1.36 +** for the VdbeOp definition.
1.37 +*/
1.38 +typedef struct VdbeFunc VdbeFunc;
1.39 +typedef struct Mem Mem;
1.40 +
1.41 +/*
1.42 +** A single instruction of the virtual machine has an opcode
1.43 +** and as many as three operands. The instruction is recorded
1.44 +** as an instance of the following structure:
1.45 +*/
1.46 +struct VdbeOp {
1.47 + u8 opcode; /* What operation to perform */
1.48 + signed char p4type; /* One of the P4_xxx constants for p4 */
1.49 + u8 opflags; /* Not currently used */
1.50 + u8 p5; /* Fifth parameter is an unsigned character */
1.51 + int p1; /* First operand */
1.52 + int p2; /* Second parameter (often the jump destination) */
1.53 + int p3; /* The third parameter */
1.54 + union { /* forth parameter */
1.55 + int i; /* Integer value if p4type==P4_INT32 */
1.56 + void *p; /* Generic pointer */
1.57 + char *z; /* Pointer to data for string (char array) types */
1.58 + i64 *pI64; /* Used when p4type is P4_INT64 */
1.59 + double *pReal; /* Used when p4type is P4_REAL */
1.60 + FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
1.61 + VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
1.62 + CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
1.63 + Mem *pMem; /* Used when p4type is P4_MEM */
1.64 + sqlite3_vtab *pVtab; /* Used when p4type is P4_VTAB */
1.65 + KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
1.66 + int *ai; /* Used when p4type is P4_INTARRAY */
1.67 + } p4;
1.68 +#ifdef SQLITE_DEBUG
1.69 + char *zComment; /* Comment to improve readability */
1.70 +#endif
1.71 +#ifdef VDBE_PROFILE
1.72 + int cnt; /* Number of times this instruction was executed */
1.73 + u64 cycles; /* Total time spent executing this instruction */
1.74 +#endif
1.75 +};
1.76 +typedef struct VdbeOp VdbeOp;
1.77 +
1.78 +/*
1.79 +** A smaller version of VdbeOp used for the VdbeAddOpList() function because
1.80 +** it takes up less space.
1.81 +*/
1.82 +struct VdbeOpList {
1.83 + u8 opcode; /* What operation to perform */
1.84 + signed char p1; /* First operand */
1.85 + signed char p2; /* Second parameter (often the jump destination) */
1.86 + signed char p3; /* Third parameter */
1.87 +};
1.88 +typedef struct VdbeOpList VdbeOpList;
1.89 +
1.90 +/*
1.91 +** Allowed values of VdbeOp.p3type
1.92 +*/
1.93 +#define P4_NOTUSED 0 /* The P4 parameter is not used */
1.94 +#define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
1.95 +#define P4_STATIC (-2) /* Pointer to a static string */
1.96 +#define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
1.97 +#define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
1.98 +#define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
1.99 +#define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
1.100 +#define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
1.101 +#define P4_TRANSIENT (-9) /* P4 is a pointer to a transient string */
1.102 +#define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
1.103 +#define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
1.104 +#define P4_REAL (-12) /* P4 is a 64-bit floating point value */
1.105 +#define P4_INT64 (-13) /* P4 is a 64-bit signed integer */
1.106 +#define P4_INT32 (-14) /* P4 is a 32-bit signed integer */
1.107 +#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
1.108 +
1.109 +/* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure
1.110 +** is made. That copy is freed when the Vdbe is finalized. But if the
1.111 +** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still
1.112 +** gets freed when the Vdbe is finalized so it still should be obtained
1.113 +** from a single sqliteMalloc(). But no copy is made and the calling
1.114 +** function should *not* try to free the KeyInfo.
1.115 +*/
1.116 +#define P4_KEYINFO_HANDOFF (-16)
1.117 +#define P4_KEYINFO_STATIC (-17)
1.118 +
1.119 +/*
1.120 +** The Vdbe.aColName array contains 5n Mem structures, where n is the
1.121 +** number of columns of data returned by the statement.
1.122 +*/
1.123 +#define COLNAME_NAME 0
1.124 +#define COLNAME_DECLTYPE 1
1.125 +#define COLNAME_DATABASE 2
1.126 +#define COLNAME_TABLE 3
1.127 +#define COLNAME_COLUMN 4
1.128 +#ifdef SQLITE_ENABLE_COLUMN_METADATA
1.129 +# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */
1.130 +#else
1.131 +# ifdef SQLITE_OMIT_DECLTYPE
1.132 +# define COLNAME_N 1 /* Store only the name */
1.133 +# else
1.134 +# define COLNAME_N 2 /* Store the name and decltype */
1.135 +# endif
1.136 +#endif
1.137 +
1.138 +/*
1.139 +** The following macro converts a relative address in the p2 field
1.140 +** of a VdbeOp structure into a negative number so that
1.141 +** sqlite3VdbeAddOpList() knows that the address is relative. Calling
1.142 +** the macro again restores the address.
1.143 +*/
1.144 +#define ADDR(X) (-1-(X))
1.145 +
1.146 +/*
1.147 +** The makefile scans the vdbe.c source file and creates the "opcodes.h"
1.148 +** header file that defines a number for each opcode used by the VDBE.
1.149 +*/
1.150 +#include "opcodes.h"
1.151 +
1.152 +/*
1.153 +** Prototypes for the VDBE interface. See comments on the implementation
1.154 +** for a description of what each of these routines does.
1.155 +*/
1.156 +Vdbe *sqlite3VdbeCreate(sqlite3*);
1.157 +int sqlite3VdbeAddOp0(Vdbe*,int);
1.158 +int sqlite3VdbeAddOp1(Vdbe*,int,int);
1.159 +int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
1.160 +int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
1.161 +int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
1.162 +int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
1.163 +void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
1.164 +void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
1.165 +void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
1.166 +void sqlite3VdbeChangeP5(Vdbe*, u8 P5);
1.167 +void sqlite3VdbeJumpHere(Vdbe*, int addr);
1.168 +void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N);
1.169 +void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
1.170 +void sqlite3VdbeUsesBtree(Vdbe*, int);
1.171 +VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
1.172 +int sqlite3VdbeMakeLabel(Vdbe*);
1.173 +void sqlite3VdbeDelete(Vdbe*);
1.174 +void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int);
1.175 +int sqlite3VdbeFinalize(Vdbe*);
1.176 +void sqlite3VdbeResolveLabel(Vdbe*, int);
1.177 +int sqlite3VdbeCurrentAddr(Vdbe*);
1.178 +#ifdef SQLITE_DEBUG
1.179 + void sqlite3VdbeTrace(Vdbe*,FILE*);
1.180 +#endif
1.181 +void sqlite3VdbeResetStepResult(Vdbe*);
1.182 +int sqlite3VdbeReset(Vdbe*);
1.183 +void sqlite3VdbeSetNumCols(Vdbe*,int);
1.184 +int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, int);
1.185 +void sqlite3VdbeCountChanges(Vdbe*);
1.186 +sqlite3 *sqlite3VdbeDb(Vdbe*);
1.187 +void sqlite3VdbeSetSql(Vdbe*, const char *z, int n);
1.188 +void sqlite3VdbeSwap(Vdbe*,Vdbe*);
1.189 +
1.190 +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
1.191 +int sqlite3VdbeReleaseMemory(int);
1.192 +#endif
1.193 +UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,
1.194 + UnpackedRecord*,int);
1.195 +void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
1.196 +int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
1.197 +
1.198 +
1.199 +#ifndef NDEBUG
1.200 + void sqlite3VdbeComment(Vdbe*, const char*, ...);
1.201 +# define VdbeComment(X) sqlite3VdbeComment X
1.202 + void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);
1.203 +# define VdbeNoopComment(X) sqlite3VdbeNoopComment X
1.204 +#else
1.205 +# define VdbeComment(X)
1.206 +# define VdbeNoopComment(X)
1.207 +#endif
1.208 +
1.209 +#endif