OLD | NEW |
1 /* | 1 /* |
2 ** 2001 September 15 | 2 ** 2001 September 15 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
11 ************************************************************************* | 11 ************************************************************************* |
12 ** Header file for the Virtual DataBase Engine (VDBE) | 12 ** Header file for the Virtual DataBase Engine (VDBE) |
13 ** | 13 ** |
14 ** This header defines the interface to the virtual database engine | 14 ** This header defines the interface to the virtual database engine |
15 ** or VDBE. The VDBE implements an abstract machine that runs a | 15 ** or VDBE. The VDBE implements an abstract machine that runs a |
16 ** simple program to access and modify the underlying database. | 16 ** simple program to access and modify the underlying database. |
17 ** | |
18 ** $Id: vdbe.h,v 1.142 2009/07/24 17:58:53 danielk1977 Exp $ | |
19 */ | 17 */ |
20 #ifndef _SQLITE_VDBE_H_ | 18 #ifndef _SQLITE_VDBE_H_ |
21 #define _SQLITE_VDBE_H_ | 19 #define _SQLITE_VDBE_H_ |
22 #include <stdio.h> | 20 #include <stdio.h> |
23 | 21 |
24 /* | 22 /* |
25 ** A single VDBE is an opaque structure named "Vdbe". Only routines | 23 ** A single VDBE is an opaque structure named "Vdbe". Only routines |
26 ** in the source file sqliteVdbe.c are allowed to see the insides | 24 ** in the source file sqliteVdbe.c are allowed to see the insides |
27 ** of this structure. | 25 ** of this structure. |
28 */ | 26 */ |
29 typedef struct Vdbe Vdbe; | 27 typedef struct Vdbe Vdbe; |
30 | 28 |
31 /* | 29 /* |
32 ** The names of the following types declared in vdbeInt.h are required | 30 ** The names of the following types declared in vdbeInt.h are required |
33 ** for the VdbeOp definition. | 31 ** for the VdbeOp definition. |
34 */ | 32 */ |
35 typedef struct VdbeFunc VdbeFunc; | 33 typedef struct VdbeFunc VdbeFunc; |
36 typedef struct Mem Mem; | 34 typedef struct Mem Mem; |
37 typedef struct SubProgram SubProgram; | 35 typedef struct SubProgram SubProgram; |
38 | 36 |
39 /* | 37 /* |
40 ** A single instruction of the virtual machine has an opcode | 38 ** A single instruction of the virtual machine has an opcode |
41 ** and as many as three operands. The instruction is recorded | 39 ** and as many as three operands. The instruction is recorded |
42 ** as an instance of the following structure: | 40 ** as an instance of the following structure: |
43 */ | 41 */ |
44 struct VdbeOp { | 42 struct VdbeOp { |
45 u8 opcode; /* What operation to perform */ | 43 u8 opcode; /* What operation to perform */ |
46 signed char p4type; /* One of the P4_xxx constants for p4 */ | 44 signed char p4type; /* One of the P4_xxx constants for p4 */ |
47 u8 opflags; /* Not currently used */ | 45 u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */ |
48 u8 p5; /* Fifth parameter is an unsigned character */ | 46 u8 p5; /* Fifth parameter is an unsigned character */ |
49 int p1; /* First operand */ | 47 int p1; /* First operand */ |
50 int p2; /* Second parameter (often the jump destination) */ | 48 int p2; /* Second parameter (often the jump destination) */ |
51 int p3; /* The third parameter */ | 49 int p3; /* The third parameter */ |
52 union { /* fourth parameter */ | 50 union { /* fourth parameter */ |
53 int i; /* Integer value if p4type==P4_INT32 */ | 51 int i; /* Integer value if p4type==P4_INT32 */ |
54 void *p; /* Generic pointer */ | 52 void *p; /* Generic pointer */ |
55 char *z; /* Pointer to data for string (char array) types */ | 53 char *z; /* Pointer to data for string (char array) types */ |
56 i64 *pI64; /* Used when p4type is P4_INT64 */ | 54 i64 *pI64; /* Used when p4type is P4_INT64 */ |
57 double *pReal; /* Used when p4type is P4_REAL */ | 55 double *pReal; /* Used when p4type is P4_REAL */ |
(...skipping 18 matching lines...) Expand all Loading... |
76 | 74 |
77 | 75 |
78 /* | 76 /* |
79 ** A sub-routine used to implement a trigger program. | 77 ** A sub-routine used to implement a trigger program. |
80 */ | 78 */ |
81 struct SubProgram { | 79 struct SubProgram { |
82 VdbeOp *aOp; /* Array of opcodes for sub-program */ | 80 VdbeOp *aOp; /* Array of opcodes for sub-program */ |
83 int nOp; /* Elements in aOp[] */ | 81 int nOp; /* Elements in aOp[] */ |
84 int nMem; /* Number of memory cells required */ | 82 int nMem; /* Number of memory cells required */ |
85 int nCsr; /* Number of cursors required */ | 83 int nCsr; /* Number of cursors required */ |
86 int nRef; /* Number of pointers to this structure */ | |
87 void *token; /* id that may be used to recursive triggers */ | 84 void *token; /* id that may be used to recursive triggers */ |
| 85 SubProgram *pNext; /* Next sub-program already visited */ |
88 }; | 86 }; |
89 | 87 |
90 /* | 88 /* |
91 ** A smaller version of VdbeOp used for the VdbeAddOpList() function because | 89 ** A smaller version of VdbeOp used for the VdbeAddOpList() function because |
92 ** it takes up less space. | 90 ** it takes up less space. |
93 */ | 91 */ |
94 struct VdbeOpList { | 92 struct VdbeOpList { |
95 u8 opcode; /* What operation to perform */ | 93 u8 opcode; /* What operation to perform */ |
96 signed char p1; /* First operand */ | 94 signed char p1; /* First operand */ |
97 signed char p2; /* Second parameter (often the jump destination) */ | 95 signed char p2; /* Second parameter (often the jump destination) */ |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 /* | 163 /* |
166 ** Prototypes for the VDBE interface. See comments on the implementation | 164 ** Prototypes for the VDBE interface. See comments on the implementation |
167 ** for a description of what each of these routines does. | 165 ** for a description of what each of these routines does. |
168 */ | 166 */ |
169 Vdbe *sqlite3VdbeCreate(sqlite3*); | 167 Vdbe *sqlite3VdbeCreate(sqlite3*); |
170 int sqlite3VdbeAddOp0(Vdbe*,int); | 168 int sqlite3VdbeAddOp0(Vdbe*,int); |
171 int sqlite3VdbeAddOp1(Vdbe*,int,int); | 169 int sqlite3VdbeAddOp1(Vdbe*,int,int); |
172 int sqlite3VdbeAddOp2(Vdbe*,int,int,int); | 170 int sqlite3VdbeAddOp2(Vdbe*,int,int,int); |
173 int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); | 171 int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); |
174 int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); | 172 int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); |
| 173 int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); |
175 int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); | 174 int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); |
176 void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); | 175 void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); |
177 void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); | 176 void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); |
178 void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); | 177 void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); |
179 void sqlite3VdbeChangeP5(Vdbe*, u8 P5); | 178 void sqlite3VdbeChangeP5(Vdbe*, u8 P5); |
180 void sqlite3VdbeJumpHere(Vdbe*, int addr); | 179 void sqlite3VdbeJumpHere(Vdbe*, int addr); |
181 void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); | 180 void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); |
182 void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); | 181 void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); |
183 void sqlite3VdbeUsesBtree(Vdbe*, int); | 182 void sqlite3VdbeUsesBtree(Vdbe*, int); |
184 VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); | 183 VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
185 int sqlite3VdbeMakeLabel(Vdbe*); | 184 int sqlite3VdbeMakeLabel(Vdbe*); |
| 185 void sqlite3VdbeRunOnlyOnce(Vdbe*); |
186 void sqlite3VdbeDelete(Vdbe*); | 186 void sqlite3VdbeDelete(Vdbe*); |
| 187 void sqlite3VdbeDeleteObject(sqlite3*,Vdbe*); |
187 void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int); | 188 void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int); |
188 int sqlite3VdbeFinalize(Vdbe*); | 189 int sqlite3VdbeFinalize(Vdbe*); |
189 void sqlite3VdbeResolveLabel(Vdbe*, int); | 190 void sqlite3VdbeResolveLabel(Vdbe*, int); |
190 int sqlite3VdbeCurrentAddr(Vdbe*); | 191 int sqlite3VdbeCurrentAddr(Vdbe*); |
191 #ifdef SQLITE_DEBUG | 192 #ifdef SQLITE_DEBUG |
192 int sqlite3VdbeAssertMayAbort(Vdbe *, int); | 193 int sqlite3VdbeAssertMayAbort(Vdbe *, int); |
193 void sqlite3VdbeTrace(Vdbe*,FILE*); | 194 void sqlite3VdbeTrace(Vdbe*,FILE*); |
194 #endif | 195 #endif |
195 void sqlite3VdbeResetStepResult(Vdbe*); | 196 void sqlite3VdbeResetStepResult(Vdbe*); |
196 int sqlite3VdbeReset(Vdbe*); | 197 int sqlite3VdbeReset(Vdbe*); |
197 void sqlite3VdbeSetNumCols(Vdbe*,int); | 198 void sqlite3VdbeSetNumCols(Vdbe*,int); |
198 int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); | 199 int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); |
199 void sqlite3VdbeCountChanges(Vdbe*); | 200 void sqlite3VdbeCountChanges(Vdbe*); |
200 sqlite3 *sqlite3VdbeDb(Vdbe*); | 201 sqlite3 *sqlite3VdbeDb(Vdbe*); |
201 void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); | 202 void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); |
202 void sqlite3VdbeSwap(Vdbe*,Vdbe*); | 203 void sqlite3VdbeSwap(Vdbe*,Vdbe*); |
203 VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); | 204 VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); |
204 void sqlite3VdbeProgramDelete(sqlite3 *, SubProgram *, int); | 205 sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); |
| 206 void sqlite3VdbeSetVarmask(Vdbe*, int); |
| 207 #ifndef SQLITE_OMIT_TRACE |
| 208 char *sqlite3VdbeExpandSql(Vdbe*, const char*); |
| 209 #endif |
205 | 210 |
206 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT | |
207 int sqlite3VdbeReleaseMemory(int); | |
208 #endif | |
209 UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); | 211 UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); |
210 void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*); | 212 void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*); |
211 int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); | 213 int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); |
212 | 214 |
| 215 #ifndef SQLITE_OMIT_TRIGGER |
| 216 void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 217 #endif |
| 218 |
213 | 219 |
214 #ifndef NDEBUG | 220 #ifndef NDEBUG |
215 void sqlite3VdbeComment(Vdbe*, const char*, ...); | 221 void sqlite3VdbeComment(Vdbe*, const char*, ...); |
216 # define VdbeComment(X) sqlite3VdbeComment X | 222 # define VdbeComment(X) sqlite3VdbeComment X |
217 void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); | 223 void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); |
218 # define VdbeNoopComment(X) sqlite3VdbeNoopComment X | 224 # define VdbeNoopComment(X) sqlite3VdbeNoopComment X |
219 #else | 225 #else |
220 # define VdbeComment(X) | 226 # define VdbeComment(X) |
221 # define VdbeNoopComment(X) | 227 # define VdbeNoopComment(X) |
222 #endif | 228 #endif |
223 | 229 |
224 #endif | 230 #endif |
OLD | NEW |