PageRenderTime 88ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/library/Library/WP7/SQLiteDriver/sqlite/sqlite3_h.cs

https://bitbucket.org/digitalizarte/coolstorage
C# | 6931 lines | 559 code | 195 blank | 6177 comment | 1 complexity | 9e04f0da16d31674651fb379356f4e22 MD5 | raw file
  1. using u8 = System.Byte;
  2. using System.Diagnostics;
  3. namespace Community.CsharpSqlite
  4. {
  5. public partial class Sqlite3
  6. {
  7. /*
  8. ** 2001 September 15
  9. **
  10. ** The author disclaims copyright to this source code. In place of
  11. ** a legal notice, here is a blessing:
  12. **
  13. ** May you do good and not evil.
  14. ** May you find forgiveness for yourself and forgive others.
  15. ** May you share freely, never taking more than you give.
  16. **
  17. *************************************************************************
  18. ** This header file defines the interface that the SQLite library
  19. ** presents to client programs. If a C-function, structure, datatype,
  20. ** or constant definition does not appear in this file, then it is
  21. ** not a published API of SQLite, is subject to change without
  22. ** notice, and should not be referenced by programs that use SQLite.
  23. **
  24. ** Some of the definitions that are in this file are marked as
  25. ** "experimental". Experimental interfaces are normally new
  26. ** features recently added to SQLite. We do not anticipate changes
  27. ** to experimental interfaces but reserve the right to make minor changes
  28. ** if experience from use "in the wild" suggest such changes are prudent.
  29. **
  30. ** The official C-language API documentation for SQLite is derived
  31. ** from comments in this file. This file is the authoritative source
  32. ** on how SQLite interfaces are suppose to operate.
  33. **
  34. ** The name of this file under configuration management is "sqlite.h.in".
  35. ** The makefile makes some minor changes to this file (such as inserting
  36. ** the version number) and changes its name to "sqlite3.h" as
  37. ** part of the build process.
  38. *************************************************************************
  39. ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
  40. ** C#-SQLite is an independent reimplementation of the SQLite software library
  41. **
  42. ** SQLITE_SOURCE_ID: 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7
  43. **
  44. *************************************************************************
  45. */
  46. //#ifndef _SQLITE3_H_
  47. //#define _SQLITE3_H_
  48. //#include <stdarg.h> /* Needed for the definition of va_list */
  49. /*
  50. ** Make sure we can call this stuff from C++.
  51. */
  52. //#ifdef __cplusplus
  53. //extern "C" {
  54. //#endif
  55. /*
  56. ** Add the ability to override 'extern'
  57. */
  58. //#ifndef SQLITE_EXTERN
  59. //# define SQLITE_EXTERN extern
  60. //#endif
  61. //#ifndef SQLITE_API
  62. //# define SQLITE_API
  63. //#endif
  64. /*
  65. ** These no-op macros are used in front of interfaces to mark those
  66. ** interfaces as either deprecated or experimental. New applications
  67. ** should not use deprecated interfaces - they are support for backwards
  68. ** compatibility only. Application writers should be aware that
  69. ** experimental interfaces are subject to change in point releases.
  70. **
  71. ** These macros used to resolve to various kinds of compiler magic that
  72. ** would generate warning messages when they were used. But that
  73. ** compiler magic ended up generating such a flurry of bug reports
  74. ** that we have taken it all out and gone back to using simple
  75. ** noop macros.
  76. */
  77. //#define SQLITE_DEPRECATED
  78. //#define SQLITE_EXPERIMENTAL
  79. /*
  80. ** Ensure these symbols were not defined by some previous header file.
  81. */
  82. //#ifdef SQLITE_VERSION
  83. //# undef SQLITE_VERSION
  84. //#endif
  85. //#ifdef SQLITE_VERSION_NUMBER
  86. //# undef SQLITE_VERSION_NUMBER
  87. //#endif
  88. /*
  89. ** CAPI3REF: Compile-Time Library Version Numbers
  90. **
  91. ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
  92. ** evaluates to a string literal that is the SQLite version in the
  93. ** format "X.Y.Z" where X is the major version number (always 3 for
  94. ** SQLite3) and Y is the minor version number and Z is the release number.)^
  95. ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
  96. ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
  97. ** numbers used in [SQLITE_VERSION].)^
  98. ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
  99. ** be larger than the release from which it is derived. Either Y will
  100. ** be held constant and Z will be incremented or else Y will be incremented
  101. ** and Z will be reset to zero.
  102. **
  103. ** Since version 3.6.18, SQLite source code has been stored in the
  104. ** <a href="http://www.fossil-scm.org/">Fossil configuration management
  105. ** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to
  106. ** a string which identifies a particular check-in of SQLite
  107. ** within its configuration management system. ^The SQLITE_SOURCE_ID
  108. ** string contains the date and time of the check-in (UTC) and an SHA1
  109. ** hash of the entire source tree.
  110. **
  111. ** See also: [sqlite3_libversion()],
  112. ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
  113. ** [sqlite_version()] and [sqlite_source_id()].
  114. */
  115. //#define SQLITE_VERSION "3.7.5"
  116. //#define SQLITE_VERSION_NUMBER 3007005
  117. //#define SQLITE_SOURCE_ID "2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7"
  118. const string SQLITE_VERSION = "3.7.5.C#";
  119. const int SQLITE_VERSION_NUMBER = 300700567;
  120. const string SQLITE_SOURCE_ID = "Ported to C# from 2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7";
  121. /*
  122. ** CAPI3REF: Run-Time Library Version Numbers
  123. ** KEYWORDS: sqlite3_version, sqlite3_sourceid
  124. **
  125. ** These interfaces provide the same information as the [SQLITE_VERSION],
  126. ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
  127. ** but are associated with the library instead of the header file. ^(Cautious
  128. ** programmers might include assert() statements in their application to
  129. ** verify that values returned by these interfaces match the macros in
  130. ** the header, and thus insure that the application is
  131. ** compiled with matching library and header files.
  132. **
  133. ** <blockquote><pre>
  134. ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
  135. ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
  136. ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
  137. ** </pre></blockquote>)^
  138. **
  139. ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
  140. ** macro. ^The sqlite3_libversion() function returns a pointer to the
  141. ** to the sqlite3_version[] string constant. The sqlite3_libversion()
  142. ** function is provided for use in DLLs since DLL users usually do not have
  143. ** direct access to string constants within the DLL. ^The
  144. ** sqlite3_libversion_number() function returns an integer equal to
  145. ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns
  146. ** a pointer to a string constant whose value is the same as the
  147. ** [SQLITE_SOURCE_ID] C preprocessor macro.
  148. **
  149. ** See also: [sqlite_version()] and [sqlite_source_id()].
  150. */
  151. //SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
  152. //SQLITE_API const char *sqlite3_libversion(void);
  153. //SQLITE_API const char *sqlite3_sourceid(void);
  154. //SQLITE_API int sqlite3_libversion_number(void);
  155. /*
  156. ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
  157. **
  158. ** ^The sqlite3_compileoption_used() function returns 0 or 1
  159. ** indicating whether the specified option was defined at
  160. ** compile time. ^The SQLITE_ prefix may be omitted from the
  161. ** option name passed to sqlite3_compileoption_used().
  162. **
  163. ** ^The sqlite3_compileoption_get() function allows iterating
  164. ** over the list of options that were defined at compile time by
  165. ** returning the N-th compile time option string. ^If N is out of range,
  166. ** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_
  167. ** prefix is omitted from any strings returned by
  168. ** sqlite3_compileoption_get().
  169. **
  170. ** ^Support for the diagnostic functions sqlite3_compileoption_used()
  171. ** and sqlite3_compileoption_get() may be omitted by specifying the
  172. ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
  173. **
  174. ** See also: SQL functions [sqlite_compileoption_used()] and
  175. ** [sqlite_compileoption_get()] and the [compile_options pragma].
  176. */
  177. //#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
  178. //SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
  179. //SQLITE_API const char *sqlite3_compileoption_get(int N);
  180. //#endif
  181. /*
  182. ** CAPI3REF: Test To See If The Library Is Threadsafe
  183. **
  184. ** ^The sqlite3_threadsafe() function returns zero if and only if
  185. ** SQLite was compiled mutexing code omitted due to the
  186. ** [SQLITE_THREADSAFE] compile-time option being set to 0.
  187. **
  188. ** SQLite can be compiled with or without mutexes. When
  189. ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
  190. ** are enabled and SQLite is threadsafe. When the
  191. ** [SQLITE_THREADSAFE] macro is 0,
  192. ** the mutexes are omitted. Without the mutexes, it is not safe
  193. ** to use SQLite concurrently from more than one thread.
  194. **
  195. ** Enabling mutexes incurs a measurable performance penalty.
  196. ** So if speed is of utmost importance, it makes sense to disable
  197. ** the mutexes. But for maximum safety, mutexes should be enabled.
  198. ** ^The default behavior is for mutexes to be enabled.
  199. **
  200. ** This interface can be used by an application to make sure that the
  201. ** version of SQLite that it is linking against was compiled with
  202. ** the desired setting of the [SQLITE_THREADSAFE] macro.
  203. **
  204. ** This interface only reports on the compile-time mutex setting
  205. ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
  206. ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
  207. ** can be fully or partially disabled using a call to [sqlite3_config()]
  208. ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
  209. ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
  210. ** sqlite3_threadsafe() function shows only the compile-time setting of
  211. ** thread safety, not any run-time changes to that setting made by
  212. ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
  213. ** is unchanged by calls to sqlite3_config().)^
  214. **
  215. ** See the [threading mode] documentation for additional information.
  216. */
  217. //SQLITE_API int sqlite3_threadsafe(void);
  218. /*
  219. ** CAPI3REF: Database Connection Handle
  220. ** KEYWORDS: {database connection} {database connections}
  221. **
  222. ** Each open SQLite database is represented by a pointer to an instance of
  223. ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
  224. ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
  225. ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
  226. ** is its destructor. There are many other interfaces (such as
  227. ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
  228. ** [sqlite3_busy_timeout()] to name but three) that are methods on an
  229. ** sqlite3 object.
  230. */
  231. //typedef struct sqlite3 sqlite3;
  232. /*
  233. ** CAPI3REF: 64-Bit Integer Types
  234. ** KEYWORDS: sqlite_int64 sqlite_uint64
  235. **
  236. ** Because there is no cross-platform way to specify 64-bit integer types
  237. ** SQLite includes typedefs for 64-bit signed and unsigned integers.
  238. **
  239. ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
  240. ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
  241. ** compatibility only.
  242. **
  243. ** ^The sqlite3_int64 and sqlite_int64 types can store integer values
  244. ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The
  245. ** sqlite3_uint64 and sqlite_uint64 types can store integer values
  246. ** between 0 and +18446744073709551615 inclusive.
  247. */
  248. //#ifdef SQLITE_INT64_TYPE
  249. // typedef SQLITE_INT64_TYPE sqlite_int64;
  250. // typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
  251. //#elif defined(_MSC_VER) || defined(__BORLANDC__)
  252. // typedef __int64 sqlite_int64;
  253. // typedef unsigned __int64 sqlite_uint64;
  254. //#else
  255. // typedef long long int sqlite_int64;
  256. // typedef unsigned long long int sqlite_uint64;
  257. //#endif
  258. //typedef sqlite_int64 sqlite3_int64;
  259. //typedef sqlite_uint64 sqlite3_uint64;
  260. /*
  261. ** If compiling for a processor that lacks floating point support,
  262. ** substitute integer for floating-point.
  263. */
  264. //#ifdef SQLITE_OMIT_FLOATING_POINT
  265. //# define double sqlite3_int64
  266. //#endif
  267. /*
  268. ** CAPI3REF: Closing A Database Connection
  269. **
  270. ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
  271. ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
  272. ** successfully destroyed and all associated resources are deallocated.
  273. **
  274. ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
  275. ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
  276. ** the [sqlite3] object prior to attempting to close the object. ^If
  277. ** sqlite3_close() is called on a [database connection] that still has
  278. ** outstanding [prepared statements] or [BLOB handles], then it returns
  279. ** SQLITE_BUSY.
  280. **
  281. ** ^If [sqlite3_close()] is invoked while a transaction is open,
  282. ** the transaction is automatically rolled back.
  283. **
  284. ** The C parameter to [sqlite3_close(C)] must be either a NULL
  285. ** pointer or an [sqlite3] object pointer obtained
  286. ** from [sqlite3_open()], [sqlite3_open16()], or
  287. ** [sqlite3_open_v2()], and not previously closed.
  288. ** ^Calling sqlite3_close() with a NULL pointer argument is a
  289. ** harmless no-op.
  290. */
  291. //SQLITE_API int sqlite3_close(sqlite3 *);
  292. /*
  293. ** The type for a callback function.
  294. ** This is legacy and deprecated. It is included for historical
  295. ** compatibility and is not documented.
  296. */
  297. //typedef int (*sqlite3_callback)(void*,int,char**, char**);
  298. /*
  299. ** CAPI3REF: One-Step Query Execution Interface
  300. **
  301. ** The sqlite3_exec() interface is a convenience wrapper around
  302. ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
  303. ** that allows an application to run multiple statements of SQL
  304. ** without having to use a lot of C code.
  305. **
  306. ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
  307. ** semicolon-separate SQL statements passed into its 2nd argument,
  308. ** in the context of the [database connection] passed in as its 1st
  309. ** argument. ^If the callback function of the 3rd argument to
  310. ** sqlite3_exec() is not NULL, then it is invoked for each result row
  311. ** coming out of the evaluated SQL statements. ^The 4th argument to
  312. ** to sqlite3_exec() is relayed through to the 1st argument of each
  313. ** callback invocation. ^If the callback pointer to sqlite3_exec()
  314. ** is NULL, then no callback is ever invoked and result rows are
  315. ** ignored.
  316. **
  317. ** ^If an error occurs while evaluating the SQL statements passed into
  318. ** sqlite3_exec(), then execution of the current statement stops and
  319. ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
  320. ** is not NULL then any error message is written into memory obtained
  321. ** from [sqlite3_malloc()] and passed back through the 5th parameter.
  322. ** To avoid memory leaks, the application should invoke [sqlite3_free()]
  323. ** on error message strings returned through the 5th parameter of
  324. ** of sqlite3_exec() after the error message string is no longer needed.
  325. ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
  326. ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
  327. ** NULL before returning.
  328. **
  329. ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
  330. ** routine returns SQLITE_ABORT without invoking the callback again and
  331. ** without running any subsequent SQL statements.
  332. **
  333. ** ^The 2nd argument to the sqlite3_exec() callback function is the
  334. ** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
  335. ** callback is an array of pointers to strings obtained as if from
  336. ** [sqlite3_column_text()], one for each column. ^If an element of a
  337. ** result row is NULL then the corresponding string pointer for the
  338. ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
  339. ** sqlite3_exec() callback is an array of pointers to strings where each
  340. ** entry represents the name of corresponding result column as obtained
  341. ** from [sqlite3_column_name()].
  342. **
  343. ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
  344. ** to an empty string, or a pointer that contains only whitespace and/or
  345. ** SQL comments, then no SQL statements are evaluated and the database
  346. ** is not changed.
  347. **
  348. ** Restrictions:
  349. **
  350. ** <ul>
  351. ** <li> The application must insure that the 1st parameter to sqlite3_exec()
  352. ** is a valid and open [database connection].
  353. ** <li> The application must not close [database connection] specified by
  354. ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
  355. ** <li> The application must not modify the SQL statement text passed into
  356. ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
  357. ** </ul>
  358. */
  359. //SQLITE_API int sqlite3_exec(
  360. // sqlite3*, /* An open database */
  361. // const char *sql, /* SQL to be evaluated */
  362. // int (*callback)(void*,int,char**,char**), /* Callback function */
  363. // void *, /* 1st argument to callback */
  364. // char **errmsg /* Error msg written here */
  365. //);
  366. /*
  367. ** CAPI3REF: Result Codes
  368. ** KEYWORDS: SQLITE_OK {error code} {error codes}
  369. ** KEYWORDS: {result code} {result codes}
  370. **
  371. ** Many SQLite functions return an integer result code from the set shown
  372. ** here in order to indicates success or failure.
  373. **
  374. ** New error codes may be added in future versions of SQLite.
  375. **
  376. ** See also: [SQLITE_IOERR_READ | extended result codes]
  377. */
  378. //#define SQLITE_OK 0 /* Successful result */
  379. ///* beginning-of-error-codes */
  380. //#define SQLITE_ERROR 1 /* SQL error or missing database */
  381. //#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
  382. //#define SQLITE_PERM 3 /* Access permission denied */
  383. //#define SQLITE_ABORT 4 /* Callback routine requested an abort */
  384. //#define SQLITE_BUSY 5 /* The database file is locked */
  385. //#define SQLITE_LOCKED 6 /* A table in the database is locked */
  386. //#define SQLITE_NOMEM 7 /* A malloc() failed */
  387. //#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
  388. //#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
  389. //#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
  390. //#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
  391. //#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
  392. //#define SQLITE_FULL 13 /* Insertion failed because database is full */
  393. //#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
  394. //#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
  395. //#define SQLITE_EMPTY 16 /* Database is empty */
  396. //#define SQLITE_SCHEMA 17 /* The database schema changed */
  397. //#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
  398. //#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
  399. //#define SQLITE_MISMATCH 20 /* Data type mismatch */
  400. //#define SQLITE_MISUSE 21 /* Library used incorrectly */
  401. //#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
  402. //#define SQLITE_AUTH 23 /* Authorization denied */
  403. //#define SQLITE_FORMAT 24 /* Auxiliary database format error */
  404. //#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
  405. //#define SQLITE_NOTADB 26 /* File opened that is not a database file */
  406. //#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
  407. //#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
  408. /* end-of-error-codes */
  409. public const int SQLITE_OK = 0;
  410. public const int SQLITE_ERROR = 1;
  411. public const int SQLITE_INTERNAL = 2;
  412. public const int SQLITE_PERM = 3;
  413. public const int SQLITE_ABORT = 4;
  414. public const int SQLITE_BUSY = 5;
  415. public const int SQLITE_LOCKED = 6;
  416. public const int SQLITE_NOMEM = 7;
  417. public const int SQLITE_READONLY = 8;
  418. public const int SQLITE_INTERRUPT = 9;
  419. public const int SQLITE_IOERR = 10;
  420. public const int SQLITE_CORRUPT = 11;
  421. public const int SQLITE_NOTFOUND = 12;
  422. public const int SQLITE_FULL = 13;
  423. public const int SQLITE_CANTOPEN = 14;
  424. public const int SQLITE_PROTOCOL = 15;
  425. public const int SQLITE_EMPTY = 16;
  426. public const int SQLITE_SCHEMA = 17;
  427. public const int SQLITE_TOOBIG = 18;
  428. public const int SQLITE_CONSTRAINT = 19;
  429. public const int SQLITE_MISMATCH = 20;
  430. public const int SQLITE_MISUSE = 21;
  431. public const int SQLITE_NOLFS = 22;
  432. public const int SQLITE_AUTH = 23;
  433. public const int SQLITE_FORMAT = 24;
  434. public const int SQLITE_RANGE = 25;
  435. public const int SQLITE_NOTADB = 26;
  436. public const int SQLITE_ROW = 100;
  437. public const int SQLITE_DONE = 101;
  438. /*
  439. ** CAPI3REF: Extended Result Codes
  440. ** KEYWORDS: {extended error code} {extended error codes}
  441. ** KEYWORDS: {extended result code} {extended result codes}
  442. **
  443. ** In its default configuration, SQLite API routines return one of 26 integer
  444. ** [SQLITE_OK | result codes]. However, experience has shown that many of
  445. ** these result codes are too coarse-grained. They do not provide as
  446. ** much information about problems as programmers might like. In an effort to
  447. ** address this, newer versions of SQLite (version 3.3.8 and later) include
  448. ** support for additional result codes that provide more detailed information
  449. ** about errors. The extended result codes are enabled or disabled
  450. ** on a per database connection basis using the
  451. ** [sqlite3_extended_result_codes()] API.
  452. **
  453. ** Some of the available extended result codes are listed here.
  454. ** One may expect the number of extended result codes will be expand
  455. ** over time. Software that uses extended result codes should expect
  456. ** to see new result codes in future releases of SQLite.
  457. **
  458. ** The SQLITE_OK result code will never be extended. It will always
  459. ** be exactly zero.
  460. */
  461. //#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
  462. //#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
  463. //#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
  464. //#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
  465. //#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
  466. //#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
  467. //#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
  468. //#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
  469. //#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
  470. //#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
  471. //#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))
  472. //#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))
  473. //#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
  474. //#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
  475. //#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
  476. //#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
  477. //#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
  478. //#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
  479. //#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
  480. //#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
  481. //#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
  482. //#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
  483. //#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
  484. const int SQLITE_IOERR_READ = ( SQLITE_IOERR | ( 1 << 8 ) );
  485. const int SQLITE_IOERR_SHORT_READ = ( SQLITE_IOERR | ( 2 << 8 ) );
  486. const int SQLITE_IOERR_WRITE = ( SQLITE_IOERR | ( 3 << 8 ) );
  487. const int SQLITE_IOERR_FSYNC = ( SQLITE_IOERR | ( 4 << 8 ) );
  488. const int SQLITE_IOERR_DIR_FSYNC = ( SQLITE_IOERR | ( 5 << 8 ) );
  489. const int SQLITE_IOERR_TRUNCATE = ( SQLITE_IOERR | ( 6 << 8 ) );
  490. const int SQLITE_IOERR_FSTAT = ( SQLITE_IOERR | ( 7 << 8 ) );
  491. const int SQLITE_IOERR_UNLOCK = ( SQLITE_IOERR | ( 8 << 8 ) );
  492. const int SQLITE_IOERR_RDLOCK = ( SQLITE_IOERR | ( 9 << 8 ) );
  493. const int SQLITE_IOERR_DELETE = ( SQLITE_IOERR | ( 10 << 8 ) );
  494. const int SQLITE_IOERR_BLOCKED = ( SQLITE_IOERR | ( 11 << 8 ) );
  495. const int SQLITE_IOERR_NOMEM = ( SQLITE_IOERR | ( 12 << 8 ) );
  496. const int SQLITE_IOERR_ACCESS = ( SQLITE_IOERR | ( 13 << 8 ) );
  497. const int SQLITE_IOERR_CHECKRESERVEDLOCK = ( SQLITE_IOERR | ( 14 << 8 ) );
  498. const int SQLITE_IOERR_LOCK = ( SQLITE_IOERR | ( 15 << 8 ) );
  499. const int SQLITE_IOERR_CLOSE = ( SQLITE_IOERR | ( 16 << 8 ) );
  500. const int SQLITE_IOERR_DIR_CLOSE = ( SQLITE_IOERR | ( 17 << 8 ) );
  501. const int SQLITE_IOERR_SHMOPEN = ( SQLITE_IOERR | ( 18 << 8 ) );
  502. const int SQLITE_IOERR_SHMSIZE = ( SQLITE_IOERR | ( 19 << 8 ) );
  503. const int SQLITE_IOERR_SHMLOCK = ( SQLITE_IOERR | ( 20 << 8 ) );
  504. const int SQLITE_LOCKED_SHAREDCACHE = ( SQLITE_LOCKED | ( 1 << 8 ) );
  505. const int SQLITE_BUSY_RECOVERY = ( SQLITE_BUSY | ( 1 << 8 ) );
  506. const int SQLITE_CANTOPEN_NOTEMPDIR = ( SQLITE_CANTOPEN | ( 1 << 8 ) );
  507. /*
  508. ** CAPI3REF: Flags For File Open Operations
  509. **
  510. ** These bit values are intended for use in the
  511. ** 3rd parameter to the [sqlite3_open_v2()] interface and
  512. ** in the 4th parameter to the xOpen method of the
  513. ** [sqlite3_vfs] object.
  514. */
  515. //#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
  516. //#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
  517. //#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
  518. //#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
  519. //#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
  520. //#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
  521. //#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
  522. //#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
  523. //#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */
  524. //#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */
  525. //#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */
  526. //#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */
  527. //#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */
  528. //#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
  529. //#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
  530. //#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
  531. //#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
  532. //#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
  533. /* Reserved: 0x00F00000 */
  534. public const int SQLITE_OPEN_READONLY = 0x00000001;
  535. public const int SQLITE_OPEN_READWRITE = 0x00000002;
  536. public const int SQLITE_OPEN_CREATE = 0x00000004;
  537. public const int SQLITE_OPEN_DELETEONCLOSE = 0x00000008;
  538. public const int SQLITE_OPEN_EXCLUSIVE = 0x00000010;
  539. public const int SQLITE_OPEN_AUTOPROXY = 0x00000020;
  540. public const int SQLITE_OPEN_MAIN_DB = 0x00000100;
  541. public const int SQLITE_OPEN_TEMP_DB = 0x00000200;
  542. public const int SQLITE_OPEN_TRANSIENT_DB = 0x00000400;
  543. public const int SQLITE_OPEN_MAIN_JOURNAL = 0x00000800;
  544. public const int SQLITE_OPEN_TEMP_JOURNAL = 0x00001000;
  545. public const int SQLITE_OPEN_SUBJOURNAL = 0x00002000;
  546. public const int SQLITE_OPEN_MASTER_JOURNAL = 0x00004000;
  547. public const int SQLITE_OPEN_NOMUTEX = 0x00008000;
  548. public const int SQLITE_OPEN_FULLMUTEX = 0x00010000;
  549. public const int SQLITE_OPEN_SHAREDCACHE = 0x00020000;
  550. public const int SQLITE_OPEN_PRIVATECACHE = 0x00040000;
  551. public const int SQLITE_OPEN_WAL = 0x00080000;
  552. /*
  553. ** CAPI3REF: Device Characteristics
  554. **
  555. ** The xDeviceCharacteristics method of the [sqlite3_io_methods]
  556. ** object returns an integer which is a vector of the these
  557. ** bit values expressing I/O characteristics of the mass storage
  558. ** device that holds the file that the [sqlite3_io_methods]
  559. ** refers to.
  560. **
  561. ** The SQLITE_IOCAP_ATOMIC property means that all writes of
  562. ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
  563. ** mean that writes of blocks that are nnn bytes in size and
  564. ** are aligned to an address which is an integer multiple of
  565. ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
  566. ** that when data is appended to a file, the data is appended
  567. ** first then the size of the file is extended, never the other
  568. ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
  569. ** information is written to disk in the same order as calls
  570. ** to xWrite().
  571. */
  572. //#define SQLITE_IOCAP_ATOMIC 0x00000001
  573. //#define SQLITE_IOCAP_ATOMIC512 0x00000002
  574. //#define SQLITE_IOCAP_ATOMIC1K 0x00000004
  575. //#define SQLITE_IOCAP_ATOMIC2K 0x00000008
  576. //#define SQLITE_IOCAP_ATOMIC4K 0x00000010
  577. //#define SQLITE_IOCAP_ATOMIC8K 0x00000020
  578. //#define SQLITE_IOCAP_ATOMIC16K 0x00000040
  579. //#define SQLITE_IOCAP_ATOMIC32K 0x00000080
  580. //#define SQLITE_IOCAP_ATOMIC64K 0x00000100
  581. //#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
  582. //#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
  583. //#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
  584. const int SQLITE_IOCAP_ATOMIC = 0x00000001;
  585. const int SQLITE_IOCAP_ATOMIC512 = 0x00000002;
  586. const int SQLITE_IOCAP_ATOMIC1K = 0x00000004;
  587. const int SQLITE_IOCAP_ATOMIC2K = 0x00000008;
  588. const int SQLITE_IOCAP_ATOMIC4K = 0x00000010;
  589. const int SQLITE_IOCAP_ATOMIC8K = 0x00000020;
  590. const int SQLITE_IOCAP_ATOMIC16K = 0x00000040;
  591. const int SQLITE_IOCAP_ATOMIC32K = 0x00000080;
  592. const int SQLITE_IOCAP_ATOMIC64K = 0x00000100;
  593. const int SQLITE_IOCAP_SAFE_APPEND = 0x00000200;
  594. const int SQLITE_IOCAP_SEQUENTIAL = 0x00000400;
  595. const int SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800;
  596. /*
  597. ** CAPI3REF: File Locking Levels
  598. **
  599. ** SQLite uses one of these integer values as the second
  600. ** argument to calls it makes to the xLock() and xUnlock() methods
  601. ** of an [sqlite3_io_methods] object.
  602. */
  603. //#define SQLITE_LOCK_NONE 0
  604. //#define SQLITE_LOCK_SHARED 1
  605. //#define SQLITE_LOCK_RESERVED 2
  606. //#define SQLITE_LOCK_PENDING 3
  607. //#define SQLITE_LOCK_EXCLUSIVE 4
  608. const int SQLITE_LOCK_NONE = 0;
  609. const int SQLITE_LOCK_SHARED = 1;
  610. const int SQLITE_LOCK_RESERVED = 2;
  611. const int SQLITE_LOCK_PENDING = 3;
  612. const int SQLITE_LOCK_EXCLUSIVE = 4;
  613. /*
  614. ** CAPI3REF: Synchronization Type Flags
  615. **
  616. ** When SQLite invokes the xSync() method of an
  617. ** [sqlite3_io_methods] object it uses a combination of
  618. ** these integer values as the second argument.
  619. **
  620. ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
  621. ** sync operation only needs to flush data to mass storage. Inode
  622. ** information need not be flushed. If the lower four bits of the flag
  623. ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
  624. ** If the lower four bits equal SQLITE_SYNC_FULL, that means
  625. ** to use Mac OS X style fullsync instead of fsync().
  626. **
  627. ** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
  628. ** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
  629. ** settings. The [synchronous pragma] determines when calls to the
  630. ** xSync VFS method occur and applies uniformly across all platforms.
  631. ** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
  632. ** energetic or rigorous or forceful the sync operations are and
  633. ** only make a difference on Mac OSX for the default SQLite code.
  634. ** (Third-party VFS implementations might also make the distinction
  635. ** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
  636. ** operating systems natively supported by SQLite, only Mac OSX
  637. ** cares about the difference.)
  638. */
  639. //#define SQLITE_SYNC_NORMAL 0x00002
  640. //#define SQLITE_SYNC_FULL 0x00003
  641. //#define SQLITE_SYNC_DATAONLY 0x00010
  642. const int SQLITE_SYNC_NORMAL = 0x00002;
  643. const int SQLITE_SYNC_FULL = 0x00003;
  644. const int SQLITE_SYNC_DATAONLY = 0x00010;
  645. /*
  646. ** CAPI3REF: OS Interface Open File Handle
  647. **
  648. ** An [sqlite3_file] object represents an open file in the
  649. ** [sqlite3_vfs | OS interface layer]. Individual OS interface
  650. ** implementations will
  651. ** want to subclass this object by appending additional fields
  652. ** for their own use. The pMethods entry is a pointer to an
  653. ** [sqlite3_io_methods] object that defines methods for performing
  654. ** I/O operations on the open file.
  655. */
  656. //typedef struct sqlite3_file sqlite3_file;
  657. //struct sqlite3_file {
  658. // const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
  659. //};
  660. public partial class sqlite3_file
  661. {
  662. public sqlite3_io_methods pMethods;/* Must be first */
  663. }
  664. /*
  665. ** CAPI3REF: OS Interface File Virtual Methods Object
  666. **
  667. ** Every file opened by the [sqlite3_vfs] xOpen method populates an
  668. ** [sqlite3_file] object (or, more commonly, a subclass of the
  669. ** [sqlite3_file] object) with a pointer to an instance of this object.
  670. ** This object defines the methods used to perform various operations
  671. ** against the open file represented by the [sqlite3_file] object.
  672. **
  673. ** If the xOpen method sets the sqlite3_file.pMethods element
  674. ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
  675. ** may be invoked even if the xOpen reported that it failed. The
  676. ** only way to prevent a call to xClose following a failed xOpen
  677. ** is for the xOpen to set the sqlite3_file.pMethods element to NULL.
  678. **
  679. ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
  680. ** [SQLITE_SYNC_FULL]. The first choice is the normal fsync().
  681. ** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY]
  682. ** flag may be ORed in to indicate that only the data of the file
  683. ** and not its inode needs to be synced.
  684. **
  685. ** The integer values to xLock() and xUnlock() are one of
  686. ** <ul>
  687. ** <li> [SQLITE_LOCK_NONE],
  688. ** <li> [SQLITE_LOCK_SHARED],
  689. ** <li> [SQLITE_LOCK_RESERVED],
  690. ** <li> [SQLITE_LOCK_PENDING], or
  691. ** <li> [SQLITE_LOCK_EXCLUSIVE].
  692. ** </ul>
  693. ** xLock() increases the lock. xUnlock() decreases the lock.
  694. ** The xCheckReservedLock() method checks whether any database connection,
  695. ** either in this process or in some other process, is holding a RESERVED,
  696. ** PENDING, or EXCLUSIVE lock on the file. It returns true
  697. ** if such a lock exists and false otherwise.
  698. **
  699. ** The xFileControl() method is a generic interface that allows custom
  700. ** VFS implementations to directly control an open file using the
  701. ** [sqlite3_file_control()] interface. The second "op" argument is an
  702. ** integer opcode. The third argument is a generic pointer intended to
  703. ** point to a structure that may contain arguments or space in which to
  704. ** write return values. Potential uses for xFileControl() might be
  705. ** functions to enable blocking locks with timeouts, to change the
  706. ** locking strategy (for example to use dot-file locks), to inquire
  707. ** about the status of a lock, or to break stale locks. The SQLite
  708. ** core reserves all opcodes less than 100 for its own use.
  709. ** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.
  710. ** Applications that define a custom xFileControl method should use opcodes
  711. ** greater than 100 to avoid conflicts. VFS implementations should
  712. ** return [SQLITE_NOTFOUND] for file control opcodes that they do not
  713. ** recognize.
  714. **
  715. ** The xSectorSize() method returns the sector size of the
  716. ** device that underlies the file. The sector size is the
  717. ** minimum write that can be performed without disturbing
  718. ** other bytes in the file. The xDeviceCharacteristics()
  719. ** method returns a bit vector describing behaviors of the
  720. ** underlying device:
  721. **
  722. ** <ul>
  723. ** <li> [SQLITE_IOCAP_ATOMIC]
  724. ** <li> [SQLITE_IOCAP_ATOMIC512]
  725. ** <li> [SQLITE_IOCAP_ATOMIC1K]
  726. ** <li> [SQLITE_IOCAP_ATOMIC2K]
  727. ** <li> [SQLITE_IOCAP_ATOMIC4K]
  728. ** <li> [SQLITE_IOCAP_ATOMIC8K]
  729. ** <li> [SQLITE_IOCAP_ATOMIC16K]
  730. ** <li> [SQLITE_IOCAP_ATOMIC32K]
  731. ** <li> [SQLITE_IOCAP_ATOMIC64K]
  732. ** <li> [SQLITE_IOCAP_SAFE_APPEND]
  733. ** <li> [SQLITE_IOCAP_SEQUENTIAL]
  734. ** </ul>
  735. **
  736. ** The SQLITE_IOCAP_ATOMIC property means that all writes of
  737. ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
  738. ** mean that writes of blocks that are nnn bytes in size and
  739. ** are aligned to an address which is an integer multiple of
  740. ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
  741. ** that when data is appended to a file, the data is appended
  742. ** first then the size of the file is extended, never the other
  743. ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
  744. ** information is written to disk in the same order as calls
  745. ** to xWrite().
  746. **
  747. ** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
  748. ** in the unread portions of the buffer with zeros. A VFS that
  749. ** fails to zero-fill short reads might seem to work. However,
  750. ** failure to zero-fill short reads will eventually lead to
  751. ** database corruption.
  752. */
  753. //typedef struct sqlite3_io_methods sqlite3_io_methods;
  754. //struct sqlite3_io_methods {
  755. // int iVersion;
  756. // int (*xClose)(sqlite3_file*);
  757. // int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
  758. // int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
  759. // int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
  760. // int (*xSync)(sqlite3_file*, int flags);
  761. // int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
  762. // int (*xLock)(sqlite3_file*, int);
  763. // int (*xUnlock)(sqlite3_file*, int);
  764. // int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
  765. // int (*xFileControl)(sqlite3_file*, int op, void *pArg);
  766. // int (*xSectorSize)(sqlite3_file*);
  767. // int (*xDeviceCharacteristics)(sqlite3_file*);
  768. // /* Methods above are valid for version 1 */
  769. // int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
  770. // int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
  771. // void (*xShmBarrier)(sqlite3_file*);
  772. // int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
  773. // /* Methods above are valid for version 2 */
  774. // /* Additional methods may be added in future releases */
  775. //};
  776. public class sqlite3_io_methods
  777. {
  778. public int iVersion;
  779. public dxClose xClose;
  780. public dxRead xRead;
  781. public dxWrite xWrite;
  782. public dxTruncate xTruncate;
  783. public dxSync xSync;
  784. public dxFileSize xFileSize;
  785. public dxLock xLock;
  786. public dxUnlock xUnlock;
  787. public dxCheckReservedLock xCheckReservedLock;
  788. public dxFileControl xFileControl;
  789. public dxSectorSize xSectorSize;
  790. public dxDeviceCharacteristics xDeviceCharacteristics;
  791. public dxShmMap xShmMap;//int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
  792. public dxShmLock xShmLock;//int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
  793. public dxShmBarrier xShmBarrier;//void (*xShmBarrier)(sqlite3_file*);
  794. public dxShmUnmap xShmUnmap;//int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
  795. /* Additional methods may be added in future releases */
  796. public sqlite3_io_methods( int iVersion,
  797. dxClose xClose,
  798. dxRead xRead,
  799. dxWrite xWrite,
  800. dxTruncate xTruncate,
  801. dxSync xSync,
  802. dxFileSize xFileSize,
  803. dxLock xLock,
  804. dxUnlock xUnlock,
  805. dxCheckReservedLock xCheckReservedLock,
  806. dxFileControl xFileControl,
  807. dxSectorSize xSectorSize,
  808. dxDeviceCharacteristics xDeviceCharacteristics,
  809. dxShmMap xShmMap,
  810. dxShmLock xShmLock,
  811. dxShmBarrier xShmBarrier,
  812. dxShmUnmap xShmUnmap
  813. )
  814. {
  815. this.iVersion = iVersion;
  816. this.xClose = xClose;
  817. this.xRead = xRead;
  818. this.xWrite = xWrite;
  819. this.xTruncate = xTruncate;
  820. this.xSync = xSync;
  821. this.xFileSize = xFileSize;
  822. this.xLock = xLock;
  823. this.xUnlock = xUnlock;
  824. this.xCheckReservedLock = xCheckReservedLock;
  825. this.xFileControl = xFileControl;
  826. this.xSectorSize = xSectorSize;
  827. this.xDeviceCharacteristics = xDeviceCharacteristics;
  828. this.xShmMap = xShmMap;
  829. this.xShmLock = xShmLock;
  830. this.xShmBarrier = xShmBarrier;
  831. this.xShmUnmap = xShmUnmap;
  832. }
  833. }
  834. /*
  835. ** CAPI3REF: Standard File Control Opcodes
  836. **
  837. ** These integer constants are opcodes for the xFileControl method
  838. ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
  839. ** interface.
  840. **
  841. ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
  842. ** opcode causes the xFileControl method to write the current state of
  843. ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
  844. ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
  845. ** into an integer that the pArg argument points to. This capability
  846. ** is used during testing and only needs to be supported when SQLITE_TEST
  847. ** is defined.
  848. **
  849. ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
  850. ** layer a hint of how large the database file will grow to be during the
  851. ** current transaction. This hint is not guaranteed to be accurate but it
  852. ** is often close. The underlying VFS might choose to preallocate database
  853. ** file space based on this hint in order to help writes to the database
  854. ** file run faster.
  855. **
  856. ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
  857. ** extends and truncates the database file in chunks of a size specified
  858. ** by the user. The fourth argument to [sqlite3_file_control()] should
  859. ** point to an integer (type int) containing the new chunk-size to use
  860. ** for the nominated database. Allocating database file space in large
  861. ** chunks (say 1MB at a time), may reduce file-system fragmentation and
  862. ** improve performance on some systems.
  863. **
  864. ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
  865. ** to the [sqlite3_file] object associated with a particular database
  866. ** connection. See the [sqlite3_file_control()] documentation for
  867. ** additional information.
  868. **
  869. ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by
  870. ** SQLite and sent to all VFSes in place of a call to the xSync method
  871. ** when the database connection has [PRAGMA synchronous] set to OFF.)^
  872. ** Some specialized VFSes need this signal in order to operate correctly
  873. ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most
  874. ** VFSes do not need this signal and should silently ignore this opcode.
  875. ** Applications should not call [sqlite3_file_control()] with this
  876. ** opcode as doing so may disrupt the operation of the specilized VFSes
  877. ** that do require it.
  878. */
  879. //#define SQLITE_FCNTL_LOCKSTATE 1
  880. //#define SQLITE_GET_LOCKPROXYFILE 2
  881. //#define SQLITE_SET_LOCKPROXYFILE 3
  882. //#define SQLITE_LAST_ERRNO 4
  883. //#define SQLITE_FCNTL_SIZE_HINT 5
  884. //#define SQLITE_FCNTL_CHUNK_SIZE 6
  885. //#define SQLITE_FCNTL_FILE_POINTER 7
  886. //#define SQLITE_FCNTL_SYNC_OMITTED 8
  887. const int SQLITE_FCNTL_LOCKSTATE = 1;
  888. const int SQLITE_GET_LOCKPROXYFILE = 2;
  889. const int SQLITE_SET_LOCKPROXYFILE = 3;
  890. const int SQLITE_LAST_ERRNO = 4;
  891. const int SQLITE_FCNTL_SIZE_HINT = 5;
  892. const int SQLITE_FCNTL_CHUNK_SIZE = 6;
  893. const int SQLITE_FCNTL_FILE_POINTER = 7;
  894. const int SQLITE_FCNTL_SYNC_OMITTED = 8;
  895. /*
  896. ** CAPI3REF: Mutex Handle
  897. **
  898. ** The mutex module within SQLite defines [sqlite3_mutex] to be an
  899. ** abstract type for a mutex object. The SQLite core never looks
  900. ** at the internal representation of an [sqlite3_mutex]. It only
  901. ** deals with pointers to the [sqlite3_mutex] object.
  902. **
  903. ** Mutexes are created using [sqlite3_mutex_alloc()].
  904. */
  905. //typedef struct sqlite3_mutex sqlite3_mutex;
  906. /*
  907. ** CAPI3REF: OS Interface Object
  908. **
  909. ** An instance of the sqlite3_vfs object defines the interface between
  910. ** the SQLite core and the underlying operating system. The "vfs"
  911. ** in the name of the object stands for "virtual file system".
  912. **
  913. ** The value of the iVersion field is initially 1 but may be larger in
  914. ** future versions of SQLite. Additional fields may be appended to this
  915. ** object when the iVersion value is increased. Note that the structure
  916. ** of the sqlite3_vfs object changes in the transaction between
  917. ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not
  918. ** modified.
  919. **
  920. ** The szOsFile field is the size of the subclassed [sqlite3_file]
  921. ** structure used by this VFS. mxPathname is the maximum length of
  922. ** a pathname in this VFS.
  923. **
  924. ** Registered sqlite3_vfs objects are kept on a linked list formed by
  925. ** the pNext pointer. The [sqlite3_vfs_register()]
  926. ** and [sqlite3_vfs_unregister()] interfaces manage this list
  927. ** in a thread-safe way. The [sqlite3_vfs_find()] interface
  928. ** searches the list. Neither the application code nor the VFS
  929. ** implementation should use the pNext pointer.
  930. **
  931. ** The pNext field is the only field in the sqlite3_vfs
  932. ** structure that SQLite will ever modify. SQLite will only access
  933. ** or modify this field while holding a particular static mutex.
  934. ** The application should never modify anything within the sqlite3_vfs
  935. ** object once the object has been registered.
  936. **
  937. ** The zName field holds the name of the VFS module. The name must
  938. ** be unique across all VFS modules.
  939. **
  940. ** ^SQLite guarantees that the zFilename parameter to xOpen
  941. ** is either a NULL pointer or string obtained
  942. ** from xFullPathname() with an optional suffix added.
  943. ** ^If a suffix is added to the zFilename parameter, it will
  944. ** consist of a single "-" character followed by no more than
  945. ** 10 alphanumeric and/or "-" characters.
  946. ** ^SQLite further guarantees that
  947. ** the string will be valid and unchanged until xClose() is
  948. ** called. Because of the previous sentence,
  949. ** the [sqlite3_file] can safely store a pointer to the
  950. ** filename if it needs to remember the filename for some reason.
  951. ** If the zFilename parameter to xOpen is a NULL pointer then xOpen
  952. ** must invent its own temporary name for the file. ^Whenever the
  953. ** xFilename parameter is NULL it will also be the case that the
  954. ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
  955. **
  956. ** The flags argument to xOpen() includes all bits set in
  957. ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()]
  958. ** or [sqlite3_open16()] is used, then flags includes at least
  959. ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
  960. ** If xOpen() opens a file read-only then it sets *pOutFlags to
  961. ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set.
  962. **
  963. ** ^(SQLite will also add one of the following flags to the xOpen()
  964. ** call, depending on the object being opened:
  965. **
  966. ** <ul>
  967. ** <li> [SQLITE_OPEN_MAIN_DB]
  968. ** <li> [SQLITE_OPEN_MAIN_JOURNAL]
  969. ** <li> [SQLITE_OPEN_TEMP_DB]
  970. ** <li> [SQLITE_OPEN_TEMP_JOURNAL]
  971. ** <li> [SQLITE_OPEN_TRANSIENT_DB]
  972. ** <li> [SQLITE_OPEN_SUBJOURNAL]
  973. ** <li> [SQLITE_OPEN_MASTER_JOURNAL]
  974. ** <li> [SQLITE_OPEN_WAL]
  975. ** </ul>)^
  976. **
  977. ** The file I/O implementation can use the object type flags to
  978. ** change the way it deals with files. For example, an application
  979. ** that does not care about crash recovery or rollback might make
  980. ** the open of a journal file a no-op. Writes to this journal would
  981. ** also be no-ops, and any attempt to read the journal would return
  982. ** SQLITE_IOERR. Or the implementation might recognize that a database
  983. ** file will be doing page-aligned sector reads and writes in a random
  984. ** order and set up its I/O subsystem accordingly.
  985. **
  986. ** SQLite might also add one of the following flags to the xOpen method:
  987. **
  988. ** <ul>
  989. ** <li> [SQLITE_OPEN_DELETEONCLOSE]
  990. ** <li> [SQLITE_OPEN_EXCLUSIVE]
  991. ** </ul>
  992. **
  993. ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
  994. ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE]
  995. ** will be set for TEMP databases and their journals, transient
  996. ** databases, and subjournals.
  997. **
  998. ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
  999. ** with the [SQLITE_OPEN_CREATE] flag, which are both directly
  1000. ** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
  1001. ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
  1002. ** SQLITE_OPEN_CREATE, is used to indicate that file should always
  1003. ** be created, and that it is an error if it already exists.
  1004. ** It is <i>not</i> used to indicate the file should be opened
  1005. ** for exclusive access.
  1006. **
  1007. ** ^At least szOsFile bytes of memory are allocated by SQLite
  1008. ** to hold the [sqlite3_file] structure passed as the third
  1009. ** argument to xOpen. The xOpen method does not have to
  1010. ** allocate the structure; it should just fill it in. Note that
  1011. ** the xOpen method must set the sqlite3_file.pMethods to either
  1012. ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
  1013. ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
  1014. ** element will be valid after xOpen returns regardless of the success
  1015. ** or failure of the xOpen call.
  1016. **
  1017. ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
  1018. ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
  1019. ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
  1020. ** to test whether a file is at least readable. The file can be a
  1021. ** directory.
  1022. **
  1023. ** ^SQLite will always allocate at least mxPathname+1 bytes for the
  1024. ** output buffer xFullPathname. The exact size of the output buffer
  1025. ** is also passed as a parameter to both methods. If the output buffer
  1026. ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
  1027. ** handled as a fatal error by SQLite, vfs implementations should endeavor
  1028. ** to prevent this by setting mxPathname to a sufficiently large value.
  1029. **
  1030. ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
  1031. ** interfaces are not strictly a part of the filesystem, but they are
  1032. ** included in the VFS structure for completeness.
  1033. ** The xRandomness() function attempts to return nBytes bytes
  1034. ** of good-quality randomness into zOut. The return value is
  1035. ** the actual number of bytes of randomness obtained.
  1036. ** The xSleep() method causes the calling thread to sleep for at
  1037. ** least the number of microseconds given. ^The xCurrentTime()
  1038. ** method returns a Julian Day Number for the current date and time as
  1039. ** a floating point value.
  1040. ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
  1041. ** Day Number multipled by 86400000 (the number of milliseconds in
  1042. ** a 24-hour day).
  1043. ** ^SQLite will use the xCurrentTimeInt64() method to get the current
  1044. ** date and time if that method is available (if iVersion is 2 or
  1045. ** greater and the function pointer is not NULL) and will fall back
  1046. ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
  1047. */
  1048. //typedef struct sqlite3_vfs sqlite3_vfs;
  1049. //struct sqlite3_vfs {
  1050. // int iVersion; /* Structure version number (currently 2) */
  1051. // int szOsFile; /* Size of subclassed sqlite3_file */
  1052. // int mxPathname; /* Maximum file pathname length */
  1053. // sqlite3_vfs *pNext; /* Next registered VFS */
  1054. // const char *zName; /* Name of this virtual file system */
  1055. // void *pAppData; /* Pointer to application-specific data */
  1056. // int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
  1057. // int flags, int *pOutFlags);
  1058. // int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
  1059. // int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
  1060. // int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
  1061. // void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
  1062. // void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
  1063. // void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
  1064. // void (*xDlClose)(sqlite3_vfs*, void*);
  1065. // int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
  1066. // int (*xSleep)(sqlite3_vfs*, int microseconds);
  1067. // int (*xCurrentTime)(sqlite3_vfs*, double*);
  1068. // int (*xGetLastError)(sqlite3_vfs*, int, char *);
  1069. // /*
  1070. // ** The methods above are in version 1 of the sqlite_vfs object
  1071. // ** definition. Those that follow are added in version 2 or later
  1072. // */
  1073. // int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
  1074. // /*
  1075. // ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
  1076. // ** New fields may be appended in figure versions. The iVersion
  1077. // ** value will increment whenever this happens.
  1078. // */
  1079. //};
  1080. public class sqlite3_vfs
  1081. {
  1082. public int iVersion; /* Structure version number */
  1083. public int szOsFile; /* Size of subclassed sqlite3_file */
  1084. public int mxPathname; /* Maximum file pathname length */
  1085. public sqlite3_vfs pNext; /* Next registered VFS */
  1086. public string zName; /* Name of this virtual file system */
  1087. public object pAppData; /* Pointer to application-specific data */
  1088. public dxOpen xOpen;
  1089. public dxDelete xDelete;
  1090. public dxAccess xAccess;
  1091. public dxFullPathname xFullPathname;
  1092. public dxDlOpen xDlOpen;
  1093. public dxDlError xDlError;
  1094. public dxDlSym xDlSym;
  1095. public dxDlClose xDlClose;
  1096. public dxRandomness xRandomness;
  1097. public dxSleep xSleep;
  1098. public dxCurrentTime xCurrentTime;
  1099. public dxGetLastError xGetLastError;
  1100. /*
  1101. ** The methods above are in version 1 of the sqlite_vfs object
  1102. ** definition. Those that follow are added in version 2 or later
  1103. */
  1104. public dxCurrentTimeInt64 xCurrentTimeInt64;
  1105. /*
  1106. ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
  1107. ** New fields may be appended in figure versions. The iVersion
  1108. ** value will increment whenever this happens.
  1109. */
  1110. /* New fields may be appended in figure versions. The iVersion
  1111. ** value will increment whenever this happens. */
  1112. public sqlite3_vfs()
  1113. {
  1114. }
  1115. public sqlite3_vfs( int iVersion,
  1116. int szOsFile,
  1117. int mxPathname,
  1118. sqlite3_vfs pNext,
  1119. string zName,
  1120. object pAppData,
  1121. dxOpen xOpen,
  1122. dxDelete xDelete,
  1123. dxAccess xAccess,
  1124. dxFullPathname xFullPathname,
  1125. dxDlOpen xDlOpen,
  1126. dxDlError xDlError,
  1127. dxDlSym xDlSym,
  1128. dxDlClose xDlClose,
  1129. dxRandomness xRandomness,
  1130. dxSleep xSleep,
  1131. dxCurrentTime xCurrentTime,
  1132. dxGetLastError xGetLastError,
  1133. dxCurrentTimeInt64 xCurrentTimeInt64 )
  1134. {
  1135. this.iVersion = iVersion;
  1136. this.szOsFile = szOsFile;
  1137. this.mxPathname = mxPathname;
  1138. this.pNext = pNext;
  1139. this.zName = zName;
  1140. this.pAppData = pAppData;
  1141. this.xOpen = xOpen;
  1142. this.xDelete = xDelete;
  1143. this.xAccess = xAccess;
  1144. this.xFullPathname = xFullPathname;
  1145. this.xDlOpen = xDlOpen;
  1146. this.xDlError = xDlError;
  1147. this.xDlSym = xDlSym;
  1148. this.xDlClose = xDlClose;
  1149. this.xRandomness = xRandomness;
  1150. this.xSleep = xSleep;
  1151. this.xCurrentTime = xCurrentTime;
  1152. this.xGetLastError = xGetLastError;
  1153. this.xCurrentTimeInt64 = xCurrentTimeInt64;
  1154. }
  1155. }
  1156. /*
  1157. ** CAPI3REF: Flags for the xAccess VFS method
  1158. **
  1159. ** These integer constants can be used as the third parameter to
  1160. ** the xAccess method of an [sqlite3_vfs] object. They determine
  1161. ** what kind of permissions the xAccess method is looking for.
  1162. ** With SQLITE_ACCESS_EXISTS, the xAccess method
  1163. ** simply checks whether the file exists.
  1164. ** With SQLITE_ACCESS_READWRITE, the xAccess method
  1165. ** checks whether the named directory is both readable and writable
  1166. ** (in other words, if files can be added, removed, and renamed within
  1167. ** the directory).
  1168. ** The SQLITE_ACCESS_READWRITE constant is currently used only by the
  1169. ** [temp_store_directory pragma], though this could change in a future
  1170. ** release of SQLite.
  1171. ** With SQLITE_ACCESS_READ, the xAccess method
  1172. ** checks whether the file is readable. The SQLITE_ACCESS_READ constant is
  1173. ** currently unused, though it might be used in a future release of
  1174. ** SQLite.
  1175. */
  1176. //#define SQLITE_ACCESS_EXISTS 0
  1177. //#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
  1178. //#define SQLITE_ACCESS_READ 2 /* Unused */
  1179. const int SQLITE_ACCESS_EXISTS = 0;
  1180. const int SQLITE_ACCESS_READWRITE = 1;
  1181. const int SQLITE_ACCESS_READ = 2;
  1182. /*
  1183. ** CAPI3REF: Flags for the xShmLock VFS method
  1184. **
  1185. ** These integer constants define the various locking operations
  1186. ** allowed by the xShmLock method of [sqlite3_io_methods]. The
  1187. ** following are the only legal combinations of flags to the
  1188. ** xShmLock method:
  1189. **
  1190. ** <ul>
  1191. ** <li> SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
  1192. ** <li> SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
  1193. ** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
  1194. ** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
  1195. ** </ul>
  1196. **
  1197. ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
  1198. ** was given no the corresponding lock.
  1199. **
  1200. ** The xShmLock method can transition between unlocked and SHARED or
  1201. ** between unlocked and EXCLUSIVE. It cannot transition between SHARED
  1202. ** and EXCLUSIVE.
  1203. */
  1204. //#define SQLITE_SHM_UNLOCK 1
  1205. //#define SQLITE_SHM_LOCK 2
  1206. //#define SQLITE_SHM_SHARED 4
  1207. //#define SQLITE_SHM_EXCLUSIVE 8
  1208. const int SQLITE_SHM_UNLOCK = 1;
  1209. const int SQLITE_SHM_LOCK = 2;
  1210. const int SQLITE_SHM_SHARED = 4;
  1211. const int SQLITE_SHM_EXCLUSIVE = 8;
  1212. /*
  1213. ** CAPI3REF: Maximum xShmLock index
  1214. **
  1215. ** The xShmLock method on [sqlite3_io_methods] may use values
  1216. ** between 0 and this upper bound as its "offset" argument.
  1217. ** The SQLite core will never attempt to acquire or release a
  1218. ** lock outside of this range
  1219. */
  1220. //#define SQLITE_SHM_NLOCK 8
  1221. const int SQLITE_SHM_NLOCK = 8;
  1222. /*
  1223. ** CAPI3REF: Initialize The SQLite Library
  1224. **
  1225. ** ^The sqlite3_initialize() routine initializes the
  1226. ** SQLite library. ^The sqlite3_shutdown() routine
  1227. ** deallocates any resources that were allocated by sqlite3_initialize().
  1228. ** These routines are designed to aid in process initialization and
  1229. ** shutdown on embedded systems. Workstation applications using
  1230. ** SQLite normally do not need to invoke either of these routines.
  1231. **
  1232. ** A call to sqlite3_initialize() is an "effective" call if it is
  1233. ** the first time sqlite3_initialize() is invoked during the lifetime of
  1234. ** the process, or if it is the first time sqlite3_initialize() is invoked
  1235. ** following a call to sqlite3_shutdown(). ^(Only an effective call
  1236. ** of sqlite3_initialize() does any initialization. All other calls
  1237. ** are harmless no-ops.)^
  1238. **
  1239. ** A call to sqlite3_shutdown() is an "effective" call if it is the first
  1240. ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only
  1241. ** an effective call to sqlite3_shutdown() does any deinitialization.
  1242. ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
  1243. **
  1244. ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
  1245. ** is not. The sqlite3_shutdown() interface must only be called from a
  1246. ** single thread. All open [database connections] must be closed and all
  1247. ** other SQLite resources must be deallocated prior to invoking
  1248. ** sqlite3_shutdown().
  1249. **
  1250. ** Among other things, ^sqlite3_initialize() will invoke
  1251. ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown()
  1252. ** will invoke sqlite3_os_end().
  1253. **
  1254. ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
  1255. ** ^If for some reason, sqlite3_initialize() is unable to initialize
  1256. ** the library (perhaps it is unable to allocate a needed resource such
  1257. ** as a mutex) it returns an [error code] other than [SQLITE_OK].
  1258. **
  1259. ** ^The sqlite3_initialize() routine is called internally by many other
  1260. ** SQLite interfaces so that an application usually does not need to
  1261. ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
  1262. ** calls sqlite3_initialize() so the SQLite library will be automatically
  1263. ** initialized when [sqlite3_open()] is called if it has not be initialized
  1264. ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
  1265. ** compile-time option, then the automatic calls to sqlite3_initialize()
  1266. ** are omitted and the application must call sqlite3_initialize() directly
  1267. ** prior to using any other SQLite interface. For maximum portability,
  1268. ** it is recommended that applications always invoke sqlite3_initialize()
  1269. ** directly prior to using any other SQLite interface. Future releases
  1270. ** of SQLite may require this. In other words, the behavior exhibited
  1271. ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the
  1272. ** default behavior in some future release of SQLite.
  1273. **
  1274. ** The sqlite3_os_init() routine does operating-system specific
  1275. ** initialization of the SQLite library. The sqlite3_os_end()
  1276. ** routine undoes the effect of sqlite3_os_init(). Typical tasks
  1277. ** performed by these routines include allocation or deallocation
  1278. ** of static resources, initialization of global variables,
  1279. ** setting up a default [sqlite3_vfs] module, or setting up
  1280. ** a default configuration using [sqlite3_config()].
  1281. **
  1282. ** The application should never invoke either sqlite3_os_init()
  1283. ** or sqlite3_os_end() directly. The application should only invoke
  1284. ** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init()
  1285. ** interface is called automatically by sqlite3_initialize() and
  1286. ** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate
  1287. ** implementations for sqlite3_os_init() and sqlite3_os_end()
  1288. ** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
  1289. ** When [custom builds | built for other platforms]
  1290. ** (using the [SQLITE_OS_OTHER=1] compile-time
  1291. ** option) the application must supply a suitable implementation for
  1292. ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
  1293. ** implementation of sqlite3_os_init() or sqlite3_os_end()
  1294. ** must return [SQLITE_OK] on success and some other [error code] upon
  1295. ** failure.
  1296. */
  1297. //SQLITE_API int sqlite3_initialize(void);
  1298. //SQLITE_API int sqlite3_shutdown(void);
  1299. //SQLITE_API int sqlite3_os_init(void);
  1300. //SQLITE_API int sqlite3_os_end(void);
  1301. /*
  1302. ** CAPI3REF: Configuring The SQLite Library
  1303. **
  1304. ** The sqlite3_config() interface is used to make global configuration
  1305. ** changes to SQLite in order to tune SQLite to the specific needs of
  1306. ** the application. The default configuration is recommended for most
  1307. ** applications and so this routine is usually not necessary. It is
  1308. ** provided to support rare applications with unusual needs.
  1309. **
  1310. ** The sqlite3_config() interface is not threadsafe. The application
  1311. ** must insure that no other SQLite interfaces are invoked by other
  1312. ** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
  1313. ** may only be invoked prior to library initialization using
  1314. ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
  1315. ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
  1316. ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
  1317. ** Note, however, that ^sqlite3_config() can be called as part of the
  1318. ** implementation of an application-defined [sqlite3_os_init()].
  1319. **
  1320. ** The first argument to sqlite3_config() is an integer
  1321. ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
  1322. ** what property of SQLite is to be configured. Subsequent arguments
  1323. ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
  1324. ** in the first argument.
  1325. **
  1326. ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
  1327. ** ^If the option is unknown or SQLite is unable to set the option
  1328. ** then this routine returns a non-zero [error code].
  1329. */
  1330. //SQLITE_API int sqlite3_config(int, ...);
  1331. /*
  1332. ** CAPI3REF: Configure database connections
  1333. **
  1334. ** The sqlite3_db_config() interface is used to make configuration
  1335. ** changes to a [database connection]. The interface is similar to
  1336. ** [sqlite3_config()] except that the changes apply to a single
  1337. ** [database connection] (specified in the first argument). The
  1338. ** sqlite3_db_config() interface should only be used immediately after
  1339. ** the database connection is created using [sqlite3_open()],
  1340. ** [sqlite3_open16()], or [sqlite3_open_v2()].
  1341. **
  1342. ** The second argument to sqlite3_db_config(D,V,...) is the
  1343. ** configuration verb - an integer code that indicates what
  1344. ** aspect of the [database connection] is being configured.
  1345. ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
  1346. ** New verbs are likely to be added in future releases of SQLite.
  1347. ** Additional arguments depend on the verb.
  1348. **
  1349. ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
  1350. ** the call is considered successful.
  1351. */
  1352. //SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
  1353. /*
  1354. ** CAPI3REF: Memory Allocation Routines
  1355. **
  1356. ** An instance of this object defines the interface between SQLite
  1357. ** and low-level memory allocation routines.
  1358. **
  1359. ** This object is used in only one place in the SQLite interface.
  1360. ** A pointer to an instance of this object is the argument to
  1361. ** [sqlite3_config()] when the configuration option is
  1362. ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].
  1363. ** By creating an instance of this object
  1364. ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
  1365. ** during configuration, an application can specify an alternative
  1366. ** memory allocation subsystem for SQLite to use for all of its
  1367. ** dynamic memory needs.
  1368. **
  1369. ** Note that SQLite comes with several [built-in memory allocators]
  1370. ** that are perfectly adequate for the overwhelming majority of applications
  1371. ** and that this object is only useful to a tiny minority of applications
  1372. ** with specialized memory allocation requirements. This object is
  1373. ** also used during testing of SQLite in order to specify an alternative
  1374. ** memory allocator that simulates memory out-of-memory conditions in
  1375. ** order to verify that SQLite recovers gracefully from such
  1376. ** conditions.
  1377. **
  1378. ** The xMalloc and xFree methods must work like the
  1379. ** malloc() and free() functions from the standard C library.
  1380. ** The xRealloc method must work like realloc() from the standard C library
  1381. ** with the exception that if the second argument to xRealloc is zero,
  1382. ** xRealloc must be a no-op - it must not perform any allocation or
  1383. ** deallocation. ^SQLite guarantees that the second argument to
  1384. ** xRealloc is always a value returned by a prior call to xRoundup.
  1385. ** And so in cases where xRoundup always returns a positive number,
  1386. ** xRealloc can perform exactly as the standard library realloc() and
  1387. ** still be in compliance with this specification.
  1388. **
  1389. ** xSize should return the allocated size of a memory allocation
  1390. ** previously obtained from xMalloc or xRealloc. The allocated size
  1391. ** is always at least as big as the requested size but may be larger.
  1392. **
  1393. ** The xRoundup method returns what would be the allocated size of
  1394. ** a memory allocation given a particular requested size. Most memory
  1395. ** allocators round up memory allocations at least to the next multiple
  1396. ** of 8. Some allocators round up to a larger multiple or to a power of 2.
  1397. ** Every memory allocation request coming in through [sqlite3_malloc()]
  1398. ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
  1399. ** that causes the corresponding memory allocation to fail.
  1400. **
  1401. ** The xInit method initializes the memory allocator. (For example,
  1402. ** it might allocate any require mutexes or initialize internal data
  1403. ** structures. The xShutdown method is invoked (indirectly) by
  1404. ** [sqlite3_shutdown()] and should deallocate any resources acquired
  1405. ** by xInit. The pAppData pointer is used as the only parameter to
  1406. ** xInit and xShutdown.
  1407. **
  1408. ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
  1409. ** the xInit method, so the xInit method need not be threadsafe. The
  1410. ** xShutdown method is only called from [sqlite3_shutdown()] so it does
  1411. ** not need to be threadsafe either. For all other methods, SQLite
  1412. ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
  1413. ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
  1414. ** it is by default) and so the methods are automatically serialized.
  1415. ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
  1416. ** methods must be threadsafe or else make their own arrangements for
  1417. ** serialization.
  1418. **
  1419. ** SQLite will never invoke xInit() more than once without an intervening
  1420. ** call to xShutdown().
  1421. */
  1422. //typedef struct sqlite3_mem_methods sqlite3_mem_methods;
  1423. //struct sqlite3_mem_methods {
  1424. // void *(*xMalloc)(int); /* Memory allocation function */
  1425. // void (*xFree)(void*); /* Free a prior allocation */
  1426. // void *(*xRealloc)(void*,int); /* Resize an allocation */
  1427. // int (*xSize)(void*); /* Return the size of an allocation */
  1428. // int (*xRoundup)(int); /* Round up request size to allocation size */
  1429. // int (*xInit)(void*); /* Initialize the memory allocator */
  1430. // void (*xShutdown)(void*); /* Deinitialize the memory allocator */
  1431. // void *pAppData; /* Argument to xInit() and xShutdown() */
  1432. //};
  1433. public struct sqlite3_mem_methods
  1434. {
  1435. public dxMalloc xMalloc; //void *(*xMalloc)(int); /* Memory allocation function */
  1436. public dxMallocInt xMallocInt; //void *(*xMalloc)(int); /* Memory allocation function */
  1437. public dxMallocMem xMallocMem; //void *(*xMalloc)(int); /* Memory allocation function */
  1438. public dxFree xFree; //void (*xFree)(void*); /* Free a prior allocation */
  1439. public dxFreeInt xFreeInt; //void (*xFree)(void*); /* Free a prior allocation */
  1440. public dxFreeMem xFreeMem; //void (*xFree)(void*); /* Free a prior allocation */
  1441. public dxRealloc xRealloc; //void *(*xRealloc)(void*,int); /* Resize an allocation */
  1442. public dxSize xSize; //int (*xSize)(void*); /* Return the size of an allocation */
  1443. public dxRoundup xRoundup; //int (*xRoundup)(int); /* Round up request size to allocation size */
  1444. public dxMemInit xInit; //int (*xInit)(void*); /* Initialize the memory allocator */
  1445. public dxMemShutdown xShutdown; //void (*xShutdown)(void*); /* Deinitialize the memory allocator */
  1446. public object pAppData; /* Argument to xInit() and xShutdown() */
  1447. public sqlite3_mem_methods(
  1448. dxMalloc xMalloc,
  1449. dxMallocInt xMallocInt,
  1450. dxMallocMem xMallocMem,
  1451. dxFree xFree,
  1452. dxFreeInt xFreeInt,
  1453. dxFreeMem xFreeMem,
  1454. dxRealloc xRealloc,
  1455. dxSize xSize,
  1456. dxRoundup xRoundup,
  1457. dxMemInit xInit,
  1458. dxMemShutdown xShutdown,
  1459. object pAppData
  1460. )
  1461. {
  1462. this.xMalloc = xMalloc;
  1463. this.xMallocInt = xMallocInt;
  1464. this.xMallocMem = xMallocMem;
  1465. this.xFree = xFree;
  1466. this.xFreeInt = xFreeInt;
  1467. this.xFreeMem = xFreeMem;
  1468. this.xRealloc = xRealloc;
  1469. this.xSize = xSize;
  1470. this.xRoundup = xRoundup;
  1471. this.xInit = xInit;
  1472. this.xShutdown = xShutdown;
  1473. this.pAppData = pAppData;
  1474. }
  1475. }
  1476. /*
  1477. ** CAPI3REF: Configuration Options
  1478. **
  1479. ** These constants are the available integer configuration options that
  1480. ** can be passed as the first argument to the [sqlite3_config()] interface.
  1481. **
  1482. ** New configuration options may be added in future releases of SQLite.
  1483. ** Existing configuration options might be discontinued. Applications
  1484. ** should check the return code from [sqlite3_config()] to make sure that
  1485. ** the call worked. The [sqlite3_config()] interface will return a
  1486. ** non-zero [error code] if a discontinued or unsupported configuration option
  1487. ** is invoked.
  1488. **
  1489. ** <dl>
  1490. ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
  1491. ** <dd>There are no arguments to this option. ^This option sets the
  1492. ** [threading mode] to Single-thread. In other words, it disables
  1493. ** all mutexing and puts SQLite into a mode where it can only be used
  1494. ** by a single thread. ^If SQLite is compiled with
  1495. ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1496. ** it is not possible to change the [threading mode] from its default
  1497. ** value of Single-thread and so [sqlite3_config()] will return
  1498. ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
  1499. ** configuration option.</dd>
  1500. **
  1501. ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
  1502. ** <dd>There are no arguments to this option. ^This option sets the
  1503. ** [threading mode] to Multi-thread. In other words, it disables
  1504. ** mutexing on [database connection] and [prepared statement] objects.
  1505. ** The application is responsible for serializing access to
  1506. ** [database connections] and [prepared statements]. But other mutexes
  1507. ** are enabled so that SQLite will be safe to use in a multi-threaded
  1508. ** environment as long as no two threads attempt to use the same
  1509. ** [database connection] at the same time. ^If SQLite is compiled with
  1510. ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1511. ** it is not possible to set the Multi-thread [threading mode] and
  1512. ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
  1513. ** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
  1514. **
  1515. ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
  1516. ** <dd>There are no arguments to this option. ^This option sets the
  1517. ** [threading mode] to Serialized. In other words, this option enables
  1518. ** all mutexes including the recursive
  1519. ** mutexes on [database connection] and [prepared statement] objects.
  1520. ** In this mode (which is the default when SQLite is compiled with
  1521. ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
  1522. ** to [database connections] and [prepared statements] so that the
  1523. ** application is free to use the same [database connection] or the
  1524. ** same [prepared statement] in different threads at the same time.
  1525. ** ^If SQLite is compiled with
  1526. ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1527. ** it is not possible to set the Serialized [threading mode] and
  1528. ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
  1529. ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
  1530. **
  1531. ** <dt>SQLITE_CONFIG_MALLOC</dt>
  1532. ** <dd> ^(This option takes a single argument which is a pointer to an
  1533. ** instance of the [sqlite3_mem_methods] structure. The argument specifies
  1534. ** alternative low-level memory allocation routines to be used in place of
  1535. ** the memory allocation routines built into SQLite.)^ ^SQLite makes
  1536. ** its own private copy of the content of the [sqlite3_mem_methods] structure
  1537. ** before the [sqlite3_config()] call returns.</dd>
  1538. **
  1539. ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
  1540. ** <dd> ^(This option takes a single argument which is a pointer to an
  1541. ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
  1542. ** structure is filled with the currently defined memory allocation routines.)^
  1543. ** This option can be used to overload the default memory allocation
  1544. ** routines with a wrapper that simulations memory allocation failure or
  1545. ** tracks memory usage, for example. </dd>
  1546. **
  1547. ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
  1548. ** <dd> ^This option takes single argument of type int, interpreted as a
  1549. ** boolean, which enables or disables the collection of memory allocation
  1550. ** statistics. ^(When memory allocation statistics are disabled, the
  1551. ** following SQLite interfaces become non-operational:
  1552. ** <ul>
  1553. ** <li> [sqlite3_memory_used()]
  1554. ** <li> [sqlite3_memory_highwater()]
  1555. ** <li> [sqlite3_soft_heap_limit64()]
  1556. ** <li> [sqlite3_status()]
  1557. ** </ul>)^
  1558. ** ^Memory allocation statistics are enabled by default unless SQLite is
  1559. ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
  1560. ** allocation statistics are disabled by default.
  1561. ** </dd>
  1562. **
  1563. ** <dt>SQLITE_CONFIG_SCRATCH</dt>
  1564. ** <dd> ^This option specifies a static memory buffer that SQLite can use for
  1565. ** scratch memory. There are three arguments: A pointer an 8-byte
  1566. ** aligned memory buffer from which the scrach allocations will be
  1567. ** drawn, the size of each scratch allocation (sz),
  1568. ** and the maximum number of scratch allocations (N). The sz
  1569. ** argument must be a multiple of 16.
  1570. ** The first argument must be a pointer to an 8-byte aligned buffer
  1571. ** of at least sz*N bytes of memory.
  1572. ** ^SQLite will use no more than two scratch buffers per thread. So
  1573. ** N should be set to twice the expected maximum number of threads.
  1574. ** ^SQLite will never require a scratch buffer that is more than 6
  1575. ** times the database page size. ^If SQLite needs needs additional
  1576. ** scratch memory beyond what is provided by this configuration option, then
  1577. ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
  1578. **
  1579. ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
  1580. ** <dd> ^This option specifies a static memory buffer that SQLite can use for
  1581. ** the database page cache with the default page cache implemenation.
  1582. ** This configuration should not be used if an application-define page
  1583. ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
  1584. ** There are three arguments to this option: A pointer to 8-byte aligned
  1585. ** memory, the size of each page buffer (sz), and the number of pages (N).
  1586. ** The sz argument should be the size of the largest database page
  1587. ** (a power of two between 512 and 32768) plus a little extra for each
  1588. ** page header. ^The page header size is 20 to 40 bytes depending on
  1589. ** the host architecture. ^It is harmless, apart from the wasted memory,
  1590. ** to make sz a little too large. The first
  1591. ** argument should point to an allocation of at least sz*N bytes of memory.
  1592. ** ^SQLite will use the memory provided by the first argument to satisfy its
  1593. ** memory needs for the first N pages that it adds to cache. ^If additional
  1594. ** page cache memory is needed beyond what is provided by this option, then
  1595. ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
  1596. ** The pointer in the first argument must
  1597. ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
  1598. ** will be undefined.</dd>
  1599. **
  1600. ** <dt>SQLITE_CONFIG_HEAP</dt>
  1601. ** <dd> ^This option specifies a static memory buffer that SQLite will use
  1602. ** for all of its dynamic memory allocation needs beyond those provided
  1603. ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
  1604. ** There are three arguments: An 8-byte aligned pointer to the memory,
  1605. ** the number of bytes in the memory buffer, and the minimum allocation size.
  1606. ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
  1607. ** to using its default memory allocator (the system malloc() implementation),
  1608. ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
  1609. ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
  1610. ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
  1611. ** allocator is engaged to handle all of SQLites memory allocation needs.
  1612. ** The first pointer (the memory pointer) must be aligned to an 8-byte
  1613. ** boundary or subsequent behavior of SQLite will be undefined.</dd>
  1614. **
  1615. ** <dt>SQLITE_CONFIG_MUTEX</dt>
  1616. ** <dd> ^(This option takes a single argument which is a pointer to an
  1617. ** instance of the [sqlite3_mutex_methods] structure. The argument specifies
  1618. ** alternative low-level mutex routines to be used in place
  1619. ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
  1620. ** content of the [sqlite3_mutex_methods] structure before the call to
  1621. ** [sqlite3_config()] returns. ^If SQLite is compiled with
  1622. ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1623. ** the entire mutexing subsystem is omitted from the build and hence calls to
  1624. ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
  1625. ** return [SQLITE_ERROR].</dd>
  1626. **
  1627. ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
  1628. ** <dd> ^(This option takes a single argument which is a pointer to an
  1629. ** instance of the [sqlite3_mutex_methods] structure. The
  1630. ** [sqlite3_mutex_methods]
  1631. ** structure is filled with the currently defined mutex routines.)^
  1632. ** This option can be used to overload the default mutex allocation
  1633. ** routines with a wrapper used to track mutex usage for performance
  1634. ** profiling or testing, for example. ^If SQLite is compiled with
  1635. ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1636. ** the entire mutexing subsystem is omitted from the build and hence calls to
  1637. ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
  1638. ** return [SQLITE_ERROR].</dd>
  1639. **
  1640. ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
  1641. ** <dd> ^(This option takes two arguments that determine the default
  1642. ** memory allocation for the lookaside memory allocator on each
  1643. ** [database connection]. The first argument is the
  1644. ** size of each lookaside buffer slot and the second is the number of
  1645. ** slots allocated to each database connection.)^ ^(This option sets the
  1646. ** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
  1647. ** verb to [sqlite3_db_config()] can be used to change the lookaside
  1648. ** configuration on individual connections.)^ </dd>
  1649. **
  1650. ** <dt>SQLITE_CONFIG_PCACHE</dt>
  1651. ** <dd> ^(This option takes a single argument which is a pointer to
  1652. ** an [sqlite3_pcache_methods] object. This object specifies the interface
  1653. ** to a custom page cache implementation.)^ ^SQLite makes a copy of the
  1654. ** object and uses it for page cache memory allocations.</dd>
  1655. **
  1656. ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
  1657. ** <dd> ^(This option takes a single argument which is a pointer to an
  1658. ** [sqlite3_pcache_methods] object. SQLite copies of the current
  1659. ** page cache implementation into that object.)^ </dd>
  1660. **
  1661. ** <dt>SQLITE_CONFIG_LOG</dt>
  1662. ** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
  1663. ** function with a call signature of void(*)(void*,int,const char*),
  1664. ** and a pointer to void. ^If the function pointer is not NULL, it is
  1665. ** invoked by [sqlite3_log()] to process each logging event. ^If the
  1666. ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
  1667. ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
  1668. ** passed through as the first parameter to the application-defined logger
  1669. ** function whenever that function is invoked. ^The second parameter to
  1670. ** the logger function is a copy of the first parameter to the corresponding
  1671. ** [sqlite3_log()] call and is intended to be a [result code] or an
  1672. ** [extended result code]. ^The third parameter passed to the logger is
  1673. ** log message after formatting via [sqlite3_snprintf()].
  1674. ** The SQLite logging interface is not reentrant; the logger function
  1675. ** supplied by the application must not invoke any SQLite interface.
  1676. ** In a multi-threaded application, the application-defined logger
  1677. ** function must be threadsafe. </dd>
  1678. **
  1679. ** </dl>
  1680. */
  1681. //#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
  1682. //#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
  1683. //#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
  1684. //#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
  1685. //#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
  1686. //#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */
  1687. //#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
  1688. //#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
  1689. //#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
  1690. //#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
  1691. //#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
  1692. ///* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
  1693. //#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
  1694. //#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
  1695. //#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
  1696. //#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
  1697. const int SQLITE_CONFIG_SINGLETHREAD = 1;
  1698. const int SQLITE_CONFIG_MULTITHREAD = 2;
  1699. const int SQLITE_CONFIG_SERIALIZED = 3;
  1700. const int SQLITE_CONFIG_MALLOC = 4;
  1701. const int SQLITE_CONFIG_GETMALLOC = 5;
  1702. const int SQLITE_CONFIG_SCRATCH = 6;
  1703. const int SQLITE_CONFIG_PAGECACHE = 7;
  1704. const int SQLITE_CONFIG_HEAP = 8;
  1705. const int SQLITE_CONFIG_MEMSTATUS = 9;
  1706. const int SQLITE_CONFIG_MUTEX = 10;
  1707. const int SQLITE_CONFIG_GETMUTEX = 11;
  1708. const int SQLITE_CONFIG_LOOKASIDE = 13;
  1709. const int SQLITE_CONFIG_PCACHE = 14;
  1710. const int SQLITE_CONFIG_GETPCACHE = 15;
  1711. const int SQLITE_CONFIG_LOG = 16;
  1712. /*
  1713. ** CAPI3REF: Database Connection Configuration Options
  1714. **
  1715. ** These constants are the available integer configuration options that
  1716. ** can be passed as the second argument to the [sqlite3_db_config()] interface.
  1717. **
  1718. ** New configuration options may be added in future releases of SQLite.
  1719. ** Existing configuration options might be discontinued. Applications
  1720. ** should check the return code from [sqlite3_db_config()] to make sure that
  1721. ** the call worked. ^The [sqlite3_db_config()] interface will return a
  1722. ** non-zero [error code] if a discontinued or unsupported configuration option
  1723. ** is invoked.
  1724. **
  1725. ** <dl>
  1726. ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
  1727. ** <dd> ^This option takes three additional arguments that determine the
  1728. ** [lookaside memory allocator] configuration for the [database connection].
  1729. ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
  1730. ** pointer to an memory buffer to use for lookaside memory.
  1731. ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
  1732. ** may be NULL in which case SQLite will allocate the
  1733. ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
  1734. ** size of each lookaside buffer slot. ^The third argument is the number of
  1735. ** slots. The size of the buffer in the first argument must be greater than
  1736. ** or equal to the product of the second and third arguments. The buffer
  1737. ** must be aligned to an 8-byte boundary. ^If the second argument to
  1738. ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
  1739. ** rounded down to the next smaller multiple of 8. ^(The lookaside memory
  1740. ** configuration for a database connection can only be changed when that
  1741. ** connection is not currently using lookaside memory, or in other words
  1742. ** when the "current value" returned by
  1743. ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
  1744. ** Any attempt to change the lookaside memory configuration when lookaside
  1745. ** memory is in use leaves the configuration unchanged and returns
  1746. ** [SQLITE_BUSY].)^</dd>
  1747. **
  1748. ** </dl>
  1749. */
  1750. //#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
  1751. const int SQLITE_DBCONFIG_LOOKASIDE = 1001;
  1752. /*
  1753. ** CAPI3REF: Enable Or Disable Extended Result Codes
  1754. **
  1755. ** ^The sqlite3_extended_result_codes() routine enables or disables the
  1756. ** [extended result codes] feature of SQLite. ^The extended result
  1757. ** codes are disabled by default for historical compatibility.
  1758. */
  1759. //SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
  1760. /*
  1761. ** CAPI3REF: Last Insert Rowid
  1762. **
  1763. ** ^Each entry in an SQLite table has a unique 64-bit signed
  1764. ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
  1765. ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
  1766. ** names are not also used by explicitly declared columns. ^If
  1767. ** the table has a column of type [INTEGER PRIMARY KEY] then that column
  1768. ** is another alias for the rowid.
  1769. **
  1770. ** ^This routine returns the [rowid] of the most recent
  1771. ** successful [INSERT] into the database from the [database connection]
  1772. ** in the first argument. ^If no successful [INSERT]s
  1773. ** have ever occurred on that database connection, zero is returned.
  1774. **
  1775. ** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
  1776. ** row is returned by this routine as long as the trigger is running.
  1777. ** But once the trigger terminates, the value returned by this routine
  1778. ** reverts to the last value inserted before the trigger fired.)^
  1779. **
  1780. ** ^An [INSERT] that fails due to a constraint violation is not a
  1781. ** successful [INSERT] and does not change the value returned by this
  1782. ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
  1783. ** and INSERT OR ABORT make no changes to the return value of this
  1784. ** routine when their insertion fails. ^(When INSERT OR REPLACE
  1785. ** encounters a constraint violation, it does not fail. The
  1786. ** INSERT continues to completion after deleting rows that caused
  1787. ** the constraint problem so INSERT OR REPLACE will always change
  1788. ** the return value of this interface.)^
  1789. **
  1790. ** ^For the purposes of this routine, an [INSERT] is considered to
  1791. ** be successful even if it is subsequently rolled back.
  1792. **
  1793. ** This function is accessible to SQL statements via the
  1794. ** [last_insert_rowid() SQL function].
  1795. **
  1796. ** If a separate thread performs a new [INSERT] on the same
  1797. ** database connection while the [sqlite3_last_insert_rowid()]
  1798. ** function is running and thus changes the last insert [rowid],
  1799. ** then the value returned by [sqlite3_last_insert_rowid()] is
  1800. ** unpredictable and might not equal either the old or the new
  1801. ** last insert [rowid].
  1802. */
  1803. //SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
  1804. /*
  1805. ** CAPI3REF: Count The Number Of Rows Modified
  1806. **
  1807. ** ^This function returns the number of database rows that were changed
  1808. ** or inserted or deleted by the most recently completed SQL statement
  1809. ** on the [database connection] specified by the first parameter.
  1810. ** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
  1811. ** or [DELETE] statement are counted. Auxiliary changes caused by
  1812. ** triggers or [foreign key actions] are not counted.)^ Use the
  1813. ** [sqlite3_total_changes()] function to find the total number of changes
  1814. ** including changes caused by triggers and foreign key actions.
  1815. **
  1816. ** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
  1817. ** are not counted. Only real table changes are counted.
  1818. **
  1819. ** ^(A "row change" is a change to a single row of a single table
  1820. ** caused by an INSERT, DELETE, or UPDATE statement. Rows that
  1821. ** are changed as side effects of [REPLACE] constraint resolution,
  1822. ** rollback, ABORT processing, [DROP TABLE], or by any other
  1823. ** mechanisms do not count as direct row changes.)^
  1824. **
  1825. ** A "trigger context" is a scope of execution that begins and
  1826. ** ends with the script of a [CREATE TRIGGER | trigger].
  1827. ** Most SQL statements are
  1828. ** evaluated outside of any trigger. This is the "top level"
  1829. ** trigger context. If a trigger fires from the top level, a
  1830. ** new trigger context is entered for the duration of that one
  1831. ** trigger. Subtriggers create subcontexts for their duration.
  1832. **
  1833. ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
  1834. ** not create a new trigger context.
  1835. **
  1836. ** ^This function returns the number of direct row changes in the
  1837. ** most recent INSERT, UPDATE, or DELETE statement within the same
  1838. ** trigger context.
  1839. **
  1840. ** ^Thus, when called from the top level, this function returns the
  1841. ** number of changes in the most recent INSERT, UPDATE, or DELETE
  1842. ** that also occurred at the top level. ^(Within the body of a trigger,
  1843. ** the sqlite3_changes() interface can be called to find the number of
  1844. ** changes in the most recently completed INSERT, UPDATE, or DELETE
  1845. ** statement within the body of the same trigger.
  1846. ** However, the number returned does not include changes
  1847. ** caused by subtriggers since those have their own context.)^
  1848. **
  1849. ** See also the [sqlite3_total_changes()] interface, the
  1850. ** [count_changes pragma], and the [changes() SQL function].
  1851. **
  1852. ** If a separate thread makes changes on the same database connection
  1853. ** while [sqlite3_changes()] is running then the value returned
  1854. ** is unpredictable and not meaningful.
  1855. */
  1856. //SQLITE_API int sqlite3_changes(sqlite3*);
  1857. /*
  1858. ** CAPI3REF: Total Number Of Rows Modified
  1859. **
  1860. ** ^This function returns the number of row changes caused by [INSERT],
  1861. ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
  1862. ** ^(The count returned by sqlite3_total_changes() includes all changes
  1863. ** from all [CREATE TRIGGER | trigger] contexts and changes made by
  1864. ** [foreign key actions]. However,
  1865. ** the count does not include changes used to implement [REPLACE] constraints,
  1866. ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
  1867. ** count does not include rows of views that fire an [INSTEAD OF trigger],
  1868. ** though if the INSTEAD OF trigger makes changes of its own, those changes
  1869. ** are counted.)^
  1870. ** ^The sqlite3_total_changes() function counts the changes as soon as
  1871. ** the statement that makes them is completed (when the statement handle
  1872. ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
  1873. **
  1874. ** See also the [sqlite3_changes()] interface, the
  1875. ** [count_changes pragma], and the [total_changes() SQL function].
  1876. **
  1877. ** If a separate thread makes changes on the same database connection
  1878. ** while [sqlite3_total_changes()] is running then the value
  1879. ** returned is unpredictable and not meaningful.
  1880. */
  1881. //SQLITE_API int sqlite3_total_changes(sqlite3*);
  1882. /*
  1883. ** CAPI3REF: Interrupt A Long-Running Query
  1884. **
  1885. ** ^This function causes any pending database operation to abort and
  1886. ** return at its earliest opportunity. This routine is typically
  1887. ** called in response to a user action such as pressing "Cancel"
  1888. ** or Ctrl-C where the user wants a long query operation to halt
  1889. ** immediately.
  1890. **
  1891. ** ^It is safe to call this routine from a thread different from the
  1892. ** thread that is currently running the database operation. But it
  1893. ** is not safe to call this routine with a [database connection] that
  1894. ** is closed or might close before sqlite3_interrupt() returns.
  1895. **
  1896. ** ^If an SQL operation is very nearly finished at the time when
  1897. ** sqlite3_interrupt() is called, then it might not have an opportunity
  1898. ** to be interrupted and might continue to completion.
  1899. **
  1900. ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
  1901. ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
  1902. ** that is inside an explicit transaction, then the entire transaction
  1903. ** will be rolled back automatically.
  1904. **
  1905. ** ^The sqlite3_interrupt(D) call is in effect until all currently running
  1906. ** SQL statements on [database connection] D complete. ^Any new SQL statements
  1907. ** that are started after the sqlite3_interrupt() call and before the
  1908. ** running statements reaches zero are interrupted as if they had been
  1909. ** running prior to the sqlite3_interrupt() call. ^New SQL statements
  1910. ** that are started after the running statement count reaches zero are
  1911. ** not effected by the sqlite3_interrupt().
  1912. ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
  1913. ** SQL statements is a no-op and has no effect on SQL statements
  1914. ** that are started after the sqlite3_interrupt() call returns.
  1915. **
  1916. ** If the database connection closes while [sqlite3_interrupt()]
  1917. ** is running then bad things will likely happen.
  1918. */
  1919. //SQLITE_API void sqlite3_interrupt(sqlite3*);
  1920. /*
  1921. ** CAPI3REF: Determine If An SQL Statement Is Complete
  1922. **
  1923. ** These routines are useful during command-line input to determine if the
  1924. ** currently entered text seems to form a complete SQL statement or
  1925. ** if additional input is needed before sending the text into
  1926. ** SQLite for parsing. ^These routines return 1 if the input string
  1927. ** appears to be a complete SQL statement. ^A statement is judged to be
  1928. ** complete if it ends with a semicolon token and is not a prefix of a
  1929. ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
  1930. ** string literals or quoted identifier names or comments are not
  1931. ** independent tokens (they are part of the token in which they are
  1932. ** embedded) and thus do not count as a statement terminator. ^Whitespace
  1933. ** and comments that follow the final semicolon are ignored.
  1934. **
  1935. ** ^These routines return 0 if the statement is incomplete. ^If a
  1936. ** memory allocation fails, then SQLITE_NOMEM is returned.
  1937. **
  1938. ** ^These routines do not parse the SQL statements thus
  1939. ** will not detect syntactically incorrect SQL.
  1940. **
  1941. ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
  1942. ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
  1943. ** automatically by sqlite3_complete16(). If that initialization fails,
  1944. ** then the return value from sqlite3_complete16() will be non-zero
  1945. ** regardless of whether or not the input SQL is complete.)^
  1946. **
  1947. ** The input to [sqlite3_complete()] must be a zero-terminated
  1948. ** UTF-8 string.
  1949. **
  1950. ** The input to [sqlite3_complete16()] must be a zero-terminated
  1951. ** UTF-16 string in native byte order.
  1952. */
  1953. //SQLITE_API int sqlite3_complete(const char *sql);
  1954. //SQLITE_API int sqlite3_complete16(const void *sql);
  1955. /*
  1956. ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
  1957. **
  1958. ** ^This routine sets a callback function that might be invoked whenever
  1959. ** an attempt is made to open a database table that another thread
  1960. ** or process has locked.
  1961. **
  1962. ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
  1963. ** is returned immediately upon encountering the lock. ^If the busy callback
  1964. ** is not NULL, then the callback might be invoked with two arguments.
  1965. **
  1966. ** ^The first argument to the busy handler is a copy of the void* pointer which
  1967. ** is the third argument to sqlite3_busy_handler(). ^The second argument to
  1968. ** the busy handler callback is the number of times that the busy handler has
  1969. ** been invoked for this locking event. ^If the
  1970. ** busy callback returns 0, then no additional attempts are made to
  1971. ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
  1972. ** ^If the callback returns non-zero, then another attempt
  1973. ** is made to open the database for reading and the cycle repeats.
  1974. **
  1975. ** The presence of a busy handler does not guarantee that it will be invoked
  1976. ** when there is lock contention. ^If SQLite determines that invoking the busy
  1977. ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
  1978. ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
  1979. ** Consider a scenario where one process is holding a read lock that
  1980. ** it is trying to promote to a reserved lock and
  1981. ** a second process is holding a reserved lock that it is trying
  1982. ** to promote to an exclusive lock. The first process cannot proceed
  1983. ** because it is blocked by the second and the second process cannot
  1984. ** proceed because it is blocked by the first. If both processes
  1985. ** invoke the busy handlers, neither will make any progress. Therefore,
  1986. ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
  1987. ** will induce the first process to release its read lock and allow
  1988. ** the second process to proceed.
  1989. **
  1990. ** ^The default busy callback is NULL.
  1991. **
  1992. ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
  1993. ** when SQLite is in the middle of a large transaction where all the
  1994. ** changes will not fit into the in-memory cache. SQLite will
  1995. ** already hold a RESERVED lock on the database file, but it needs
  1996. ** to promote this lock to EXCLUSIVE so that it can spill cache
  1997. ** pages into the database file without harm to concurrent
  1998. ** readers. ^If it is unable to promote the lock, then the in-memory
  1999. ** cache will be left in an inconsistent state and so the error
  2000. ** code is promoted from the relatively benign [SQLITE_BUSY] to
  2001. ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion
  2002. ** forces an automatic rollback of the changes. See the
  2003. ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
  2004. ** CorruptionFollowingBusyError</a> wiki page for a discussion of why
  2005. ** this is important.
  2006. **
  2007. ** ^(There can only be a single busy handler defined for each
  2008. ** [database connection]. Setting a new busy handler clears any
  2009. ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()]
  2010. ** will also set or clear the busy handler.
  2011. **
  2012. ** The busy callback should not take any actions which modify the
  2013. ** database connection that invoked the busy handler. Any such actions
  2014. ** result in undefined behavior.
  2015. **
  2016. ** A busy handler must not close the database connection
  2017. ** or [prepared statement] that invoked the busy handler.
  2018. */
  2019. //SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
  2020. /*
  2021. ** CAPI3REF: Set A Busy Timeout
  2022. **
  2023. ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
  2024. ** for a specified amount of time when a table is locked. ^The handler
  2025. ** will sleep multiple times until at least "ms" milliseconds of sleeping
  2026. ** have accumulated. ^After at least "ms" milliseconds of sleeping,
  2027. ** the handler returns 0 which causes [sqlite3_step()] to return
  2028. ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
  2029. **
  2030. ** ^Calling this routine with an argument less than or equal to zero
  2031. ** turns off all busy handlers.
  2032. **
  2033. ** ^(There can only be a single busy handler for a particular
  2034. ** [database connection] any any given moment. If another busy handler
  2035. ** was defined (using [sqlite3_busy_handler()]) prior to calling
  2036. ** this routine, that other busy handler is cleared.)^
  2037. */
  2038. //SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
  2039. /*
  2040. ** CAPI3REF: Convenience Routines For Running Queries
  2041. **
  2042. ** This is a legacy interface that is preserved for backwards compatibility.
  2043. ** Use of this interface is not recommended.
  2044. **
  2045. ** Definition: A <b>result table</b> is memory data structure created by the
  2046. ** [sqlite3_get_table()] interface. A result table records the
  2047. ** complete query results from one or more queries.
  2048. **
  2049. ** The table conceptually has a number of rows and columns. But
  2050. ** these numbers are not part of the result table itself. These
  2051. ** numbers are obtained separately. Let N be the number of rows
  2052. ** and M be the number of columns.
  2053. **
  2054. ** A result table is an array of pointers to zero-terminated UTF-8 strings.
  2055. ** There are (N+1)*M elements in the array. The first M pointers point
  2056. ** to zero-terminated strings that contain the names of the columns.
  2057. ** The remaining entries all point to query results. NULL values result
  2058. ** in NULL pointers. All other values are in their UTF-8 zero-terminated
  2059. ** string representation as returned by [sqlite3_column_text()].
  2060. **
  2061. ** A result table might consist of one or more memory allocations.
  2062. ** It is not safe to pass a result table directly to [sqlite3_free()].
  2063. ** A result table should be deallocated using [sqlite3_free_table()].
  2064. **
  2065. ** ^(As an example of the result table format, suppose a query result
  2066. ** is as follows:
  2067. **
  2068. ** <blockquote><pre>
  2069. ** Name | Age
  2070. ** -----------------------
  2071. ** Alice | 43
  2072. ** Bob | 28
  2073. ** Cindy | 21
  2074. ** </pre></blockquote>
  2075. **
  2076. ** There are two column (M==2) and three rows (N==3). Thus the
  2077. ** result table has 8 entries. Suppose the result table is stored
  2078. ** in an array names azResult. Then azResult holds this content:
  2079. **
  2080. ** <blockquote><pre>
  2081. ** azResult&#91;0] = "Name";
  2082. ** azResult&#91;1] = "Age";
  2083. ** azResult&#91;2] = "Alice";
  2084. ** azResult&#91;3] = "43";
  2085. ** azResult&#91;4] = "Bob";
  2086. ** azResult&#91;5] = "28";
  2087. ** azResult&#91;6] = "Cindy";
  2088. ** azResult&#91;7] = "21";
  2089. ** </pre></blockquote>)^
  2090. **
  2091. ** ^The sqlite3_get_table() function evaluates one or more
  2092. ** semicolon-separated SQL statements in the zero-terminated UTF-8
  2093. ** string of its 2nd parameter and returns a result table to the
  2094. ** pointer given in its 3rd parameter.
  2095. **
  2096. ** After the application has finished with the result from sqlite3_get_table(),
  2097. ** it must pass the result table pointer to sqlite3_free_table() in order to
  2098. ** release the memory that was malloced. Because of the way the
  2099. ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
  2100. ** function must not try to call [sqlite3_free()] directly. Only
  2101. ** [sqlite3_free_table()] is able to release the memory properly and safely.
  2102. **
  2103. ** The sqlite3_get_table() interface is implemented as a wrapper around
  2104. ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access
  2105. ** to any internal data structures of SQLite. It uses only the public
  2106. ** interface defined here. As a consequence, errors that occur in the
  2107. ** wrapper layer outside of the internal [sqlite3_exec()] call are not
  2108. ** reflected in subsequent calls to [sqlite3_errcode()] or
  2109. ** [sqlite3_errmsg()].
  2110. */
  2111. //SQLITE_API int sqlite3_get_table(
  2112. // sqlite3 *db, /* An open database */
  2113. // const char *zSql, /* SQL to be evaluated */
  2114. // char ***pazResult, /* Results of the query */
  2115. // int *pnRow, /* Number of result rows written here */
  2116. // int *pnColumn, /* Number of result columns written here */
  2117. // char **pzErrmsg /* Error msg written here */
  2118. //);
  2119. //SQLITE_API void sqlite3_free_table(char **result);
  2120. /*
  2121. ** CAPI3REF: Formatted String Printing Functions
  2122. **
  2123. ** These routines are work-alikes of the "printf()" family of functions
  2124. ** from the standard C library.
  2125. **
  2126. ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
  2127. ** results into memory obtained from [sqlite3_malloc()].
  2128. ** The strings returned by these two routines should be
  2129. ** released by [sqlite3_free()]. ^Both routines return a
  2130. ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
  2131. ** memory to hold the resulting string.
  2132. **
  2133. ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from
  2134. ** the standard C library. The result is written into the
  2135. ** buffer supplied as the second parameter whose size is given by
  2136. ** the first parameter. Note that the order of the
  2137. ** first two parameters is reversed from snprintf().)^ This is an
  2138. ** historical accident that cannot be fixed without breaking
  2139. ** backwards compatibility. ^(Note also that sqlite3_snprintf()
  2140. ** returns a pointer to its buffer instead of the number of
  2141. ** characters actually written into the buffer.)^ We admit that
  2142. ** the number of characters written would be a more useful return
  2143. ** value but we cannot change the implementation of sqlite3_snprintf()
  2144. ** now without breaking compatibility.
  2145. **
  2146. ** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
  2147. ** guarantees that the buffer is always zero-terminated. ^The first
  2148. ** parameter "n" is the total size of the buffer, including space for
  2149. ** the zero terminator. So the longest string that can be completely
  2150. ** written will be n-1 characters.
  2151. **
  2152. ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().
  2153. **
  2154. ** These routines all implement some additional formatting
  2155. ** options that are useful for constructing SQL statements.
  2156. ** All of the usual printf() formatting options apply. In addition, there
  2157. ** is are "%q", "%Q", and "%z" options.
  2158. **
  2159. ** ^(The %q option works like %s in that it substitutes a null-terminated
  2160. ** string from the argument list. But %q also doubles every '\'' character.
  2161. ** %q is designed for use inside a string literal.)^ By doubling each '\''
  2162. ** character it escapes that character and allows it to be inserted into
  2163. ** the string.
  2164. **
  2165. ** For example, assume the string variable zText contains text as follows:
  2166. **
  2167. ** <blockquote><pre>
  2168. ** char *zText = "It's a happy day!";
  2169. ** </pre></blockquote>
  2170. **
  2171. ** One can use this text in an SQL statement as follows:
  2172. **
  2173. ** <blockquote><pre>
  2174. ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
  2175. ** sqlite3_exec(db, zSQL, 0, 0, 0);
  2176. ** sqlite3_free(zSQL);
  2177. ** </pre></blockquote>
  2178. **
  2179. ** Because the %q format string is used, the '\'' character in zText
  2180. ** is escaped and the SQL generated is as follows:
  2181. **
  2182. ** <blockquote><pre>
  2183. ** INSERT INTO table1 VALUES('It''s a happy day!')
  2184. ** </pre></blockquote>
  2185. **
  2186. ** This is correct. Had we used %s instead of %q, the generated SQL
  2187. ** would have looked like this:
  2188. **
  2189. ** <blockquote><pre>
  2190. ** INSERT INTO table1 VALUES('It's a happy day!');
  2191. ** </pre></blockquote>
  2192. **
  2193. ** This second example is an SQL syntax error. As a general rule you should
  2194. ** always use %q instead of %s when inserting text into a string literal.
  2195. **
  2196. ** ^(The %Q option works like %q except it also adds single quotes around
  2197. ** the outside of the total string. Additionally, if the parameter in the
  2198. ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
  2199. ** single quotes).)^ So, for example, one could say:
  2200. **
  2201. ** <blockquote><pre>
  2202. ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
  2203. ** sqlite3_exec(db, zSQL, 0, 0, 0);
  2204. ** sqlite3_free(zSQL);
  2205. ** </pre></blockquote>
  2206. **
  2207. ** The code above will render a correct SQL statement in the zSQL
  2208. ** variable even if the zText variable is a NULL pointer.
  2209. **
  2210. ** ^(The "%z" formatting option works like "%s" but with the
  2211. ** addition that after the string has been read and copied into
  2212. ** the result, [sqlite3_free()] is called on the input string.)^
  2213. */
  2214. //SQLITE_API char *sqlite3_mprintf(const char*,...);
  2215. //SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
  2216. //SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
  2217. //SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
  2218. /*
  2219. ** CAPI3REF: Memory Allocation Subsystem
  2220. **
  2221. ** The SQLite core uses these three routines for all of its own
  2222. ** internal memory allocation needs. "Core" in the previous sentence
  2223. ** does not include operating-system specific VFS implementation. The
  2224. ** Windows VFS uses native malloc() and free() for some operations.
  2225. **
  2226. ** ^The sqlite3_malloc() routine returns a pointer to a block
  2227. ** of memory at least N bytes in length, where N is the parameter.
  2228. ** ^If sqlite3_malloc() is unable to obtain sufficient free
  2229. ** memory, it returns a NULL pointer. ^If the parameter N to
  2230. ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
  2231. ** a NULL pointer.
  2232. **
  2233. ** ^Calling sqlite3_free() with a pointer previously returned
  2234. ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
  2235. ** that it might be reused. ^The sqlite3_free() routine is
  2236. ** a no-op if is called with a NULL pointer. Passing a NULL pointer
  2237. ** to sqlite3_free() is harmless. After being freed, memory
  2238. ** should neither be read nor written. Even reading previously freed
  2239. ** memory might result in a segmentation fault or other severe error.
  2240. ** Memory corruption, a segmentation fault, or other severe error
  2241. ** might result if sqlite3_free() is called with a non-NULL pointer that
  2242. ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
  2243. **
  2244. ** ^(The sqlite3_realloc() interface attempts to resize a
  2245. ** prior memory allocation to be at least N bytes, where N is the
  2246. ** second parameter. The memory allocation to be resized is the first
  2247. ** parameter.)^ ^ If the first parameter to sqlite3_realloc()
  2248. ** is a NULL pointer then its behavior is identical to calling
  2249. ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
  2250. ** ^If the second parameter to sqlite3_realloc() is zero or
  2251. ** negative then the behavior is exactly the same as calling
  2252. ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
  2253. ** ^sqlite3_realloc() returns a pointer to a memory allocation
  2254. ** of at least N bytes in size or NULL if sufficient memory is unavailable.
  2255. ** ^If M is the size of the prior allocation, then min(N,M) bytes
  2256. ** of the prior allocation are copied into the beginning of buffer returned
  2257. ** by sqlite3_realloc() and the prior allocation is freed.
  2258. ** ^If sqlite3_realloc() returns NULL, then the prior allocation
  2259. ** is not freed.
  2260. **
  2261. ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
  2262. ** is always aligned to at least an 8 byte boundary, or to a
  2263. ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
  2264. ** option is used.
  2265. **
  2266. ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
  2267. ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
  2268. ** implementation of these routines to be omitted. That capability
  2269. ** is no longer provided. Only built-in memory allocators can be used.
  2270. **
  2271. ** The Windows OS interface layer calls
  2272. ** the system malloc() and free() directly when converting
  2273. ** filenames between the UTF-8 encoding used by SQLite
  2274. ** and whatever filename encoding is used by the particular Windows
  2275. ** installation. Memory allocation errors are detected, but
  2276. ** they are reported back as [SQLITE_CANTOPEN] or
  2277. ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
  2278. **
  2279. ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
  2280. ** must be either NULL or else pointers obtained from a prior
  2281. ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
  2282. ** not yet been released.
  2283. **
  2284. ** The application must not read or write any part of
  2285. ** a block of memory after it has been released using
  2286. ** [sqlite3_free()] or [sqlite3_realloc()].
  2287. */
  2288. //SQLITE_API void *sqlite3_malloc(int);
  2289. //SQLITE_API void *sqlite3_realloc(void*, int);
  2290. //SQLITE_API void sqlite3_free(void*);
  2291. /*
  2292. ** CAPI3REF: Memory Allocator Statistics
  2293. **
  2294. ** SQLite provides these two interfaces for reporting on the status
  2295. ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
  2296. ** routines, which form the built-in memory allocation subsystem.
  2297. **
  2298. ** ^The [sqlite3_memory_used()] routine returns the number of bytes
  2299. ** of memory currently outstanding (malloced but not freed).
  2300. ** ^The [sqlite3_memory_highwater()] routine returns the maximum
  2301. ** value of [sqlite3_memory_used()] since the high-water mark
  2302. ** was last reset. ^The values returned by [sqlite3_memory_used()] and
  2303. ** [sqlite3_memory_highwater()] include any overhead
  2304. ** added by SQLite in its implementation of [sqlite3_malloc()],
  2305. ** but not overhead added by the any underlying system library
  2306. ** routines that [sqlite3_malloc()] may call.
  2307. **
  2308. ** ^The memory high-water mark is reset to the current value of
  2309. ** [sqlite3_memory_used()] if and only if the parameter to
  2310. ** [sqlite3_memory_highwater()] is true. ^The value returned
  2311. ** by [sqlite3_memory_highwater(1)] is the high-water mark
  2312. ** prior to the reset.
  2313. */
  2314. //SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
  2315. //SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
  2316. /*
  2317. ** CAPI3REF: Pseudo-Random Number Generator
  2318. **
  2319. ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
  2320. ** select random [ROWID | ROWIDs] when inserting new records into a table that
  2321. ** already uses the largest possible [ROWID]. The PRNG is also used for
  2322. ** the build-in random() and randomblob() SQL functions. This interface allows
  2323. ** applications to access the same PRNG for other purposes.
  2324. **
  2325. ** ^A call to this routine stores N bytes of randomness into buffer P.
  2326. **
  2327. ** ^The first time this routine is invoked (either internally or by
  2328. ** the application) the PRNG is seeded using randomness obtained
  2329. ** from the xRandomness method of the default [sqlite3_vfs] object.
  2330. ** ^On all subsequent invocations, the pseudo-randomness is generated
  2331. ** internally and without recourse to the [sqlite3_vfs] xRandomness
  2332. ** method.
  2333. */
  2334. //SQLITE_API void sqlite3_randomness(int N, void *P);
  2335. /*
  2336. ** CAPI3REF: Compile-Time Authorization Callbacks
  2337. **
  2338. ** ^This routine registers a authorizer callback with a particular
  2339. ** [database connection], supplied in the first argument.
  2340. ** ^The authorizer callback is invoked as SQL statements are being compiled
  2341. ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
  2342. ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
  2343. ** points during the compilation process, as logic is being created
  2344. ** to perform various actions, the authorizer callback is invoked to
  2345. ** see if those actions are allowed. ^The authorizer callback should
  2346. ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
  2347. ** specific action but allow the SQL statement to continue to be
  2348. ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
  2349. ** rejected with an error. ^If the authorizer callback returns
  2350. ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
  2351. ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
  2352. ** the authorizer will fail with an error message.
  2353. **
  2354. ** When the callback returns [SQLITE_OK], that means the operation
  2355. ** requested is ok. ^When the callback returns [SQLITE_DENY], the
  2356. ** [sqlite3_prepare_v2()] or equivalent call that triggered the
  2357. ** authorizer will fail with an error message explaining that
  2358. ** access is denied.
  2359. **
  2360. ** ^The first parameter to the authorizer callback is a copy of the third
  2361. ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
  2362. ** to the callback is an integer [SQLITE_COPY | action code] that specifies
  2363. ** the particular action to be authorized. ^The third through sixth parameters
  2364. ** to the callback are zero-terminated strings that contain additional
  2365. ** details about the action to be authorized.
  2366. **
  2367. ** ^If the action code is [SQLITE_READ]
  2368. ** and the callback returns [SQLITE_IGNORE] then the
  2369. ** [prepared statement] statement is constructed to substitute
  2370. ** a NULL value in place of the table column that would have
  2371. ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
  2372. ** return can be used to deny an untrusted user access to individual
  2373. ** columns of a table.
  2374. ** ^If the action code is [SQLITE_DELETE] and the callback returns
  2375. ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
  2376. ** [truncate optimization] is disabled and all rows are deleted individually.
  2377. **
  2378. ** An authorizer is used when [sqlite3_prepare | preparing]
  2379. ** SQL statements from an untrusted source, to ensure that the SQL statements
  2380. ** do not try to access data they are not allowed to see, or that they do not
  2381. ** try to execute malicious statements that damage the database. For
  2382. ** example, an application may allow a user to enter arbitrary
  2383. ** SQL queries for evaluation by a database. But the application does
  2384. ** not want the user to be able to make arbitrary changes to the
  2385. ** database. An authorizer could then be put in place while the
  2386. ** user-entered SQL is being [sqlite3_prepare | prepared] that
  2387. ** disallows everything except [SELECT] statements.
  2388. **
  2389. ** Applications that need to process SQL from untrusted sources
  2390. ** might also consider lowering resource limits using [sqlite3_limit()]
  2391. ** and limiting database size using the [max_page_count] [PRAGMA]
  2392. ** in addition to using an authorizer.
  2393. **
  2394. ** ^(Only a single authorizer can be in place on a database connection
  2395. ** at a time. Each call to sqlite3_set_authorizer overrides the
  2396. ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
  2397. ** The authorizer is disabled by default.
  2398. **
  2399. ** The authorizer callback must not do anything that will modify
  2400. ** the database connection that invoked the authorizer callback.
  2401. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  2402. ** database connections for the meaning of "modify" in this paragraph.
  2403. **
  2404. ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
  2405. ** statement might be re-prepared during [sqlite3_step()] due to a
  2406. ** schema change. Hence, the application should ensure that the
  2407. ** correct authorizer callback remains in place during the [sqlite3_step()].
  2408. **
  2409. ** ^Note that the authorizer callback is invoked only during
  2410. ** [sqlite3_prepare()] or its variants. Authorization is not
  2411. ** performed during statement evaluation in [sqlite3_step()], unless
  2412. ** as stated in the previous paragraph, sqlite3_step() invokes
  2413. ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
  2414. */
  2415. //SQLITE_API int sqlite3_set_authorizer(
  2416. // sqlite3*,
  2417. // int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
  2418. // void *pUserData
  2419. //);
  2420. /*
  2421. ** CAPI3REF: Authorizer Return Codes
  2422. **
  2423. ** The [sqlite3_set_authorizer | authorizer callback function] must
  2424. ** return either [SQLITE_OK] or one of these two constants in order
  2425. ** to signal SQLite whether or not the action is permitted. See the
  2426. ** [sqlite3_set_authorizer | authorizer documentation] for additional
  2427. ** information.
  2428. */
  2429. //#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
  2430. //#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
  2431. const int SQLITE_DENY = 1;
  2432. const int SQLITE_IGNORE = 2;
  2433. /*
  2434. ** CAPI3REF: Authorizer Action Codes
  2435. **
  2436. ** The [sqlite3_set_authorizer()] interface registers a callback function
  2437. ** that is invoked to authorize certain SQL statement actions. The
  2438. ** second parameter to the callback is an integer code that specifies
  2439. ** what action is being authorized. These are the integer action codes that
  2440. ** the authorizer callback may be passed.
  2441. **
  2442. ** These action code values signify what kind of operation is to be
  2443. ** authorized. The 3rd and 4th parameters to the authorization
  2444. ** callback function will be parameters or NULL depending on which of these
  2445. ** codes is used as the second parameter. ^(The 5th parameter to the
  2446. ** authorizer callback is the name of the database ("main", "temp",
  2447. ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback
  2448. ** is the name of the inner-most trigger or view that is responsible for
  2449. ** the access attempt or NULL if this access attempt is directly from
  2450. ** top-level SQL code.
  2451. */
  2452. /******************************************* 3rd ************ 4th ***********/
  2453. //#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
  2454. //#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
  2455. //#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
  2456. //#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
  2457. //#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
  2458. //#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */
  2459. //#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
  2460. //#define SQLITE_CREATE_VIEW 8 /* View Name NULL */
  2461. //#define SQLITE_DELETE 9 /* Table Name NULL */
  2462. //#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
  2463. //#define SQLITE_DROP_TABLE 11 /* Table Name NULL */
  2464. //#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
  2465. //#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
  2466. //#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
  2467. //#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */
  2468. //#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
  2469. //#define SQLITE_DROP_VIEW 17 /* View Name NULL */
  2470. //#define SQLITE_INSERT 18 /* Table Name NULL */
  2471. //#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */
  2472. //#define SQLITE_READ 20 /* Table Name Column Name */
  2473. //#define SQLITE_SELECT 21 /* NULL NULL */
  2474. //#define SQLITE_TRANSACTION 22 /* Operation NULL */
  2475. //#define SQLITE_UPDATE 23 /* Table Name Column Name */
  2476. //#define SQLITE_ATTACH 24 /* Filename NULL */
  2477. //#define SQLITE_DETACH 25 /* Database Name NULL */
  2478. //#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
  2479. //#define SQLITE_REINDEX 27 /* Index Name NULL */
  2480. //#define SQLITE_ANALYZE 28 /* Table Name NULL */
  2481. //#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
  2482. //#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
  2483. //#define SQLITE_FUNCTION 31 /* NULL Function Name */
  2484. //#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
  2485. //#define SQLITE_COPY 0 /* No longer used */
  2486. const int SQLITE_CREATE_INDEX = 1;
  2487. const int SQLITE_CREATE_TABLE = 2;
  2488. const int SQLITE_CREATE_TEMP_INDEX = 3;
  2489. const int SQLITE_CREATE_TEMP_TABLE = 4;
  2490. const int SQLITE_CREATE_TEMP_TRIGGER = 5;
  2491. const int SQLITE_CREATE_TEMP_VIEW = 6;
  2492. const int SQLITE_CREATE_TRIGGER = 7;
  2493. const int SQLITE_CREATE_VIEW = 8;
  2494. const int SQLITE_DELETE = 9;
  2495. const int SQLITE_DROP_INDEX = 10;
  2496. const int SQLITE_DROP_TABLE = 11;
  2497. const int SQLITE_DROP_TEMP_INDEX = 12;
  2498. const int SQLITE_DROP_TEMP_TABLE = 13;
  2499. const int SQLITE_DROP_TEMP_TRIGGER = 14;
  2500. const int SQLITE_DROP_TEMP_VIEW = 15;
  2501. const int SQLITE_DROP_TRIGGER = 16;
  2502. const int SQLITE_DROP_VIEW = 17;
  2503. const int SQLITE_INSERT = 18;
  2504. const int SQLITE_PRAGMA = 19;
  2505. const int SQLITE_READ = 20;
  2506. const int SQLITE_SELECT = 21;
  2507. const int SQLITE_TRANSACTION = 22;
  2508. const int SQLITE_UPDATE = 23;
  2509. const int SQLITE_ATTACH = 24;
  2510. const int SQLITE_DETACH = 25;
  2511. const int SQLITE_ALTER_TABLE = 26;
  2512. const int SQLITE_REINDEX = 27;
  2513. const int SQLITE_ANALYZE = 28;
  2514. const int SQLITE_CREATE_VTABLE = 29;
  2515. const int SQLITE_DROP_VTABLE = 30;
  2516. const int SQLITE_FUNCTION = 31;
  2517. const int SQLITE_SAVEPOINT = 32;
  2518. const int SQLITE_COPY = 0;
  2519. /*
  2520. ** CAPI3REF: Tracing And Profiling Functions
  2521. **
  2522. ** These routines register callback functions that can be used for
  2523. ** tracing and profiling the execution of SQL statements.
  2524. **
  2525. ** ^The callback function registered by sqlite3_trace() is invoked at
  2526. ** various times when an SQL statement is being run by [sqlite3_step()].
  2527. ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
  2528. ** SQL statement text as the statement first begins executing.
  2529. ** ^(Additional sqlite3_trace() callbacks might occur
  2530. ** as each triggered subprogram is entered. The callbacks for triggers
  2531. ** contain a UTF-8 SQL comment that identifies the trigger.)^
  2532. **
  2533. ** ^The callback function registered by sqlite3_profile() is invoked
  2534. ** as each SQL statement finishes. ^The profile callback contains
  2535. ** the original statement text and an estimate of wall-clock time
  2536. ** of how long that statement took to run. ^The profile callback
  2537. ** time is in units of nanoseconds, however the current implementation
  2538. ** is only capable of millisecond resolution so the six least significant
  2539. ** digits in the time are meaningless. Future versions of SQLite
  2540. ** might provide greater resolution on the profiler callback. The
  2541. ** sqlite3_profile() function is considered experimental and is
  2542. ** subject to change in future versions of SQLite.
  2543. */
  2544. //SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  2545. //SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
  2546. // void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
  2547. /*
  2548. ** CAPI3REF: Query Progress Callbacks
  2549. **
  2550. ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
  2551. ** function X to be invoked periodically during long running calls to
  2552. ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
  2553. ** database connection D. An example use for this
  2554. ** interface is to keep a GUI updated during a large query.
  2555. **
  2556. ** ^The parameter P is passed through as the only parameter to the
  2557. ** callback function X. ^The parameter N is the number of
  2558. ** [virtual machine instructions] that are evaluated between successive
  2559. ** invocations of the callback X.
  2560. **
  2561. ** ^Only a single progress handler may be defined at one time per
  2562. ** [database connection]; setting a new progress handler cancels the
  2563. ** old one. ^Setting parameter X to NULL disables the progress handler.
  2564. ** ^The progress handler is also disabled by setting N to a value less
  2565. ** than 1.
  2566. **
  2567. ** ^If the progress callback returns non-zero, the operation is
  2568. ** interrupted. This feature can be used to implement a
  2569. ** "Cancel" button on a GUI progress dialog box.
  2570. **
  2571. ** The progress handler callback must not do anything that will modify
  2572. ** the database connection that invoked the progress handler.
  2573. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  2574. ** database connections for the meaning of "modify" in this paragraph.
  2575. **
  2576. */
  2577. //SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  2578. /*
  2579. ** CAPI3REF: Opening A New Database Connection
  2580. **
  2581. ** ^These routines open an SQLite database file whose name is given by the
  2582. ** filename argument. ^The filename argument is interpreted as UTF-8 for
  2583. ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
  2584. ** order for sqlite3_open16(). ^(A [database connection] handle is usually
  2585. ** returned in *ppDb, even if an error occurs. The only exception is that
  2586. ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
  2587. ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
  2588. ** object.)^ ^(If the database is opened (and/or created) successfully, then
  2589. ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The
  2590. ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
  2591. ** an English language description of the error following a failure of any
  2592. ** of the sqlite3_open() routines.
  2593. **
  2594. ** ^The default encoding for the database will be UTF-8 if
  2595. ** sqlite3_open() or sqlite3_open_v2() is called and
  2596. ** UTF-16 in the native byte order if sqlite3_open16() is used.
  2597. **
  2598. ** Whether or not an error occurs when it is opened, resources
  2599. ** associated with the [database connection] handle should be released by
  2600. ** passing it to [sqlite3_close()] when it is no longer required.
  2601. **
  2602. ** The sqlite3_open_v2() interface works like sqlite3_open()
  2603. ** except that it accepts two additional parameters for additional control
  2604. ** over the new database connection. ^(The flags parameter to
  2605. ** sqlite3_open_v2() can take one of
  2606. ** the following three values, optionally combined with the
  2607. ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
  2608. ** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
  2609. **
  2610. ** <dl>
  2611. ** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
  2612. ** <dd>The database is opened in read-only mode. If the database does not
  2613. ** already exist, an error is returned.</dd>)^
  2614. **
  2615. ** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
  2616. ** <dd>The database is opened for reading and writing if possible, or reading
  2617. ** only if the file is write protected by the operating system. In either
  2618. ** case the database must already exist, otherwise an error is returned.</dd>)^
  2619. **
  2620. ** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
  2621. ** <dd>The database is opened for reading and writing, and is created if
  2622. ** it does not already exist. This is the behavior that is always used for
  2623. ** sqlite3_open() and sqlite3_open16().</dd>)^
  2624. ** </dl>
  2625. **
  2626. ** If the 3rd parameter to sqlite3_open_v2() is not one of the
  2627. ** combinations shown above or one of the combinations shown above combined
  2628. ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
  2629. ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_PRIVATECACHE] flags,
  2630. ** then the behavior is undefined.
  2631. **
  2632. ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
  2633. ** opens in the multi-thread [threading mode] as long as the single-thread
  2634. ** mode has not been set at compile-time or start-time. ^If the
  2635. ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
  2636. ** in the serialized [threading mode] unless single-thread was
  2637. ** previously selected at compile-time or start-time.
  2638. ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
  2639. ** eligible to use [shared cache mode], regardless of whether or not shared
  2640. ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The
  2641. ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
  2642. ** participate in [shared cache mode] even if it is enabled.
  2643. **
  2644. ** ^If the filename is ":memory:", then a private, temporary in-memory database
  2645. ** is created for the connection. ^This in-memory database will vanish when
  2646. ** the database connection is closed. Future versions of SQLite might
  2647. ** make use of additional special filenames that begin with the ":" character.
  2648. ** It is recommended that when a database filename actually does begin with
  2649. ** a ":" character you should prefix the filename with a pathname such as
  2650. ** "./" to avoid ambiguity.
  2651. **
  2652. ** ^If the filename is an empty string, then a private, temporary
  2653. ** on-disk database will be created. ^This private database will be
  2654. ** automatically deleted as soon as the database connection is closed.
  2655. **
  2656. ** ^The fourth parameter to sqlite3_open_v2() is the name of the
  2657. ** [sqlite3_vfs] object that defines the operating system interface that
  2658. ** the new database connection should use. ^If the fourth parameter is
  2659. ** a NULL pointer then the default [sqlite3_vfs] object is used.
  2660. **
  2661. ** <b>Note to Windows users:</b> The encoding used for the filename argument
  2662. ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
  2663. ** codepage is currently defined. Filenames containing international
  2664. ** characters must be converted to UTF-8 prior to passing them into
  2665. ** sqlite3_open() or sqlite3_open_v2().
  2666. */
  2667. //SQLITE_API int sqlite3_open(
  2668. // const char *filename, /* Database filename (UTF-8) */
  2669. // sqlite3 **ppDb /* OUT: SQLite db handle */
  2670. //);
  2671. //SQLITE_API int sqlite3_open16(
  2672. // const void *filename, /* Database filename (UTF-16) */
  2673. // sqlite3 **ppDb /* OUT: SQLite db handle */
  2674. //);
  2675. //SQLITE_API int sqlite3_open_v2(
  2676. // const char *filename, /* Database filename (UTF-8) */
  2677. // sqlite3 **ppDb, /* OUT: SQLite db handle */
  2678. // int flags, /* Flags */
  2679. // const char *zVfs /* Name of VFS module to use */
  2680. //);
  2681. /*
  2682. ** CAPI3REF: Error Codes And Messages
  2683. **
  2684. ** ^The sqlite3_errcode() interface returns the numeric [result code] or
  2685. ** [extended result code] for the most recent failed sqlite3_* API call
  2686. ** associated with a [database connection]. If a prior API call failed
  2687. ** but the most recent API call succeeded, the return value from
  2688. ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
  2689. ** interface is the same except that it always returns the
  2690. ** [extended result code] even when extended result codes are
  2691. ** disabled.
  2692. **
  2693. ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
  2694. ** text that describes the error, as either UTF-8 or UTF-16 respectively.
  2695. ** ^(Memory to hold the error message string is managed internally.
  2696. ** The application does not need to worry about freeing the result.
  2697. ** However, the error string might be overwritten or deallocated by
  2698. ** subsequent calls to other SQLite interface functions.)^
  2699. **
  2700. ** When the serialized [threading mode] is in use, it might be the
  2701. ** case that a second error occurs on a separate thread in between
  2702. ** the time of the first error and the call to these interfaces.
  2703. ** When that happens, the second error will be reported since these
  2704. ** interfaces always report the most recent result. To avoid
  2705. ** this, each thread can obtain exclusive use of the [database connection] D
  2706. ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning
  2707. ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after
  2708. ** all calls to the interfaces listed here are completed.
  2709. **
  2710. ** If an interface fails with SQLITE_MISUSE, that means the interface
  2711. ** was invoked incorrectly by the application. In that case, the
  2712. ** error code and message may or may not be set.
  2713. */
  2714. //SQLITE_API int sqlite3_errcode(sqlite3 *db);
  2715. //SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
  2716. //SQLITE_API const char *sqlite3_errmsg(sqlite3*);
  2717. //SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
  2718. /*
  2719. ** CAPI3REF: SQL Statement Object
  2720. ** KEYWORDS: {prepared statement} {prepared statements}
  2721. **
  2722. ** An instance of this object represents a single SQL statement.
  2723. ** This object is variously known as a "prepared statement" or a
  2724. ** "compiled SQL statement" or simply as a "statement".
  2725. **
  2726. ** The life of a statement object goes something like this:
  2727. **
  2728. ** <ol>
  2729. ** <li> Create the object using [sqlite3_prepare_v2()] or a related
  2730. ** function.
  2731. ** <li> Bind values to [host parameters] using the sqlite3_bind_*()
  2732. ** interfaces.
  2733. ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
  2734. ** <li> Reset the statement using [sqlite3_reset()] then go back
  2735. ** to step 2. Do this zero or more times.
  2736. ** <li> Destroy the object using [sqlite3_finalize()].
  2737. ** </ol>
  2738. **
  2739. ** Refer to documentation on individual methods above for additional
  2740. ** information.
  2741. */
  2742. //typedef struct sqlite3_stmt sqlite3_stmt;
  2743. /*
  2744. ** CAPI3REF: Run-time Limits
  2745. **
  2746. ** ^(This interface allows the size of various constructs to be limited
  2747. ** on a connection by connection basis. The first parameter is the
  2748. ** [database connection] whose limit is to be set or queried. The
  2749. ** second parameter is one of the [limit categories] that define a
  2750. ** class of constructs to be size limited. The third parameter is the
  2751. ** new limit for that construct.)^
  2752. **
  2753. ** ^If the new limit is a negative number, the limit is unchanged.
  2754. ** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a
  2755. ** [limits | hard upper bound]
  2756. ** set at compile-time by a C preprocessor macro called
  2757. ** [limits | SQLITE_MAX_<i>NAME</i>].
  2758. ** (The "_LIMIT_" in the name is changed to "_MAX_".))^
  2759. ** ^Attempts to increase a limit above its hard upper bound are
  2760. ** silently truncated to the hard upper bound.
  2761. **
  2762. ** ^Regardless of whether or not the limit was changed, the
  2763. ** [sqlite3_limit()] interface returns the prior value of the limit.
  2764. ** ^Hence, to find the current value of a limit without changing it,
  2765. ** simply invoke this interface with the third parameter set to -1.
  2766. **
  2767. ** Run-time limits are intended for use in applications that manage
  2768. ** both their own internal database and also databases that are controlled
  2769. ** by untrusted external sources. An example application might be a
  2770. ** web browser that has its own databases for storing history and
  2771. ** separate databases controlled by JavaScript applications downloaded
  2772. ** off the Internet. The internal databases can be given the
  2773. ** large, default limits. Databases managed by external sources can
  2774. ** be given much smaller limits designed to prevent a denial of service
  2775. ** attack. Developers might also want to use the [sqlite3_set_authorizer()]
  2776. ** interface to further control untrusted SQL. The size of the database
  2777. ** created by an untrusted script can be contained using the
  2778. ** [max_page_count] [PRAGMA].
  2779. **
  2780. ** New run-time limit categories may be added in future releases.
  2781. */
  2782. //SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
  2783. /*
  2784. ** CAPI3REF: Run-Time Limit Categories
  2785. ** KEYWORDS: {limit category} {*limit categories}
  2786. **
  2787. ** These constants define various performance limits
  2788. ** that can be lowered at run-time using [sqlite3_limit()].
  2789. ** The synopsis of the meanings of the various limits is shown below.
  2790. ** Additional information is available at [limits | Limits in SQLite].
  2791. **
  2792. ** <dl>
  2793. ** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
  2794. ** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
  2795. **
  2796. ** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
  2797. ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
  2798. **
  2799. ** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
  2800. ** <dd>The maximum number of columns in a table definition or in the
  2801. ** result set of a [SELECT] or the maximum number of columns in an index
  2802. ** or in an ORDER BY or GROUP BY clause.</dd>)^
  2803. **
  2804. ** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
  2805. ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
  2806. **
  2807. ** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
  2808. ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
  2809. **
  2810. ** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
  2811. ** <dd>The maximum number of instructions in a virtual machine program
  2812. ** used to implement an SQL statement. This limit is not currently
  2813. ** enforced, though that might be added in some future release of
  2814. ** SQLite.</dd>)^
  2815. **
  2816. ** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
  2817. ** <dd>The maximum number of arguments on a function.</dd>)^
  2818. **
  2819. ** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
  2820. ** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
  2821. **
  2822. ** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
  2823. ** <dd>The maximum length of the pattern argument to the [LIKE] or
  2824. ** [GLOB] operators.</dd>)^
  2825. **
  2826. ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
  2827. ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
  2828. **
  2829. ** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
  2830. ** <dd>The maximum depth of recursion for triggers.</dd>)^
  2831. ** </dl>
  2832. */
  2833. //#define SQLITE_LIMIT_LENGTH 0
  2834. //#define SQLITE_LIMIT_SQL_LENGTH 1
  2835. //#define SQLITE_LIMIT_COLUMN 2
  2836. //#define SQLITE_LIMIT_EXPR_DEPTH 3
  2837. //#define SQLITE_LIMIT_COMPOUND_SELECT 4
  2838. //#define SQLITE_LIMIT_VDBE_OP 5
  2839. //#define SQLITE_LIMIT_FUNCTION_ARG 6
  2840. //#define SQLITE_LIMIT_ATTACHED 7
  2841. //#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
  2842. //#define SQLITE_LIMIT_VARIABLE_NUMBER 9
  2843. //#define SQLITE_LIMIT_TRIGGER_DEPTH 10
  2844. const int SQLITE_LIMIT_LENGTH = 0;
  2845. const int SQLITE_LIMIT_SQL_LENGTH = 1;
  2846. const int SQLITE_LIMIT_COLUMN = 2;
  2847. const int SQLITE_LIMIT_EXPR_DEPTH = 3;
  2848. const int SQLITE_LIMIT_COMPOUND_SELECT = 4;
  2849. const int SQLITE_LIMIT_VDBE_OP = 5;
  2850. const int SQLITE_LIMIT_FUNCTION_ARG = 6;
  2851. const int SQLITE_LIMIT_ATTACHED = 7;
  2852. const int SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8;
  2853. const int SQLITE_LIMIT_VARIABLE_NUMBER = 9;
  2854. const int SQLITE_LIMIT_TRIGGER_DEPTH = 10;
  2855. /*
  2856. ** CAPI3REF: Compiling An SQL Statement
  2857. ** KEYWORDS: {SQL statement compiler}
  2858. **
  2859. ** To execute an SQL query, it must first be compiled into a byte-code
  2860. ** program using one of these routines.
  2861. **
  2862. ** The first argument, "db", is a [database connection] obtained from a
  2863. ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
  2864. ** [sqlite3_open16()]. The database connection must not have been closed.
  2865. **
  2866. ** The second argument, "zSql", is the statement to be compiled, encoded
  2867. ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
  2868. ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
  2869. ** use UTF-16.
  2870. **
  2871. ** ^If the nByte argument is less than zero, then zSql is read up to the
  2872. ** first zero terminator. ^If nByte is non-negative, then it is the maximum
  2873. ** number of bytes read from zSql. ^When nByte is non-negative, the
  2874. ** zSql string ends at either the first '\000' or '\u0000' character or
  2875. ** the nByte-th byte, whichever comes first. If the caller knows
  2876. ** that the supplied string is nul-terminated, then there is a small
  2877. ** performance advantage to be gained by passing an nByte parameter that
  2878. ** is equal to the number of bytes in the input string <i>including</i>
  2879. ** the nul-terminator bytes.
  2880. **
  2881. ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
  2882. ** past the end of the first SQL statement in zSql. These routines only
  2883. ** compile the first statement in zSql, so *pzTail is left pointing to
  2884. ** what remains uncompiled.
  2885. **
  2886. ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
  2887. ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set
  2888. ** to NULL. ^If the input text contains no SQL (if the input is an empty
  2889. ** string or a comment) then *ppStmt is set to NULL.
  2890. ** The calling procedure is responsible for deleting the compiled
  2891. ** SQL statement using [sqlite3_finalize()] after it has finished with it.
  2892. ** ppStmt may not be NULL.
  2893. **
  2894. ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
  2895. ** otherwise an [error code] is returned.
  2896. **
  2897. ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
  2898. ** recommended for all new programs. The two older interfaces are retained
  2899. ** for backwards compatibility, but their use is discouraged.
  2900. ** ^In the "v2" interfaces, the prepared statement
  2901. ** that is returned (the [sqlite3_stmt] object) contains a copy of the
  2902. ** original SQL text. This causes the [sqlite3_step()] interface to
  2903. ** behave differently in three ways:
  2904. **
  2905. ** <ol>
  2906. ** <li>
  2907. ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
  2908. ** always used to do, [sqlite3_step()] will automatically recompile the SQL
  2909. ** statement and try to run it again.
  2910. ** </li>
  2911. **
  2912. ** <li>
  2913. ** ^When an error occurs, [sqlite3_step()] will return one of the detailed
  2914. ** [error codes] or [extended error codes]. ^The legacy behavior was that
  2915. ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
  2916. ** and the application would have to make a second call to [sqlite3_reset()]
  2917. ** in order to find the underlying cause of the problem. With the "v2" prepare
  2918. ** interfaces, the underlying reason for the error is returned immediately.
  2919. ** </li>
  2920. **
  2921. ** <li>
  2922. ** ^If the specific value bound to [parameter | host parameter] in the
  2923. ** WHERE clause might influence the choice of query plan for a statement,
  2924. ** then the statement will be automatically recompiled, as if there had been
  2925. ** a schema change, on the first [sqlite3_step()] call following any change
  2926. ** to the [sqlite3_bind_text | bindings] of that [parameter].
  2927. ** ^The specific value of WHERE-clause [parameter] might influence the
  2928. ** choice of query plan if the parameter is the left-hand side of a [LIKE]
  2929. ** or [GLOB] operator or if the parameter is compared to an indexed column
  2930. ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled.
  2931. ** the
  2932. ** </li>
  2933. ** </ol>
  2934. */
  2935. //SQLITE_API int sqlite3_prepare(
  2936. // sqlite3 *db, /* Database handle */
  2937. // const char *zSql, /* SQL statement, UTF-8 encoded */
  2938. // int nByte, /* Maximum length of zSql in bytes. */
  2939. // sqlite3_stmt **ppStmt, /* OUT: Statement handle */
  2940. // const char **pzTail /* OUT: Pointer to unused portion of zSql */
  2941. //);
  2942. //SQLITE_API int sqlite3_prepare_v2(
  2943. // sqlite3 *db, /* Database handle */
  2944. // const char *zSql, /* SQL statement, UTF-8 encoded */
  2945. // int nByte, /* Maximum length of zSql in bytes. */
  2946. // sqlite3_stmt **ppStmt, /* OUT: Statement handle */
  2947. // const char **pzTail /* OUT: Pointer to unused portion of zSql */
  2948. //);
  2949. //SQLITE_API int sqlite3_prepare16(
  2950. // sqlite3 *db, /* Database handle */
  2951. // const void *zSql, /* SQL statement, UTF-16 encoded */
  2952. // int nByte, /* Maximum length of zSql in bytes. */
  2953. // sqlite3_stmt **ppStmt, /* OUT: Statement handle */
  2954. // const void **pzTail /* OUT: Pointer to unused portion of zSql */
  2955. //);
  2956. //SQLITE_API int sqlite3_prepare16_v2(
  2957. // sqlite3 *db, /* Database handle */
  2958. // const void *zSql, /* SQL statement, UTF-16 encoded */
  2959. // int nByte, /* Maximum length of zSql in bytes. */
  2960. // sqlite3_stmt **ppStmt, /* OUT: Statement handle */
  2961. // const void **pzTail /* OUT: Pointer to unused portion of zSql */
  2962. //);
  2963. /*
  2964. ** CAPI3REF: Retrieving Statement SQL
  2965. **
  2966. ** ^This interface can be used to retrieve a saved copy of the original
  2967. ** SQL text used to create a [prepared statement] if that statement was
  2968. ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
  2969. */
  2970. //SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
  2971. /*
  2972. ** CAPI3REF: Determine If An SQL Statement Writes The Database
  2973. **
  2974. ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
  2975. ** and only if the [prepared statement] X makes no direct changes to
  2976. ** the content of the database file.
  2977. **
  2978. ** Note that [application-defined SQL functions] or
  2979. ** [virtual tables] might change the database indirectly as a side effect.
  2980. ** ^(For example, if an application defines a function "eval()" that
  2981. ** calls [sqlite3_exec()], then the following SQL statement would
  2982. ** change the database file through side-effects:
  2983. **
  2984. ** <blockquote><pre>
  2985. ** SELECT eval('DELETE FROM t1') FROM t2;
  2986. ** </pre></blockquote>
  2987. **
  2988. ** But because the [SELECT] statement does not change the database file
  2989. ** directly, sqlite3_stmt_readonly() would still return true.)^
  2990. **
  2991. ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],
  2992. ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,
  2993. ** since the statements themselves do not actually modify the database but
  2994. ** rather they control the timing of when other statements modify the
  2995. ** database. ^The [ATTACH] and [DETACH] statements also cause
  2996. ** sqlite3_stmt_readonly() to return true since, while those statements
  2997. ** change the configuration of a database connection, they do not make
  2998. ** changes to the content of the database files on disk.
  2999. */
  3000. //SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  3001. /*
  3002. ** CAPI3REF: Dynamically Typed Value Object
  3003. ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
  3004. **
  3005. ** SQLite uses the sqlite3_value object to represent all values
  3006. ** that can be stored in a database table. SQLite uses dynamic typing
  3007. ** for the values it stores. ^Values stored in sqlite3_value objects
  3008. ** can be integers, floating point values, strings, BLOBs, or NULL.
  3009. **
  3010. ** An sqlite3_value object may be either "protected" or "unprotected".
  3011. ** Some interfaces require a protected sqlite3_value. Other interfaces
  3012. ** will accept either a protected or an unprotected sqlite3_value.
  3013. ** Every interface that accepts sqlite3_value arguments specifies
  3014. ** whether or not it requires a protected sqlite3_value.
  3015. **
  3016. ** The terms "protected" and "unprotected" refer to whether or not
  3017. ** a mutex is held. A internal mutex is held for a protected
  3018. ** sqlite3_value object but no mutex is held for an unprotected
  3019. ** sqlite3_value object. If SQLite is compiled to be single-threaded
  3020. ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
  3021. ** or if SQLite is run in one of reduced mutex modes
  3022. ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]
  3023. ** then there is no distinction between protected and unprotected
  3024. ** sqlite3_value objects and they can be used interchangeably. However,
  3025. ** for maximum code portability it is recommended that applications
  3026. ** still make the distinction between protected and unprotected
  3027. ** sqlite3_value objects even when not strictly required.
  3028. **
  3029. ** ^The sqlite3_value objects that are passed as parameters into the
  3030. ** implementation of [application-defined SQL functions] are protected.
  3031. ** ^The sqlite3_value object returned by
  3032. ** [sqlite3_column_value()] is unprotected.
  3033. ** Unprotected sqlite3_value objects may only be used with
  3034. ** [sqlite3_result_value()] and [sqlite3_bind_value()].
  3035. ** The [sqlite3_value_blob | sqlite3_value_type()] family of
  3036. ** interfaces require protected sqlite3_value objects.
  3037. */
  3038. //typedef struct Mem sqlite3_value;
  3039. /*
  3040. ** CAPI3REF: SQL Function Context Object
  3041. **
  3042. ** The context in which an SQL function executes is stored in an
  3043. ** sqlite3_context object. ^A pointer to an sqlite3_context object
  3044. ** is always first parameter to [application-defined SQL functions].
  3045. ** The application-defined SQL function implementation will pass this
  3046. ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
  3047. ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
  3048. ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
  3049. ** and/or [sqlite3_set_auxdata()].
  3050. */
  3051. //typedef struct sqlite3_context sqlite3_context;
  3052. /*
  3053. ** CAPI3REF: Binding Values To Prepared Statements
  3054. ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
  3055. ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
  3056. **
  3057. ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
  3058. ** literals may be replaced by a [parameter] that matches one of following
  3059. ** templates:
  3060. **
  3061. ** <ul>
  3062. ** <li> ?
  3063. ** <li> ?NNN
  3064. ** <li> :VVV
  3065. ** <li> @VVV
  3066. ** <li> $VVV
  3067. ** </ul>
  3068. **
  3069. ** In the templates above, NNN represents an integer literal,
  3070. ** and VVV represents an alphanumeric identifier.)^ ^The values of these
  3071. ** parameters (also called "host parameter names" or "SQL parameters")
  3072. ** can be set using the sqlite3_bind_*() routines defined here.
  3073. **
  3074. ** ^The first argument to the sqlite3_bind_*() routines is always
  3075. ** a pointer to the [sqlite3_stmt] object returned from
  3076. ** [sqlite3_prepare_v2()] or its variants.
  3077. **
  3078. ** ^The second argument is the index of the SQL parameter to be set.
  3079. ** ^The leftmost SQL parameter has an index of 1. ^When the same named
  3080. ** SQL parameter is used more than once, second and subsequent
  3081. ** occurrences have the same index as the first occurrence.
  3082. ** ^The index for named parameters can be looked up using the
  3083. ** [sqlite3_bind_parameter_index()] API if desired. ^The index
  3084. ** for "?NNN" parameters is the value of NNN.
  3085. ** ^The NNN value must be between 1 and the [sqlite3_limit()]
  3086. ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
  3087. **
  3088. ** ^The third argument is the value to bind to the parameter.
  3089. **
  3090. ** ^(In those routines that have a fourth argument, its value is the
  3091. ** number of bytes in the parameter. To be clear: the value is the
  3092. ** number of <u>bytes</u> in the value, not the number of characters.)^
  3093. ** ^If the fourth parameter is negative, the length of the string is
  3094. ** the number of bytes up to the first zero terminator.
  3095. **
  3096. ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
  3097. ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
  3098. ** string after SQLite has finished with it. ^The destructor is called
  3099. ** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
  3100. ** sqlite3_bind_text(), or sqlite3_bind_text16() fails.
  3101. ** ^If the fifth argument is
  3102. ** the special value [SQLITE_STATIC], then SQLite assumes that the
  3103. ** information is in static, unmanaged space and does not need to be freed.
  3104. ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
  3105. ** SQLite makes its own private copy of the data immediately, before
  3106. ** the sqlite3_bind_*() routine returns.
  3107. **
  3108. ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
  3109. ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory
  3110. ** (just an integer to hold its size) while it is being processed.
  3111. ** Zeroblobs are intended to serve as placeholders for BLOBs whose
  3112. ** content is later written using
  3113. ** [sqlite3_blob_open | incremental BLOB I/O] routines.
  3114. ** ^A negative value for the zeroblob results in a zero-length BLOB.
  3115. **
  3116. ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
  3117. ** for the [prepared statement] or with a prepared statement for which
  3118. ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
  3119. ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
  3120. ** routine is passed a [prepared statement] that has been finalized, the
  3121. ** result is undefined and probably harmful.
  3122. **
  3123. ** ^Bindings are not cleared by the [sqlite3_reset()] routine.
  3124. ** ^Unbound parameters are interpreted as NULL.
  3125. **
  3126. ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
  3127. ** [error code] if anything goes wrong.
  3128. ** ^[SQLITE_RANGE] is returned if the parameter
  3129. ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
  3130. **
  3131. ** See also: [sqlite3_bind_parameter_count()],
  3132. ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
  3133. */
  3134. //SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  3135. //SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
  3136. //SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
  3137. //SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  3138. //SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
  3139. //SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
  3140. //SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  3141. //SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  3142. //SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  3143. /*
  3144. ** CAPI3REF: Number Of SQL Parameters
  3145. **
  3146. ** ^This routine can be used to find the number of [SQL parameters]
  3147. ** in a [prepared statement]. SQL parameters are tokens of the
  3148. ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
  3149. ** placeholders for values that are [sqlite3_bind_blob | bound]
  3150. ** to the parameters at a later time.
  3151. **
  3152. ** ^(This routine actually returns the index of the largest (rightmost)
  3153. ** parameter. For all forms except ?NNN, this will correspond to the
  3154. ** number of unique parameters. If parameters of the ?NNN form are used,
  3155. ** there may be gaps in the list.)^
  3156. **
  3157. ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  3158. ** [sqlite3_bind_parameter_name()], and
  3159. ** [sqlite3_bind_parameter_index()].
  3160. */
  3161. //SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
  3162. /*
  3163. ** CAPI3REF: Name Of A Host Parameter
  3164. **
  3165. ** ^The sqlite3_bind_parameter_name(P,N) interface returns
  3166. ** the name of the N-th [SQL parameter] in the [prepared statement] P.
  3167. ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
  3168. ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
  3169. ** respectively.
  3170. ** In other words, the initial ":" or "$" or "@" or "?"
  3171. ** is included as part of the name.)^
  3172. ** ^Parameters of the form "?" without a following integer have no name
  3173. ** and are referred to as "nameless" or "anonymous parameters".
  3174. **
  3175. ** ^The first host parameter has an index of 1, not 0.
  3176. **
  3177. ** ^If the value N is out of range or if the N-th parameter is
  3178. ** nameless, then NULL is returned. ^The returned string is
  3179. ** always in UTF-8 encoding even if the named parameter was
  3180. ** originally specified as UTF-16 in [sqlite3_prepare16()] or
  3181. ** [sqlite3_prepare16_v2()].
  3182. **
  3183. ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  3184. ** [sqlite3_bind_parameter_count()], and
  3185. ** [sqlite3_bind_parameter_index()].
  3186. */
  3187. //SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  3188. /*
  3189. ** CAPI3REF: Index Of A Parameter With A Given Name
  3190. **
  3191. ** ^Return the index of an SQL parameter given its name. ^The
  3192. ** index value returned is suitable for use as the second
  3193. ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
  3194. ** is returned if no matching parameter is found. ^The parameter
  3195. ** name must be given in UTF-8 even if the original statement
  3196. ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
  3197. **
  3198. ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  3199. ** [sqlite3_bind_parameter_count()], and
  3200. ** [sqlite3_bind_parameter_index()].
  3201. */
  3202. //SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  3203. /*
  3204. ** CAPI3REF: Reset All Bindings On A Prepared Statement
  3205. **
  3206. ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
  3207. ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
  3208. ** ^Use this routine to reset all host parameters to NULL.
  3209. */
  3210. //SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
  3211. /*
  3212. ** CAPI3REF: Number Of Columns In A Result Set
  3213. **
  3214. ** ^Return the number of columns in the result set returned by the
  3215. ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
  3216. ** statement that does not return data (for example an [UPDATE]).
  3217. **
  3218. ** See also: [sqlite3_data_count()]
  3219. */
  3220. //SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
  3221. /*
  3222. ** CAPI3REF: Column Names In A Result Set
  3223. **
  3224. ** ^These routines return the name assigned to a particular column
  3225. ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
  3226. ** interface returns a pointer to a zero-terminated UTF-8 string
  3227. ** and sqlite3_column_name16() returns a pointer to a zero-terminated
  3228. ** UTF-16 string. ^The first parameter is the [prepared statement]
  3229. ** that implements the [SELECT] statement. ^The second parameter is the
  3230. ** column number. ^The leftmost column is number 0.
  3231. **
  3232. ** ^The returned string pointer is valid until either the [prepared statement]
  3233. ** is destroyed by [sqlite3_finalize()] or until the next call to
  3234. ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
  3235. **
  3236. ** ^If sqlite3_malloc() fails during the processing of either routine
  3237. ** (for example during a conversion from UTF-8 to UTF-16) then a
  3238. ** NULL pointer is returned.
  3239. **
  3240. ** ^The name of a result column is the value of the "AS" clause for
  3241. ** that column, if there is an AS clause. If there is no AS clause
  3242. ** then the name of the column is unspecified and may change from
  3243. ** one release of SQLite to the next.
  3244. */
  3245. //SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
  3246. //SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
  3247. /*
  3248. ** CAPI3REF: Source Of Data In A Query Result
  3249. **
  3250. ** ^These routines provide a means to determine the database, table, and
  3251. ** table column that is the origin of a particular result column in
  3252. ** [SELECT] statement.
  3253. ** ^The name of the database or table or column can be returned as
  3254. ** either a UTF-8 or UTF-16 string. ^The _database_ routines return
  3255. ** the database name, the _table_ routines return the table name, and
  3256. ** the origin_ routines return the column name.
  3257. ** ^The returned string is valid until the [prepared statement] is destroyed
  3258. ** using [sqlite3_finalize()] or until the same information is requested
  3259. ** again in a different encoding.
  3260. **
  3261. ** ^The names returned are the original un-aliased names of the
  3262. ** database, table, and column.
  3263. **
  3264. ** ^The first argument to these interfaces is a [prepared statement].
  3265. ** ^These functions return information about the Nth result column returned by
  3266. ** the statement, where N is the second function argument.
  3267. ** ^The left-most column is column 0 for these routines.
  3268. **
  3269. ** ^If the Nth column returned by the statement is an expression or
  3270. ** subquery and is not a column value, then all of these functions return
  3271. ** NULL. ^These routine might also return NULL if a memory allocation error
  3272. ** occurs. ^Otherwise, they return the name of the attached database, table,
  3273. ** or column that query result column was extracted from.
  3274. **
  3275. ** ^As with all other SQLite APIs, those whose names end with "16" return
  3276. ** UTF-16 encoded strings and the other functions return UTF-8.
  3277. **
  3278. ** ^These APIs are only available if the library was compiled with the
  3279. ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
  3280. **
  3281. ** If two or more threads call one or more of these routines against the same
  3282. ** prepared statement and column at the same time then the results are
  3283. ** undefined.
  3284. **
  3285. ** If two or more threads call one or more
  3286. ** [sqlite3_column_database_name | column metadata interfaces]
  3287. ** for the same [prepared statement] and result column
  3288. ** at the same time then the results are undefined.
  3289. */
  3290. //SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
  3291. //SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
  3292. //SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
  3293. //SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
  3294. //SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
  3295. //SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
  3296. /*
  3297. ** CAPI3REF: Declared Datatype Of A Query Result
  3298. **
  3299. ** ^(The first parameter is a [prepared statement].
  3300. ** If this statement is a [SELECT] statement and the Nth column of the
  3301. ** returned result set of that [SELECT] is a table column (not an
  3302. ** expression or subquery) then the declared type of the table
  3303. ** column is returned.)^ ^If the Nth column of the result set is an
  3304. ** expression or subquery, then a NULL pointer is returned.
  3305. ** ^The returned string is always UTF-8 encoded.
  3306. **
  3307. ** ^(For example, given the database schema:
  3308. **
  3309. ** CREATE TABLE t1(c1 VARIANT);
  3310. **
  3311. ** and the following statement to be compiled:
  3312. **
  3313. ** SELECT c1 + 1, c1 FROM t1;
  3314. **
  3315. ** this routine would return the string "VARIANT" for the second result
  3316. ** column (i==1), and a NULL pointer for the first result column (i==0).)^
  3317. **
  3318. ** ^SQLite uses dynamic run-time typing. ^So just because a column
  3319. ** is declared to contain a particular type does not mean that the
  3320. ** data stored in that column is of the declared type. SQLite is
  3321. ** strongly typed, but the typing is dynamic not static. ^Type
  3322. ** is associated with individual values, not with the containers
  3323. ** used to hold those values.
  3324. */
  3325. //SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
  3326. //SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
  3327. /*
  3328. ** CAPI3REF: Evaluate An SQL Statement
  3329. **
  3330. ** After a [prepared statement] has been prepared using either
  3331. ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
  3332. ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
  3333. ** must be called one or more times to evaluate the statement.
  3334. **
  3335. ** The details of the behavior of the sqlite3_step() interface depend
  3336. ** on whether the statement was prepared using the newer "v2" interface
  3337. ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
  3338. ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
  3339. ** new "v2" interface is recommended for new applications but the legacy
  3340. ** interface will continue to be supported.
  3341. **
  3342. ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
  3343. ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
  3344. ** ^With the "v2" interface, any of the other [result codes] or
  3345. ** [extended result codes] might be returned as well.
  3346. **
  3347. ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
  3348. ** database locks it needs to do its job. ^If the statement is a [COMMIT]
  3349. ** or occurs outside of an explicit transaction, then you can retry the
  3350. ** statement. If the statement is not a [COMMIT] and occurs within a
  3351. ** explicit transaction then you should rollback the transaction before
  3352. ** continuing.
  3353. **
  3354. ** ^[SQLITE_DONE] means that the statement has finished executing
  3355. ** successfully. sqlite3_step() should not be called again on this virtual
  3356. ** machine without first calling [sqlite3_reset()] to reset the virtual
  3357. ** machine back to its initial state.
  3358. **
  3359. ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
  3360. ** is returned each time a new row of data is ready for processing by the
  3361. ** caller. The values may be accessed using the [column access functions].
  3362. ** sqlite3_step() is called again to retrieve the next row of data.
  3363. **
  3364. ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
  3365. ** violation) has occurred. sqlite3_step() should not be called again on
  3366. ** the VM. More information may be found by calling [sqlite3_errmsg()].
  3367. ** ^With the legacy interface, a more specific error code (for example,
  3368. ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
  3369. ** can be obtained by calling [sqlite3_reset()] on the
  3370. ** [prepared statement]. ^In the "v2" interface,
  3371. ** the more specific error code is returned directly by sqlite3_step().
  3372. **
  3373. ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
  3374. ** Perhaps it was called on a [prepared statement] that has
  3375. ** already been [sqlite3_finalize | finalized] or on one that had
  3376. ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could
  3377. ** be the case that the same database connection is being used by two or
  3378. ** more threads at the same moment in time.
  3379. **
  3380. ** For all versions of SQLite up to and including 3.6.23.1, a call to
  3381. ** [sqlite3_reset()] was required after sqlite3_step() returned anything
  3382. ** other than [SQLITE_ROW] before any subsequent invocation of
  3383. ** sqlite3_step(). Failure to reset the prepared statement using
  3384. ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from
  3385. ** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began
  3386. ** calling [sqlite3_reset()] automatically in this circumstance rather
  3387. ** than returning [SQLITE_MISUSE]. This is not considered a compatibility
  3388. ** break because any application that ever receives an SQLITE_MISUSE error
  3389. ** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option
  3390. ** can be used to restore the legacy behavior.
  3391. **
  3392. ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
  3393. ** API always returns a generic error code, [SQLITE_ERROR], following any
  3394. ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
  3395. ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
  3396. ** specific [error codes] that better describes the error.
  3397. ** We admit that this is a goofy design. The problem has been fixed
  3398. ** with the "v2" interface. If you prepare all of your SQL statements
  3399. ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
  3400. ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
  3401. ** then the more specific [error codes] are returned directly
  3402. ** by sqlite3_step(). The use of the "v2" interface is recommended.
  3403. */
  3404. //SQLITE_API int sqlite3_step(sqlite3_stmt*);
  3405. /*
  3406. ** CAPI3REF: Number of columns in a result set
  3407. **
  3408. ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  3409. ** current row of the result set of [prepared statement] P.
  3410. ** ^If prepared statement P does not have results ready to return
  3411. ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
  3412. ** interfaces) then sqlite3_data_count(P) returns 0.
  3413. ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
  3414. **
  3415. ** See also: [sqlite3_column_count()]
  3416. */
  3417. //SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
  3418. /*
  3419. ** CAPI3REF: Fundamental Datatypes
  3420. ** KEYWORDS: SQLITE_TEXT
  3421. **
  3422. ** ^(Every value in SQLite has one of five fundamental datatypes:
  3423. **
  3424. ** <ul>
  3425. ** <li> 64-bit signed integer
  3426. ** <li> 64-bit IEEE floating point number
  3427. ** <li> string
  3428. ** <li> BLOB
  3429. ** <li> NULL
  3430. ** </ul>)^
  3431. **
  3432. ** These constants are codes for each of those types.
  3433. **
  3434. ** Note that the SQLITE_TEXT constant was also used in SQLite version 2
  3435. ** for a completely different meaning. Software that links against both
  3436. ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not
  3437. ** SQLITE_TEXT.
  3438. */
  3439. //#define SQLITE_INTEGER 1
  3440. //#define SQLITE_FLOAT 2
  3441. //#define SQLITE_BLOB 4
  3442. //#define SQLITE_NULL 5
  3443. //#ifdef SQLITE_TEXT
  3444. //# undef SQLITE_TEXT
  3445. //#else
  3446. //# define SQLITE_TEXT 3
  3447. //#endif
  3448. //#define SQLITE3_TEXT 3
  3449. public const u8 SQLITE_INTEGER = 1;
  3450. public const u8 SQLITE_FLOAT = 2;
  3451. public const u8 SQLITE_BLOB = 4;
  3452. public const u8 SQLITE_NULL = 5;
  3453. public const u8 SQLITE_TEXT = 3;
  3454. public const u8 SQLITE3_TEXT = 3;
  3455. /*
  3456. ** CAPI3REF: Result Values From A Query
  3457. ** KEYWORDS: {column access functions}
  3458. **
  3459. ** These routines form the "result set" interface.
  3460. **
  3461. ** ^These routines return information about a single column of the current
  3462. ** result row of a query. ^In every case the first argument is a pointer
  3463. ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
  3464. ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
  3465. ** and the second argument is the index of the column for which information
  3466. ** should be returned. ^The leftmost column of the result set has the index 0.
  3467. ** ^The number of columns in the result can be determined using
  3468. ** [sqlite3_column_count()].
  3469. **
  3470. ** If the SQL statement does not currently point to a valid row, or if the
  3471. ** column index is out of range, the result is undefined.
  3472. ** These routines may only be called when the most recent call to
  3473. ** [sqlite3_step()] has returned [SQLITE_ROW] and neither
  3474. ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.
  3475. ** If any of these routines are called after [sqlite3_reset()] or
  3476. ** [sqlite3_finalize()] or after [sqlite3_step()] has returned
  3477. ** something other than [SQLITE_ROW], the results are undefined.
  3478. ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
  3479. ** are called from a different thread while any of these routines
  3480. ** are pending, then the results are undefined.
  3481. **
  3482. ** ^The sqlite3_column_type() routine returns the
  3483. ** [SQLITE_INTEGER | datatype code] for the initial data type
  3484. ** of the result column. ^The returned value is one of [SQLITE_INTEGER],
  3485. ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
  3486. ** returned by sqlite3_column_type() is only meaningful if no type
  3487. ** conversions have occurred as described below. After a type conversion,
  3488. ** the value returned by sqlite3_column_type() is undefined. Future
  3489. ** versions of SQLite may change the behavior of sqlite3_column_type()
  3490. ** following a type conversion.
  3491. **
  3492. ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
  3493. ** routine returns the number of bytes in that BLOB or string.
  3494. ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
  3495. ** the string to UTF-8 and then returns the number of bytes.
  3496. ** ^If the result is a numeric value then sqlite3_column_bytes() uses
  3497. ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
  3498. ** the number of bytes in that string.
  3499. ** ^If the result is NULL, then sqlite3_column_bytes() returns zero.
  3500. **
  3501. ** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()
  3502. ** routine returns the number of bytes in that BLOB or string.
  3503. ** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts
  3504. ** the string to UTF-16 and then returns the number of bytes.
  3505. ** ^If the result is a numeric value then sqlite3_column_bytes16() uses
  3506. ** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns
  3507. ** the number of bytes in that string.
  3508. ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.
  3509. **
  3510. ** ^The values returned by [sqlite3_column_bytes()] and
  3511. ** [sqlite3_column_bytes16()] do not include the zero terminators at the end
  3512. ** of the string. ^For clarity: the values returned by
  3513. ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
  3514. ** bytes in the string, not the number of characters.
  3515. **
  3516. ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
  3517. ** even empty strings, are always zero terminated. ^The return
  3518. ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
  3519. **
  3520. ** ^The object returned by [sqlite3_column_value()] is an
  3521. ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
  3522. ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
  3523. ** If the [unprotected sqlite3_value] object returned by
  3524. ** [sqlite3_column_value()] is used in any other way, including calls
  3525. ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
  3526. ** or [sqlite3_value_bytes()], then the behavior is undefined.
  3527. **
  3528. ** These routines attempt to convert the value where appropriate. ^For
  3529. ** example, if the internal representation is FLOAT and a text result
  3530. ** is requested, [sqlite3_snprintf()] is used internally to perform the
  3531. ** conversion automatically. ^(The following table details the conversions
  3532. ** that are applied:
  3533. **
  3534. ** <blockquote>
  3535. ** <table border="1">
  3536. ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
  3537. **
  3538. ** <tr><td> NULL <td> INTEGER <td> Result is 0
  3539. ** <tr><td> NULL <td> FLOAT <td> Result is 0.0
  3540. ** <tr><td> NULL <td> TEXT <td> Result is NULL pointer
  3541. ** <tr><td> NULL <td> BLOB <td> Result is NULL pointer
  3542. ** <tr><td> INTEGER <td> FLOAT <td> Convert from integer to float
  3543. ** <tr><td> INTEGER <td> TEXT <td> ASCII rendering of the integer
  3544. ** <tr><td> INTEGER <td> BLOB <td> Same as INTEGER->TEXT
  3545. ** <tr><td> FLOAT <td> INTEGER <td> Convert from float to integer
  3546. ** <tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float
  3547. ** <tr><td> FLOAT <td> BLOB <td> Same as FLOAT->TEXT
  3548. ** <tr><td> TEXT <td> INTEGER <td> Use atoi()
  3549. ** <tr><td> TEXT <td> FLOAT <td> Use atof()
  3550. ** <tr><td> TEXT <td> BLOB <td> No change
  3551. ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
  3552. ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
  3553. ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
  3554. ** </table>
  3555. ** </blockquote>)^
  3556. **
  3557. ** The table above makes reference to standard C library functions atoi()
  3558. ** and atof(). SQLite does not really use these functions. It has its
  3559. ** own equivalent internal routines. The atoi() and atof() names are
  3560. ** used in the table for brevity and because they are familiar to most
  3561. ** C programmers.
  3562. **
  3563. ** Note that when type conversions occur, pointers returned by prior
  3564. ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
  3565. ** sqlite3_column_text16() may be invalidated.
  3566. ** Type conversions and pointer invalidations might occur
  3567. ** in the following cases:
  3568. **
  3569. ** <ul>
  3570. ** <li> The initial content is a BLOB and sqlite3_column_text() or
  3571. ** sqlite3_column_text16() is called. A zero-terminator might
  3572. ** need to be added to the string.</li>
  3573. ** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or
  3574. ** sqlite3_column_text16() is called. The content must be converted
  3575. ** to UTF-16.</li>
  3576. ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
  3577. ** sqlite3_column_text() is called. The content must be converted
  3578. ** to UTF-8.</li>
  3579. ** </ul>
  3580. **
  3581. ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
  3582. ** not invalidate a prior pointer, though of course the content of the buffer
  3583. ** that the prior pointer references will have been modified. Other kinds
  3584. ** of conversion are done in place when it is possible, but sometimes they
  3585. ** are not possible and in those cases prior pointers are invalidated.
  3586. **
  3587. ** The safest and easiest to remember policy is to invoke these routines
  3588. ** in one of the following ways:
  3589. **
  3590. ** <ul>
  3591. ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
  3592. ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
  3593. ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
  3594. ** </ul>
  3595. **
  3596. ** In other words, you should call sqlite3_column_text(),
  3597. ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
  3598. ** into the desired format, then invoke sqlite3_column_bytes() or
  3599. ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
  3600. ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
  3601. ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
  3602. ** with calls to sqlite3_column_bytes().
  3603. **
  3604. ** ^The pointers returned are valid until a type conversion occurs as
  3605. ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  3606. ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
  3607. ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
  3608. ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  3609. ** [sqlite3_free()].
  3610. **
  3611. ** ^(If a memory allocation error occurs during the evaluation of any
  3612. ** of these routines, a default value is returned. The default value
  3613. ** is either the integer 0, the floating point number 0.0, or a NULL
  3614. ** pointer. Subsequent calls to [sqlite3_errcode()] will return
  3615. ** [SQLITE_NOMEM].)^
  3616. */
  3617. //SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  3618. //SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  3619. //SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  3620. //SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  3621. //SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  3622. //SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  3623. //SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  3624. //SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
  3625. //SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
  3626. //SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
  3627. /*
  3628. ** CAPI3REF: Destroy A Prepared Statement Object
  3629. **
  3630. ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
  3631. ** ^If the most recent evaluation of the statement encountered no errors or
  3632. ** or if the statement is never been evaluated, then sqlite3_finalize() returns
  3633. ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
  3634. ** sqlite3_finalize(S) returns the appropriate [error code] or
  3635. ** [extended error code].
  3636. **
  3637. ** ^The sqlite3_finalize(S) routine can be called at any point during
  3638. ** the life cycle of [prepared statement] S:
  3639. ** before statement S is ever evaluated, after
  3640. ** one or more calls to [sqlite3_reset()], or after any call
  3641. ** to [sqlite3_step()] regardless of whether or not the statement has
  3642. ** completed execution.
  3643. **
  3644. ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.
  3645. **
  3646. ** The application must finalize every [prepared statement] in order to avoid
  3647. ** resource leaks. It is a grievous error for the application to try to use
  3648. ** a prepared statement after it has been finalized. Any use of a prepared
  3649. ** statement after it has been finalized can result in undefined and
  3650. ** undesirable behavior such as segfaults and heap corruption.
  3651. */
  3652. //SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
  3653. /*
  3654. ** CAPI3REF: Reset A Prepared Statement Object
  3655. **
  3656. ** The sqlite3_reset() function is called to reset a [prepared statement]
  3657. ** object back to its initial state, ready to be re-executed.
  3658. ** ^Any SQL statement variables that had values bound to them using
  3659. ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
  3660. ** Use [sqlite3_clear_bindings()] to reset the bindings.
  3661. **
  3662. ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
  3663. ** back to the beginning of its program.
  3664. **
  3665. ** ^If the most recent call to [sqlite3_step(S)] for the
  3666. ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
  3667. ** or if [sqlite3_step(S)] has never before been called on S,
  3668. ** then [sqlite3_reset(S)] returns [SQLITE_OK].
  3669. **
  3670. ** ^If the most recent call to [sqlite3_step(S)] for the
  3671. ** [prepared statement] S indicated an error, then
  3672. ** [sqlite3_reset(S)] returns an appropriate [error code].
  3673. **
  3674. ** ^The [sqlite3_reset(S)] interface does not change the values
  3675. ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
  3676. */
  3677. //SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
  3678. /*
  3679. ** CAPI3REF: Create Or Redefine SQL Functions
  3680. ** KEYWORDS: {function creation routines}
  3681. ** KEYWORDS: {application-defined SQL function}
  3682. ** KEYWORDS: {application-defined SQL functions}
  3683. **
  3684. ** ^These functions (collectively known as "function creation routines")
  3685. ** are used to add SQL functions or aggregates or to redefine the behavior
  3686. ** of existing SQL functions or aggregates. The only differences between
  3687. ** these routines are the text encoding expected for
  3688. ** the the second parameter (the name of the function being created)
  3689. ** and the presence or absence of a destructor callback for
  3690. ** the application data pointer.
  3691. **
  3692. ** ^The first parameter is the [database connection] to which the SQL
  3693. ** function is to be added. ^If an application uses more than one database
  3694. ** connection then application-defined SQL functions must be added
  3695. ** to each database connection separately.
  3696. **
  3697. ** ^The second parameter is the name of the SQL function to be created or
  3698. ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8
  3699. ** representation, exclusive of the zero-terminator. ^Note that the name
  3700. ** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.
  3701. ** ^Any attempt to create a function with a longer name
  3702. ** will result in [SQLITE_MISUSE] being returned.
  3703. **
  3704. ** ^The third parameter (nArg)
  3705. ** is the number of arguments that the SQL function or
  3706. ** aggregate takes. ^If this parameter is -1, then the SQL function or
  3707. ** aggregate may take any number of arguments between 0 and the limit
  3708. ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third
  3709. ** parameter is less than -1 or greater than 127 then the behavior is
  3710. ** undefined.
  3711. **
  3712. ** ^The fourth parameter, eTextRep, specifies what
  3713. ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
  3714. ** its parameters. Every SQL function implementation must be able to work
  3715. ** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
  3716. ** more efficient with one encoding than another. ^An application may
  3717. ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
  3718. ** times with the same function but with different values of eTextRep.
  3719. ** ^When multiple implementations of the same function are available, SQLite
  3720. ** will pick the one that involves the least amount of data conversion.
  3721. ** If there is only a single implementation which does not care what text
  3722. ** encoding is used, then the fourth argument should be [SQLITE_ANY].
  3723. **
  3724. ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
  3725. ** function can gain access to this pointer using [sqlite3_user_data()].)^
  3726. **
  3727. ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
  3728. ** pointers to C-language functions that implement the SQL function or
  3729. ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
  3730. ** callback only; NULL pointers must be passed as the xStep and xFinal
  3731. ** parameters. ^An aggregate SQL function requires an implementation of xStep
  3732. ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
  3733. ** SQL function or aggregate, pass NULL poiners for all three function
  3734. ** callbacks.
  3735. **
  3736. ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
  3737. ** then it is destructor for the application data pointer.
  3738. ** The destructor is invoked when the function is deleted, either by being
  3739. ** overloaded or when the database connection closes.)^
  3740. ** ^The destructor is also invoked if the call to
  3741. ** sqlite3_create_function_v2() fails.
  3742. ** ^When the destructor callback of the tenth parameter is invoked, it
  3743. ** is passed a single argument which is a copy of the application data
  3744. ** pointer which was the fifth parameter to sqlite3_create_function_v2().
  3745. **
  3746. ** ^It is permitted to register multiple implementations of the same
  3747. ** functions with the same name but with either differing numbers of
  3748. ** arguments or differing preferred text encodings. ^SQLite will use
  3749. ** the implementation that most closely matches the way in which the
  3750. ** SQL function is used. ^A function implementation with a non-negative
  3751. ** nArg parameter is a better match than a function implementation with
  3752. ** a negative nArg. ^A function where the preferred text encoding
  3753. ** matches the database encoding is a better
  3754. ** match than a function where the encoding is different.
  3755. ** ^A function where the encoding difference is between UTF16le and UTF16be
  3756. ** is a closer match than a function where the encoding difference is
  3757. ** between UTF8 and UTF16.
  3758. **
  3759. ** ^Built-in functions may be overloaded by new application-defined functions.
  3760. **
  3761. ** ^An application-defined function is permitted to call other
  3762. ** SQLite interfaces. However, such calls must not
  3763. ** close the database connection nor finalize or reset the prepared
  3764. ** statement in which the function is running.
  3765. */
  3766. //SQLITE_API int sqlite3_create_function(
  3767. // sqlite3 *db,
  3768. // const char *zFunctionName,
  3769. // int nArg,
  3770. // int eTextRep,
  3771. // void *pApp,
  3772. // void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  3773. // void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  3774. // void (*xFinal)(sqlite3_context*)
  3775. //);
  3776. //SQLITE_API int sqlite3_create_function16(
  3777. // sqlite3 *db,
  3778. // const void *zFunctionName,
  3779. // int nArg,
  3780. // int eTextRep,
  3781. // void *pApp,
  3782. // void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  3783. // void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  3784. // void (*xFinal)(sqlite3_context*)
  3785. //);
  3786. //SQLITE_API int sqlite3_create_function_v2(
  3787. // sqlite3 *db,
  3788. // const char *zFunctionName,
  3789. // int nArg,
  3790. // int eTextRep,
  3791. // void *pApp,
  3792. // void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  3793. // void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  3794. // void (*xFinal)(sqlite3_context*),
  3795. // void(*xDestroy)(void*)
  3796. //);
  3797. /*
  3798. ** CAPI3REF: Text Encodings
  3799. **
  3800. ** These constant define integer codes that represent the various
  3801. ** text encodings supported by SQLite.
  3802. */
  3803. //#define SQLITE_UTF8 1
  3804. //#define SQLITE_UTF16LE 2
  3805. //#define SQLITE_UTF16BE 3
  3806. //#define SQLITE_UTF16 4 /* Use native byte order */
  3807. //#define SQLITE_ANY 5 /* sqlite3_create_function only */
  3808. //#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
  3809. public const u8 SQLITE_UTF8 = 1;
  3810. public const u8 SQLITE_UTF16LE = 2;
  3811. public const u8 SQLITE_UTF16BE = 3;
  3812. public const u8 SQLITE_UTF16 = 4;
  3813. public const u8 SQLITE_ANY = 5;
  3814. public const u8 SQLITE_UTF16_ALIGNED = 8;
  3815. /*
  3816. ** CAPI3REF: Deprecated Functions
  3817. ** DEPRECATED
  3818. **
  3819. ** These functions are [deprecated]. In order to maintain
  3820. ** backwards compatibility with older code, these functions continue
  3821. ** to be supported. However, new applications should avoid
  3822. ** the use of these functions. To help encourage people to avoid
  3823. ** using these functions, we are not going to tell you what they do.
  3824. */
  3825. //#ifndef SQLITE_OMIT_DEPRECATED
  3826. //SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  3827. //SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  3828. //SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  3829. //SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
  3830. //SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  3831. //SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
  3832. //#endif
  3833. /*
  3834. ** CAPI3REF: Obtaining SQL Function Parameter Values
  3835. **
  3836. ** The C-language implementation of SQL functions and aggregates uses
  3837. ** this set of interface routines to access the parameter values on
  3838. ** the function or aggregate.
  3839. **
  3840. ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
  3841. ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
  3842. ** define callbacks that implement the SQL functions and aggregates.
  3843. ** The 3rd parameter to these callbacks is an array of pointers to
  3844. ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for
  3845. ** each parameter to the SQL function. These routines are used to
  3846. ** extract values from the [sqlite3_value] objects.
  3847. **
  3848. ** These routines work only with [protected sqlite3_value] objects.
  3849. ** Any attempt to use these routines on an [unprotected sqlite3_value]
  3850. ** object results in undefined behavior.
  3851. **
  3852. ** ^These routines work just like the corresponding [column access functions]
  3853. ** except that these routines take a single [protected sqlite3_value] object
  3854. ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  3855. **
  3856. ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  3857. ** in the native byte-order of the host machine. ^The
  3858. ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
  3859. ** extract UTF-16 strings as big-endian and little-endian respectively.
  3860. **
  3861. ** ^(The sqlite3_value_numeric_type() interface attempts to apply
  3862. ** numeric affinity to the value. This means that an attempt is
  3863. ** made to convert the value to an integer or floating point. If
  3864. ** such a conversion is possible without loss of information (in other
  3865. ** words, if the value is a string that looks like a number)
  3866. ** then the conversion is performed. Otherwise no conversion occurs.
  3867. ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
  3868. **
  3869. ** Please pay particular attention to the fact that the pointer returned
  3870. ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
  3871. ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
  3872. ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
  3873. ** or [sqlite3_value_text16()].
  3874. **
  3875. ** These routines must be called from the same thread as
  3876. ** the SQL function that supplied the [sqlite3_value*] parameters.
  3877. */
  3878. //SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  3879. //SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
  3880. //SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
  3881. //SQLITE_API double sqlite3_value_double(sqlite3_value*);
  3882. //SQLITE_API int sqlite3_value_int(sqlite3_value*);
  3883. //SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  3884. //SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
  3885. //SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
  3886. //SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
  3887. //SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
  3888. //SQLITE_API int sqlite3_value_type(sqlite3_value*);
  3889. //SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
  3890. /*
  3891. ** CAPI3REF: Obtain Aggregate Function Context
  3892. **
  3893. ** Implementations of aggregate SQL functions use this
  3894. ** routine to allocate memory for storing their state.
  3895. **
  3896. ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
  3897. ** for a particular aggregate function, SQLite
  3898. ** allocates N of memory, zeroes out that memory, and returns a pointer
  3899. ** to the new memory. ^On second and subsequent calls to
  3900. ** sqlite3_aggregate_context() for the same aggregate function instance,
  3901. ** the same buffer is returned. Sqlite3_aggregate_context() is normally
  3902. ** called once for each invocation of the xStep callback and then one
  3903. ** last time when the xFinal callback is invoked. ^(When no rows match
  3904. ** an aggregate query, the xStep() callback of the aggregate function
  3905. ** implementation is never called and xFinal() is called exactly once.
  3906. ** In those cases, sqlite3_aggregate_context() might be called for the
  3907. ** first time from within xFinal().)^
  3908. **
  3909. ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
  3910. ** less than or equal to zero or if a memory allocate error occurs.
  3911. **
  3912. ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
  3913. ** determined by the N parameter on first successful call. Changing the
  3914. ** value of N in subsequent call to sqlite3_aggregate_context() within
  3915. ** the same aggregate function instance will not resize the memory
  3916. ** allocation.)^
  3917. **
  3918. ** ^SQLite automatically frees the memory allocated by
  3919. ** sqlite3_aggregate_context() when the aggregate query concludes.
  3920. **
  3921. ** The first parameter must be a copy of the
  3922. ** [sqlite3_context | SQL function context] that is the first parameter
  3923. ** to the xStep or xFinal callback routine that implements the aggregate
  3924. ** function.
  3925. **
  3926. ** This routine must be called from the same thread in which
  3927. ** the aggregate SQL function is running.
  3928. */
  3929. //SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  3930. /*
  3931. ** CAPI3REF: User Data For Functions
  3932. **
  3933. ** ^The sqlite3_user_data() interface returns a copy of
  3934. ** the pointer that was the pUserData parameter (the 5th parameter)
  3935. ** of the [sqlite3_create_function()]
  3936. ** and [sqlite3_create_function16()] routines that originally
  3937. ** registered the application defined function.
  3938. **
  3939. ** This routine must be called from the same thread in which
  3940. ** the application-defined function is running.
  3941. */
  3942. //SQLITE_API void *sqlite3_user_data(sqlite3_context*);
  3943. /*
  3944. ** CAPI3REF: Database Connection For Functions
  3945. **
  3946. ** ^The sqlite3_context_db_handle() interface returns a copy of
  3947. ** the pointer to the [database connection] (the 1st parameter)
  3948. ** of the [sqlite3_create_function()]
  3949. ** and [sqlite3_create_function16()] routines that originally
  3950. ** registered the application defined function.
  3951. */
  3952. //SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
  3953. /*
  3954. ** CAPI3REF: Function Auxiliary Data
  3955. **
  3956. ** The following two functions may be used by scalar SQL functions to
  3957. ** associate metadata with argument values. If the same value is passed to
  3958. ** multiple invocations of the same SQL function during query execution, under
  3959. ** some circumstances the associated metadata may be preserved. This may
  3960. ** be used, for example, to add a regular-expression matching scalar
  3961. ** function. The compiled version of the regular expression is stored as
  3962. ** metadata associated with the SQL value passed as the regular expression
  3963. ** pattern. The compiled regular expression can be reused on multiple
  3964. ** invocations of the same function so that the original pattern string
  3965. ** does not need to be recompiled on each invocation.
  3966. **
  3967. ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
  3968. ** associated by the sqlite3_set_auxdata() function with the Nth argument
  3969. ** value to the application-defined function. ^If no metadata has been ever
  3970. ** been set for the Nth argument of the function, or if the corresponding
  3971. ** function parameter has changed since the meta-data was set,
  3972. ** then sqlite3_get_auxdata() returns a NULL pointer.
  3973. **
  3974. ** ^The sqlite3_set_auxdata() interface saves the metadata
  3975. ** pointed to by its 3rd parameter as the metadata for the N-th
  3976. ** argument of the application-defined function. Subsequent
  3977. ** calls to sqlite3_get_auxdata() might return this data, if it has
  3978. ** not been destroyed.
  3979. ** ^If it is not NULL, SQLite will invoke the destructor
  3980. ** function given by the 4th parameter to sqlite3_set_auxdata() on
  3981. ** the metadata when the corresponding function parameter changes
  3982. ** or when the SQL statement completes, whichever comes first.
  3983. **
  3984. ** SQLite is free to call the destructor and drop metadata on any
  3985. ** parameter of any function at any time. ^The only guarantee is that
  3986. ** the destructor will be called before the metadata is dropped.
  3987. **
  3988. ** ^(In practice, metadata is preserved between function calls for
  3989. ** expressions that are constant at compile time. This includes literal
  3990. ** values and [parameters].)^
  3991. **
  3992. ** These routines must be called from the same thread in which
  3993. ** the SQL function is running.
  3994. */
  3995. //SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
  3996. //SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  3997. /*
  3998. ** CAPI3REF: Constants Defining Special Destructor Behavior
  3999. **
  4000. ** These are special values for the destructor that is passed in as the
  4001. ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor
  4002. ** argument is SQLITE_STATIC, it means that the content pointer is constant
  4003. ** and will never change. It does not need to be destroyed. ^The
  4004. ** SQLITE_TRANSIENT value means that the content will likely change in
  4005. ** the near future and that SQLite should make its own private copy of
  4006. ** the content before returning.
  4007. **
  4008. ** The typedef is necessary to work around problems in certain
  4009. ** C++ compilers. See ticket #2191.
  4010. */
  4011. //typedef void (*sqlite3_destructor_type)(void*);
  4012. //#define SQLITE_STATIC ((sqlite3_destructor_type)0)
  4013. //#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
  4014. static public dxDel SQLITE_STATIC;
  4015. static public dxDel SQLITE_TRANSIENT;
  4016. /*
  4017. ** CAPI3REF: Setting The Result Of An SQL Function
  4018. **
  4019. ** These routines are used by the xFunc or xFinal callbacks that
  4020. ** implement SQL functions and aggregates. See
  4021. ** [sqlite3_create_function()] and [sqlite3_create_function16()]
  4022. ** for additional information.
  4023. **
  4024. ** These functions work very much like the [parameter binding] family of
  4025. ** functions used to bind values to host parameters in prepared statements.
  4026. ** Refer to the [SQL parameter] documentation for additional information.
  4027. **
  4028. ** ^The sqlite3_result_blob() interface sets the result from
  4029. ** an application-defined function to be the BLOB whose content is pointed
  4030. ** to by the second parameter and which is N bytes long where N is the
  4031. ** third parameter.
  4032. **
  4033. ** ^The sqlite3_result_zeroblob() interfaces set the result of
  4034. ** the application-defined function to be a BLOB containing all zero
  4035. ** bytes and N bytes in size, where N is the value of the 2nd parameter.
  4036. **
  4037. ** ^The sqlite3_result_double() interface sets the result from
  4038. ** an application-defined function to be a floating point value specified
  4039. ** by its 2nd argument.
  4040. **
  4041. ** ^The sqlite3_result_error() and sqlite3_result_error16() functions
  4042. ** cause the implemented SQL function to throw an exception.
  4043. ** ^SQLite uses the string pointed to by the
  4044. ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
  4045. ** as the text of an error message. ^SQLite interprets the error
  4046. ** message string from sqlite3_result_error() as UTF-8. ^SQLite
  4047. ** interprets the string from sqlite3_result_error16() as UTF-16 in native
  4048. ** byte order. ^If the third parameter to sqlite3_result_error()
  4049. ** or sqlite3_result_error16() is negative then SQLite takes as the error
  4050. ** message all text up through the first zero character.
  4051. ** ^If the third parameter to sqlite3_result_error() or
  4052. ** sqlite3_result_error16() is non-negative then SQLite takes that many
  4053. ** bytes (not characters) from the 2nd parameter as the error message.
  4054. ** ^The sqlite3_result_error() and sqlite3_result_error16()
  4055. ** routines make a private copy of the error message text before
  4056. ** they return. Hence, the calling function can deallocate or
  4057. ** modify the text after they return without harm.
  4058. ** ^The sqlite3_result_error_code() function changes the error code
  4059. ** returned by SQLite as a result of an error in a function. ^By default,
  4060. ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error()
  4061. ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
  4062. **
  4063. ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
  4064. ** indicating that a string or BLOB is too long to represent.
  4065. **
  4066. ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
  4067. ** indicating that a memory allocation failed.
  4068. **
  4069. ** ^The sqlite3_result_int() interface sets the return value
  4070. ** of the application-defined function to be the 32-bit signed integer
  4071. ** value given in the 2nd argument.
  4072. ** ^The sqlite3_result_int64() interface sets the return value
  4073. ** of the application-defined function to be the 64-bit signed integer
  4074. ** value given in the 2nd argument.
  4075. **
  4076. ** ^The sqlite3_result_null() interface sets the return value
  4077. ** of the application-defined function to be NULL.
  4078. **
  4079. ** ^The sqlite3_result_text(), sqlite3_result_text16(),
  4080. ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
  4081. ** set the return value of the application-defined function to be
  4082. ** a text string which is represented as UTF-8, UTF-16 native byte order,
  4083. ** UTF-16 little endian, or UTF-16 big endian, respectively.
  4084. ** ^SQLite takes the text result from the application from
  4085. ** the 2nd parameter of the sqlite3_result_text* interfaces.
  4086. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  4087. ** is negative, then SQLite takes result text from the 2nd parameter
  4088. ** through the first zero character.
  4089. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  4090. ** is non-negative, then as many bytes (not characters) of the text
  4091. ** pointed to by the 2nd parameter are taken as the application-defined
  4092. ** function result.
  4093. ** ^If the 4th parameter to the sqlite3_result_text* interfaces
  4094. ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
  4095. ** function as the destructor on the text or BLOB result when it has
  4096. ** finished using that result.
  4097. ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
  4098. ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
  4099. ** assumes that the text or BLOB result is in constant space and does not
  4100. ** copy the content of the parameter nor call a destructor on the content
  4101. ** when it has finished using that result.
  4102. ** ^If the 4th parameter to the sqlite3_result_text* interfaces
  4103. ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
  4104. ** then SQLite makes a copy of the result into space obtained from
  4105. ** from [sqlite3_malloc()] before it returns.
  4106. **
  4107. ** ^The sqlite3_result_value() interface sets the result of
  4108. ** the application-defined function to be a copy the
  4109. ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
  4110. ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  4111. ** so that the [sqlite3_value] specified in the parameter may change or
  4112. ** be deallocated after sqlite3_result_value() returns without harm.
  4113. ** ^A [protected sqlite3_value] object may always be used where an
  4114. ** [unprotected sqlite3_value] object is required, so either
  4115. ** kind of [sqlite3_value] object can be used with this interface.
  4116. **
  4117. ** If these routines are called from within the different thread
  4118. ** than the one containing the application-defined function that received
  4119. ** the [sqlite3_context] pointer, the results are undefined.
  4120. */
  4121. //SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  4122. //SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
  4123. //SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
  4124. //SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
  4125. //SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
  4126. //SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
  4127. //SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
  4128. //SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
  4129. //SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  4130. //SQLITE_API void sqlite3_result_null(sqlite3_context*);
  4131. //SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  4132. //SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  4133. //SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  4134. //SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  4135. //SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  4136. //SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
  4137. /*
  4138. ** CAPI3REF: Define New Collating Sequences
  4139. **
  4140. ** ^These functions add, remove, or modify a [collation] associated
  4141. ** with the [database connection] specified as the first argument.
  4142. **
  4143. ** ^The name of the collation is a UTF-8 string
  4144. ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
  4145. ** and a UTF-16 string in native byte order for sqlite3_create_collation16().
  4146. ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are
  4147. ** considered to be the same name.
  4148. **
  4149. ** ^(The third argument (eTextRep) must be one of the constants:
  4150. ** <ul>
  4151. ** <li> [SQLITE_UTF8],
  4152. ** <li> [SQLITE_UTF16LE],
  4153. ** <li> [SQLITE_UTF16BE],
  4154. ** <li> [SQLITE_UTF16], or
  4155. ** <li> [SQLITE_UTF16_ALIGNED].
  4156. ** </ul>)^
  4157. ** ^The eTextRep argument determines the encoding of strings passed
  4158. ** to the collating function callback, xCallback.
  4159. ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep
  4160. ** force strings to be UTF16 with native byte order.
  4161. ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin
  4162. ** on an even byte address.
  4163. **
  4164. ** ^The fourth argument, pArg, is a application data pointer that is passed
  4165. ** through as the first argument to the collating function callback.
  4166. **
  4167. ** ^The fifth argument, xCallback, is a pointer to the collating function.
  4168. ** ^Multiple collating functions can be registered using the same name but
  4169. ** with different eTextRep parameters and SQLite will use whichever
  4170. ** function requires the least amount of data transformation.
  4171. ** ^If the xCallback argument is NULL then the collating function is
  4172. ** deleted. ^When all collating functions having the same name are deleted,
  4173. ** that collation is no longer usable.
  4174. **
  4175. ** ^The collating function callback is invoked with a copy of the pArg
  4176. ** application data pointer and with two strings in the encoding specified
  4177. ** by the eTextRep argument. The collating function must return an
  4178. ** integer that is negative, zero, or positive
  4179. ** if the first string is less than, equal to, or greater than the second,
  4180. ** respectively. A collating function must alway return the same answer
  4181. ** given the same inputs. If two or more collating functions are registered
  4182. ** to the same collation name (using different eTextRep values) then all
  4183. ** must give an equivalent answer when invoked with equivalent strings.
  4184. ** The collating function must obey the following properties for all
  4185. ** strings A, B, and C:
  4186. **
  4187. ** <ol>
  4188. ** <li> If A==B then B==A.
  4189. ** <li> If A==B and B==C then A==C.
  4190. ** <li> If A&lt;B THEN B&gt;A.
  4191. ** <li> If A&lt;B and B&lt;C then A&lt;C.
  4192. ** </ol>
  4193. **
  4194. ** If a collating function fails any of the above constraints and that
  4195. ** collating function is registered and used, then the behavior of SQLite
  4196. ** is undefined.
  4197. **
  4198. ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
  4199. ** with the addition that the xDestroy callback is invoked on pArg when
  4200. ** the collating function is deleted.
  4201. ** ^Collating functions are deleted when they are overridden by later
  4202. ** calls to the collation creation functions or when the
  4203. ** [database connection] is closed using [sqlite3_close()].
  4204. **
  4205. ** ^The xDestroy callback is <u>not</u> called if the
  4206. ** sqlite3_create_collation_v2() function fails. Applications that invoke
  4207. ** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should
  4208. ** check the return code and dispose of the application data pointer
  4209. ** themselves rather than expecting SQLite to deal with it for them.
  4210. ** This is different from every other SQLite interface. The inconsistency
  4211. ** is unfortunate but cannot be changed without breaking backwards
  4212. ** compatibility.
  4213. **
  4214. ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
  4215. */
  4216. //SQLITE_API int sqlite3_create_collation(
  4217. // sqlite3*,
  4218. // const char *zName,
  4219. // int eTextRep,
  4220. // void *pArg,
  4221. // int(*xCompare)(void*,int,const void*,int,const void*)
  4222. //);
  4223. //SQLITE_API int sqlite3_create_collation_v2(
  4224. // sqlite3*,
  4225. // const char *zName,
  4226. // int eTextRep,
  4227. // void *pArg,
  4228. // int(*xCompare)(void*,int,const void*,int,const void*),
  4229. // void(*xDestroy)(void*)
  4230. //);
  4231. //SQLITE_API int sqlite3_create_collation16(
  4232. // sqlite3*,
  4233. // const void *zName,
  4234. // int eTextRep,
  4235. // void *pArg,
  4236. // int(*xCompare)(void*,int,const void*,int,const void*)
  4237. //);
  4238. /*
  4239. ** CAPI3REF: Collation Needed Callbacks
  4240. **
  4241. ** ^To avoid having to register all collation sequences before a database
  4242. ** can be used, a single callback function may be registered with the
  4243. ** [database connection] to be invoked whenever an undefined collation
  4244. ** sequence is required.
  4245. **
  4246. ** ^If the function is registered using the sqlite3_collation_needed() API,
  4247. ** then it is passed the names of undefined collation sequences as strings
  4248. ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
  4249. ** the names are passed as UTF-16 in machine native byte order.
  4250. ** ^A call to either function replaces the existing collation-needed callback.
  4251. **
  4252. ** ^(When the callback is invoked, the first argument passed is a copy
  4253. ** of the second argument to sqlite3_collation_needed() or
  4254. ** sqlite3_collation_needed16(). The second argument is the database
  4255. ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
  4256. ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
  4257. ** sequence function required. The fourth parameter is the name of the
  4258. ** required collation sequence.)^
  4259. **
  4260. ** The callback function should register the desired collation using
  4261. ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
  4262. ** [sqlite3_create_collation_v2()].
  4263. */
  4264. //SQLITE_API int sqlite3_collation_needed(
  4265. // sqlite3*,
  4266. // void*,
  4267. // void(*)(void*,sqlite3*,int eTextRep,const char*)
  4268. //);
  4269. //SQLITE_API int sqlite3_collation_needed16(
  4270. // sqlite3*,
  4271. // void*,
  4272. // void(*)(void*,sqlite3*,int eTextRep,const void*)
  4273. //);
  4274. //#ifdef SQLITE_HAS_CODEC
  4275. /*
  4276. ** Specify the key for an encrypted database. This routine should be
  4277. ** called right after sqlite3_open().
  4278. **
  4279. ** The code to implement this API is not available in the public release
  4280. ** of SQLite.
  4281. */
  4282. //SQLITE_API int sqlite3_key(
  4283. // sqlite3 *db, /* Database to be rekeyed */
  4284. // const void *pKey, int nKey /* The key */
  4285. //);
  4286. /*
  4287. ** Change the key on an open database. If the current database is not
  4288. ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
  4289. ** database is decrypted.
  4290. **
  4291. ** The code to implement this API is not available in the public release
  4292. ** of SQLite.
  4293. */
  4294. //SQLITE_API int sqlite3_rekey(
  4295. // sqlite3 *db, /* Database to be rekeyed */
  4296. // const void *pKey, int nKey /* The new key */
  4297. //);
  4298. /*
  4299. ** Specify the activation key for a SEE database. Unless
  4300. ** activated, none of the SEE routines will work.
  4301. */
  4302. //SQLITE_API void sqlite3_activate_see(
  4303. // const char *zPassPhrase /* Activation phrase */
  4304. //);
  4305. //#endif
  4306. //#ifdef SQLITE_ENABLE_CEROD
  4307. /*
  4308. ** Specify the activation key for a CEROD database. Unless
  4309. ** activated, none of the CEROD routines will work.
  4310. */
  4311. //SQLITE_API void sqlite3_activate_cerod(
  4312. // const char *zPassPhrase /* Activation phrase */
  4313. //);
  4314. //#endif
  4315. /*
  4316. ** CAPI3REF: Suspend Execution For A Short Time
  4317. **
  4318. ** The sqlite3_sleep() function causes the current thread to suspend execution
  4319. ** for at least a number of milliseconds specified in its parameter.
  4320. **
  4321. ** If the operating system does not support sleep requests with
  4322. ** millisecond time resolution, then the time will be rounded up to
  4323. ** the nearest second. The number of milliseconds of sleep actually
  4324. ** requested from the operating system is returned.
  4325. **
  4326. ** ^SQLite implements this interface by calling the xSleep()
  4327. ** method of the default [sqlite3_vfs] object. If the xSleep() method
  4328. ** of the default VFS is not implemented correctly, or not implemented at
  4329. ** all, then the behavior of sqlite3_sleep() may deviate from the description
  4330. ** in the previous paragraphs.
  4331. */
  4332. //SQLITE_API int sqlite3_sleep(int);
  4333. /*
  4334. ** CAPI3REF: Name Of The Folder Holding Temporary Files
  4335. **
  4336. ** ^(If this global variable is made to point to a string which is
  4337. ** the name of a folder (a.k.a. directory), then all temporary files
  4338. ** created by SQLite when using a built-in [sqlite3_vfs | VFS]
  4339. ** will be placed in that directory.)^ ^If this variable
  4340. ** is a NULL pointer, then SQLite performs a search for an appropriate
  4341. ** temporary file directory.
  4342. **
  4343. ** It is not safe to read or modify this variable in more than one
  4344. ** thread at a time. It is not safe to read or modify this variable
  4345. ** if a [database connection] is being used at the same time in a separate
  4346. ** thread.
  4347. ** It is intended that this variable be set once
  4348. ** as part of process initialization and before any SQLite interface
  4349. ** routines have been called and that this variable remain unchanged
  4350. ** thereafter.
  4351. **
  4352. ** ^The [temp_store_directory pragma] may modify this variable and cause
  4353. ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
  4354. ** the [temp_store_directory pragma] always assumes that any string
  4355. ** that this variable points to is held in memory obtained from
  4356. ** [sqlite3_malloc] and the pragma may attempt to free that memory
  4357. ** using [sqlite3_free].
  4358. ** Hence, if this variable is modified directly, either it should be
  4359. ** made NULL or made to point to memory obtained from [sqlite3_malloc]
  4360. ** or else the use of the [temp_store_directory pragma] should be avoided.
  4361. */
  4362. //SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
  4363. /*
  4364. ** CAPI3REF: Test For Auto-Commit Mode
  4365. ** KEYWORDS: {autocommit mode}
  4366. **
  4367. ** ^The sqlite3_get_autocommit() interface returns non-zero or
  4368. ** zero if the given database connection is or is not in autocommit mode,
  4369. ** respectively. ^Autocommit mode is on by default.
  4370. ** ^Autocommit mode is disabled by a [BEGIN] statement.
  4371. ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
  4372. **
  4373. ** If certain kinds of errors occur on a statement within a multi-statement
  4374. ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
  4375. ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
  4376. ** transaction might be rolled back automatically. The only way to
  4377. ** find out whether SQLite automatically rolled back the transaction after
  4378. ** an error is to use this function.
  4379. **
  4380. ** If another thread changes the autocommit status of the database
  4381. ** connection while this routine is running, then the return value
  4382. ** is undefined.
  4383. */
  4384. //SQLITE_API int sqlite3_get_autocommit(sqlite3*);
  4385. /*
  4386. ** CAPI3REF: Find The Database Handle Of A Prepared Statement
  4387. **
  4388. ** ^The sqlite3_db_handle interface returns the [database connection] handle
  4389. ** to which a [prepared statement] belongs. ^The [database connection]
  4390. ** returned by sqlite3_db_handle is the same [database connection]
  4391. ** that was the first argument
  4392. ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
  4393. ** create the statement in the first place.
  4394. */
  4395. //SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
  4396. /*
  4397. ** CAPI3REF: Find the next prepared statement
  4398. **
  4399. ** ^This interface returns a pointer to the next [prepared statement] after
  4400. ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
  4401. ** then this interface returns a pointer to the first prepared statement
  4402. ** associated with the database connection pDb. ^If no prepared statement
  4403. ** satisfies the conditions of this routine, it returns NULL.
  4404. **
  4405. ** The [database connection] pointer D in a call to
  4406. ** [sqlite3_next_stmt(D,S)] must refer to an open database
  4407. ** connection and in particular must not be a NULL pointer.
  4408. */
  4409. //SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  4410. /*
  4411. ** CAPI3REF: Commit And Rollback Notification Callbacks
  4412. **
  4413. ** ^The sqlite3_commit_hook() interface registers a callback
  4414. ** function to be invoked whenever a transaction is [COMMIT | committed].
  4415. ** ^Any callback set by a previous call to sqlite3_commit_hook()
  4416. ** for the same database connection is overridden.
  4417. ** ^The sqlite3_rollback_hook() interface registers a callback
  4418. ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
  4419. ** ^Any callback set by a previous call to sqlite3_rollback_hook()
  4420. ** for the same database connection is overridden.
  4421. ** ^The pArg argument is passed through to the callback.
  4422. ** ^If the callback on a commit hook function returns non-zero,
  4423. ** then the commit is converted into a rollback.
  4424. **
  4425. ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
  4426. ** return the P argument from the previous call of the same function
  4427. ** on the same [database connection] D, or NULL for
  4428. ** the first call for each function on D.
  4429. **
  4430. ** The callback implementation must not do anything that will modify
  4431. ** the database connection that invoked the callback. Any actions
  4432. ** to modify the database connection must be deferred until after the
  4433. ** completion of the [sqlite3_step()] call that triggered the commit
  4434. ** or rollback hook in the first place.
  4435. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  4436. ** database connections for the meaning of "modify" in this paragraph.
  4437. **
  4438. ** ^Registering a NULL function disables the callback.
  4439. **
  4440. ** ^When the commit hook callback routine returns zero, the [COMMIT]
  4441. ** operation is allowed to continue normally. ^If the commit hook
  4442. ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
  4443. ** ^The rollback hook is invoked on a rollback that results from a commit
  4444. ** hook returning non-zero, just as it would be with any other rollback.
  4445. **
  4446. ** ^For the purposes of this API, a transaction is said to have been
  4447. ** rolled back if an explicit "ROLLBACK" statement is executed, or
  4448. ** an error or constraint causes an implicit rollback to occur.
  4449. ** ^The rollback callback is not invoked if a transaction is
  4450. ** automatically rolled back because the database connection is closed.
  4451. **
  4452. ** See also the [sqlite3_update_hook()] interface.
  4453. */
  4454. //SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  4455. //SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  4456. /*
  4457. ** CAPI3REF: Data Change Notification Callbacks
  4458. **
  4459. ** ^The sqlite3_update_hook() interface registers a callback function
  4460. ** with the [database connection] identified by the first argument
  4461. ** to be invoked whenever a row is updated, inserted or deleted.
  4462. ** ^Any callback set by a previous call to this function
  4463. ** for the same database connection is overridden.
  4464. **
  4465. ** ^The second argument is a pointer to the function to invoke when a
  4466. ** row is updated, inserted or deleted.
  4467. ** ^The first argument to the callback is a copy of the third argument
  4468. ** to sqlite3_update_hook().
  4469. ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
  4470. ** or [SQLITE_UPDATE], depending on the operation that caused the callback
  4471. ** to be invoked.
  4472. ** ^The third and fourth arguments to the callback contain pointers to the
  4473. ** database and table name containing the affected row.
  4474. ** ^The final callback parameter is the [rowid] of the row.
  4475. ** ^In the case of an update, this is the [rowid] after the update takes place.
  4476. **
  4477. ** ^(The update hook is not invoked when internal system tables are
  4478. ** modified (i.e. sqlite_master and sqlite_sequence).)^
  4479. **
  4480. ** ^In the current implementation, the update hook
  4481. ** is not invoked when duplication rows are deleted because of an
  4482. ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook
  4483. ** invoked when rows are deleted using the [truncate optimization].
  4484. ** The exceptions defined in this paragraph might change in a future
  4485. ** release of SQLite.
  4486. **
  4487. ** The update hook implementation must not do anything that will modify
  4488. ** the database connection that invoked the update hook. Any actions
  4489. ** to modify the database connection must be deferred until after the
  4490. ** completion of the [sqlite3_step()] call that triggered the update hook.
  4491. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  4492. ** database connections for the meaning of "modify" in this paragraph.
  4493. **
  4494. ** ^The sqlite3_update_hook(D,C,P) function
  4495. ** returns the P argument from the previous call
  4496. ** on the same [database connection] D, or NULL for
  4497. ** the first call on D.
  4498. **
  4499. ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
  4500. ** interfaces.
  4501. */
  4502. //SQLITE_API void *sqlite3_update_hook(
  4503. // sqlite3*,
  4504. // void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  4505. // void*
  4506. //);
  4507. /*
  4508. ** CAPI3REF: Enable Or Disable Shared Pager Cache
  4509. ** KEYWORDS: {shared cache}
  4510. **
  4511. ** ^(This routine enables or disables the sharing of the database cache
  4512. ** and schema data structures between [database connection | connections]
  4513. ** to the same database. Sharing is enabled if the argument is true
  4514. ** and disabled if the argument is false.)^
  4515. **
  4516. ** ^Cache sharing is enabled and disabled for an entire process.
  4517. ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
  4518. ** sharing was enabled or disabled for each thread separately.
  4519. **
  4520. ** ^(The cache sharing mode set by this interface effects all subsequent
  4521. ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
  4522. ** Existing database connections continue use the sharing mode
  4523. ** that was in effect at the time they were opened.)^
  4524. **
  4525. ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
  4526. ** successfully. An [error code] is returned otherwise.)^
  4527. **
  4528. ** ^Shared cache is disabled by default. But this might change in
  4529. ** future releases of SQLite. Applications that care about shared
  4530. ** cache setting should set it explicitly.
  4531. **
  4532. ** See Also: [SQLite Shared-Cache Mode]
  4533. */
  4534. //SQLITE_API int sqlite3_enable_shared_cache(int);
  4535. /*
  4536. ** CAPI3REF: Attempt To Free Heap Memory
  4537. **
  4538. ** ^The sqlite3_release_memory() interface attempts to free N bytes
  4539. ** of heap memory by deallocating non-essential memory allocations
  4540. ** held by the database library. Memory used to cache database
  4541. ** pages to improve performance is an example of non-essential memory.
  4542. ** ^sqlite3_release_memory() returns the number of bytes actually freed,
  4543. ** which might be more or less than the amount requested.
  4544. ** ^The sqlite3_release_memory() routine is a no-op returning zero
  4545. ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  4546. */
  4547. //SQLITE_API int sqlite3_release_memory(int);
  4548. /*
  4549. ** CAPI3REF: Impose A Limit On Heap Size
  4550. **
  4551. ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
  4552. ** soft limit on the amount of heap memory that may be allocated by SQLite.
  4553. ** ^SQLite strives to keep heap memory utilization below the soft heap
  4554. ** limit by reducing the number of pages held in the page cache
  4555. ** as heap memory usages approaches the limit.
  4556. ** ^The soft heap limit is "soft" because even though SQLite strives to stay
  4557. ** below the limit, it will exceed the limit rather than generate
  4558. ** an [SQLITE_NOMEM] error. In other words, the soft heap limit
  4559. ** is advisory only.
  4560. **
  4561. ** ^The return value from sqlite3_soft_heap_limit64() is the size of
  4562. ** the soft heap limit prior to the call. ^If the argument N is negative
  4563. ** then no change is made to the soft heap limit. Hence, the current
  4564. ** size of the soft heap limit can be determined by invoking
  4565. ** sqlite3_soft_heap_limit64() with a negative argument.
  4566. **
  4567. ** ^If the argument N is zero then the soft heap limit is disabled.
  4568. **
  4569. ** ^(The soft heap limit is not enforced in the current implementation
  4570. ** if one or more of following conditions are true:
  4571. **
  4572. ** <ul>
  4573. ** <li> The soft heap limit is set to zero.
  4574. ** <li> Memory accounting is disabled using a combination of the
  4575. ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
  4576. ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
  4577. ** <li> An alternative page cache implementation is specifed using
  4578. ** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
  4579. ** <li> The page cache allocates from its own memory pool supplied
  4580. ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
  4581. ** from the heap.
  4582. ** </ul>)^
  4583. **
  4584. ** Beginning with SQLite version 3.7.3, the soft heap limit is enforced
  4585. ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
  4586. ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
  4587. ** the soft heap limit is enforced on every memory allocation. Without
  4588. ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
  4589. ** when memory is allocated by the page cache. Testing suggests that because
  4590. ** the page cache is the predominate memory user in SQLite, most
  4591. ** applications will achieve adequate soft heap limit enforcement without
  4592. ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  4593. **
  4594. ** The circumstances under which SQLite will enforce the soft heap limit may
  4595. ** changes in future releases of SQLite.
  4596. */
  4597. //SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
  4598. /*
  4599. ** CAPI3REF: Deprecated Soft Heap Limit Interface
  4600. ** DEPRECATED
  4601. **
  4602. ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
  4603. ** interface. This routine is provided for historical compatibility
  4604. ** only. All new applications should use the
  4605. ** [sqlite3_soft_heap_limit64()] interface rather than this one.
  4606. */
  4607. //SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
  4608. /*
  4609. ** CAPI3REF: Extract Metadata About A Column Of A Table
  4610. **
  4611. ** ^This routine returns metadata about a specific column of a specific
  4612. ** database table accessible using the [database connection] handle
  4613. ** passed as the first function argument.
  4614. **
  4615. ** ^The column is identified by the second, third and fourth parameters to
  4616. ** this function. ^The second parameter is either the name of the database
  4617. ** (i.e. "main", "temp", or an attached database) containing the specified
  4618. ** table or NULL. ^If it is NULL, then all attached databases are searched
  4619. ** for the table using the same algorithm used by the database engine to
  4620. ** resolve unqualified table references.
  4621. **
  4622. ** ^The third and fourth parameters to this function are the table and column
  4623. ** name of the desired column, respectively. Neither of these parameters
  4624. ** may be NULL.
  4625. **
  4626. ** ^Metadata is returned by writing to the memory locations passed as the 5th
  4627. ** and subsequent parameters to this function. ^Any of these arguments may be
  4628. ** NULL, in which case the corresponding element of metadata is omitted.
  4629. **
  4630. ** ^(<blockquote>
  4631. ** <table border="1">
  4632. ** <tr><th> Parameter <th> Output<br>Type <th> Description
  4633. **
  4634. ** <tr><td> 5th <td> const char* <td> Data type
  4635. ** <tr><td> 6th <td> const char* <td> Name of default collation sequence
  4636. ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
  4637. ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
  4638. ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
  4639. ** </table>
  4640. ** </blockquote>)^
  4641. **
  4642. ** ^The memory pointed to by the character pointers returned for the
  4643. ** declaration type and collation sequence is valid only until the next
  4644. ** call to any SQLite API function.
  4645. **
  4646. ** ^If the specified table is actually a view, an [error code] is returned.
  4647. **
  4648. ** ^If the specified column is "rowid", "oid" or "_rowid_" and an
  4649. ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
  4650. ** parameters are set for the explicitly declared column. ^(If there is no
  4651. ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
  4652. ** parameters are set as follows:
  4653. **
  4654. ** <pre>
  4655. ** data type: "INTEGER"
  4656. ** collation sequence: "BINARY"
  4657. ** not null: 0
  4658. ** primary key: 1
  4659. ** auto increment: 0
  4660. ** </pre>)^
  4661. **
  4662. ** ^(This function may load one or more schemas from database files. If an
  4663. ** error occurs during this process, or if the requested table or column
  4664. ** cannot be found, an [error code] is returned and an error message left
  4665. ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
  4666. **
  4667. ** ^This API is only available if the library was compiled with the
  4668. ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
  4669. */
  4670. //SQLITE_API int sqlite3_table_column_metadata(
  4671. // sqlite3 *db, /* Connection handle */
  4672. // const char *zDbName, /* Database name or NULL */
  4673. // const char *zTableName, /* Table name */
  4674. // const char *zColumnName, /* Column name */
  4675. // char const **pzDataType, /* OUTPUT: Declared data type */
  4676. // char const **pzCollSeq, /* OUTPUT: Collation sequence name */
  4677. // int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */
  4678. // int *pPrimaryKey, /* OUTPUT: True if column part of PK */
  4679. // int *pAutoinc /* OUTPUT: True if column is auto-increment */
  4680. //);
  4681. /*
  4682. ** CAPI3REF: Load An Extension
  4683. **
  4684. ** ^This interface loads an SQLite extension library from the named file.
  4685. **
  4686. ** ^The sqlite3_load_extension() interface attempts to load an
  4687. ** SQLite extension library contained in the file zFile.
  4688. **
  4689. ** ^The entry point is zProc.
  4690. ** ^zProc may be 0, in which case the name of the entry point
  4691. ** defaults to "sqlite3_extension_init".
  4692. ** ^The sqlite3_load_extension() interface returns
  4693. ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
  4694. ** ^If an error occurs and pzErrMsg is not 0, then the
  4695. ** [sqlite3_load_extension()] interface shall attempt to
  4696. ** fill *pzErrMsg with error message text stored in memory
  4697. ** obtained from [sqlite3_malloc()]. The calling function
  4698. ** should free this memory by calling [sqlite3_free()].
  4699. **
  4700. ** ^Extension loading must be enabled using
  4701. ** [sqlite3_enable_load_extension()] prior to calling this API,
  4702. ** otherwise an error will be returned.
  4703. **
  4704. ** See also the [load_extension() SQL function].
  4705. */
  4706. //SQLITE_API int sqlite3_load_extension(
  4707. // sqlite3 *db, /* Load the extension into this database connection */
  4708. // const char *zFile, /* Name of the shared library containing extension */
  4709. // const char *zProc, /* Entry point. Derived from zFile if 0 */
  4710. // char **pzErrMsg /* Put error message here if not 0 */
  4711. //);
  4712. /*
  4713. ** CAPI3REF: Enable Or Disable Extension Loading
  4714. **
  4715. ** ^So as not to open security holes in older applications that are
  4716. ** unprepared to deal with extension loading, and as a means of disabling
  4717. ** extension loading while evaluating user-entered SQL, the following API
  4718. ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
  4719. **
  4720. ** ^Extension loading is off by default. See ticket #1863.
  4721. ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
  4722. ** to turn extension loading on and call it with onoff==0 to turn
  4723. ** it back off again.
  4724. */
  4725. //SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  4726. /*
  4727. ** CAPI3REF: Automatically Load Statically Linked Extensions
  4728. **
  4729. ** ^This interface causes the xEntryPoint() function to be invoked for
  4730. ** each new [database connection] that is created. The idea here is that
  4731. ** xEntryPoint() is the entry point for a statically linked SQLite extension
  4732. ** that is to be automatically loaded into all new database connections.
  4733. **
  4734. ** ^(Even though the function prototype shows that xEntryPoint() takes
  4735. ** no arguments and returns void, SQLite invokes xEntryPoint() with three
  4736. ** arguments and expects and integer result as if the signature of the
  4737. ** entry point where as follows:
  4738. **
  4739. ** <blockquote><pre>
  4740. ** &nbsp; int xEntryPoint(
  4741. ** &nbsp; sqlite3 *db,
  4742. ** &nbsp; const char **pzErrMsg,
  4743. ** &nbsp; const struct sqlite3_api_routines *pThunk
  4744. ** &nbsp; );
  4745. ** </pre></blockquote>)^
  4746. **
  4747. ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
  4748. ** point to an appropriate error message (obtained from [sqlite3_mprintf()])
  4749. ** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg
  4750. ** is NULL before calling the xEntryPoint(). ^SQLite will invoke
  4751. ** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any
  4752. ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],
  4753. ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.
  4754. **
  4755. ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
  4756. ** on the list of automatic extensions is a harmless no-op. ^No entry point
  4757. ** will be called more than once for each database connection that is opened.
  4758. **
  4759. ** See also: [sqlite3_reset_auto_extension()].
  4760. */
  4761. //SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
  4762. /*
  4763. ** CAPI3REF: Reset Automatic Extension Loading
  4764. **
  4765. ** ^This interface disables all automatic extensions previously
  4766. ** registered using [sqlite3_auto_extension()].
  4767. */
  4768. //SQLITE_API void sqlite3_reset_auto_extension(void);
  4769. /*
  4770. ** The interface to the virtual-table mechanism is currently considered
  4771. ** to be experimental. The interface might change in incompatible ways.
  4772. ** If this is a problem for you, do not use the interface at this time.
  4773. **
  4774. ** When the virtual-table mechanism stabilizes, we will declare the
  4775. ** interface fixed, support it indefinitely, and remove this comment.
  4776. */
  4777. /*
  4778. ** Structures used by the virtual table interface
  4779. */
  4780. //typedef struct sqlite3_vtab sqlite3_vtab;
  4781. //typedef struct sqlite3_index_info sqlite3_index_info;
  4782. //typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
  4783. //typedef struct sqlite3_module sqlite3_module;
  4784. /*
  4785. ** CAPI3REF: Virtual Table Object
  4786. ** KEYWORDS: sqlite3_module {virtual table module}
  4787. **
  4788. ** This structure, sometimes called a a "virtual table module",
  4789. ** defines the implementation of a [virtual tables].
  4790. ** This structure consists mostly of methods for the module.
  4791. **
  4792. ** ^A virtual table module is created by filling in a persistent
  4793. ** instance of this structure and passing a pointer to that instance
  4794. ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
  4795. ** ^The registration remains valid until it is replaced by a different
  4796. ** module or until the [database connection] closes. The content
  4797. ** of this structure must not change while it is registered with
  4798. ** any database connection.
  4799. */
  4800. //struct sqlite3_module {
  4801. // int iVersion;
  4802. // int (*xCreate)(sqlite3*, void *pAux,
  4803. // int argc, const char *const*argv,
  4804. // sqlite3_vtab **ppVTab, char**);
  4805. // int (*xConnect)(sqlite3*, void *pAux,
  4806. // int argc, const char *const*argv,
  4807. // sqlite3_vtab **ppVTab, char**);
  4808. // int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
  4809. // int (*xDisconnect)(sqlite3_vtab *pVTab);
  4810. // int (*xDestroy)(sqlite3_vtab *pVTab);
  4811. // int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
  4812. // int (*xClose)(sqlite3_vtab_cursor*);
  4813. // int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
  4814. // int argc, sqlite3_value **argv);
  4815. // int (*xNext)(sqlite3_vtab_cursor*);
  4816. // int (*xEof)(sqlite3_vtab_cursor*);
  4817. // int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
  4818. // int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
  4819. // int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
  4820. // int (*xBegin)(sqlite3_vtab *pVTab);
  4821. // int (*xSync)(sqlite3_vtab *pVTab);
  4822. // int (*xCommit)(sqlite3_vtab *pVTab);
  4823. // int (*xRollback)(sqlite3_vtab *pVTab);
  4824. // int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
  4825. // void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
  4826. // void **ppArg);
  4827. // int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
  4828. //};
  4829. // MINIMAL STRUCTURE
  4830. public class sqlite3_module
  4831. {
  4832. public int iVersion;
  4833. public smdxCreate xCreate;
  4834. public smdxConnect xConnect;
  4835. public smdxBestIndex xBestIndex;
  4836. public smdxDisconnect xDisconnect;
  4837. public smdxDestroy xDestroy;
  4838. public smdxOpen xOpen;
  4839. public smdxClose xClose;
  4840. public smdxFilter xFilter;
  4841. public smdxNext xNext;
  4842. public smdxEof xEof;
  4843. public smdxColumn xColumn;
  4844. public smdxRowid xRowid;
  4845. public smdxUpdate xUpdate;
  4846. public smdxBegin xBegin;
  4847. public smdxSync xSync;
  4848. public smdxCommit xCommit;
  4849. public smdxRollback xRollback;
  4850. public smdxFindFunction xFindFunction;
  4851. public smdxRename xRename;
  4852. }
  4853. /*
  4854. ** CAPI3REF: Virtual Table Indexing Information
  4855. ** KEYWORDS: sqlite3_index_info
  4856. **
  4857. ** The sqlite3_index_info structure and its substructures is used as part
  4858. ** of the [virtual table] interface to
  4859. ** pass information into and receive the reply from the [xBestIndex]
  4860. ** method of a [virtual table module]. The fields under **Inputs** are the
  4861. ** inputs to xBestIndex and are read-only. xBestIndex inserts its
  4862. ** results into the **Outputs** fields.
  4863. **
  4864. ** ^(The aConstraint[] array records WHERE clause constraints of the form:
  4865. **
  4866. ** <blockquote>column OP expr</blockquote>
  4867. **
  4868. ** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^ ^(The particular operator is
  4869. ** stored in aConstraint[].op using one of the
  4870. ** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^
  4871. ** ^(The index of the column is stored in
  4872. ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the
  4873. ** expr on the right-hand side can be evaluated (and thus the constraint
  4874. ** is usable) and false if it cannot.)^
  4875. **
  4876. ** ^The optimizer automatically inverts terms of the form "expr OP column"
  4877. ** and makes other simplifications to the WHERE clause in an attempt to
  4878. ** get as many WHERE clause terms into the form shown above as possible.
  4879. ** ^The aConstraint[] array only reports WHERE clause terms that are
  4880. ** relevant to the particular virtual table being queried.
  4881. **
  4882. ** ^Information about the ORDER BY clause is stored in aOrderBy[].
  4883. ** ^Each term of aOrderBy records a column of the ORDER BY clause.
  4884. **
  4885. ** The [xBestIndex] method must fill aConstraintUsage[] with information
  4886. ** about what parameters to pass to xFilter. ^If argvIndex>0 then
  4887. ** the right-hand side of the corresponding aConstraint[] is evaluated
  4888. ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
  4889. ** is true, then the constraint is assumed to be fully handled by the
  4890. ** virtual table and is not checked again by SQLite.)^
  4891. **
  4892. ** ^The idxNum and idxPtr values are recorded and passed into the
  4893. ** [xFilter] method.
  4894. ** ^[sqlite3_free()] is used to free idxPtr if and only if
  4895. ** needToFreeIdxPtr is true.
  4896. **
  4897. ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
  4898. ** the correct order to satisfy the ORDER BY clause so that no separate
  4899. ** sorting step is required.
  4900. **
  4901. ** ^The estimatedCost value is an estimate of the cost of doing the
  4902. ** particular lookup. A full scan of a table with N entries should have
  4903. ** a cost of N. A binary search of a table of N entries should have a
  4904. ** cost of approximately log(N).
  4905. */
  4906. //struct sqlite3_index_info {
  4907. // /* Inputs */
  4908. // int nConstraint; /* Number of entries in aConstraint */
  4909. // struct sqlite3_index_constraint {
  4910. // int iColumn; /* Column on left-hand side of constraint */
  4911. // unsigned char op; /* Constraint operator */
  4912. // unsigned char usable; /* True if this constraint is usable */
  4913. // int iTermOffset; /* Used internally - xBestIndex should ignore */
  4914. // } *aConstraint; /* Table of WHERE clause constraints */
  4915. // int nOrderBy; /* Number of terms in the ORDER BY clause */
  4916. // struct sqlite3_index_orderby {
  4917. // int iColumn; /* Column number */
  4918. // unsigned char desc; /* True for DESC. False for ASC. */
  4919. // } *aOrderBy; /* The ORDER BY clause */
  4920. // /* Outputs */
  4921. // struct sqlite3_index_constraint_usage {
  4922. // int argvIndex; /* if >0, constraint is part of argv to xFilter */
  4923. // unsigned char omit; /* Do not code a test for this constraint */
  4924. // } *aConstraintUsage;
  4925. // int idxNum; /* Number used to identify the index */
  4926. // char *idxStr; /* String, possibly obtained from sqlite3_malloc */
  4927. // int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
  4928. // int orderByConsumed; /* True if output is already ordered */
  4929. // double estimatedCost; /* Estimated cost of using this index */
  4930. //};
  4931. public class sqlite3_index_constraint
  4932. {
  4933. public int iColumn; /* Column on left-hand side of constraint */
  4934. public int op; /* Constraint operator */
  4935. public bool usable; /* True if this constraint is usable */
  4936. public int iTermOffset; /* Used internally - xBestIndex should ignore */
  4937. }
  4938. public class sqlite3_index_orderby
  4939. {
  4940. public int iColumn; /* Column number */
  4941. public bool desc; /* True for DESC. False for ASC. */
  4942. }
  4943. public class sqlite3_index_constraint_usage
  4944. {
  4945. public int argvIndex; /* if >0, constraint is part of argv to xFilter */
  4946. public bool omit; /* Do not code a test for this constraint */
  4947. }
  4948. public class sqlite3_index_info
  4949. {
  4950. /* Inputs */
  4951. public int nConstraint; /* Number of entries in aConstraint */
  4952. public sqlite3_index_constraint[] aConstraint; /* Table of WHERE clause constraints */
  4953. public int nOrderBy; /* Number of terms in the ORDER BY clause */
  4954. public sqlite3_index_orderby[] aOrderBy;/* The ORDER BY clause */
  4955. /* Outputs */
  4956. public sqlite3_index_constraint_usage[] aConstraintUsage;
  4957. public int idxNum; /* Number used to identify the index */
  4958. public string idxStr; /* String, possibly obtained from sqlite3Malloc */
  4959. public int needToFreeIdxStr; /* Free idxStr using sqlite3DbFree(db,) if true */
  4960. public bool orderByConsumed; /* True if output is already ordered */
  4961. public double estimatedCost; /* Estimated cost of using this index */
  4962. }
  4963. /*
  4964. ** CAPI3REF: Virtual Table Constraint Operator Codes
  4965. **
  4966. ** These macros defined the allowed values for the
  4967. ** [sqlite3_index_info].aConstraint[].op field. Each value represents
  4968. ** an operator that is part of a constraint term in the wHERE clause of
  4969. ** a query that uses a [virtual table].
  4970. */
  4971. //#define SQLITE_INDEX_CONSTRAINT_EQ 2
  4972. //#define SQLITE_INDEX_CONSTRAINT_GT 4
  4973. //#define SQLITE_INDEX_CONSTRAINT_LE 8
  4974. //#define SQLITE_INDEX_CONSTRAINT_LT 16
  4975. //#define SQLITE_INDEX_CONSTRAINT_GE 32
  4976. //#define SQLITE_INDEX_CONSTRAINT_MATCH 64
  4977. const int SQLITE_INDEX_CONSTRAINT_EQ = 2;
  4978. const int SQLITE_INDEX_CONSTRAINT_GT = 4;
  4979. const int SQLITE_INDEX_CONSTRAINT_LE = 8;
  4980. const int SQLITE_INDEX_CONSTRAINT_LT = 16;
  4981. const int SQLITE_INDEX_CONSTRAINT_GE = 32;
  4982. const int SQLITE_INDEX_CONSTRAINT_MATCH = 64;
  4983. /*
  4984. ** CAPI3REF: Register A Virtual Table Implementation
  4985. **
  4986. ** ^These routines are used to register a new [virtual table module] name.
  4987. ** ^Module names must be registered before
  4988. ** creating a new [virtual table] using the module and before using a
  4989. ** preexisting [virtual table] for the module.
  4990. **
  4991. ** ^The module name is registered on the [database connection] specified
  4992. ** by the first parameter. ^The name of the module is given by the
  4993. ** second parameter. ^The third parameter is a pointer to
  4994. ** the implementation of the [virtual table module]. ^The fourth
  4995. ** parameter is an arbitrary client data pointer that is passed through
  4996. ** into the [xCreate] and [xConnect] methods of the virtual table module
  4997. ** when a new virtual table is be being created or reinitialized.
  4998. **
  4999. ** ^The sqlite3_create_module_v2() interface has a fifth parameter which
  5000. ** is a pointer to a destructor for the pClientData. ^SQLite will
  5001. ** invoke the destructor function (if it is not NULL) when SQLite
  5002. ** no longer needs the pClientData pointer. ^The destructor will also
  5003. ** be invoked if the call to sqlite3_create_module_v2() fails.
  5004. ** ^The sqlite3_create_module()
  5005. ** interface is equivalent to sqlite3_create_module_v2() with a NULL
  5006. ** destructor.
  5007. */
  5008. //SQLITE_API int sqlite3_create_module(
  5009. // sqlite3 *db, /* SQLite connection to register module with */
  5010. // const char *zName, /* Name of the module */
  5011. // const sqlite3_module *p, /* Methods for the module */
  5012. // void *pClientData /* Client data for xCreate/xConnect */
  5013. //);
  5014. //SQLITE_API int sqlite3_create_module_v2(
  5015. // sqlite3 *db, /* SQLite connection to register module with */
  5016. // const char *zName, /* Name of the module */
  5017. // const sqlite3_module *p, /* Methods for the module */
  5018. // void *pClientData, /* Client data for xCreate/xConnect */
  5019. // void(*xDestroy)(void*) /* Module destructor function */
  5020. //);
  5021. /*
  5022. ** CAPI3REF: Virtual Table Instance Object
  5023. ** KEYWORDS: sqlite3_vtab
  5024. **
  5025. ** Every [virtual table module] implementation uses a subclass
  5026. ** of this object to describe a particular instance
  5027. ** of the [virtual table]. Each subclass will
  5028. ** be tailored to the specific needs of the module implementation.
  5029. ** The purpose of this superclass is to define certain fields that are
  5030. ** common to all module implementations.
  5031. **
  5032. ** ^Virtual tables methods can set an error message by assigning a
  5033. ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
  5034. ** take care that any prior string is freed by a call to [sqlite3_free()]
  5035. ** prior to assigning a new string to zErrMsg. ^After the error message
  5036. ** is delivered up to the client application, the string will be automatically
  5037. ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
  5038. */
  5039. //struct sqlite3_vtab {
  5040. // const sqlite3_module *pModule; /* The module for this virtual table */
  5041. // int nRef; /* NO LONGER USED */
  5042. // char *zErrMsg; /* Error message from sqlite3_mprintf() */
  5043. // /* Virtual table implementations will typically add additional fields */
  5044. //};
  5045. public struct sqlite3_vtab
  5046. {
  5047. public sqlite3_module pModule; /* The module for this virtual table */
  5048. public int nRef; /* Used internally */
  5049. public string zErrMsg; /* Error message from sqlite3_mprintf() */
  5050. /* Virtual table implementations will typically add additional fields */
  5051. };
  5052. /*
  5053. ** CAPI3REF: Virtual Table Cursor Object
  5054. ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
  5055. **
  5056. ** Every [virtual table module] implementation uses a subclass of the
  5057. ** following structure to describe cursors that point into the
  5058. ** [virtual table] and are used
  5059. ** to loop through the virtual table. Cursors are created using the
  5060. ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
  5061. ** by the [sqlite3_module.xClose | xClose] method. Cursors are used
  5062. ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
  5063. ** of the module. Each module implementation will define
  5064. ** the content of a cursor structure to suit its own needs.
  5065. **
  5066. ** This superclass exists in order to define fields of the cursor that
  5067. ** are common to all implementations.
  5068. */
  5069. //struct sqlite3_vtab_cursor {
  5070. // sqlite3_vtab *pVtab; /* Virtual table of this cursor */
  5071. // /* Virtual table implementations will typically add additional fields */
  5072. //};
  5073. public class sqlite3_vtab_cursor
  5074. {
  5075. sqlite3_vtab pVtab; /* Virtual table of this cursor */
  5076. /* Virtual table implementations will typically add additional fields */
  5077. };
  5078. /*
  5079. ** CAPI3REF: Declare The Schema Of A Virtual Table
  5080. **
  5081. ** ^The [xCreate] and [xConnect] methods of a
  5082. ** [virtual table module] call this interface
  5083. ** to declare the format (the names and datatypes of the columns) of
  5084. ** the virtual tables they implement.
  5085. */
  5086. //SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  5087. /*
  5088. ** CAPI3REF: Overload A Function For A Virtual Table
  5089. **
  5090. ** ^(Virtual tables can provide alternative implementations of functions
  5091. ** using the [xFindFunction] method of the [virtual table module].
  5092. ** But global versions of those functions
  5093. ** must exist in order to be overloaded.)^
  5094. **
  5095. ** ^(This API makes sure a global version of a function with a particular
  5096. ** name and number of parameters exists. If no such function exists
  5097. ** before this API is called, a new function is created.)^ ^The implementation
  5098. ** of the new function always causes an exception to be thrown. So
  5099. ** the new function is not good for anything by itself. Its only
  5100. ** purpose is to be a placeholder function that can be overloaded
  5101. ** by a [virtual table].
  5102. */
  5103. //SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  5104. /*
  5105. ** The interface to the virtual-table mechanism defined above (back up
  5106. ** to a comment remarkably similar to this one) is currently considered
  5107. ** to be experimental. The interface might change in incompatible ways.
  5108. ** If this is a problem for you, do not use the interface at this time.
  5109. **
  5110. ** When the virtual-table mechanism stabilizes, we will declare the
  5111. ** interface fixed, support it indefinitely, and remove this comment.
  5112. */
  5113. /*
  5114. ** CAPI3REF: A Handle To An Open BLOB
  5115. ** KEYWORDS: {BLOB handle} {BLOB handles}
  5116. **
  5117. ** An instance of this object represents an open BLOB on which
  5118. ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
  5119. ** ^Objects of this type are created by [sqlite3_blob_open()]
  5120. ** and destroyed by [sqlite3_blob_close()].
  5121. ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
  5122. ** can be used to read or write small subsections of the BLOB.
  5123. ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
  5124. */
  5125. //typedef struct sqlite3_blob sqlite3_blob;
  5126. /*
  5127. ** CAPI3REF: Open A BLOB For Incremental I/O
  5128. **
  5129. ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
  5130. ** in row iRow, column zColumn, table zTable in database zDb;
  5131. ** in other words, the same BLOB that would be selected by:
  5132. **
  5133. ** <pre>
  5134. ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
  5135. ** </pre>)^
  5136. **
  5137. ** ^If the flags parameter is non-zero, then the BLOB is opened for read
  5138. ** and write access. ^If it is zero, the BLOB is opened for read access.
  5139. ** ^It is not possible to open a column that is part of an index or primary
  5140. ** key for writing. ^If [foreign key constraints] are enabled, it is
  5141. ** not possible to open a column that is part of a [child key] for writing.
  5142. **
  5143. ** ^Note that the database name is not the filename that contains
  5144. ** the database but rather the symbolic name of the database that
  5145. ** appears after the AS keyword when the database is connected using [ATTACH].
  5146. ** ^For the main database file, the database name is "main".
  5147. ** ^For TEMP tables, the database name is "temp".
  5148. **
  5149. ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
  5150. ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
  5151. ** to be a null pointer.)^
  5152. ** ^This function sets the [database connection] error code and message
  5153. ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
  5154. ** functions. ^Note that the *ppBlob variable is always initialized in a
  5155. ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
  5156. ** regardless of the success or failure of this routine.
  5157. **
  5158. ** ^(If the row that a BLOB handle points to is modified by an
  5159. ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
  5160. ** then the BLOB handle is marked as "expired".
  5161. ** This is true if any column of the row is changed, even a column
  5162. ** other than the one the BLOB handle is open on.)^
  5163. ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
  5164. ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
  5165. ** ^(Changes written into a BLOB prior to the BLOB expiring are not
  5166. ** rolled back by the expiration of the BLOB. Such changes will eventually
  5167. ** commit if the transaction continues to completion.)^
  5168. **
  5169. ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
  5170. ** the opened blob. ^The size of a blob may not be changed by this
  5171. ** interface. Use the [UPDATE] SQL command to change the size of a
  5172. ** blob.
  5173. **
  5174. ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
  5175. ** and the built-in [zeroblob] SQL function can be used, if desired,
  5176. ** to create an empty, zero-filled blob in which to read or write using
  5177. ** this interface.
  5178. **
  5179. ** To avoid a resource leak, every open [BLOB handle] should eventually
  5180. ** be released by a call to [sqlite3_blob_close()].
  5181. */
  5182. //SQLITE_API int sqlite3_blob_open(
  5183. // sqlite3*,
  5184. // const char *zDb,
  5185. // const char *zTable,
  5186. // const char *zColumn,
  5187. // sqlite3_int64 iRow,
  5188. // int flags,
  5189. // sqlite3_blob **ppBlob
  5190. //);
  5191. /*
  5192. ** CAPI3REF: Move a BLOB Handle to a New Row
  5193. **
  5194. ** ^This function is used to move an existing blob handle so that it points
  5195. ** to a different row of the same database table. ^The new row is identified
  5196. ** by the rowid value passed as the second argument. Only the row can be
  5197. ** changed. ^The database, table and column on which the blob handle is open
  5198. ** remain the same. Moving an existing blob handle to a new row can be
  5199. ** faster than closing the existing handle and opening a new one.
  5200. **
  5201. ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -
  5202. ** it must exist and there must be either a blob or text value stored in
  5203. ** the nominated column.)^ ^If the new row is not present in the table, or if
  5204. ** it does not contain a blob or text value, or if another error occurs, an
  5205. ** SQLite error code is returned and the blob handle is considered aborted.
  5206. ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or
  5207. ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return
  5208. ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
  5209. ** always returns zero.
  5210. **
  5211. ** ^This function sets the database handle error code and message.
  5212. */
  5213. //SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  5214. /*
  5215. ** CAPI3REF: Close A BLOB Handle
  5216. **
  5217. ** ^Closes an open [BLOB handle].
  5218. **
  5219. ** ^Closing a BLOB shall cause the current transaction to commit
  5220. ** if there are no other BLOBs, no pending prepared statements, and the
  5221. ** database connection is in [autocommit mode].
  5222. ** ^If any writes were made to the BLOB, they might be held in cache
  5223. ** until the close operation if they will fit.
  5224. **
  5225. ** ^(Closing the BLOB often forces the changes
  5226. ** out to disk and so if any I/O errors occur, they will likely occur
  5227. ** at the time when the BLOB is closed. Any errors that occur during
  5228. ** closing are reported as a non-zero return value.)^
  5229. **
  5230. ** ^(The BLOB is closed unconditionally. Even if this routine returns
  5231. ** an error code, the BLOB is still closed.)^
  5232. **
  5233. ** ^Calling this routine with a null pointer (such as would be returned
  5234. ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
  5235. */
  5236. //SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
  5237. /*
  5238. ** CAPI3REF: Return The Size Of An Open BLOB
  5239. **
  5240. ** ^Returns the size in bytes of the BLOB accessible via the
  5241. ** successfully opened [BLOB handle] in its only argument. ^The
  5242. ** incremental blob I/O routines can only read or overwriting existing
  5243. ** blob content; they cannot change the size of a blob.
  5244. **
  5245. ** This routine only works on a [BLOB handle] which has been created
  5246. ** by a prior successful call to [sqlite3_blob_open()] and which has not
  5247. ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
  5248. ** to this routine results in undefined and probably undesirable behavior.
  5249. */
  5250. //SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
  5251. /*
  5252. ** CAPI3REF: Read Data From A BLOB Incrementally
  5253. **
  5254. ** ^(This function is used to read data from an open [BLOB handle] into a
  5255. ** caller-supplied buffer. N bytes of data are copied into buffer Z
  5256. ** from the open BLOB, starting at offset iOffset.)^
  5257. **
  5258. ** ^If offset iOffset is less than N bytes from the end of the BLOB,
  5259. ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is
  5260. ** less than zero, [SQLITE_ERROR] is returned and no data is read.
  5261. ** ^The size of the blob (and hence the maximum value of N+iOffset)
  5262. ** can be determined using the [sqlite3_blob_bytes()] interface.
  5263. **
  5264. ** ^An attempt to read from an expired [BLOB handle] fails with an
  5265. ** error code of [SQLITE_ABORT].
  5266. **
  5267. ** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
  5268. ** Otherwise, an [error code] or an [extended error code] is returned.)^
  5269. **
  5270. ** This routine only works on a [BLOB handle] which has been created
  5271. ** by a prior successful call to [sqlite3_blob_open()] and which has not
  5272. ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
  5273. ** to this routine results in undefined and probably undesirable behavior.
  5274. **
  5275. ** See also: [sqlite3_blob_write()].
  5276. */
  5277. //SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  5278. /*
  5279. ** CAPI3REF: Write Data Into A BLOB Incrementally
  5280. **
  5281. ** ^This function is used to write data into an open [BLOB handle] from a
  5282. ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
  5283. ** into the open BLOB, starting at offset iOffset.
  5284. **
  5285. ** ^If the [BLOB handle] passed as the first argument was not opened for
  5286. ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
  5287. ** this function returns [SQLITE_READONLY].
  5288. **
  5289. ** ^This function may only modify the contents of the BLOB; it is
  5290. ** not possible to increase the size of a BLOB using this API.
  5291. ** ^If offset iOffset is less than N bytes from the end of the BLOB,
  5292. ** [SQLITE_ERROR] is returned and no data is written. ^If N is
  5293. ** less than zero [SQLITE_ERROR] is returned and no data is written.
  5294. ** The size of the BLOB (and hence the maximum value of N+iOffset)
  5295. ** can be determined using the [sqlite3_blob_bytes()] interface.
  5296. **
  5297. ** ^An attempt to write to an expired [BLOB handle] fails with an
  5298. ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
  5299. ** before the [BLOB handle] expired are not rolled back by the
  5300. ** expiration of the handle, though of course those changes might
  5301. ** have been overwritten by the statement that expired the BLOB handle
  5302. ** or by other independent statements.
  5303. **
  5304. ** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  5305. ** Otherwise, an [error code] or an [extended error code] is returned.)^
  5306. **
  5307. ** This routine only works on a [BLOB handle] which has been created
  5308. ** by a prior successful call to [sqlite3_blob_open()] and which has not
  5309. ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
  5310. ** to this routine results in undefined and probably undesirable behavior.
  5311. **
  5312. ** See also: [sqlite3_blob_read()].
  5313. */
  5314. //SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  5315. /*
  5316. ** CAPI3REF: Virtual File System Objects
  5317. **
  5318. ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
  5319. ** that SQLite uses to interact
  5320. ** with the underlying operating system. Most SQLite builds come with a
  5321. ** single default VFS that is appropriate for the host computer.
  5322. ** New VFSes can be registered and existing VFSes can be unregistered.
  5323. ** The following interfaces are provided.
  5324. **
  5325. ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
  5326. ** ^Names are case sensitive.
  5327. ** ^Names are zero-terminated UTF-8 strings.
  5328. ** ^If there is no match, a NULL pointer is returned.
  5329. ** ^If zVfsName is NULL then the default VFS is returned.
  5330. **
  5331. ** ^New VFSes are registered with sqlite3_vfs_register().
  5332. ** ^Each new VFS becomes the default VFS if the makeDflt flag is set.
  5333. ** ^The same VFS can be registered multiple times without injury.
  5334. ** ^To make an existing VFS into the default VFS, register it again
  5335. ** with the makeDflt flag set. If two different VFSes with the
  5336. ** same name are registered, the behavior is undefined. If a
  5337. ** VFS is registered with a name that is NULL or an empty string,
  5338. ** then the behavior is undefined.
  5339. **
  5340. ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
  5341. ** ^(If the default VFS is unregistered, another VFS is chosen as
  5342. ** the default. The choice for the new VFS is arbitrary.)^
  5343. */
  5344. //SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
  5345. //SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  5346. //SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
  5347. /*
  5348. ** CAPI3REF: Mutexes
  5349. **
  5350. ** The SQLite core uses these routines for thread
  5351. ** synchronization. Though they are intended for internal
  5352. ** use by SQLite, code that links against SQLite is
  5353. ** permitted to use any of these routines.
  5354. **
  5355. ** The SQLite source code contains multiple implementations
  5356. ** of these mutex routines. An appropriate implementation
  5357. ** is selected automatically at compile-time. ^(The following
  5358. ** implementations are available in the SQLite core:
  5359. **
  5360. ** <ul>
  5361. ** <li> SQLITE_MUTEX_OS2
  5362. ** <li> SQLITE_MUTEX_PTHREAD
  5363. ** <li> SQLITE_MUTEX_W32
  5364. ** <li> SQLITE_MUTEX_NOOP
  5365. ** </ul>)^
  5366. **
  5367. ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
  5368. ** that does no real locking and is appropriate for use in
  5369. ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
  5370. ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
  5371. ** are appropriate for use on OS/2, Unix, and Windows.
  5372. **
  5373. ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  5374. ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
  5375. ** implementation is included with the library. In this case the
  5376. ** application must supply a custom mutex implementation using the
  5377. ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
  5378. ** before calling sqlite3_initialize() or any other public sqlite3_
  5379. ** function that calls sqlite3_initialize().)^
  5380. **
  5381. ** ^The sqlite3_mutex_alloc() routine allocates a new
  5382. ** mutex and returns a pointer to it. ^If it returns NULL
  5383. ** that means that a mutex could not be allocated. ^SQLite
  5384. ** will unwind its stack and return an error. ^(The argument
  5385. ** to sqlite3_mutex_alloc() is one of these integer constants:
  5386. **
  5387. ** <ul>
  5388. ** <li> SQLITE_MUTEX_FAST
  5389. ** <li> SQLITE_MUTEX_RECURSIVE
  5390. ** <li> SQLITE_MUTEX_STATIC_MASTER
  5391. ** <li> SQLITE_MUTEX_STATIC_MEM
  5392. ** <li> SQLITE_MUTEX_STATIC_MEM2
  5393. ** <li> SQLITE_MUTEX_STATIC_PRNG
  5394. ** <li> SQLITE_MUTEX_STATIC_LRU
  5395. ** <li> SQLITE_MUTEX_STATIC_LRU2
  5396. ** </ul>)^
  5397. **
  5398. ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
  5399. ** cause sqlite3_mutex_alloc() to create
  5400. ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
  5401. ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
  5402. ** The mutex implementation does not need to make a distinction
  5403. ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
  5404. ** not want to. ^SQLite will only request a recursive mutex in
  5405. ** cases where it really needs one. ^If a faster non-recursive mutex
  5406. ** implementation is available on the host platform, the mutex subsystem
  5407. ** might return such a mutex in response to SQLITE_MUTEX_FAST.
  5408. **
  5409. ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
  5410. ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
  5411. ** a pointer to a static preexisting mutex. ^Six static mutexes are
  5412. ** used by the current version of SQLite. Future versions of SQLite
  5413. ** may add additional static mutexes. Static mutexes are for internal
  5414. ** use by SQLite only. Applications that use SQLite mutexes should
  5415. ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
  5416. ** SQLITE_MUTEX_RECURSIVE.
  5417. **
  5418. ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
  5419. ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
  5420. ** returns a different mutex on every call. ^But for the static
  5421. ** mutex types, the same mutex is returned on every call that has
  5422. ** the same type number.
  5423. **
  5424. ** ^The sqlite3_mutex_free() routine deallocates a previously
  5425. ** allocated dynamic mutex. ^SQLite is careful to deallocate every
  5426. ** dynamic mutex that it allocates. The dynamic mutexes must not be in
  5427. ** use when they are deallocated. Attempting to deallocate a static
  5428. ** mutex results in undefined behavior. ^SQLite never deallocates
  5429. ** a static mutex.
  5430. **
  5431. ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
  5432. ** to enter a mutex. ^If another thread is already within the mutex,
  5433. ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
  5434. ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
  5435. ** upon successful entry. ^(Mutexes created using
  5436. ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
  5437. ** In such cases the,
  5438. ** mutex must be exited an equal number of times before another thread
  5439. ** can enter.)^ ^(If the same thread tries to enter any other
  5440. ** kind of mutex more than once, the behavior is undefined.
  5441. ** SQLite will never exhibit
  5442. ** such behavior in its own use of mutexes.)^
  5443. **
  5444. ** ^(Some systems (for example, Windows 95) do not support the operation
  5445. ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
  5446. ** will always return SQLITE_BUSY. The SQLite core only ever uses
  5447. ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
  5448. **
  5449. ** ^The sqlite3_mutex_leave() routine exits a mutex that was
  5450. ** previously entered by the same thread. ^(The behavior
  5451. ** is undefined if the mutex is not currently entered by the
  5452. ** calling thread or is not currently allocated. SQLite will
  5453. ** never do either.)^
  5454. **
  5455. ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
  5456. ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
  5457. ** behave as no-ops.
  5458. **
  5459. ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
  5460. */
  5461. //SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
  5462. //SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
  5463. //SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
  5464. //SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
  5465. //SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
  5466. /*
  5467. ** CAPI3REF: Mutex Methods Object
  5468. **
  5469. ** An instance of this structure defines the low-level routines
  5470. ** used to allocate and use mutexes.
  5471. **
  5472. ** Usually, the default mutex implementations provided by SQLite are
  5473. ** sufficient, however the user has the option of substituting a custom
  5474. ** implementation for specialized deployments or systems for which SQLite
  5475. ** does not provide a suitable implementation. In this case, the user
  5476. ** creates and populates an instance of this structure to pass
  5477. ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
  5478. ** Additionally, an instance of this structure can be used as an
  5479. ** output variable when querying the system for the current mutex
  5480. ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
  5481. **
  5482. ** ^The xMutexInit method defined by this structure is invoked as
  5483. ** part of system initialization by the sqlite3_initialize() function.
  5484. ** ^The xMutexInit routine is called by SQLite exactly once for each
  5485. ** effective call to [sqlite3_initialize()].
  5486. **
  5487. ** ^The xMutexEnd method defined by this structure is invoked as
  5488. ** part of system shutdown by the sqlite3_shutdown() function. The
  5489. ** implementation of this method is expected to release all outstanding
  5490. ** resources obtained by the mutex methods implementation, especially
  5491. ** those obtained by the xMutexInit method. ^The xMutexEnd()
  5492. ** interface is invoked exactly once for each call to [sqlite3_shutdown()].
  5493. **
  5494. ** ^(The remaining seven methods defined by this structure (xMutexAlloc,
  5495. ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
  5496. ** xMutexNotheld) implement the following interfaces (respectively):
  5497. **
  5498. ** <ul>
  5499. ** <li> [sqlite3_mutex_alloc()] </li>
  5500. ** <li> [sqlite3_mutex_free()] </li>
  5501. ** <li> [sqlite3_mutex_enter()] </li>
  5502. ** <li> [sqlite3_mutex_try()] </li>
  5503. ** <li> [sqlite3_mutex_leave()] </li>
  5504. ** <li> [sqlite3_mutex_held()] </li>
  5505. ** <li> [sqlite3_mutex_notheld()] </li>
  5506. ** </ul>)^
  5507. **
  5508. ** The only difference is that the public sqlite3_XXX functions enumerated
  5509. ** above silently ignore any invocations that pass a NULL pointer instead
  5510. ** of a valid mutex handle. The implementations of the methods defined
  5511. ** by this structure are not required to handle this case, the results
  5512. ** of passing a NULL pointer instead of a valid mutex handle are undefined
  5513. ** (i.e. it is acceptable to provide an implementation that segfaults if
  5514. ** it is passed a NULL pointer).
  5515. **
  5516. ** The xMutexInit() method must be threadsafe. ^It must be harmless to
  5517. ** invoke xMutexInit() multiple times within the same process and without
  5518. ** intervening calls to xMutexEnd(). Second and subsequent calls to
  5519. ** xMutexInit() must be no-ops.
  5520. **
  5521. ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  5522. ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory
  5523. ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
  5524. ** memory allocation for a fast or recursive mutex.
  5525. **
  5526. ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
  5527. ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
  5528. ** If xMutexInit fails in any way, it is expected to clean up after itself
  5529. ** prior to returning.
  5530. */
  5531. //typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
  5532. //struct sqlite3_mutex_methods {
  5533. // int (*xMutexInit)(void);
  5534. // int (*xMutexEnd)(void);
  5535. // sqlite3_mutex *(*xMutexAlloc)(int);
  5536. // void (*xMutexFree)(sqlite3_mutex *);
  5537. // void (*xMutexEnter)(sqlite3_mutex *);
  5538. // int (*xMutexTry)(sqlite3_mutex *);
  5539. // void (*xMutexLeave)(sqlite3_mutex *);
  5540. // int (*xMutexHeld)(sqlite3_mutex *);
  5541. // int (*xMutexNotheld)(sqlite3_mutex *);
  5542. //};
  5543. public class sqlite3_mutex_methods
  5544. {
  5545. public dxMutexInit xMutexInit;
  5546. public dxMutexEnd xMutexEnd;
  5547. public dxMutexAlloc xMutexAlloc;
  5548. public dxMutexFree xMutexFree;
  5549. public dxMutexEnter xMutexEnter;
  5550. public dxMutexTry xMutexTry;
  5551. public dxMutexLeave xMutexLeave;
  5552. public dxMutexHeld xMutexHeld;
  5553. public dxMutexNotheld xMutexNotheld;
  5554. public sqlite3_mutex_methods()
  5555. {
  5556. }
  5557. public sqlite3_mutex_methods(
  5558. dxMutexInit xMutexInit,
  5559. dxMutexEnd xMutexEnd,
  5560. dxMutexAlloc xMutexAlloc,
  5561. dxMutexFree xMutexFree,
  5562. dxMutexEnter xMutexEnter,
  5563. dxMutexTry xMutexTry,
  5564. dxMutexLeave xMutexLeave,
  5565. dxMutexHeld xMutexHeld,
  5566. dxMutexNotheld xMutexNotheld
  5567. )
  5568. {
  5569. this.xMutexInit = xMutexInit;
  5570. this.xMutexEnd = xMutexEnd;
  5571. this.xMutexAlloc = xMutexAlloc;
  5572. this.xMutexFree = xMutexFree;
  5573. this.xMutexEnter = xMutexEnter;
  5574. this.xMutexTry = xMutexTry;
  5575. this.xMutexLeave = xMutexLeave;
  5576. this.xMutexHeld = xMutexHeld;
  5577. this.xMutexNotheld = xMutexNotheld;
  5578. }
  5579. //Copy sqlite3_mutex_methods from existing
  5580. public void Copy( sqlite3_mutex_methods cp )
  5581. {
  5582. Debug.Assert( cp != null );
  5583. this.xMutexInit = cp.xMutexInit;
  5584. this.xMutexEnd = cp.xMutexEnd;
  5585. this.xMutexAlloc = cp.xMutexAlloc;
  5586. this.xMutexFree = cp.xMutexFree;
  5587. this.xMutexEnter = cp.xMutexEnter;
  5588. this.xMutexTry = cp.xMutexTry;
  5589. this.xMutexLeave = cp.xMutexLeave;
  5590. this.xMutexHeld = cp.xMutexHeld;
  5591. this.xMutexNotheld = cp.xMutexNotheld;
  5592. }
  5593. }
  5594. /*
  5595. ** CAPI3REF: Mutex Verification Routines
  5596. **
  5597. ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
  5598. ** are intended for use inside assert() statements. ^The SQLite core
  5599. ** never uses these routines except inside an assert() and applications
  5600. ** are advised to follow the lead of the core. ^The SQLite core only
  5601. ** provides implementations for these routines when it is compiled
  5602. ** with the SQLITE_DEBUG flag. ^External mutex implementations
  5603. ** are only required to provide these routines if SQLITE_DEBUG is
  5604. ** defined and if NDEBUG is not defined.
  5605. **
  5606. ** ^These routines should return true if the mutex in their argument
  5607. ** is held or not held, respectively, by the calling thread.
  5608. **
  5609. ** ^The implementation is not required to provided versions of these
  5610. ** routines that actually work. If the implementation does not provide working
  5611. ** versions of these routines, it should at least provide stubs that always
  5612. ** return true so that one does not get spurious assertion failures.
  5613. **
  5614. ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
  5615. ** the routine should return 1. This seems counter-intuitive since
  5616. ** clearly the mutex cannot be held if it does not exist. But the
  5617. ** the reason the mutex does not exist is because the build is not
  5618. ** using mutexes. And we do not want the assert() containing the
  5619. ** call to sqlite3_mutex_held() to fail, so a non-zero return is
  5620. ** the appropriate thing to do. ^The sqlite3_mutex_notheld()
  5621. ** interface should also return 1 when given a NULL pointer.
  5622. */
  5623. //#ifndef NDEBUG
  5624. //SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
  5625. //SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
  5626. //#endif
  5627. /*
  5628. ** CAPI3REF: Mutex Types
  5629. **
  5630. ** The [sqlite3_mutex_alloc()] interface takes a single argument
  5631. ** which is one of these integer constants.
  5632. **
  5633. ** The set of static mutexes may change from one SQLite release to the
  5634. ** next. Applications that override the built-in mutex logic must be
  5635. ** prepared to accommodate additional static mutexes.
  5636. */
  5637. //#define SQLITE_MUTEX_FAST 0
  5638. //#define SQLITE_MUTEX_RECURSIVE 1
  5639. //#define SQLITE_MUTEX_STATIC_MASTER 2
  5640. //#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */
  5641. //#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */
  5642. //#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */
  5643. //#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
  5644. //#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
  5645. //#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */
  5646. //#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */
  5647. const int SQLITE_MUTEX_FAST = 0;
  5648. const int SQLITE_MUTEX_RECURSIVE = 1;
  5649. const int SQLITE_MUTEX_STATIC_MASTER = 2;
  5650. const int SQLITE_MUTEX_STATIC_MEM = 3;
  5651. const int SQLITE_MUTEX_STATIC_MEM2 = 4;
  5652. const int SQLITE_MUTEX_STATIC_OPEN = 4;
  5653. const int SQLITE_MUTEX_STATIC_PRNG = 5;
  5654. const int SQLITE_MUTEX_STATIC_LRU = 6;
  5655. const int SQLITE_MUTEX_STATIC_LRU2 = 7;
  5656. const int SQLITE_MUTEX_STATIC_PMEM = 7;
  5657. /*
  5658. ** CAPI3REF: Retrieve the mutex for a database connection
  5659. **
  5660. ** ^This interface returns a pointer the [sqlite3_mutex] object that
  5661. ** serializes access to the [database connection] given in the argument
  5662. ** when the [threading mode] is Serialized.
  5663. ** ^If the [threading mode] is Single-thread or Multi-thread then this
  5664. ** routine returns a NULL pointer.
  5665. */
  5666. //SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
  5667. /*
  5668. ** CAPI3REF: Low-Level Control Of Database Files
  5669. **
  5670. ** ^The [sqlite3_file_control()] interface makes a direct call to the
  5671. ** xFileControl method for the [sqlite3_io_methods] object associated
  5672. ** with a particular database identified by the second argument. ^The
  5673. ** name of the database is "main" for the main database or "temp" for the
  5674. ** TEMP database, or the name that appears after the AS keyword for
  5675. ** databases that are added using the [ATTACH] SQL command.
  5676. ** ^A NULL pointer can be used in place of "main" to refer to the
  5677. ** main database file.
  5678. ** ^The third and fourth parameters to this routine
  5679. ** are passed directly through to the second and third parameters of
  5680. ** the xFileControl method. ^The return value of the xFileControl
  5681. ** method becomes the return value of this routine.
  5682. **
  5683. ** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes
  5684. ** a pointer to the underlying [sqlite3_file] object to be written into
  5685. ** the space pointed to by the 4th parameter. ^The SQLITE_FCNTL_FILE_POINTER
  5686. ** case is a short-circuit path which does not actually invoke the
  5687. ** underlying sqlite3_io_methods.xFileControl method.
  5688. **
  5689. ** ^If the second parameter (zDbName) does not match the name of any
  5690. ** open database file, then SQLITE_ERROR is returned. ^This error
  5691. ** code is not remembered and will not be recalled by [sqlite3_errcode()]
  5692. ** or [sqlite3_errmsg()]. The underlying xFileControl method might
  5693. ** also return SQLITE_ERROR. There is no way to distinguish between
  5694. ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
  5695. ** xFileControl method.
  5696. **
  5697. ** See also: [SQLITE_FCNTL_LOCKSTATE]
  5698. */
  5699. //SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  5700. /*
  5701. ** CAPI3REF: Testing Interface
  5702. **
  5703. ** ^The sqlite3_test_control() interface is used to read out internal
  5704. ** state of SQLite and to inject faults into SQLite for testing
  5705. ** purposes. ^The first parameter is an operation code that determines
  5706. ** the number, meaning, and operation of all subsequent parameters.
  5707. **
  5708. ** This interface is not for use by applications. It exists solely
  5709. ** for verifying the correct operation of the SQLite library. Depending
  5710. ** on how the SQLite library is compiled, this interface might not exist.
  5711. **
  5712. ** The details of the operation codes, their meanings, the parameters
  5713. ** they take, and what they do are all subject to change without notice.
  5714. ** Unlike most of the SQLite API, this function is not guaranteed to
  5715. ** operate consistently from one release to the next.
  5716. */
  5717. //SQLITE_API int sqlite3_test_control(int op, ...);
  5718. /*
  5719. ** CAPI3REF: Testing Interface Operation Codes
  5720. **
  5721. ** These constants are the valid operation code parameters used
  5722. ** as the first argument to [sqlite3_test_control()].
  5723. **
  5724. ** These parameters and their meanings are subject to change
  5725. ** without notice. These values are for testing purposes only.
  5726. ** Applications should not use any of these parameters or the
  5727. ** [sqlite3_test_control()] interface.
  5728. */
  5729. //#define SQLITE_TESTCTRL_FIRST 5
  5730. //#define SQLITE_TESTCTRL_PRNG_SAVE 5
  5731. //#define SQLITE_TESTCTRL_PRNG_RESTORE 6
  5732. //#define SQLITE_TESTCTRL_PRNG_RESET 7
  5733. //#define SQLITE_TESTCTRL_BITVEC_TEST 8
  5734. //#define SQLITE_TESTCTRL_FAULT_INSTALL 9
  5735. //#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
  5736. //#define SQLITE_TESTCTRL_PENDING_BYTE 11
  5737. //#define SQLITE_TESTCTRL_ASSERT 12
  5738. //#define SQLITE_TESTCTRL_ALWAYS 13
  5739. //#define SQLITE_TESTCTRL_RESERVE 14
  5740. //#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
  5741. //#define SQLITE_TESTCTRL_ISKEYWORD 16
  5742. //#define SQLITE_TESTCTRL_PGHDRSZ 17
  5743. //#define SQLITE_TESTCTRL_SCRATCHMALLOC 18
  5744. //#define SQLITE_TESTCTRL_LAST 18
  5745. const int SQLITE_TESTCTRL_FIRST = 5;
  5746. const int SQLITE_TESTCTRL_PRNG_SAVE = 5;
  5747. const int SQLITE_TESTCTRL_PRNG_RESTORE = 6;
  5748. const int SQLITE_TESTCTRL_PRNG_RESET = 7;
  5749. const int SQLITE_TESTCTRL_BITVEC_TEST = 8;
  5750. const int SQLITE_TESTCTRL_FAULT_INSTALL = 9;
  5751. const int SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10;
  5752. const int SQLITE_TESTCTRL_PENDING_BYTE = 11;
  5753. const int SQLITE_TESTCTRL_ASSERT = 12;
  5754. const int SQLITE_TESTCTRL_ALWAYS = 13;
  5755. const int SQLITE_TESTCTRL_RESERVE = 14;
  5756. const int SQLITE_TESTCTRL_OPTIMIZATIONS = 15;
  5757. const int SQLITE_TESTCTRL_ISKEYWORD = 16;
  5758. const int SQLITE_TESTCTRL_PGHDRSZ = 17;
  5759. const int SQLITE_TESTCTRL_SCRATCHMALLOC = 18;
  5760. const int SQLITE_TESTCTRL_LAST = 18;
  5761. /*
  5762. ** CAPI3REF: SQLite Runtime Status
  5763. **
  5764. ** ^This interface is used to retrieve runtime status information
  5765. ** about the performance of SQLite, and optionally to reset various
  5766. ** highwater marks. ^The first argument is an integer code for
  5767. ** the specific parameter to measure. ^(Recognized integer codes
  5768. ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
  5769. ** ^The current value of the parameter is returned into *pCurrent.
  5770. ** ^The highest recorded value is returned in *pHighwater. ^If the
  5771. ** resetFlag is true, then the highest record value is reset after
  5772. ** *pHighwater is written. ^(Some parameters do not record the highest
  5773. ** value. For those parameters
  5774. ** nothing is written into *pHighwater and the resetFlag is ignored.)^
  5775. ** ^(Other parameters record only the highwater mark and not the current
  5776. ** value. For these latter parameters nothing is written into *pCurrent.)^
  5777. **
  5778. ** ^The sqlite3_status() routine returns SQLITE_OK on success and a
  5779. ** non-zero [error code] on failure.
  5780. **
  5781. ** This routine is threadsafe but is not atomic. This routine can be
  5782. ** called while other threads are running the same or different SQLite
  5783. ** interfaces. However the values returned in *pCurrent and
  5784. ** *pHighwater reflect the status of SQLite at different points in time
  5785. ** and it is possible that another thread might change the parameter
  5786. ** in between the times when *pCurrent and *pHighwater are written.
  5787. **
  5788. ** See also: [sqlite3_db_status()]
  5789. */
  5790. //SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
  5791. /*
  5792. ** CAPI3REF: Status Parameters
  5793. **
  5794. ** These integer constants designate various run-time status parameters
  5795. ** that can be returned by [sqlite3_status()].
  5796. **
  5797. ** <dl>
  5798. ** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
  5799. ** <dd>This parameter is the current amount of memory checked out
  5800. ** using [sqlite3_malloc()], either directly or indirectly. The
  5801. ** figure includes calls made to [sqlite3_malloc()] by the application
  5802. ** and internal memory usage by the SQLite library. Scratch memory
  5803. ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
  5804. ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
  5805. ** this parameter. The amount returned is the sum of the allocation
  5806. ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
  5807. **
  5808. ** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
  5809. ** <dd>This parameter records the largest memory allocation request
  5810. ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
  5811. ** internal equivalents). Only the value returned in the
  5812. ** *pHighwater parameter to [sqlite3_status()] is of interest.
  5813. ** The value written into the *pCurrent parameter is undefined.</dd>)^
  5814. **
  5815. ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
  5816. ** <dd>This parameter records the number of separate memory allocations
  5817. ** currently checked out.</dd>)^
  5818. **
  5819. ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
  5820. ** <dd>This parameter returns the number of pages used out of the
  5821. ** [pagecache memory allocator] that was configured using
  5822. ** [SQLITE_CONFIG_PAGECACHE]. The
  5823. ** value returned is in pages, not in bytes.</dd>)^
  5824. **
  5825. ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
  5826. ** <dd>This parameter returns the number of bytes of page cache
  5827. ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
  5828. ** buffer and where forced to overflow to [sqlite3_malloc()]. The
  5829. ** returned value includes allocations that overflowed because they
  5830. ** where too large (they were larger than the "sz" parameter to
  5831. ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
  5832. ** no space was left in the page cache.</dd>)^
  5833. **
  5834. ** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
  5835. ** <dd>This parameter records the largest memory allocation request
  5836. ** handed to [pagecache memory allocator]. Only the value returned in the
  5837. ** *pHighwater parameter to [sqlite3_status()] is of interest.
  5838. ** The value written into the *pCurrent parameter is undefined.</dd>)^
  5839. **
  5840. ** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
  5841. ** <dd>This parameter returns the number of allocations used out of the
  5842. ** [scratch memory allocator] configured using
  5843. ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
  5844. ** in bytes. Since a single thread may only have one scratch allocation
  5845. ** outstanding at time, this parameter also reports the number of threads
  5846. ** using scratch memory at the same time.</dd>)^
  5847. **
  5848. ** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
  5849. ** <dd>This parameter returns the number of bytes of scratch memory
  5850. ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH]
  5851. ** buffer and where forced to overflow to [sqlite3_malloc()]. The values
  5852. ** returned include overflows because the requested allocation was too
  5853. ** larger (that is, because the requested allocation was larger than the
  5854. ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
  5855. ** slots were available.
  5856. ** </dd>)^
  5857. **
  5858. ** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
  5859. ** <dd>This parameter records the largest memory allocation request
  5860. ** handed to [scratch memory allocator]. Only the value returned in the
  5861. ** *pHighwater parameter to [sqlite3_status()] is of interest.
  5862. ** The value written into the *pCurrent parameter is undefined.</dd>)^
  5863. **
  5864. ** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
  5865. ** <dd>This parameter records the deepest parser stack. It is only
  5866. ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
  5867. ** </dl>
  5868. **
  5869. ** New status parameters may be added from time to time.
  5870. */
  5871. //#define SQLITE_STATUS_MEMORY_USED 0
  5872. //#define SQLITE_STATUS_PAGECACHE_USED 1
  5873. //#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2
  5874. //#define SQLITE_STATUS_SCRATCH_USED 3
  5875. //#define SQLITE_STATUS_SCRATCH_OVERFLOW 4
  5876. //#define SQLITE_STATUS_MALLOC_SIZE 5
  5877. //#define SQLITE_STATUS_PARSER_STACK 6
  5878. //#define SQLITE_STATUS_PAGECACHE_SIZE 7
  5879. //#define SQLITE_STATUS_SCRATCH_SIZE 8
  5880. //#define SQLITE_STATUS_MALLOC_COUNT 9
  5881. const int SQLITE_STATUS_MEMORY_USED = 0;
  5882. const int SQLITE_STATUS_PAGECACHE_USED = 1;
  5883. const int SQLITE_STATUS_PAGECACHE_OVERFLOW = 2;
  5884. const int SQLITE_STATUS_SCRATCH_USED = 3;
  5885. const int SQLITE_STATUS_SCRATCH_OVERFLOW = 4;
  5886. const int SQLITE_STATUS_MALLOC_SIZE = 5;
  5887. const int SQLITE_STATUS_PARSER_STACK = 6;
  5888. const int SQLITE_STATUS_PAGECACHE_SIZE = 7;
  5889. const int SQLITE_STATUS_SCRATCH_SIZE = 8;
  5890. const int SQLITE_STATUS_MALLOC_COUNT = 9;
  5891. /*
  5892. ** CAPI3REF: Database Connection Status
  5893. **
  5894. ** ^This interface is used to retrieve runtime status information
  5895. ** about a single [database connection]. ^The first argument is the
  5896. ** database connection object to be interrogated. ^The second argument
  5897. ** is an integer constant, taken from the set of
  5898. ** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros, that
  5899. ** determines the parameter to interrogate. The set of
  5900. ** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros is likely
  5901. ** to grow in future releases of SQLite.
  5902. **
  5903. ** ^The current value of the requested parameter is written into *pCur
  5904. ** and the highest instantaneous value is written into *pHiwtr. ^If
  5905. ** the resetFlg is true, then the highest instantaneous value is
  5906. ** reset back down to the current value.
  5907. **
  5908. ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
  5909. ** non-zero [error code] on failure.
  5910. **
  5911. ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
  5912. */
  5913. //SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  5914. /*
  5915. ** CAPI3REF: Status Parameters for database connections
  5916. **
  5917. ** These constants are the available integer "verbs" that can be passed as
  5918. ** the second argument to the [sqlite3_db_status()] interface.
  5919. **
  5920. ** New verbs may be added in future releases of SQLite. Existing verbs
  5921. ** might be discontinued. Applications should check the return code from
  5922. ** [sqlite3_db_status()] to make sure that the call worked.
  5923. ** The [sqlite3_db_status()] interface will return a non-zero error code
  5924. ** if a discontinued or unsupported verb is invoked.
  5925. **
  5926. ** <dl>
  5927. ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
  5928. ** <dd>This parameter returns the number of lookaside memory slots currently
  5929. ** checked out.</dd>)^
  5930. **
  5931. ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
  5932. ** <dd>This parameter returns the number malloc attempts that were
  5933. ** satisfied using lookaside memory. Only the high-water value is meaningful;
  5934. ** the current value is always zero.
  5935. ** checked out.</dd>)^
  5936. **
  5937. ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
  5938. ** <dd>This parameter returns the number malloc attempts that might have
  5939. ** been satisfied using lookaside memory but failed due to the amount of
  5940. ** memory requested being larger than the lookaside slot size.
  5941. ** Only the high-water value is meaningful;
  5942. ** the current value is always zero.
  5943. ** checked out.</dd>)^
  5944. **
  5945. ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
  5946. ** <dd>This parameter returns the number malloc attempts that might have
  5947. ** been satisfied using lookaside memory but failed due to all lookaside
  5948. ** memory already being in use.
  5949. ** Only the high-water value is meaningful;
  5950. ** the current value is always zero.
  5951. ** checked out.</dd>)^
  5952. **
  5953. ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
  5954. ** <dd>This parameter returns the approximate number of of bytes of heap
  5955. ** memory used by all pager caches associated with the database connection.)^
  5956. ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
  5957. **
  5958. ** ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
  5959. ** <dd>This parameter returns the approximate number of of bytes of heap
  5960. ** memory used to store the schema for all databases associated
  5961. ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
  5962. ** ^The full amount of memory used by the schemas is reported, even if the
  5963. ** schema memory is shared with other database connections due to
  5964. ** [shared cache mode] being enabled.
  5965. ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
  5966. **
  5967. ** ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
  5968. ** <dd>This parameter returns the approximate number of of bytes of heap
  5969. ** and lookaside memory used by all prepared statements associated with
  5970. ** the database connection.)^
  5971. ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
  5972. ** </dd>
  5973. ** </dl>
  5974. */
  5975. //#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
  5976. //#define SQLITE_DBSTATUS_CACHE_USED 1
  5977. //#define SQLITE_DBSTATUS_SCHEMA_USED 2
  5978. //#define SQLITE_DBSTATUS_STMT_USED 3
  5979. //#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
  5980. //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
  5981. //#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
  5982. //#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */
  5983. const int SQLITE_DBSTATUS_LOOKASIDE_USED = 0;
  5984. const int SQLITE_DBSTATUS_CACHE_USED = 1;
  5985. const int SQLITE_DBSTATUS_SCHEMA_USED = 2;
  5986. const int SQLITE_DBSTATUS_STMT_USED = 3;
  5987. const int SQLITE_DBSTATUS_LOOKASIDE_HIT = 4;
  5988. const int SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5;
  5989. const int SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6;
  5990. const int SQLITE_DBSTATUS_MAX = 6;
  5991. /*
  5992. ** CAPI3REF: Prepared Statement Status
  5993. **
  5994. ** ^(Each prepared statement maintains various
  5995. ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
  5996. ** of times it has performed specific operations.)^ These counters can
  5997. ** be used to monitor the performance characteristics of the prepared
  5998. ** statements. For example, if the number of table steps greatly exceeds
  5999. ** the number of table searches or result rows, that would tend to indicate
  6000. ** that the prepared statement is using a full table scan rather than
  6001. ** an index.
  6002. **
  6003. ** ^(This interface is used to retrieve and reset counter values from
  6004. ** a [prepared statement]. The first argument is the prepared statement
  6005. ** object to be interrogated. The second argument
  6006. ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
  6007. ** to be interrogated.)^
  6008. ** ^The current value of the requested counter is returned.
  6009. ** ^If the resetFlg is true, then the counter is reset to zero after this
  6010. ** interface call returns.
  6011. **
  6012. ** See also: [sqlite3_status()] and [sqlite3_db_status()].
  6013. */
  6014. //SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  6015. /*
  6016. ** CAPI3REF: Status Parameters for prepared statements
  6017. **
  6018. ** These preprocessor macros define integer codes that name counter
  6019. ** values associated with the [sqlite3_stmt_status()] interface.
  6020. ** The meanings of the various counters are as follows:
  6021. **
  6022. ** <dl>
  6023. ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
  6024. ** <dd>^This is the number of times that SQLite has stepped forward in
  6025. ** a table as part of a full table scan. Large numbers for this counter
  6026. ** may indicate opportunities for performance improvement through
  6027. ** careful use of indices.</dd>
  6028. **
  6029. ** <dt>SQLITE_STMTSTATUS_SORT</dt>
  6030. ** <dd>^This is the number of sort operations that have occurred.
  6031. ** A non-zero value in this counter may indicate an opportunity to
  6032. ** improvement performance through careful use of indices.</dd>
  6033. **
  6034. ** <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
  6035. ** <dd>^This is the number of rows inserted into transient indices that
  6036. ** were created automatically in order to help joins run faster.
  6037. ** A non-zero value in this counter may indicate an opportunity to
  6038. ** improvement performance by adding permanent indices that do not
  6039. ** need to be reinitialized each time the statement is run.</dd>
  6040. **
  6041. ** </dl>
  6042. */
  6043. //#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
  6044. //#define SQLITE_STMTSTATUS_SORT 2
  6045. //#define SQLITE_STMTSTATUS_AUTOINDEX 3
  6046. const int SQLITE_STMTSTATUS_FULLSCAN_STEP = 1;
  6047. const int SQLITE_STMTSTATUS_SORT = 2;
  6048. const int SQLITE_STMTSTATUS_AUTOINDEX = 3;
  6049. /*
  6050. ** CAPI3REF: Custom Page Cache Object
  6051. **
  6052. ** The sqlite3_pcache type is opaque. It is implemented by
  6053. ** the pluggable module. The SQLite core has no knowledge of
  6054. ** its size or internal structure and never deals with the
  6055. ** sqlite3_pcache object except by holding and passing pointers
  6056. ** to the object.
  6057. **
  6058. ** See [sqlite3_pcache_methods] for additional information.
  6059. */
  6060. //typedef struct sqlite3_pcache sqlite3_pcache;
  6061. /*
  6062. ** CAPI3REF: Application Defined Page Cache.
  6063. ** KEYWORDS: {page cache}
  6064. **
  6065. ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
  6066. ** register an alternative page cache implementation by passing in an
  6067. ** instance of the sqlite3_pcache_methods structure.)^
  6068. ** In many applications, most of the heap memory allocated by
  6069. ** SQLite is used for the page cache.
  6070. ** By implementing a
  6071. ** custom page cache using this API, an application can better control
  6072. ** the amount of memory consumed by SQLite, the way in which
  6073. ** that memory is allocated and released, and the policies used to
  6074. ** determine exactly which parts of a database file are cached and for
  6075. ** how long.
  6076. **
  6077. ** The alternative page cache mechanism is an
  6078. ** extreme measure that is only needed by the most demanding applications.
  6079. ** The built-in page cache is recommended for most uses.
  6080. **
  6081. ** ^(The contents of the sqlite3_pcache_methods structure are copied to an
  6082. ** internal buffer by SQLite within the call to [sqlite3_config]. Hence
  6083. ** the application may discard the parameter after the call to
  6084. ** [sqlite3_config()] returns.)^
  6085. **
  6086. ** ^(The xInit() method is called once for each effective
  6087. ** call to [sqlite3_initialize()])^
  6088. ** (usually only once during the lifetime of the process). ^(The xInit()
  6089. ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
  6090. ** The intent of the xInit() method is to set up global data structures
  6091. ** required by the custom page cache implementation.
  6092. ** ^(If the xInit() method is NULL, then the
  6093. ** built-in default page cache is used instead of the application defined
  6094. ** page cache.)^
  6095. **
  6096. ** ^The xShutdown() method is called by [sqlite3_shutdown()].
  6097. ** It can be used to clean up
  6098. ** any outstanding resources before process shutdown, if required.
  6099. ** ^The xShutdown() method may be NULL.
  6100. **
  6101. ** ^SQLite automatically serializes calls to the xInit method,
  6102. ** so the xInit method need not be threadsafe. ^The
  6103. ** xShutdown method is only called from [sqlite3_shutdown()] so it does
  6104. ** not need to be threadsafe either. All other methods must be threadsafe
  6105. ** in multithreaded applications.
  6106. **
  6107. ** ^SQLite will never invoke xInit() more than once without an intervening
  6108. ** call to xShutdown().
  6109. **
  6110. ** ^SQLite invokes the xCreate() method to construct a new cache instance.
  6111. ** SQLite will typically create one cache instance for each open database file,
  6112. ** though this is not guaranteed. ^The
  6113. ** first parameter, szPage, is the size in bytes of the pages that must
  6114. ** be allocated by the cache. ^szPage will not be a power of two. ^szPage
  6115. ** will the page size of the database file that is to be cached plus an
  6116. ** increment (here called "R") of less than 250. SQLite will use the
  6117. ** extra R bytes on each page to store metadata about the underlying
  6118. ** database page on disk. The value of R depends
  6119. ** on the SQLite version, the target platform, and how SQLite was compiled.
  6120. ** ^(R is constant for a particular build of SQLite. Except, there are two
  6121. ** distinct values of R when SQLite is compiled with the proprietary
  6122. ** ZIPVFS extension.)^ ^The second argument to
  6123. ** xCreate(), bPurgeable, is true if the cache being created will
  6124. ** be used to cache database pages of a file stored on disk, or
  6125. ** false if it is used for an in-memory database. The cache implementation
  6126. ** does not have to do anything special based with the value of bPurgeable;
  6127. ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
  6128. ** never invoke xUnpin() except to deliberately delete a page.
  6129. ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to
  6130. ** false will always have the "discard" flag set to true.
  6131. ** ^Hence, a cache created with bPurgeable false will
  6132. ** never contain any unpinned pages.
  6133. **
  6134. ** ^(The xCachesize() method may be called at any time by SQLite to set the
  6135. ** suggested maximum cache-size (number of pages stored by) the cache
  6136. ** instance passed as the first argument. This is the value configured using
  6137. ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable
  6138. ** parameter, the implementation is not required to do anything with this
  6139. ** value; it is advisory only.
  6140. **
  6141. ** The xPagecount() method must return the number of pages currently
  6142. ** stored in the cache, both pinned and unpinned.
  6143. **
  6144. ** The xFetch() method locates a page in the cache and returns a pointer to
  6145. ** the page, or a NULL pointer.
  6146. ** A "page", in this context, means a buffer of szPage bytes aligned at an
  6147. ** 8-byte boundary. The page to be fetched is determined by the key. ^The
  6148. ** mimimum key value is 1. After it has been retrieved using xFetch, the page
  6149. ** is considered to be "pinned".
  6150. **
  6151. ** If the requested page is already in the page cache, then the page cache
  6152. ** implementation must return a pointer to the page buffer with its content
  6153. ** intact. If the requested page is not already in the cache, then the
  6154. ** cache implementation should use the value of the createFlag
  6155. ** parameter to help it determined what action to take:
  6156. **
  6157. ** <table border=1 width=85% align=center>
  6158. ** <tr><th> createFlag <th> Behaviour when page is not already in cache
  6159. ** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
  6160. ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
  6161. ** Otherwise return NULL.
  6162. ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
  6163. ** NULL if allocating a new page is effectively impossible.
  6164. ** </table>
  6165. **
  6166. ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
  6167. ** will only use a createFlag of 2 after a prior call with a createFlag of 1
  6168. ** failed.)^ In between the to xFetch() calls, SQLite may
  6169. ** attempt to unpin one or more cache pages by spilling the content of
  6170. ** pinned pages to disk and synching the operating system disk cache.
  6171. **
  6172. ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
  6173. ** as its second argument. If the third parameter, discard, is non-zero,
  6174. ** then the page must be evicted from the cache.
  6175. ** ^If the discard parameter is
  6176. ** zero, then the page may be discarded or retained at the discretion of
  6177. ** page cache implementation. ^The page cache implementation
  6178. ** may choose to evict unpinned pages at any time.
  6179. **
  6180. ** The cache must not perform any reference counting. A single
  6181. ** call to xUnpin() unpins the page regardless of the number of prior calls
  6182. ** to xFetch().
  6183. **
  6184. ** The xRekey() method is used to change the key value associated with the
  6185. ** page passed as the second argument. If the cache
  6186. ** previously contains an entry associated with newKey, it must be
  6187. ** discarded. ^Any prior cache entry associated with newKey is guaranteed not
  6188. ** to be pinned.
  6189. **
  6190. ** When SQLite calls the xTruncate() method, the cache must discard all
  6191. ** existing cache entries with page numbers (keys) greater than or equal
  6192. ** to the value of the iLimit parameter passed to xTruncate(). If any
  6193. ** of these pages are pinned, they are implicitly unpinned, meaning that
  6194. ** they can be safely discarded.
  6195. **
  6196. ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
  6197. ** All resources associated with the specified cache should be freed. ^After
  6198. ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
  6199. ** handle invalid, and will not use it with any other sqlite3_pcache_methods
  6200. ** functions.
  6201. */
  6202. //typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
  6203. //struct sqlite3_pcache_methods {
  6204. // void *pArg;
  6205. // int (*xInit)(void*);
  6206. // void (*xShutdown)(void*);
  6207. // sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);
  6208. // void (*xCachesize)(sqlite3_pcache*, int nCachesize);
  6209. // int (*xPagecount)(sqlite3_pcache*);
  6210. // void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
  6211. // void (*xUnpin)(sqlite3_pcache*, void*, int discard);
  6212. // void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);
  6213. // void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
  6214. // void (*xDestroy)(sqlite3_pcache*);
  6215. //};
  6216. public class sqlite3_pcache_methods
  6217. {
  6218. public object pArg;
  6219. public dxPC_Init xInit;//int (*xInit)(void*);
  6220. public dxPC_Shutdown xShutdown;//public void (*xShutdown)(void*);
  6221. public dxPC_Create xCreate;//public sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);
  6222. public dxPC_Cachesize xCachesize;//public void (*xCachesize)(sqlite3_pcache*, int nCachesize);
  6223. public dxPC_Pagecount xPagecount;//public int (*xPagecount)(sqlite3_pcache*);
  6224. public dxPC_Fetch xFetch;//public void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
  6225. public dxPC_Unpin xUnpin;//public void (*xUnpin)(sqlite3_pcache*, void*, int discard);
  6226. public dxPC_Rekey xRekey;//public void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);
  6227. public dxPC_Truncate xTruncate;//public void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
  6228. public dxPC_Destroy xDestroy;//public void (*xDestroy)(sqlite3_pcache*);
  6229. public sqlite3_pcache_methods()
  6230. {
  6231. }
  6232. public sqlite3_pcache_methods( object pArg, dxPC_Init xInit, dxPC_Shutdown xShutdown, dxPC_Create xCreate, dxPC_Cachesize xCachesize, dxPC_Pagecount xPagecount, dxPC_Fetch xFetch, dxPC_Unpin xUnpin, dxPC_Rekey xRekey, dxPC_Truncate xTruncate, dxPC_Destroy xDestroy )
  6233. {
  6234. this.pArg = pArg;
  6235. this.xInit = xInit;
  6236. this.xShutdown = xShutdown;
  6237. this.xCreate = xCreate;
  6238. this.xCachesize = xCachesize;
  6239. this.xPagecount = xPagecount;
  6240. this.xFetch = xFetch;
  6241. this.xUnpin = xUnpin;
  6242. this.xRekey = xRekey;
  6243. this.xTruncate = xTruncate;
  6244. this.xDestroy = xDestroy;
  6245. }
  6246. };
  6247. /*
  6248. ** CAPI3REF: Online Backup Object
  6249. **
  6250. ** The sqlite3_backup object records state information about an ongoing
  6251. ** online backup operation. ^The sqlite3_backup object is created by
  6252. ** a call to [sqlite3_backup_init()] and is destroyed by a call to
  6253. ** [sqlite3_backup_finish()].
  6254. **
  6255. ** See Also: [Using the SQLite Online Backup API]
  6256. */
  6257. //typedef struct sqlite3_backup sqlite3_backup;
  6258. /*
  6259. ** CAPI3REF: Online Backup API.
  6260. **
  6261. ** The backup API copies the content of one database into another.
  6262. ** It is useful either for creating backups of databases or
  6263. ** for copying in-memory databases to or from persistent files.
  6264. **
  6265. ** See Also: [Using the SQLite Online Backup API]
  6266. **
  6267. ** ^SQLite holds a write transaction open on the destination database file
  6268. ** for the duration of the backup operation.
  6269. ** ^The source database is read-locked only while it is being read;
  6270. ** it is not locked continuously for the entire backup operation.
  6271. ** ^Thus, the backup may be performed on a live source database without
  6272. ** preventing other database connections from
  6273. ** reading or writing to the source database while the backup is underway.
  6274. **
  6275. ** ^(To perform a backup operation:
  6276. ** <ol>
  6277. ** <li><b>sqlite3_backup_init()</b> is called once to initialize the
  6278. ** backup,
  6279. ** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
  6280. ** the data between the two databases, and finally
  6281. ** <li><b>sqlite3_backup_finish()</b> is called to release all resources
  6282. ** associated with the backup operation.
  6283. ** </ol>)^
  6284. ** There should be exactly one call to sqlite3_backup_finish() for each
  6285. ** successful call to sqlite3_backup_init().
  6286. **
  6287. ** <b>sqlite3_backup_init()</b>
  6288. **
  6289. ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
  6290. ** [database connection] associated with the destination database
  6291. ** and the database name, respectively.
  6292. ** ^The database name is "main" for the main database, "temp" for the
  6293. ** temporary database, or the name specified after the AS keyword in
  6294. ** an [ATTACH] statement for an attached database.
  6295. ** ^The S and M arguments passed to
  6296. ** sqlite3_backup_init(D,N,S,M) identify the [database connection]
  6297. ** and database name of the source database, respectively.
  6298. ** ^The source and destination [database connections] (parameters S and D)
  6299. ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
  6300. ** an error.
  6301. **
  6302. ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
  6303. ** returned and an error code and error message are stored in the
  6304. ** destination [database connection] D.
  6305. ** ^The error code and message for the failed call to sqlite3_backup_init()
  6306. ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
  6307. ** [sqlite3_errmsg16()] functions.
  6308. ** ^A successful call to sqlite3_backup_init() returns a pointer to an
  6309. ** [sqlite3_backup] object.
  6310. ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
  6311. ** sqlite3_backup_finish() functions to perform the specified backup
  6312. ** operation.
  6313. **
  6314. ** <b>sqlite3_backup_step()</b>
  6315. **
  6316. ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
  6317. ** the source and destination databases specified by [sqlite3_backup] object B.
  6318. ** ^If N is negative, all remaining source pages are copied.
  6319. ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
  6320. ** are still more pages to be copied, then the function returns [SQLITE_OK].
  6321. ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
  6322. ** from source to destination, then it returns [SQLITE_DONE].
  6323. ** ^If an error occurs while running sqlite3_backup_step(B,N),
  6324. ** then an [error code] is returned. ^As well as [SQLITE_OK] and
  6325. ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
  6326. ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
  6327. ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
  6328. **
  6329. ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if
  6330. ** <ol>
  6331. ** <li> the destination database was opened read-only, or
  6332. ** <li> the destination database is using write-ahead-log journaling
  6333. ** and the destination and source page sizes differ, or
  6334. ** <li> the destination database is an in-memory database and the
  6335. ** destination and source page sizes differ.
  6336. ** </ol>)^
  6337. **
  6338. ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
  6339. ** the [sqlite3_busy_handler | busy-handler function]
  6340. ** is invoked (if one is specified). ^If the
  6341. ** busy-handler returns non-zero before the lock is available, then
  6342. ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
  6343. ** sqlite3_backup_step() can be retried later. ^If the source
  6344. ** [database connection]
  6345. ** is being used to write to the source database when sqlite3_backup_step()
  6346. ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
  6347. ** case the call to sqlite3_backup_step() can be retried later on. ^(If
  6348. ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
  6349. ** [SQLITE_READONLY] is returned, then
  6350. ** there is no point in retrying the call to sqlite3_backup_step(). These
  6351. ** errors are considered fatal.)^ The application must accept
  6352. ** that the backup operation has failed and pass the backup operation handle
  6353. ** to the sqlite3_backup_finish() to release associated resources.
  6354. **
  6355. ** ^The first call to sqlite3_backup_step() obtains an exclusive lock
  6356. ** on the destination file. ^The exclusive lock is not released until either
  6357. ** sqlite3_backup_finish() is called or the backup operation is complete
  6358. ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to
  6359. ** sqlite3_backup_step() obtains a [shared lock] on the source database that
  6360. ** lasts for the duration of the sqlite3_backup_step() call.
  6361. ** ^Because the source database is not locked between calls to
  6362. ** sqlite3_backup_step(), the source database may be modified mid-way
  6363. ** through the backup process. ^If the source database is modified by an
  6364. ** external process or via a database connection other than the one being
  6365. ** used by the backup operation, then the backup will be automatically
  6366. ** restarted by the next call to sqlite3_backup_step(). ^If the source
  6367. ** database is modified by the using the same database connection as is used
  6368. ** by the backup operation, then the backup database is automatically
  6369. ** updated at the same time.
  6370. **
  6371. ** <b>sqlite3_backup_finish()</b>
  6372. **
  6373. ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
  6374. ** application wishes to abandon the backup operation, the application
  6375. ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
  6376. ** ^The sqlite3_backup_finish() interfaces releases all
  6377. ** resources associated with the [sqlite3_backup] object.
  6378. ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
  6379. ** active write-transaction on the destination database is rolled back.
  6380. ** The [sqlite3_backup] object is invalid
  6381. ** and may not be used following a call to sqlite3_backup_finish().
  6382. **
  6383. ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
  6384. ** sqlite3_backup_step() errors occurred, regardless or whether or not
  6385. ** sqlite3_backup_step() completed.
  6386. ** ^If an out-of-memory condition or IO error occurred during any prior
  6387. ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
  6388. ** sqlite3_backup_finish() returns the corresponding [error code].
  6389. **
  6390. ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
  6391. ** is not a permanent error and does not affect the return value of
  6392. ** sqlite3_backup_finish().
  6393. **
  6394. ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
  6395. **
  6396. ** ^Each call to sqlite3_backup_step() sets two values inside
  6397. ** the [sqlite3_backup] object: the number of pages still to be backed
  6398. ** up and the total number of pages in the source database file.
  6399. ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
  6400. ** retrieve these two values, respectively.
  6401. **
  6402. ** ^The values returned by these functions are only updated by
  6403. ** sqlite3_backup_step(). ^If the source database is modified during a backup
  6404. ** operation, then the values are not updated to account for any extra
  6405. ** pages that need to be updated or the size of the source database file
  6406. ** changing.
  6407. **
  6408. ** <b>Concurrent Usage of Database Handles</b>
  6409. **
  6410. ** ^The source [database connection] may be used by the application for other
  6411. ** purposes while a backup operation is underway or being initialized.
  6412. ** ^If SQLite is compiled and configured to support threadsafe database
  6413. ** connections, then the source database connection may be used concurrently
  6414. ** from within other threads.
  6415. **
  6416. ** However, the application must guarantee that the destination
  6417. ** [database connection] is not passed to any other API (by any thread) after
  6418. ** sqlite3_backup_init() is called and before the corresponding call to
  6419. ** sqlite3_backup_finish(). SQLite does not currently check to see
  6420. ** if the application incorrectly accesses the destination [database connection]
  6421. ** and so no error code is reported, but the operations may malfunction
  6422. ** nevertheless. Use of the destination database connection while a
  6423. ** backup is in progress might also also cause a mutex deadlock.
  6424. **
  6425. ** If running in [shared cache mode], the application must
  6426. ** guarantee that the shared cache used by the destination database
  6427. ** is not accessed while the backup is running. In practice this means
  6428. ** that the application must guarantee that the disk file being
  6429. ** backed up to is not accessed by any connection within the process,
  6430. ** not just the specific connection that was passed to sqlite3_backup_init().
  6431. **
  6432. ** The [sqlite3_backup] object itself is partially threadsafe. Multiple
  6433. ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
  6434. ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
  6435. ** APIs are not strictly speaking threadsafe. If they are invoked at the
  6436. ** same time as another thread is invoking sqlite3_backup_step() it is
  6437. ** possible that they return invalid values.
  6438. */
  6439. //SQLITE_API sqlite3_backup *sqlite3_backup_init(
  6440. // sqlite3 *pDest, /* Destination database handle */
  6441. // const char *zDestName, /* Destination database name */
  6442. // sqlite3 *pSource, /* Source database handle */
  6443. // const char *zSourceName /* Source database name */
  6444. //);
  6445. //SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
  6446. //SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
  6447. //SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
  6448. //SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
  6449. /*
  6450. ** CAPI3REF: Unlock Notification
  6451. **
  6452. ** ^When running in shared-cache mode, a database operation may fail with
  6453. ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
  6454. ** individual tables within the shared-cache cannot be obtained. See
  6455. ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
  6456. ** ^This API may be used to register a callback that SQLite will invoke
  6457. ** when the connection currently holding the required lock relinquishes it.
  6458. ** ^This API is only available if the library was compiled with the
  6459. ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
  6460. **
  6461. ** See Also: [Using the SQLite Unlock Notification Feature].
  6462. **
  6463. ** ^Shared-cache locks are released when a database connection concludes
  6464. ** its current transaction, either by committing it or rolling it back.
  6465. **
  6466. ** ^When a connection (known as the blocked connection) fails to obtain a
  6467. ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
  6468. ** identity of the database connection (the blocking connection) that
  6469. ** has locked the required resource is stored internally. ^After an
  6470. ** application receives an SQLITE_LOCKED error, it may call the
  6471. ** sqlite3_unlock_notify() method with the blocked connection handle as
  6472. ** the first argument to register for a callback that will be invoked
  6473. ** when the blocking connections current transaction is concluded. ^The
  6474. ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
  6475. ** call that concludes the blocking connections transaction.
  6476. **
  6477. ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
  6478. ** there is a chance that the blocking connection will have already
  6479. ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
  6480. ** If this happens, then the specified callback is invoked immediately,
  6481. ** from within the call to sqlite3_unlock_notify().)^
  6482. **
  6483. ** ^If the blocked connection is attempting to obtain a write-lock on a
  6484. ** shared-cache table, and more than one other connection currently holds
  6485. ** a read-lock on the same table, then SQLite arbitrarily selects one of
  6486. ** the other connections to use as the blocking connection.
  6487. **
  6488. ** ^(There may be at most one unlock-notify callback registered by a
  6489. ** blocked connection. If sqlite3_unlock_notify() is called when the
  6490. ** blocked connection already has a registered unlock-notify callback,
  6491. ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
  6492. ** called with a NULL pointer as its second argument, then any existing
  6493. ** unlock-notify callback is canceled. ^The blocked connections
  6494. ** unlock-notify callback may also be canceled by closing the blocked
  6495. ** connection using [sqlite3_close()].
  6496. **
  6497. ** The unlock-notify callback is not reentrant. If an application invokes
  6498. ** any sqlite3_xxx API functions from within an unlock-notify callback, a
  6499. ** crash or deadlock may be the result.
  6500. **
  6501. ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always
  6502. ** returns SQLITE_OK.
  6503. **
  6504. ** <b>Callback Invocation Details</b>
  6505. **
  6506. ** When an unlock-notify callback is registered, the application provides a
  6507. ** single void* pointer that is passed to the callback when it is invoked.
  6508. ** However, the signature of the callback function allows SQLite to pass
  6509. ** it an array of void* context pointers. The first argument passed to
  6510. ** an unlock-notify callback is a pointer to an array of void* pointers,
  6511. ** and the second is the number of entries in the array.
  6512. **
  6513. ** When a blocking connections transaction is concluded, there may be
  6514. ** more than one blocked connection that has registered for an unlock-notify
  6515. ** callback. ^If two or more such blocked connections have specified the
  6516. ** same callback function, then instead of invoking the callback function
  6517. ** multiple times, it is invoked once with the set of void* context pointers
  6518. ** specified by the blocked connections bundled together into an array.
  6519. ** This gives the application an opportunity to prioritize any actions
  6520. ** related to the set of unblocked database connections.
  6521. **
  6522. ** <b>Deadlock Detection</b>
  6523. **
  6524. ** Assuming that after registering for an unlock-notify callback a
  6525. ** database waits for the callback to be issued before taking any further
  6526. ** action (a reasonable assumption), then using this API may cause the
  6527. ** application to deadlock. For example, if connection X is waiting for
  6528. ** connection Y's transaction to be concluded, and similarly connection
  6529. ** Y is waiting on connection X's transaction, then neither connection
  6530. ** will proceed and the system may remain deadlocked indefinitely.
  6531. **
  6532. ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
  6533. ** detection. ^If a given call to sqlite3_unlock_notify() would put the
  6534. ** system in a deadlocked state, then SQLITE_LOCKED is returned and no
  6535. ** unlock-notify callback is registered. The system is said to be in
  6536. ** a deadlocked state if connection A has registered for an unlock-notify
  6537. ** callback on the conclusion of connection B's transaction, and connection
  6538. ** B has itself registered for an unlock-notify callback when connection
  6539. ** A's transaction is concluded. ^Indirect deadlock is also detected, so
  6540. ** the system is also considered to be deadlocked if connection B has
  6541. ** registered for an unlock-notify callback on the conclusion of connection
  6542. ** C's transaction, where connection C is waiting on connection A. ^Any
  6543. ** number of levels of indirection are allowed.
  6544. **
  6545. ** <b>The "DROP TABLE" Exception</b>
  6546. **
  6547. ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
  6548. ** always appropriate to call sqlite3_unlock_notify(). There is however,
  6549. ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement,
  6550. ** SQLite checks if there are any currently executing SELECT statements
  6551. ** that belong to the same connection. If there are, SQLITE_LOCKED is
  6552. ** returned. In this case there is no "blocking connection", so invoking
  6553. ** sqlite3_unlock_notify() results in the unlock-notify callback being
  6554. ** invoked immediately. If the application then re-attempts the "DROP TABLE"
  6555. ** or "DROP INDEX" query, an infinite loop might be the result.
  6556. **
  6557. ** One way around this problem is to check the extended error code returned
  6558. ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
  6559. ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
  6560. ** the special "DROP TABLE/INDEX" case, the extended error code is just
  6561. ** SQLITE_LOCKED.)^
  6562. */
  6563. //SQLITE_API int sqlite3_unlock_notify(
  6564. // sqlite3 *pBlocked, /* Waiting connection */
  6565. // void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
  6566. // void *pNotifyArg /* Argument to pass to xNotify */
  6567. //);
  6568. /*
  6569. ** CAPI3REF: String Comparison
  6570. **
  6571. ** ^The [sqlite3_strnicmp()] API allows applications and extensions to
  6572. ** compare the contents of two buffers containing UTF-8 strings in a
  6573. ** case-independent fashion, using the same definition of case independence
  6574. ** that SQLite uses internally when comparing identifiers.
  6575. */
  6576. //SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
  6577. /*
  6578. ** CAPI3REF: Error Logging Interface
  6579. **
  6580. ** ^The [sqlite3_log()] interface writes a message into the error log
  6581. ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].
  6582. ** ^If logging is enabled, the zFormat string and subsequent arguments are
  6583. ** used with [sqlite3_snprintf()] to generate the final output string.
  6584. **
  6585. ** The sqlite3_log() interface is intended for use by extensions such as
  6586. ** virtual tables, collating functions, and SQL functions. While there is
  6587. ** nothing to prevent an application from calling sqlite3_log(), doing so
  6588. ** is considered bad form.
  6589. **
  6590. ** The zFormat string must not be NULL.
  6591. **
  6592. ** To avoid deadlocks and other threading problems, the sqlite3_log() routine
  6593. ** will not use dynamically allocated memory. The log message is stored in
  6594. ** a fixed-length buffer on the stack. If the log message is longer than
  6595. ** a few hundred characters, it will be truncated to the length of the
  6596. ** buffer.
  6597. */
  6598. //SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
  6599. /*
  6600. ** CAPI3REF: Write-Ahead Log Commit Hook
  6601. **
  6602. ** ^The [sqlite3_wal_hook()] function is used to register a callback that
  6603. ** will be invoked each time a database connection commits data to a
  6604. ** [write-ahead log] (i.e. whenever a transaction is committed in
  6605. ** [journal_mode | journal_mode=WAL mode]).
  6606. **
  6607. ** ^The callback is invoked by SQLite after the commit has taken place and
  6608. ** the associated write-lock on the database released, so the implementation
  6609. ** may read, write or [checkpoint] the database as required.
  6610. **
  6611. ** ^The first parameter passed to the callback function when it is invoked
  6612. ** is a copy of the third parameter passed to sqlite3_wal_hook() when
  6613. ** registering the callback. ^The second is a copy of the database handle.
  6614. ** ^The third parameter is the name of the database that was written to -
  6615. ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
  6616. ** is the number of pages currently in the write-ahead log file,
  6617. ** including those that were just committed.
  6618. **
  6619. ** The callback function should normally return [SQLITE_OK]. ^If an error
  6620. ** code is returned, that error will propagate back up through the
  6621. ** SQLite code base to cause the statement that provoked the callback
  6622. ** to report an error, though the commit will have still occurred. If the
  6623. ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value
  6624. ** that does not correspond to any valid SQLite error code, the results
  6625. ** are undefined.
  6626. **
  6627. ** A single database handle may have at most a single write-ahead log callback
  6628. ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
  6629. ** previously registered write-ahead log callback. ^Note that the
  6630. ** [sqlite3_wal_autocheckpoint()] interface and the
  6631. ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
  6632. ** those overwrite any prior [sqlite3_wal_hook()] settings.
  6633. */
  6634. //SQLITE_API void *sqlite3_wal_hook(
  6635. // sqlite3*,
  6636. // int(*)(void *,sqlite3*,const char*,int),
  6637. // void*
  6638. //);
  6639. /*
  6640. ** CAPI3REF: Configure an auto-checkpoint
  6641. **
  6642. ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
  6643. ** [sqlite3_wal_hook()] that causes any database on [database connection] D
  6644. ** to automatically [checkpoint]
  6645. ** after committing a transaction if there are N or
  6646. ** more frames in the [write-ahead log] file. ^Passing zero or
  6647. ** a negative value as the nFrame parameter disables automatic
  6648. ** checkpoints entirely.
  6649. **
  6650. ** ^The callback registered by this function replaces any existing callback
  6651. ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback
  6652. ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism
  6653. ** configured by this function.
  6654. **
  6655. ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface
  6656. ** from SQL.
  6657. **
  6658. ** ^Every new [database connection] defaults to having the auto-checkpoint
  6659. ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
  6660. ** pages. The use of this interface
  6661. ** for a particular application.
  6662. */
  6663. //SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  6664. /*
  6665. ** CAPI3REF: Checkpoint a database
  6666. **
  6667. ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
  6668. ** on [database connection] D to be [checkpointed]. ^If X is NULL or an
  6669. ** empty string, then a checkpoint is run on all databases of
  6670. ** connection D. ^If the database connection D is not in
  6671. ** [WAL | write-ahead log mode] then this interface is a harmless no-op.
  6672. **
  6673. ** ^The [wal_checkpoint pragma] can be used to invoke this interface
  6674. ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the
  6675. ** [wal_autocheckpoint pragma] can be used to cause this interface to be
  6676. ** run whenever the WAL reaches a certain size threshold.
  6677. */
  6678. //SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  6679. /*
  6680. ** Undo the hack that converts floating point types to integer for
  6681. ** builds on processors without floating point support.
  6682. */
  6683. //#ifdef SQLITE_OMIT_FLOATING_POINT
  6684. //# undef double
  6685. //#endif
  6686. //#ifdef __cplusplus
  6687. //} /* End of the 'extern "C"' block */
  6688. //#endif
  6689. //#endif
  6690. /*
  6691. ** 2010 August 30
  6692. **
  6693. ** The author disclaims copyright to this source code. In place of
  6694. ** a legal notice, here is a blessing:
  6695. **
  6696. ** May you do good and not evil.
  6697. ** May you find forgiveness for yourself and forgive others.
  6698. ** May you share freely, never taking more than you give.
  6699. **
  6700. *************************************************************************
  6701. */
  6702. //#ifndef _SQLITE3RTREE_H_
  6703. //#define _SQLITE3RTREE_H_
  6704. //#ifdef __cplusplus
  6705. //extern "C" {
  6706. //#endif
  6707. //typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
  6708. /*
  6709. ** Register a geometry callback named zGeom that can be used as part of an
  6710. ** R-Tree geometry query as follows:
  6711. **
  6712. ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
  6713. */
  6714. //SQLITE_API int sqlite3_rtree_geometry_callback(
  6715. // sqlite3 *db,
  6716. // const char *zGeom,
  6717. // int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes),
  6718. // void *pContext
  6719. //);
  6720. /*
  6721. ** A pointer to a structure of the following type is passed as the first
  6722. ** argument to callbacks registered using rtree_geometry_callback().
  6723. */
  6724. //struct sqlite3_rtree_geometry {
  6725. // void *pContext; /* Copy of pContext passed to s_r_g_c() */
  6726. // int nParam; /* Size of array aParam[] */
  6727. // double *aParam; /* Parameters passed to SQL geom function */
  6728. // void *pUser; /* Callback implementation user data */
  6729. // void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */
  6730. //};
  6731. //#ifdef __cplusplus
  6732. //} /* end of the 'extern "C"' block */
  6733. //#endif
  6734. //#endif /* ifndef _SQLITE3RTREE_H_ */
  6735. }
  6736. }