wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using i64 = System.Int64;
2 using u8 = System.Byte;
3 using u64 = System.UInt64;
4  
5 namespace Community.CsharpSqlite
6 {
7 public partial class Sqlite3
8 {
9 /*
10 ** 2001 September 15
11 **
12 ** The author disclaims copyright to this source code. In place of
13 ** a legal notice, here is a blessing:
14 **
15 ** May you do good and not evil.
16 ** May you find forgiveness for yourself and forgive others.
17 ** May you share freely, never taking more than you give.
18 **
19 *************************************************************************
20 ** Header file for the Virtual DataBase Engine (VDBE)
21 **
22 ** This header defines the interface to the virtual database engine
23 ** or VDBE. The VDBE implements an abstract machine that runs a
24 ** simple program to access and modify the underlying database.
25 *************************************************************************
26 ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
27 ** C#-SQLite is an independent reimplementation of the SQLite software library
28 **
29 ** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2
30 **
31 *************************************************************************
32 */
33 //#if !_SQLITE_VDBE_H_
34 //#define _SQLITE_VDBE_H_
35 //#include <stdio.h>
36  
37 /*
38 ** A single VDBE is an opaque structure named "Vdbe". Only routines
39 ** in the source file sqliteVdbe.c are allowed to see the insides
40 ** of this structure.
41 */
42 //typedef struct Vdbe Vdbe;
43  
44 /*
45 ** The names of the following types declared in vdbeInt.h are required
46 ** for the VdbeOp definition.
47 */
48 //typedef struct VdbeFunc VdbeFunc;
49 //typedef struct Mem Mem;
50 //typedef struct SubProgram SubProgram;
51  
52 /*
53 ** A single instruction of the virtual machine has an opcode
54 ** and as many as three operands. The instruction is recorded
55 ** as an instance of the following structure:
56 */
57 public class union_p4
58 { /* fourth parameter */
59 public int i; /* Integer value if p4type==P4_INT32 */
60 public object p; /* Generic pointer */
61 //public string z; /* Pointer to data for string (char array) types */
62 public string z; // In C# string is unicode, so use byte[] instead
63 public i64 pI64; /* Used when p4type is P4_INT64 */
64 public double pReal; /* Used when p4type is P4_REAL */
65 public FuncDef pFunc; /* Used when p4type is P4_FUNCDEF */
66 public VdbeFunc pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
67 public CollSeq pColl; /* Used when p4type is P4_COLLSEQ */
68 public Mem pMem; /* Used when p4type is P4_MEM */
69 public VTable pVtab; /* Used when p4type is P4_VTAB */
70 public KeyInfo pKeyInfo; /* Used when p4type is P4_KEYINFO */
71 public int[] ai; /* Used when p4type is P4_INTARRAY */
72 public SubProgram pProgram; /* Used when p4type is P4_SUBPROGRAM */
73 public dxDel pFuncDel; /* Used when p4type is P4_FUNCDEL */
74 } ;
75 public class VdbeOp
76 {
77 public u8 opcode; /* What operation to perform */
78 public int p4type; /* One of the P4_xxx constants for p4 */
79 public u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */
80 public u8 p5; /* Fifth parameter is an unsigned character */
81 #if DEBUG_CLASS_VDBEOP || DEBUG_CLASS_ALL
82 public int _p1; /* First operand */
83 public int p1
84 {
85 get { return _p1; }
86 set { _p1 = value; }
87 }
88  
89 public int _p2; /* Second parameter (often the jump destination) */
90 public int p2
91 {
92 get { return _p2; }
93 set { _p2 = value; }
94 }
95  
96 public int _p3; /* The third parameter */
97 public int p3
98 {
99 get { return _p3; }
100 set { _p3 = value; }
101 }
102 #else
103 public int p1; /* First operand */
104 public int p2; /* Second parameter (often the jump destination) */
105 public int p3; /* The third parameter */
106 #endif
107 public union_p4 p4 = new union_p4();
108 #if SQLITE_DEBUG || DEBUG
109 public string zComment; /* Comment to improve readability */
110 #endif
111 #if VDBE_PROFILE
112 public int cnt; /* Number of times this instruction was executed */
113 public u64 cycles; /* Total time spend executing this instruction */
114 #endif
115 };
116 //typedef struct VdbeOp VdbeOp;
117  
118 /*
119 ** A sub-routine used to implement a trigger program.
120 */
121 public class SubProgram
122 {
123 public VdbeOp[] aOp; /* Array of opcodes for sub-program */
124 public int nOp; /* Elements in aOp[] */
125 public int nMem; /* Number of memory cells required */
126 public int nCsr; /* Number of cursors required */
127 public int token; /* id that may be used to recursive triggers */
128 public SubProgram pNext; /* Next sub-program already visited */
129 };
130  
131 /*
132 ** A smaller version of VdbeOp used for the VdbeAddOpList() function because
133 ** it takes up less space.
134 */
135 public struct VdbeOpList
136 {
137 public u8 opcode; /* What operation to perform */
138 public int p1; /* First operand */
139 public int p2; /* Second parameter (often the jump destination) */
140 public int p3; /* Third parameter */
141 public VdbeOpList( u8 opcode, int p1, int p2, int p3 )
142 {
143 this.opcode = opcode;
144 this.p1 = p1;
145 this.p2 = p2;
146 this.p3 = p3;
147 }
148  
149 };
150 //typedef struct VdbeOpList VdbeOpList;
151  
152 /*
153 ** Allowed values of VdbeOp.p4type
154 */
155 const int P4_NOTUSED = 0; /* The P4 parameter is not used */
156 const int P4_DYNAMIC = ( -1 ); /* Pointer to a string obtained from sqliteMalloc=(); */
157 const int P4_STATIC = ( -2 ); /* Pointer to a static string */
158 const int P4_COLLSEQ = ( -4 ); /* P4 is a pointer to a CollSeq structure */
159 const int P4_FUNCDEF = ( -5 ); /* P4 is a pointer to a FuncDef structure */
160 const int P4_KEYINFO = ( -6 ); /* P4 is a pointer to a KeyInfo structure */
161 const int P4_VDBEFUNC = ( -7 ); /* P4 is a pointer to a VdbeFunc structure */
162 const int P4_MEM = ( -8 ); /* P4 is a pointer to a Mem* structure */
163 const int P4_TRANSIENT = 0; /* P4 is a pointer to a transient string */
164 const int P4_VTAB = ( -10 ); /* P4 is a pointer to an sqlite3_vtab structure */
165 const int P4_MPRINTF = ( -11 ); /* P4 is a string obtained from sqlite3_mprintf=(); */
166 const int P4_REAL = ( -12 ); /* P4 is a 64-bit floating point value */
167 const int P4_INT64 = ( -13 ); /* P4 is a 64-bit signed integer */
168 const int P4_INT32 = ( -14 ); /* P4 is a 32-bit signed integer */
169 const int P4_INTARRAY = ( -15 ); /* #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
170 const int P4_SUBPROGRAM = ( -18 );/* #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */
171  
172 /* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure
173 ** is made. That copy is freed when the Vdbe is finalized. But if the
174 ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still
175 ** gets freed when the Vdbe is finalized so it still should be obtained
176 ** from a single sqliteMalloc(). But no copy is made and the calling
177 ** function should *not* try to free the KeyInfo.
178 */
179 const int P4_KEYINFO_HANDOFF = ( -16 ); // #define P4_KEYINFO_HANDOFF (-16)
180 const int P4_KEYINFO_STATIC = ( -17 ); // #define P4_KEYINFO_STATIC (-17)
181  
182 /*
183 ** The Vdbe.aColName array contains 5n Mem structures, where n is the
184 ** number of columns of data returned by the statement.
185 */
186 //#define COLNAME_NAME 0
187 //#define COLNAME_DECLTYPE 1
188 //#define COLNAME_DATABASE 2
189 //#define COLNAME_TABLE 3
190 //#define COLNAME_COLUMN 4
191 //#if SQLITE_ENABLE_COLUMN_METADATA
192 //# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */
193 //#else
194 //# ifdef SQLITE_OMIT_DECLTYPE
195 //# define COLNAME_N 1 /* Store only the name */
196 //# else
197 //# define COLNAME_N 2 /* Store the name and decltype */
198 //# endif
199 //#endif
200 const int COLNAME_NAME = 0;
201 const int COLNAME_DECLTYPE = 1;
202 const int COLNAME_DATABASE = 2;
203 const int COLNAME_TABLE = 3;
204 const int COLNAME_COLUMN = 4;
205 #if SQLITE_ENABLE_COLUMN_METADATA
206 const int COLNAME_N = 5; /* Number of COLNAME_xxx symbols */
207 #else
208 # if SQLITE_OMIT_DECLTYPE
209 const int COLNAME_N = 1; /* Number of COLNAME_xxx symbols */
210 # else
211 const int COLNAME_N = 2;
212 # endif
213 #endif
214  
215 /*
216 ** The following macro converts a relative address in the p2 field
217 ** of a VdbeOp structure into a negative number so that
218 ** sqlite3VdbeAddOpList() knows that the address is relative. Calling
219 ** the macro again restores the address.
220 */
221 //#define ADDR(X) (-1-(X))
222 static int ADDR( int x )
223 {
224 return -1 - x;
225 }
226 /*
227 ** The makefile scans the vdbe.c source file and creates the "opcodes.h"
228 ** header file that defines a number for each opcode used by the VDBE.
229 */
230 //#include "opcodes.h"
231  
232 /*
233 ** Prototypes for the VDBE interface. See comments on the implementation
234 ** for a description of what each of these routines does.
235 */
236 /*
237 ** Prototypes for the VDBE interface. See comments on the implementation
238 ** for a description of what each of these routines does.
239 */
240 //Vdbe *sqlite3VdbeCreate(sqlite3);
241 //int sqlite3VdbeAddOp0(Vdbe*,int);
242 //int sqlite3VdbeAddOp1(Vdbe*,int,int);
243 //int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
244 //int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
245 //int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,string zP4,int);
246 //int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
247 //int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
248 //void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char);
249 //void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
250 //void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
251 //void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
252 //void sqlite3VdbeChangeP5(Vdbe*, u8 P5);
253 //void sqlite3VdbeJumpHere(Vdbe*, int addr);
254 //void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N);
255 //void sqlite3VdbeChangeP4(Vdbe*, int addr, string zP4, int N);
256 //void sqlite3VdbeUsesBtree(Vdbe*, int);
257 //VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
258 //int sqlite3VdbeMakeLabel(Vdbe);
259 //void sqlite3VdbeRunOnlyOnce(Vdbe);
260 //void sqlite3VdbeDelete(Vdbe);
261 //void sqlite3VdbeDeleteObject(sqlite3*,Vdbe);
262 //void sqlite3VdbeMakeReady(Vdbe*,Parse);
263 //int sqlite3VdbeFinalize(Vdbe);
264 //void sqlite3VdbeResolveLabel(Vdbe*, int);
265 //int sqlite3VdbeCurrentAddr(Vdbe);
266 //#if SQLITE_DEBUG
267 // int sqlite3VdbeAssertMayAbort(Vdbe *, int);
268 // void sqlite3VdbeTrace(Vdbe*,FILE);
269 //#endif
270 //void sqlite3VdbeResetStepResult(Vdbe);
271 //void sqlite3VdbeRewind(Vdbe);
272 //int sqlite3VdbeReset(Vdbe);
273 //void sqlite3VdbeSetNumCols(Vdbe*,int);
274 //int sqlite3VdbeSetColName(Vdbe*, int, int, string , void()(void));
275 //void sqlite3VdbeCountChanges(Vdbe);
276 //sqlite3 *sqlite3VdbeDb(Vdbe);
277 //void sqlite3VdbeSetSql(Vdbe*, string z, int n, int);
278 //void sqlite3VdbeSwap(Vdbe*,Vdbe);
279 //VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int);
280 //sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
281 //void sqlite3VdbeSetVarmask(Vdbe*, int);
282 //#if !SQLITE_OMIT_TRACE
283 // char *sqlite3VdbeExpandSql(Vdbe*, const char);
284 //#endif
285  
286 //UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int);
287 //void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord);
288 //int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord);
289  
290 //#if !SQLITE_OMIT_TRIGGER
291 //void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram );
292 //#endif
293 #if !NDEBUG
294 //void sqlite3VdbeComment(Vdbe*, const char*, ...);
295 static void VdbeComment( Vdbe v, string zFormat, params object[] ap )
296 {
297 sqlite3VdbeComment( v, zFormat, ap );
298 }//# define VdbeComment(X) sqlite3VdbeComment X
299 //void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);
300 static void VdbeNoopComment( Vdbe v, string zFormat, params object[] ap )
301 {
302 sqlite3VdbeNoopComment( v, zFormat, ap );
303 }//# define VdbeNoopComment(X) sqlite3VdbeNoopComment X
304 #else
305 //# define VdbeComment(X)
306 static void VdbeComment( Vdbe v, string zFormat, params object[] ap ) { }
307 //# define VdbeNoopComment(X)
308 static void VdbeNoopComment( Vdbe v, string zFormat, params object[] ap ) { }
309 #endif
310 }
311 }