blob: 9b6f5459dd8cef665f42a8b2c1e1ba8ce2484809 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#ifndef _SQLITE3_H_
2#define _SQLITE3_H_
3#include <stdarg.h>
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9
10#ifndef SQLITE_EXTERN
11# define SQLITE_EXTERN extern
12#endif
13
14#ifndef SQLITE_API
15# define SQLITE_API
16#endif
17
18
19#define SQLITE_DEPRECATED
20#define SQLITE_EXPERIMENTAL
21
22
23#ifdef SQLITE_VERSION
24# undef SQLITE_VERSION
25#endif
26#ifdef SQLITE_VERSION_NUMBER
27# undef SQLITE_VERSION_NUMBER
28#endif
29
30#define SQLITE_VERSION "3.7.10"
31#define SQLITE_VERSION_NUMBER 3007010
32#define SQLITE_SOURCE_ID "2012-01-16 13:28:40 ebd01a8deffb5024a5d7494eef800d2366d97204"
33
34SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
35SQLITE_API const char *sqlite3_libversion(void);
36SQLITE_API const char *sqlite3_sourceid(void);
37SQLITE_API int sqlite3_libversion_number(void);
38
39#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
40SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
41SQLITE_API const char *sqlite3_compileoption_get(int N);
42#endif
43
44SQLITE_API int sqlite3_threadsafe(void);
45
46typedef struct sqlite3 sqlite3;
47
48#ifdef SQLITE_INT64_TYPE
49 typedef SQLITE_INT64_TYPE sqlite_int64;
50 typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
51#elif defined(_MSC_VER) || defined(__BORLANDC__)
52 typedef __int64 sqlite_int64;
53 typedef unsigned __int64 sqlite_uint64;
54#else
55 typedef long long int sqlite_int64;
56 typedef unsigned long long int sqlite_uint64;
57#endif
58typedef sqlite_int64 sqlite3_int64;
59typedef sqlite_uint64 sqlite3_uint64;
60
61
62#ifdef SQLITE_OMIT_FLOATING_POINT
63# define double sqlite3_int64
64#endif
65
66SQLITE_API int sqlite3_close(sqlite3 *);
67
68typedef int (*sqlite3_callback)(void*,int,char**, char**);
69
70SQLITE_API int sqlite3_exec(
71 sqlite3*, /* An open database */
72 const char *sql, /* SQL to be evaluated */
73 int (*callback)(void*,int,char**,char**), /* Callback function */
74 void *, /* 1st argument to callback */
75 char **errmsg /* Error msg written here */
76);
77
78
79typedef struct sqlite3_file sqlite3_file;
80struct sqlite3_file {
81 const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
82};
83
84#define SQLITE_OK 0 /* Successful result */
85/* beginning-of-error-codes */
86#define SQLITE_ERROR 1 /* SQL error or missing database */
87#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
88#define SQLITE_PERM 3 /* Access permission denied */
89#define SQLITE_ABORT 4 /* Callback routine requested an abort */
90#define SQLITE_BUSY 5 /* The database file is locked */
91#define SQLITE_LOCKED 6 /* A table in the database is locked */
92#define SQLITE_NOMEM 7 /* A malloc() failed */
93#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
94#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
95#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
96#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
97#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
98#define SQLITE_FULL 13 /* Insertion failed because database is full */
99#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
100#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
101#define SQLITE_EMPTY 16 /* Database is empty */
102#define SQLITE_SCHEMA 17 /* The database schema changed */
103#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
104#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
105#define SQLITE_MISMATCH 20 /* Data type mismatch */
106#define SQLITE_MISUSE 21 /* Library used incorrectly */
107#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
108#define SQLITE_AUTH 23 /* Authorization denied */
109#define SQLITE_FORMAT 24 /* Auxiliary database format error */
110#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
111#define SQLITE_NOTADB 26 /* File opened that is not a database file */
112
113#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
114#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
115/* end-of-error-codes */
116
117#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
118#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
119#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
120#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
121#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
122#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
123#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */
124#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
125#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
126#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */
127#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */
128#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */
129#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */
130#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */
131#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
132#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
133#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
134#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
135#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
136
137#define SQLITE_IOCAP_ATOMIC 0x00000001
138#define SQLITE_IOCAP_ATOMIC512 0x00000002
139#define SQLITE_IOCAP_ATOMIC1K 0x00000004
140#define SQLITE_IOCAP_ATOMIC2K 0x00000008
141#define SQLITE_IOCAP_ATOMIC4K 0x00000010
142#define SQLITE_IOCAP_ATOMIC8K 0x00000020
143#define SQLITE_IOCAP_ATOMIC16K 0x00000040
144#define SQLITE_IOCAP_ATOMIC32K 0x00000080
145#define SQLITE_IOCAP_ATOMIC64K 0x00000100
146#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
147#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
148#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
149#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
150
151#define SQLITE_LOCK_NONE 0
152#define SQLITE_LOCK_SHARED 1
153#define SQLITE_LOCK_RESERVED 2
154#define SQLITE_LOCK_PENDING 3
155#define SQLITE_LOCK_EXCLUSIVE 4
156
157#define SQLITE_SYNC_NORMAL 0x00002
158#define SQLITE_SYNC_FULL 0x00003
159#define SQLITE_SYNC_DATAONLY 0x00010
160
161
162#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
163#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
164#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
165#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
166#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
167#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
168#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
169#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
170#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
171#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
172#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))
173#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))
174#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
175#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
176#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
177#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
178#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
179#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
180#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
181#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
182#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
183#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
184#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
185#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
186#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
187#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
188#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
189#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
190
191
192typedef struct sqlite3_io_methods sqlite3_io_methods;
193struct sqlite3_io_methods {
194 int iVersion;
195 int (*xClose)(sqlite3_file*);
196 int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
197 int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
198 int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
199 int (*xSync)(sqlite3_file*, int flags);
200 int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
201 int (*xLock)(sqlite3_file*, int);
202 int (*xUnlock)(sqlite3_file*, int);
203 int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
204 int (*xFileControl)(sqlite3_file*, int op, void *pArg);
205 int (*xSectorSize)(sqlite3_file*);
206 int (*xDeviceCharacteristics)(sqlite3_file*);
207 /* Methods above are valid for version 1 */
208 int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
209 int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
210 void (*xShmBarrier)(sqlite3_file*);
211 int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
212 /* Methods above are valid for version 2 */
213 /* Additional methods may be added in future releases */
214};
215
216typedef struct sqlite3_mutex sqlite3_mutex;
217
218#define SQLITE_FCNTL_LOCKSTATE 1
219#define SQLITE_GET_LOCKPROXYFILE 2
220#define SQLITE_SET_LOCKPROXYFILE 3
221#define SQLITE_LAST_ERRNO 4
222#define SQLITE_FCNTL_SIZE_HINT 5
223#define SQLITE_FCNTL_CHUNK_SIZE 6
224#define SQLITE_FCNTL_FILE_POINTER 7
225#define SQLITE_FCNTL_SYNC_OMITTED 8
226#define SQLITE_FCNTL_WIN32_AV_RETRY 9
227#define SQLITE_FCNTL_PERSIST_WAL 10
228#define SQLITE_FCNTL_OVERWRITE 11
229#define SQLITE_FCNTL_VFSNAME 12
230#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
231
232
233typedef struct sqlite3_vfs sqlite3_vfs;
234typedef void (*sqlite3_syscall_ptr)(void);
235struct sqlite3_vfs {
236 int iVersion; /* Structure version number (currently 3) */
237 int szOsFile; /* Size of subclassed sqlite3_file */
238 int mxPathname; /* Maximum file pathname length */
239 sqlite3_vfs *pNext; /* Next registered VFS */
240 const char *zName; /* Name of this virtual file system */
241 void *pAppData; /* Pointer to application-specific data */
242 int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
243 int flags, int *pOutFlags);
244 int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
245 int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
246 int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
247 void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
248 void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
249 void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
250 void (*xDlClose)(sqlite3_vfs*, void*);
251 int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
252 int (*xSleep)(sqlite3_vfs*, int microseconds);
253 int (*xCurrentTime)(sqlite3_vfs*, double*);
254 int (*xGetLastError)(sqlite3_vfs*, int, char *);
255 /*
256 ** The methods above are in version 1 of the sqlite_vfs object
257 ** definition. Those that follow are added in version 2 or later
258 */
259 int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
260 /*
261 ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
262 ** Those below are for version 3 and greater.
263 */
264 int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
265 sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
266 const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
267 /*
268 ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
269 ** New fields may be appended in figure versions. The iVersion
270 ** value will increment whenever this happens.
271 */
272};
273
274
275#define SQLITE_ACCESS_EXISTS 0
276#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
277#define SQLITE_ACCESS_READ 2 /* Unused */
278
279#define SQLITE_SHM_UNLOCK 1
280#define SQLITE_SHM_LOCK 2
281#define SQLITE_SHM_SHARED 4
282#define SQLITE_SHM_EXCLUSIVE 8
283
284#define SQLITE_SHM_NLOCK 8
285
286typedef struct sqlite3_mem_methods sqlite3_mem_methods;
287struct sqlite3_mem_methods {
288 void *(*xMalloc)(int); /* Memory allocation function */
289 void (*xFree)(void*); /* Free a prior allocation */
290 void *(*xRealloc)(void*,int); /* Resize an allocation */
291 int (*xSize)(void*); /* Return the size of an allocation */
292 int (*xRoundup)(int); /* Round up request size to allocation size */
293 int (*xInit)(void*); /* Initialize the memory allocator */
294 void (*xShutdown)(void*); /* Deinitialize the memory allocator */
295 void *pAppData; /* Argument to xInit() and xShutdown() */
296};
297
298SQLITE_API int sqlite3_initialize(void);
299SQLITE_API int sqlite3_shutdown(void);
300SQLITE_API int sqlite3_os_init(void);
301SQLITE_API int sqlite3_os_end(void);
302SQLITE_API int sqlite3_config(int, ...);
303SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
304
305
306#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
307#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
308#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
309#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
310#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
311#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */
312#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
313#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
314#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
315#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
316#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
317/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
318#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
319#define SQLITE_CONFIG_PCACHE 14 /* no-op */
320#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
321#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
322#define SQLITE_CONFIG_URI 17 /* int */
323#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
324#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
325
326#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
327#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
328#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
329
330#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
331#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
332
333SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
334SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
335SQLITE_API int sqlite3_changes(sqlite3*);
336SQLITE_API int sqlite3_total_changes(sqlite3*);
337SQLITE_API void sqlite3_interrupt(sqlite3*);
338SQLITE_API int sqlite3_complete(const char *sql);
339SQLITE_API int sqlite3_complete16(const void *sql);
340SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
341SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
342SQLITE_API int sqlite3_get_table(
343 sqlite3 *db, /* An open database */
344 const char *zSql, /* SQL to be evaluated */
345 char ***pazResult, /* Results of the query */
346 int *pnRow, /* Number of result rows written here */
347 int *pnColumn, /* Number of result columns written here */
348 char **pzErrmsg /* Error msg written here */
349);
350SQLITE_API void sqlite3_free_table(char **result);
351SQLITE_API char *sqlite3_mprintf(const char*,...);
352SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
353SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
354SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
355
356SQLITE_API void *sqlite3_malloc(int);
357SQLITE_API void *sqlite3_realloc(void*, int);
358SQLITE_API void sqlite3_free(void*);
359SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
360SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
361SQLITE_API void sqlite3_randomness(int N, void *P);
362
363SQLITE_API int sqlite3_set_authorizer(
364 sqlite3*,
365 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
366 void *pUserData
367);
368
369#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
370#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
371#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
372#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
373#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
374#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */
375#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
376#define SQLITE_CREATE_VIEW 8 /* View Name NULL */
377#define SQLITE_DELETE 9 /* Table Name NULL */
378#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
379#define SQLITE_DROP_TABLE 11 /* Table Name NULL */
380#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
381#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
382#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
383#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */
384#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
385#define SQLITE_DROP_VIEW 17 /* View Name NULL */
386#define SQLITE_INSERT 18 /* Table Name NULL */
387#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */
388#define SQLITE_READ 20 /* Table Name Column Name */
389#define SQLITE_SELECT 21 /* NULL NULL */
390#define SQLITE_TRANSACTION 22 /* Operation NULL */
391#define SQLITE_UPDATE 23 /* Table Name Column Name */
392#define SQLITE_ATTACH 24 /* Filename NULL */
393#define SQLITE_DETACH 25 /* Database Name NULL */
394#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
395#define SQLITE_REINDEX 27 /* Index Name NULL */
396#define SQLITE_ANALYZE 28 /* Table Name NULL */
397#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
398#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
399#define SQLITE_FUNCTION 31 /* NULL Function Name */
400#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
401#define SQLITE_COPY 0 /* No longer used */
402
403typedef struct sqlite3_stmt sqlite3_stmt;
404
405SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
406SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
407 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
408SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
409
410SQLITE_API int sqlite3_open(
411 const char *filename, /* Database filename (UTF-8) */
412 sqlite3 **ppDb /* OUT: SQLite db handle */
413);
414SQLITE_API int sqlite3_open16(
415 const void *filename, /* Database filename (UTF-16) */
416 sqlite3 **ppDb /* OUT: SQLite db handle */
417);
418SQLITE_API int sqlite3_open_v2(
419 const char *filename, /* Database filename (UTF-8) */
420 sqlite3 **ppDb, /* OUT: SQLite db handle */
421 int flags, /* Flags */
422 const char *zVfs /* Name of VFS module to use */
423);
424
425SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
426SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
427SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
428
429SQLITE_API int sqlite3_errcode(sqlite3 *db);
430SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
431SQLITE_API const char *sqlite3_errmsg(sqlite3*);
432SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
433
434SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
435
436#define SQLITE_LIMIT_LENGTH 0
437#define SQLITE_LIMIT_SQL_LENGTH 1
438#define SQLITE_LIMIT_COLUMN 2
439#define SQLITE_LIMIT_EXPR_DEPTH 3
440#define SQLITE_LIMIT_COMPOUND_SELECT 4
441#define SQLITE_LIMIT_VDBE_OP 5
442#define SQLITE_LIMIT_FUNCTION_ARG 6
443#define SQLITE_LIMIT_ATTACHED 7
444#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
445#define SQLITE_LIMIT_VARIABLE_NUMBER 9
446#define SQLITE_LIMIT_TRIGGER_DEPTH 10
447
448SQLITE_API int sqlite3_prepare(
449 sqlite3 *db, /* Database handle */
450 const char *zSql, /* SQL statement, UTF-8 encoded */
451 int nByte, /* Maximum length of zSql in bytes. */
452 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
453 const char **pzTail /* OUT: Pointer to unused portion of zSql */
454);
455SQLITE_API int sqlite3_prepare_v2(
456 sqlite3 *db, /* Database handle */
457 const char *zSql, /* SQL statement, UTF-8 encoded */
458 int nByte, /* Maximum length of zSql in bytes. */
459 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
460 const char **pzTail /* OUT: Pointer to unused portion of zSql */
461);
462SQLITE_API int sqlite3_prepare16(
463 sqlite3 *db, /* Database handle */
464 const void *zSql, /* SQL statement, UTF-16 encoded */
465 int nByte, /* Maximum length of zSql in bytes. */
466 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
467 const void **pzTail /* OUT: Pointer to unused portion of zSql */
468);
469SQLITE_API int sqlite3_prepare16_v2(
470 sqlite3 *db, /* Database handle */
471 const void *zSql, /* SQL statement, UTF-16 encoded */
472 int nByte, /* Maximum length of zSql in bytes. */
473 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
474 const void **pzTail /* OUT: Pointer to unused portion of zSql */
475);
476
477typedef struct Mem sqlite3_value;
478typedef struct sqlite3_context sqlite3_context;
479
480SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
481SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
482SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
483
484SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
485SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
486SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
487SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
488SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
489SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
490SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
491SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
492SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
493
494SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
495SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
496SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
497SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
498SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
499SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
500SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
501SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
502SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
503SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
504SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
505SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
506SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
507SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
508SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
509
510SQLITE_API int sqlite3_step(sqlite3_stmt*);
511SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
512
513#define SQLITE_INTEGER 1
514#define SQLITE_FLOAT 2
515#define SQLITE_BLOB 4
516#define SQLITE_NULL 5
517#ifdef SQLITE_TEXT
518# undef SQLITE_TEXT
519#else
520# define SQLITE_TEXT 3
521#endif
522#define SQLITE3_TEXT 3
523
524#define SQLITE_UTF8 1
525#define SQLITE_UTF16LE 2
526#define SQLITE_UTF16BE 3
527#define SQLITE_UTF16 4 /* Use native byte order */
528#define SQLITE_ANY 5 /* sqlite3_create_function only */
529#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
530
531SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
532SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
533SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
534SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
535SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
536SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
537SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
538SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
539SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
540SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
541SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
542SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
543
544SQLITE_API int sqlite3_create_function(
545 sqlite3 *db,
546 const char *zFunctionName,
547 int nArg,
548 int eTextRep,
549 void *pApp,
550 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
551 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
552 void (*xFinal)(sqlite3_context*)
553);
554SQLITE_API int sqlite3_create_function16(
555 sqlite3 *db,
556 const void *zFunctionName,
557 int nArg,
558 int eTextRep,
559 void *pApp,
560 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
561 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
562 void (*xFinal)(sqlite3_context*)
563);
564SQLITE_API int sqlite3_create_function_v2(
565 sqlite3 *db,
566 const char *zFunctionName,
567 int nArg,
568 int eTextRep,
569 void *pApp,
570 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
571 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
572 void (*xFinal)(sqlite3_context*),
573 void(*xDestroy)(void*)
574);
575
576#ifndef SQLITE_OMIT_DEPRECATED
577SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
578SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
579SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
580SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
581SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
582SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
583#endif
584
585
586typedef void (*sqlite3_destructor_type)(void*);
587#define SQLITE_STATIC ((sqlite3_destructor_type)0)
588#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
589
590SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
591SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
592SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
593SQLITE_API double sqlite3_value_double(sqlite3_value*);
594SQLITE_API int sqlite3_value_int(sqlite3_value*);
595SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
596SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
597SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
598SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
599SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
600SQLITE_API int sqlite3_value_type(sqlite3_value*);
601SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
602
603SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
604SQLITE_API void *sqlite3_user_data(sqlite3_context*);
605SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
606SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
607SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
608
609SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
610SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
611SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
612SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
613SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
614SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
615SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
616SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
617SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
618SQLITE_API void sqlite3_result_null(sqlite3_context*);
619SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
620SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
621SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
622SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
623SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
624SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
625
626
627SQLITE_API int sqlite3_create_collation(
628 sqlite3*,
629 const char *zName,
630 int eTextRep,
631 void *pArg,
632 int(*xCompare)(void*,int,const void*,int,const void*)
633);
634SQLITE_API int sqlite3_create_collation_v2(
635 sqlite3*,
636 const char *zName,
637 int eTextRep,
638 void *pArg,
639 int(*xCompare)(void*,int,const void*,int,const void*),
640 void(*xDestroy)(void*)
641);
642SQLITE_API int sqlite3_create_collation16(
643 sqlite3*,
644 const void *zName,
645 int eTextRep,
646 void *pArg,
647 int(*xCompare)(void*,int,const void*,int,const void*)
648);
649
650SQLITE_API int sqlite3_collation_needed(
651 sqlite3*,
652 void*,
653 void(*)(void*,sqlite3*,int eTextRep,const char*)
654);
655SQLITE_API int sqlite3_collation_needed16(
656 sqlite3*,
657 void*,
658 void(*)(void*,sqlite3*,int eTextRep,const void*)
659);
660
661#ifdef SQLITE_ENABLE_CEROD
662SQLITE_API void sqlite3_activate_cerod(
663 const char *zPassPhrase /* Activation phrase */
664);
665#endif
666
667#ifdef SQLITE_HAS_CODEC
668SQLITE_API int sqlite3_key(
669 sqlite3 *db, /* Database to be rekeyed */
670 const void *pKey, int nKey /* The key */
671);
672
673SQLITE_API int sqlite3_rekey(
674 sqlite3 *db, /* Database to be rekeyed */
675 const void *pKey, int nKey /* The new key */
676);
677
678SQLITE_API void sqlite3_activate_see(
679 const char *zPassPhrase /* Activation phrase */
680);
681#endif
682
683SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
684
685SQLITE_API int sqlite3_sleep(int);
686SQLITE_API int sqlite3_get_autocommit(sqlite3*);
687SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
688SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
689SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
690SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
691SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
692SQLITE_API int sqlite3_enable_shared_cache(int);
693
694SQLITE_API void *sqlite3_update_hook(
695 sqlite3*,
696 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
697 void*
698);
699
700SQLITE_API int sqlite3_release_memory(int);
701SQLITE_API int sqlite3_db_release_memory(sqlite3*);
702
703SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
704SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
705
706SQLITE_API int sqlite3_table_column_metadata(
707 sqlite3 *db, /* Connection handle */
708 const char *zDbName, /* Database name or NULL */
709 const char *zTableName, /* Table name */
710 const char *zColumnName, /* Column name */
711 char const **pzDataType, /* OUTPUT: Declared data type */
712 char const **pzCollSeq, /* OUTPUT: Collation sequence name */
713 int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */
714 int *pPrimaryKey, /* OUTPUT: True if column part of PK */
715 int *pAutoinc /* OUTPUT: True if column is auto-increment */
716);
717
718SQLITE_API int sqlite3_load_extension(
719 sqlite3 *db, /* Load the extension into this database connection */
720 const char *zFile, /* Name of the shared library containing extension */
721 const char *zProc, /* Entry point. Derived from zFile if 0 */
722 char **pzErrMsg /* Put error message here if not 0 */
723);
724
725typedef struct sqlite3_vtab sqlite3_vtab;
726typedef struct sqlite3_index_info sqlite3_index_info;
727typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
728typedef struct sqlite3_module sqlite3_module;
729
730SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
731SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
732SQLITE_API void sqlite3_reset_auto_extension(void);
733
734
735#define SQLITE_INDEX_CONSTRAINT_EQ 2
736#define SQLITE_INDEX_CONSTRAINT_GT 4
737#define SQLITE_INDEX_CONSTRAINT_LE 8
738#define SQLITE_INDEX_CONSTRAINT_LT 16
739#define SQLITE_INDEX_CONSTRAINT_GE 32
740#define SQLITE_INDEX_CONSTRAINT_MATCH 64
741
742
743struct sqlite3_module {
744 int iVersion;
745 int (*xCreate)(sqlite3*, void *pAux,
746 int argc, const char *const*argv,
747 sqlite3_vtab **ppVTab, char**);
748 int (*xConnect)(sqlite3*, void *pAux,
749 int argc, const char *const*argv,
750 sqlite3_vtab **ppVTab, char**);
751 int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
752 int (*xDisconnect)(sqlite3_vtab *pVTab);
753 int (*xDestroy)(sqlite3_vtab *pVTab);
754 int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
755 int (*xClose)(sqlite3_vtab_cursor*);
756 int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
757 int argc, sqlite3_value **argv);
758 int (*xNext)(sqlite3_vtab_cursor*);
759 int (*xEof)(sqlite3_vtab_cursor*);
760 int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
761 int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
762 int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
763 int (*xBegin)(sqlite3_vtab *pVTab);
764 int (*xSync)(sqlite3_vtab *pVTab);
765 int (*xCommit)(sqlite3_vtab *pVTab);
766 int (*xRollback)(sqlite3_vtab *pVTab);
767 int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
768 void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
769 void **ppArg);
770 int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
771 /* The methods above are in version 1 of the sqlite_module object. Those
772 ** below are for version 2 and greater. */
773 int (*xSavepoint)(sqlite3_vtab *pVTab, int);
774 int (*xRelease)(sqlite3_vtab *pVTab, int);
775 int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
776};
777
778struct sqlite3_index_info {
779 /* Inputs */
780 int nConstraint; /* Number of entries in aConstraint */
781 struct sqlite3_index_constraint {
782 int iColumn; /* Column on left-hand side of constraint */
783 unsigned char op; /* Constraint operator */
784 unsigned char usable; /* True if this constraint is usable */
785 int iTermOffset; /* Used internally - xBestIndex should ignore */
786 } *aConstraint; /* Table of WHERE clause constraints */
787 int nOrderBy; /* Number of terms in the ORDER BY clause */
788 struct sqlite3_index_orderby {
789 int iColumn; /* Column number */
790 unsigned char desc; /* True for DESC. False for ASC. */
791 } *aOrderBy; /* The ORDER BY clause */
792 /* Outputs */
793 struct sqlite3_index_constraint_usage {
794 int argvIndex; /* if >0, constraint is part of argv to xFilter */
795 unsigned char omit; /* Do not code a test for this constraint */
796 } *aConstraintUsage;
797 int idxNum; /* Number used to identify the index */
798 char *idxStr; /* String, possibly obtained from sqlite3_malloc */
799 int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
800 int orderByConsumed; /* True if output is already ordered */
801 double estimatedCost; /* Estimated cost of using this index */
802};
803
804typedef struct sqlite3_blob sqlite3_blob;
805
806SQLITE_API int sqlite3_create_module(
807 sqlite3 *db, /* SQLite connection to register module with */
808 const char *zName, /* Name of the module */
809 const sqlite3_module *p, /* Methods for the module */
810 void *pClientData /* Client data for xCreate/xConnect */
811);
812SQLITE_API int sqlite3_create_module_v2(
813 sqlite3 *db, /* SQLite connection to register module with */
814 const char *zName, /* Name of the module */
815 const sqlite3_module *p, /* Methods for the module */
816 void *pClientData, /* Client data for xCreate/xConnect */
817 void(*xDestroy)(void*) /* Module destructor function */
818);
819
820struct sqlite3_vtab {
821 const sqlite3_module *pModule; /* The module for this virtual table */
822 int nRef; /* NO LONGER USED */
823 char *zErrMsg; /* Error message from sqlite3_mprintf() */
824 /* Virtual table implementations will typically add additional fields */
825};
826
827struct sqlite3_vtab_cursor {
828 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
829 /* Virtual table implementations will typically add additional fields */
830};
831
832SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
833SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
834
835SQLITE_API int sqlite3_blob_open(
836 sqlite3*,
837 const char *zDb,
838 const char *zTable,
839 const char *zColumn,
840 sqlite3_int64 iRow,
841 int flags,
842 sqlite3_blob **ppBlob
843);
844
845SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
846SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
847SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
848SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
849SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
850
851SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
852SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
853SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
854
855SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
856SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
857SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
858SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
859SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
860
861typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
862struct sqlite3_mutex_methods {
863 int (*xMutexInit)(void);
864 int (*xMutexEnd)(void);
865 sqlite3_mutex *(*xMutexAlloc)(int);
866 void (*xMutexFree)(sqlite3_mutex *);
867 void (*xMutexEnter)(sqlite3_mutex *);
868 int (*xMutexTry)(sqlite3_mutex *);
869 void (*xMutexLeave)(sqlite3_mutex *);
870 int (*xMutexHeld)(sqlite3_mutex *);
871 int (*xMutexNotheld)(sqlite3_mutex *);
872};
873
874#ifndef NDEBUG
875SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
876SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
877#endif
878
879
880#define SQLITE_MUTEX_FAST 0
881#define SQLITE_MUTEX_RECURSIVE 1
882#define SQLITE_MUTEX_STATIC_MASTER 2
883#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */
884#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */
885#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */
886#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
887#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
888#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */
889#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */
890
891
892SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
893
894SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
895
896SQLITE_API int sqlite3_test_control(int op, ...);
897
898#define SQLITE_TESTCTRL_FIRST 5
899#define SQLITE_TESTCTRL_PRNG_SAVE 5
900#define SQLITE_TESTCTRL_PRNG_RESTORE 6
901#define SQLITE_TESTCTRL_PRNG_RESET 7
902#define SQLITE_TESTCTRL_BITVEC_TEST 8
903#define SQLITE_TESTCTRL_FAULT_INSTALL 9
904#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
905#define SQLITE_TESTCTRL_PENDING_BYTE 11
906#define SQLITE_TESTCTRL_ASSERT 12
907#define SQLITE_TESTCTRL_ALWAYS 13
908#define SQLITE_TESTCTRL_RESERVE 14
909#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
910#define SQLITE_TESTCTRL_ISKEYWORD 16
911#define SQLITE_TESTCTRL_SCRATCHMALLOC 17
912#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
913#define SQLITE_TESTCTRL_EXPLAIN_STMT 19
914#define SQLITE_TESTCTRL_LAST 19
915
916#define SQLITE_STATUS_MEMORY_USED 0
917#define SQLITE_STATUS_PAGECACHE_USED 1
918#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2
919#define SQLITE_STATUS_SCRATCH_USED 3
920#define SQLITE_STATUS_SCRATCH_OVERFLOW 4
921#define SQLITE_STATUS_MALLOC_SIZE 5
922#define SQLITE_STATUS_PARSER_STACK 6
923#define SQLITE_STATUS_PAGECACHE_SIZE 7
924#define SQLITE_STATUS_SCRATCH_SIZE 8
925#define SQLITE_STATUS_MALLOC_COUNT 9
926
927#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
928#define SQLITE_DBSTATUS_CACHE_USED 1
929#define SQLITE_DBSTATUS_SCHEMA_USED 2
930#define SQLITE_DBSTATUS_STMT_USED 3
931#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
932#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
933#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
934#define SQLITE_DBSTATUS_CACHE_HIT 7
935#define SQLITE_DBSTATUS_CACHE_MISS 8
936#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
937
938
939SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
940
941SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
942
943SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
944
945#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
946#define SQLITE_STMTSTATUS_SORT 2
947#define SQLITE_STMTSTATUS_AUTOINDEX 3
948
949typedef struct sqlite3_pcache sqlite3_pcache;
950
951typedef struct sqlite3_pcache_page sqlite3_pcache_page;
952struct sqlite3_pcache_page {
953 void *pBuf; /* The content of the page */
954 void *pExtra; /* Extra information associated with the page */
955};
956
957typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;
958struct sqlite3_pcache_methods2 {
959 int iVersion;
960 void *pArg;
961 int (*xInit)(void*);
962 void (*xShutdown)(void*);
963 sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);
964 void (*xCachesize)(sqlite3_pcache*, int nCachesize);
965 int (*xPagecount)(sqlite3_pcache*);
966 sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
967 void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);
968 void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*,
969 unsigned oldKey, unsigned newKey);
970 void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
971 void (*xDestroy)(sqlite3_pcache*);
972 void (*xShrink)(sqlite3_pcache*);
973};
974
975
976typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
977struct sqlite3_pcache_methods {
978 void *pArg;
979 int (*xInit)(void*);
980 void (*xShutdown)(void*);
981 sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);
982 void (*xCachesize)(sqlite3_pcache*, int nCachesize);
983 int (*xPagecount)(sqlite3_pcache*);
984 void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
985 void (*xUnpin)(sqlite3_pcache*, void*, int discard);
986 void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);
987 void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
988 void (*xDestroy)(sqlite3_pcache*);
989};
990
991
992#define SQLITE_CHECKPOINT_PASSIVE 0
993#define SQLITE_CHECKPOINT_FULL 1
994#define SQLITE_CHECKPOINT_RESTART 2
995
996typedef struct sqlite3_backup sqlite3_backup;
997
998SQLITE_API sqlite3_backup *sqlite3_backup_init(
999 sqlite3 *pDest, /* Destination database handle */
1000 const char *zDestName, /* Destination database name */
1001 sqlite3 *pSource, /* Source database handle */
1002 const char *zSourceName /* Source database name */
1003);
1004SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
1005SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
1006SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
1007SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
1008
1009SQLITE_API int sqlite3_unlock_notify(
1010 sqlite3 *pBlocked, /* Waiting connection */
1011 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
1012 void *pNotifyArg /* Argument to pass to xNotify */
1013);
1014
1015
1016SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
1017
1018SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
1019
1020SQLITE_API void *sqlite3_wal_hook(
1021 sqlite3*,
1022 int(*)(void *,sqlite3*,const char*,int),
1023 void*
1024);
1025
1026SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
1027
1028SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
1029
1030SQLITE_API int sqlite3_wal_checkpoint_v2(
1031 sqlite3 *db, /* Database handle */
1032 const char *zDb, /* Name of attached database (or NULL) */
1033 int eMode, /* SQLITE_CHECKPOINT_* value */
1034 int *pnLog, /* OUT: Size of WAL log in frames */
1035 int *pnCkpt /* OUT: Total number of frames checkpointed */
1036);
1037
1038SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
1039
1040#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
1041
1042SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
1043
1044#define SQLITE_ROLLBACK 1
1045/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */
1046#define SQLITE_FAIL 3
1047/* #define SQLITE_ABORT 4 // Also an error code */
1048#define SQLITE_REPLACE 5
1049
1050#ifdef SQLITE_OMIT_FLOATING_POINT
1051# undef double
1052#endif
1053
1054#ifdef __cplusplus
1055} /* End of the 'extern "C"' block */
1056#endif
1057#endif
1058
1059
1060#ifndef _SQLITE3RTREE_H_
1061#define _SQLITE3RTREE_H_
1062
1063
1064#ifdef __cplusplus
1065extern "C" {
1066#endif
1067
1068typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
1069
1070struct sqlite3_rtree_geometry {
1071 void *pContext;
1072 int nParam;
1073 double *aParam;
1074 void *pUser;
1075 void (*xDelUser)(void *);
1076};
1077
1078SQLITE_API int sqlite3_rtree_geometry_callback(
1079 sqlite3 *db,
1080 const char *zGeom,
1081 int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes),
1082 void *pContext
1083);
1084
1085#ifdef __cplusplus
1086} /* end of the 'extern "C"' block */
1087#endif
1088
1089#endif /* ifndef _SQLITE3RTREE_H_ */
1090