Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/sqlite/src/src/sqlite.h.in

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/src/shell.c ('k') | third_party/sqlite/src/src/sqlite3ext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** 2001 September 15 2 ** 2001 September 15
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
11 ************************************************************************* 11 *************************************************************************
12 ** This header file defines the interface that the SQLite library 12 ** This header file defines the interface that the SQLite library
13 ** presents to client programs. If a C-function, structure, datatype, 13 ** presents to client programs. If a C-function, structure, datatype,
14 ** or constant definition does not appear in this file, then it is 14 ** or constant definition does not appear in this file, then it is
15 ** not a published API of SQLite, is subject to change without 15 ** not a published API of SQLite, is subject to change without
16 ** notice, and should not be referenced by programs that use SQLite. 16 ** notice, and should not be referenced by programs that use SQLite.
17 ** 17 **
18 ** Some of the definitions that are in this file are marked as 18 ** Some of the definitions that are in this file are marked as
19 ** "experimental". Experimental interfaces are normally new 19 ** "experimental". Experimental interfaces are normally new
20 ** features recently added to SQLite. We do not anticipate changes 20 ** features recently added to SQLite. We do not anticipate changes
21 ** to experimental interfaces but reserve the right to make minor changes 21 ** to experimental interfaces but reserve the right to make minor changes
22 ** if experience from use "in the wild" suggest such changes are prudent. 22 ** if experience from use "in the wild" suggest such changes are prudent.
23 ** 23 **
24 ** The official C-language API documentation for SQLite is derived 24 ** The official C-language API documentation for SQLite is derived
25 ** from comments in this file. This file is the authoritative source 25 ** from comments in this file. This file is the authoritative source
26 ** on how SQLite interfaces are suppose to operate. 26 ** on how SQLite interfaces are supposed to operate.
27 ** 27 **
28 ** The name of this file under configuration management is "sqlite.h.in". 28 ** The name of this file under configuration management is "sqlite.h.in".
29 ** The makefile makes some minor changes to this file (such as inserting 29 ** The makefile makes some minor changes to this file (such as inserting
30 ** the version number) and changes its name to "sqlite3.h" as 30 ** the version number) and changes its name to "sqlite3.h" as
31 ** part of the build process. 31 ** part of the build process.
32 */ 32 */
33 #ifndef _SQLITE3_H_ 33 #ifndef _SQLITE3_H_
34 #define _SQLITE3_H_ 34 #define _SQLITE3_H_
35 #include <stdarg.h> /* Needed for the definition of va_list */ 35 #include <stdarg.h> /* Needed for the definition of va_list */
36 36
37 /* 37 /*
38 ** Make sure we can call this stuff from C++. 38 ** Make sure we can call this stuff from C++.
39 */ 39 */
40 #ifdef __cplusplus 40 #ifdef __cplusplus
41 extern "C" { 41 extern "C" {
42 #endif 42 #endif
43 43
44 44
45 /* 45 /*
46 ** Add the ability to override 'extern' 46 ** Provide the ability to override linkage features of the interface.
47 */ 47 */
48 #ifndef SQLITE_EXTERN 48 #ifndef SQLITE_EXTERN
49 # define SQLITE_EXTERN extern 49 # define SQLITE_EXTERN extern
50 #endif 50 #endif
51 #ifndef SQLITE_API
52 # define SQLITE_API
53 #endif
54 #ifndef SQLITE_CDECL
55 # define SQLITE_CDECL
56 #endif
57 #ifndef SQLITE_STDCALL
58 # define SQLITE_STDCALL
59 #endif
51 60
52 /* 61 /*
53 ** These no-op macros are used in front of interfaces to mark those 62 ** These no-op macros are used in front of interfaces to mark those
54 ** interfaces as either deprecated or experimental. New applications 63 ** interfaces as either deprecated or experimental. New applications
55 ** should not use deprecated interfaces - they are support for backwards 64 ** should not use deprecated interfaces - they are supported for backwards
56 ** compatibility only. Application writers should be aware that 65 ** compatibility only. Application writers should be aware that
57 ** experimental interfaces are subject to change in point releases. 66 ** experimental interfaces are subject to change in point releases.
58 ** 67 **
59 ** These macros used to resolve to various kinds of compiler magic that 68 ** These macros used to resolve to various kinds of compiler magic that
60 ** would generate warning messages when they were used. But that 69 ** would generate warning messages when they were used. But that
61 ** compiler magic ended up generating such a flurry of bug reports 70 ** compiler magic ended up generating such a flurry of bug reports
62 ** that we have taken it all out and gone back to using simple 71 ** that we have taken it all out and gone back to using simple
63 ** noop macros. 72 ** noop macros.
64 */ 73 */
65 #define SQLITE_DEPRECATED 74 #define SQLITE_DEPRECATED
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 117
109 /* 118 /*
110 ** CAPI3REF: Run-Time Library Version Numbers 119 ** CAPI3REF: Run-Time Library Version Numbers
111 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
112 ** 121 **
113 ** These interfaces provide the same information as the [SQLITE_VERSION], 122 ** These interfaces provide the same information as the [SQLITE_VERSION],
114 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros 123 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
115 ** but are associated with the library instead of the header file. ^(Cautious 124 ** but are associated with the library instead of the header file. ^(Cautious
116 ** programmers might include assert() statements in their application to 125 ** programmers might include assert() statements in their application to
117 ** verify that values returned by these interfaces match the macros in 126 ** verify that values returned by these interfaces match the macros in
118 ** the header, and thus insure that the application is 127 ** the header, and thus ensure that the application is
119 ** compiled with matching library and header files. 128 ** compiled with matching library and header files.
120 ** 129 **
121 ** <blockquote><pre> 130 ** <blockquote><pre>
122 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER ); 131 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
123 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 ); 132 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
124 ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 ); 133 ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
125 ** </pre></blockquote>)^ 134 ** </pre></blockquote>)^
126 ** 135 **
127 ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] 136 ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
128 ** macro. ^The sqlite3_libversion() function returns a pointer to the 137 ** macro. ^The sqlite3_libversion() function returns a pointer to the
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ** 198 **
190 ** This interface can be used by an application to make sure that the 199 ** This interface can be used by an application to make sure that the
191 ** version of SQLite that it is linking against was compiled with 200 ** version of SQLite that it is linking against was compiled with
192 ** the desired setting of the [SQLITE_THREADSAFE] macro. 201 ** the desired setting of the [SQLITE_THREADSAFE] macro.
193 ** 202 **
194 ** This interface only reports on the compile-time mutex setting 203 ** This interface only reports on the compile-time mutex setting
195 ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with 204 ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
196 ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but 205 ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
197 ** can be fully or partially disabled using a call to [sqlite3_config()] 206 ** can be fully or partially disabled using a call to [sqlite3_config()]
198 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], 207 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
199 ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the 208 ** or [SQLITE_CONFIG_SERIALIZED]. ^(The return value of the
200 ** sqlite3_threadsafe() function shows only the compile-time setting of 209 ** sqlite3_threadsafe() function shows only the compile-time setting of
201 ** thread safety, not any run-time changes to that setting made by 210 ** thread safety, not any run-time changes to that setting made by
202 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() 211 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
203 ** is unchanged by calls to sqlite3_config().)^ 212 ** is unchanged by calls to sqlite3_config().)^
204 ** 213 **
205 ** See the [threading mode] documentation for additional information. 214 ** See the [threading mode] documentation for additional information.
206 */ 215 */
207 int sqlite3_threadsafe(void); 216 int sqlite3_threadsafe(void);
208 217
209 /* 218 /*
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 /* 263 /*
255 ** If compiling for a processor that lacks floating point support, 264 ** If compiling for a processor that lacks floating point support,
256 ** substitute integer for floating-point. 265 ** substitute integer for floating-point.
257 */ 266 */
258 #ifdef SQLITE_OMIT_FLOATING_POINT 267 #ifdef SQLITE_OMIT_FLOATING_POINT
259 # define double sqlite3_int64 268 # define double sqlite3_int64
260 #endif 269 #endif
261 270
262 /* 271 /*
263 ** CAPI3REF: Closing A Database Connection 272 ** CAPI3REF: Closing A Database Connection
273 ** DESTRUCTOR: sqlite3
264 ** 274 **
265 ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors 275 ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
266 ** for the [sqlite3] object. 276 ** for the [sqlite3] object.
267 ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if 277 ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
268 ** the [sqlite3] object is successfully destroyed and all associated 278 ** the [sqlite3] object is successfully destroyed and all associated
269 ** resources are deallocated. 279 ** resources are deallocated.
270 ** 280 **
271 ** ^If the database connection is associated with unfinalized prepared 281 ** ^If the database connection is associated with unfinalized prepared
272 ** statements or unfinished sqlite3_backup objects then sqlite3_close() 282 ** statements or unfinished sqlite3_backup objects then sqlite3_close()
273 ** will leave the database connection open and return [SQLITE_BUSY]. 283 ** will leave the database connection open and return [SQLITE_BUSY].
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 315
306 /* 316 /*
307 ** The type for a callback function. 317 ** The type for a callback function.
308 ** This is legacy and deprecated. It is included for historical 318 ** This is legacy and deprecated. It is included for historical
309 ** compatibility and is not documented. 319 ** compatibility and is not documented.
310 */ 320 */
311 typedef int (*sqlite3_callback)(void*,int,char**, char**); 321 typedef int (*sqlite3_callback)(void*,int,char**, char**);
312 322
313 /* 323 /*
314 ** CAPI3REF: One-Step Query Execution Interface 324 ** CAPI3REF: One-Step Query Execution Interface
325 ** METHOD: sqlite3
315 ** 326 **
316 ** The sqlite3_exec() interface is a convenience wrapper around 327 ** The sqlite3_exec() interface is a convenience wrapper around
317 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], 328 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
318 ** that allows an application to run multiple statements of SQL 329 ** that allows an application to run multiple statements of SQL
319 ** without having to use a lot of C code. 330 ** without having to use a lot of C code.
320 ** 331 **
321 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, 332 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
322 ** semicolon-separate SQL statements passed into its 2nd argument, 333 ** semicolon-separate SQL statements passed into its 2nd argument,
323 ** in the context of the [database connection] passed in as its 1st 334 ** in the context of the [database connection] passed in as its 1st
324 ** argument. ^If the callback function of the 3rd argument to 335 ** argument. ^If the callback function of the 3rd argument to
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 ** from [sqlite3_column_name()]. 367 ** from [sqlite3_column_name()].
357 ** 368 **
358 ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer 369 ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
359 ** to an empty string, or a pointer that contains only whitespace and/or 370 ** to an empty string, or a pointer that contains only whitespace and/or
360 ** SQL comments, then no SQL statements are evaluated and the database 371 ** SQL comments, then no SQL statements are evaluated and the database
361 ** is not changed. 372 ** is not changed.
362 ** 373 **
363 ** Restrictions: 374 ** Restrictions:
364 ** 375 **
365 ** <ul> 376 ** <ul>
366 ** <li> The application must insure that the 1st parameter to sqlite3_exec() 377 ** <li> The application must ensure that the 1st parameter to sqlite3_exec()
367 ** is a valid and open [database connection]. 378 ** is a valid and open [database connection].
368 ** <li> The application must not close the [database connection] specified by 379 ** <li> The application must not close the [database connection] specified by
369 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. 380 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
370 ** <li> The application must not modify the SQL statement text passed into 381 ** <li> The application must not modify the SQL statement text passed into
371 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. 382 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
372 ** </ul> 383 ** </ul>
373 */ 384 */
374 int sqlite3_exec( 385 int sqlite3_exec(
375 sqlite3*, /* An open database */ 386 sqlite3*, /* An open database */
376 const char *sql, /* SQL to be evaluated */ 387 const char *sql, /* SQL to be evaluated */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) 470 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
460 #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) 471 #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
461 #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) 472 #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
462 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) 473 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
463 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) 474 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
464 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) 475 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
465 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) 476 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
466 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) 477 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
467 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) 478 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
468 #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) 479 #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
480 #define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8))
481 #define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8))
469 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) 482 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
470 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) 483 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
471 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) 484 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
472 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) 485 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
473 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) 486 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
474 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) 487 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
475 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) 488 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
476 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) 489 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
477 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) 490 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
478 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) 491 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 }; 757 };
745 758
746 /* 759 /*
747 ** CAPI3REF: Standard File Control Opcodes 760 ** CAPI3REF: Standard File Control Opcodes
748 ** KEYWORDS: {file control opcodes} {file control opcode} 761 ** KEYWORDS: {file control opcodes} {file control opcode}
749 ** 762 **
750 ** These integer constants are opcodes for the xFileControl method 763 ** These integer constants are opcodes for the xFileControl method
751 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] 764 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
752 ** interface. 765 ** interface.
753 ** 766 **
767 ** <ul>
768 ** <li>[[SQLITE_FCNTL_LOCKSTATE]]
754 ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This 769 ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
755 ** opcode causes the xFileControl method to write the current state of 770 ** opcode causes the xFileControl method to write the current state of
756 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], 771 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
757 ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) 772 ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
758 ** into an integer that the pArg argument points to. This capability 773 ** into an integer that the pArg argument points to. This capability
759 ** is used during testing and only needs to be supported when SQLITE_TEST 774 ** is used during testing and is only available when the SQLITE_TEST
760 ** is defined. 775 ** compile-time option is used.
761 ** <ul> 776 **
762 ** <li>[[SQLITE_FCNTL_SIZE_HINT]] 777 ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
763 ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS 778 ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
764 ** layer a hint of how large the database file will grow to be during the 779 ** layer a hint of how large the database file will grow to be during the
765 ** current transaction. This hint is not guaranteed to be accurate but it 780 ** current transaction. This hint is not guaranteed to be accurate but it
766 ** is often close. The underlying VFS might choose to preallocate database 781 ** is often close. The underlying VFS might choose to preallocate database
767 ** file space based on this hint in order to help writes to the database 782 ** file space based on this hint in order to help writes to the database
768 ** file run faster. 783 ** file run faster.
769 ** 784 **
770 ** <li>[[SQLITE_FCNTL_CHUNK_SIZE]] 785 ** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
771 ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS 786 ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
772 ** extends and truncates the database file in chunks of a size specified 787 ** extends and truncates the database file in chunks of a size specified
773 ** by the user. The fourth argument to [sqlite3_file_control()] should 788 ** by the user. The fourth argument to [sqlite3_file_control()] should
774 ** point to an integer (type int) containing the new chunk-size to use 789 ** point to an integer (type int) containing the new chunk-size to use
775 ** for the nominated database. Allocating database file space in large 790 ** for the nominated database. Allocating database file space in large
776 ** chunks (say 1MB at a time), may reduce file-system fragmentation and 791 ** chunks (say 1MB at a time), may reduce file-system fragmentation and
777 ** improve performance on some systems. 792 ** improve performance on some systems.
778 ** 793 **
779 ** <li>[[SQLITE_FCNTL_FILE_POINTER]] 794 ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
780 ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer 795 ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
781 ** to the [sqlite3_file] object associated with a particular database 796 ** to the [sqlite3_file] object associated with a particular database
782 ** connection. See the [sqlite3_file_control()] documentation for 797 ** connection. See also [SQLITE_FCNTL_JOURNAL_POINTER].
783 ** additional information. 798 **
799 ** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
800 ** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
801 ** to the [sqlite3_file] object associated with the journal file (either
802 ** the [rollback journal] or the [write-ahead log]) for a particular database
803 ** connection. See also [SQLITE_FCNTL_FILE_POINTER].
784 ** 804 **
785 ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] 805 ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
786 ** No longer in use. 806 ** No longer in use.
787 ** 807 **
788 ** <li>[[SQLITE_FCNTL_SYNC]] 808 ** <li>[[SQLITE_FCNTL_SYNC]]
789 ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and 809 ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
790 ** sent to the VFS immediately before the xSync method is invoked on a 810 ** sent to the VFS immediately before the xSync method is invoked on a
791 ** database file descriptor. Or, if the xSync method is not invoked 811 ** database file descriptor. Or, if the xSync method is not invoked
792 ** because the user has configured SQLite with 812 ** because the user has configured SQLite with
793 ** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place 813 ** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 ** all [VFSes] in the VFS stack. The names are of all VFS shims and the 880 ** all [VFSes] in the VFS stack. The names are of all VFS shims and the
861 ** final bottom-level VFS are written into memory obtained from 881 ** final bottom-level VFS are written into memory obtained from
862 ** [sqlite3_malloc()] and the result is stored in the char* variable 882 ** [sqlite3_malloc()] and the result is stored in the char* variable
863 ** that the fourth parameter of [sqlite3_file_control()] points to. 883 ** that the fourth parameter of [sqlite3_file_control()] points to.
864 ** The caller is responsible for freeing the memory when done. As with 884 ** The caller is responsible for freeing the memory when done. As with
865 ** all file-control actions, there is no guarantee that this will actually 885 ** all file-control actions, there is no guarantee that this will actually
866 ** do anything. Callers should initialize the char* variable to a NULL 886 ** do anything. Callers should initialize the char* variable to a NULL
867 ** pointer in case this file-control is not implemented. This file-control 887 ** pointer in case this file-control is not implemented. This file-control
868 ** is intended for diagnostic use only. 888 ** is intended for diagnostic use only.
869 ** 889 **
890 ** <li>[[SQLITE_FCNTL_VFS_POINTER]]
891 ** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
892 ** [VFSes] currently in use. ^(The argument X in
893 ** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
894 ** of type "[sqlite3_vfs] **". This opcodes will set *X
895 ** to a pointer to the top-level VFS.)^
896 ** ^When there are multiple VFS shims in the stack, this opcode finds the
897 ** upper-most shim only.
898 **
870 ** <li>[[SQLITE_FCNTL_PRAGMA]] 899 ** <li>[[SQLITE_FCNTL_PRAGMA]]
871 ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 900 ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
872 ** file control is sent to the open [sqlite3_file] object corresponding 901 ** file control is sent to the open [sqlite3_file] object corresponding
873 ** to the database file to which the pragma statement refers. ^The argument 902 ** to the database file to which the pragma statement refers. ^The argument
874 ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of 903 ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
875 ** pointers to strings (char**) in which the second element of the array 904 ** pointers to strings (char**) in which the second element of the array
876 ** is the name of the pragma and the third element is the argument to the 905 ** is the name of the pragma and the third element is the argument to the
877 ** pragma or NULL if the pragma has no argument. ^The handler for an 906 ** pragma or NULL if the pragma has no argument. ^The handler for an
878 ** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element 907 ** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
879 ** of the char** argument point to a string obtained from [sqlite3_mprintf()] 908 ** of the char** argument point to a string obtained from [sqlite3_mprintf()]
880 ** or the equivalent and that string will become the result of the pragma or 909 ** or the equivalent and that string will become the result of the pragma or
881 ** the error message if the pragma fails. ^If the 910 ** the error message if the pragma fails. ^If the
882 ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal 911 ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
883 ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] 912 ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
884 ** file control returns [SQLITE_OK], then the parser assumes that the 913 ** file control returns [SQLITE_OK], then the parser assumes that the
885 ** VFS has handled the PRAGMA itself and the parser generates a no-op 914 ** VFS has handled the PRAGMA itself and the parser generates a no-op
886 ** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns 915 ** prepared statement if result string is NULL, or that returns a copy
916 ** of the result string if the string is non-NULL.
917 ** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
887 ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means 918 ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
888 ** that the VFS encountered an error while handling the [PRAGMA] and the 919 ** that the VFS encountered an error while handling the [PRAGMA] and the
889 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] 920 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
890 ** file control occurs at the beginning of pragma statement analysis and so 921 ** file control occurs at the beginning of pragma statement analysis and so
891 ** it is able to override built-in [PRAGMA] statements. 922 ** it is able to override built-in [PRAGMA] statements.
892 ** 923 **
893 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]] 924 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
894 ** ^The [SQLITE_FCNTL_BUSYHANDLER] 925 ** ^The [SQLITE_FCNTL_BUSYHANDLER]
895 ** file-control may be invoked by SQLite on the database file handle 926 ** file-control may be invoked by SQLite on the database file handle
896 ** shortly after it is opened in order to provide a custom VFS with access 927 ** shortly after it is opened in order to provide a custom VFS with access
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 ** pointer to an integer and it writes a boolean into that integer depending 965 ** pointer to an integer and it writes a boolean into that integer depending
935 ** on whether or not the file has been renamed, moved, or deleted since it 966 ** on whether or not the file has been renamed, moved, or deleted since it
936 ** was first opened. 967 ** was first opened.
937 ** 968 **
938 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]] 969 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
939 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This 970 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
940 ** opcode causes the xFileControl method to swap the file handle with the one 971 ** opcode causes the xFileControl method to swap the file handle with the one
941 ** pointed to by the pArg argument. This capability is used during testing 972 ** pointed to by the pArg argument. This capability is used during testing
942 ** and only needs to be supported when SQLITE_TEST is defined. 973 ** and only needs to be supported when SQLITE_TEST is defined.
943 ** 974 **
975 ** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
976 ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
977 ** be advantageous to block on the next WAL lock if the lock is not immediately
978 ** available. The WAL subsystem issues this signal during rare
979 ** circumstances in order to fix a problem with priority inversion.
980 ** Applications should <em>not</em> use this file-control.
981 **
982 ** <li>[[SQLITE_FCNTL_ZIPVFS]]
983 ** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
984 ** VFS should return SQLITE_NOTFOUND for this opcode.
985 **
986 ** <li>[[SQLITE_FCNTL_RBU]]
987 ** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
988 ** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for
989 ** this opcode.
944 ** </ul> 990 ** </ul>
945 */ 991 */
946 #define SQLITE_FCNTL_LOCKSTATE 1 992 #define SQLITE_FCNTL_LOCKSTATE 1
947 #define SQLITE_GET_LOCKPROXYFILE 2 993 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
948 #define SQLITE_SET_LOCKPROXYFILE 3 994 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
949 #define SQLITE_LAST_ERRNO 4 995 #define SQLITE_FCNTL_LAST_ERRNO 4
950 #define SQLITE_FCNTL_SIZE_HINT 5 996 #define SQLITE_FCNTL_SIZE_HINT 5
951 #define SQLITE_FCNTL_CHUNK_SIZE 6 997 #define SQLITE_FCNTL_CHUNK_SIZE 6
952 #define SQLITE_FCNTL_FILE_POINTER 7 998 #define SQLITE_FCNTL_FILE_POINTER 7
953 #define SQLITE_FCNTL_SYNC_OMITTED 8 999 #define SQLITE_FCNTL_SYNC_OMITTED 8
954 #define SQLITE_FCNTL_WIN32_AV_RETRY 9 1000 #define SQLITE_FCNTL_WIN32_AV_RETRY 9
955 #define SQLITE_FCNTL_PERSIST_WAL 10 1001 #define SQLITE_FCNTL_PERSIST_WAL 10
956 #define SQLITE_FCNTL_OVERWRITE 11 1002 #define SQLITE_FCNTL_OVERWRITE 11
957 #define SQLITE_FCNTL_VFSNAME 12 1003 #define SQLITE_FCNTL_VFSNAME 12
958 #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 1004 #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
959 #define SQLITE_FCNTL_PRAGMA 14 1005 #define SQLITE_FCNTL_PRAGMA 14
960 #define SQLITE_FCNTL_BUSYHANDLER 15 1006 #define SQLITE_FCNTL_BUSYHANDLER 15
961 #define SQLITE_FCNTL_TEMPFILENAME 16 1007 #define SQLITE_FCNTL_TEMPFILENAME 16
962 #define SQLITE_FCNTL_MMAP_SIZE 18 1008 #define SQLITE_FCNTL_MMAP_SIZE 18
963 #define SQLITE_FCNTL_TRACE 19 1009 #define SQLITE_FCNTL_TRACE 19
964 #define SQLITE_FCNTL_HAS_MOVED 20 1010 #define SQLITE_FCNTL_HAS_MOVED 20
965 #define SQLITE_FCNTL_SYNC 21 1011 #define SQLITE_FCNTL_SYNC 21
966 #define SQLITE_FCNTL_COMMIT_PHASETWO 22 1012 #define SQLITE_FCNTL_COMMIT_PHASETWO 22
967 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23 1013 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23
1014 #define SQLITE_FCNTL_WAL_BLOCK 24
1015 #define SQLITE_FCNTL_ZIPVFS 25
1016 #define SQLITE_FCNTL_RBU 26
1017 #define SQLITE_FCNTL_VFS_POINTER 27
1018 #define SQLITE_FCNTL_JOURNAL_POINTER 28
1019
1020 /* deprecated names */
1021 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1022 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1023 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
1024
968 1025
969 /* 1026 /*
970 ** CAPI3REF: Mutex Handle 1027 ** CAPI3REF: Mutex Handle
971 ** 1028 **
972 ** The mutex module within SQLite defines [sqlite3_mutex] to be an 1029 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
973 ** abstract type for a mutex object. The SQLite core never looks 1030 ** abstract type for a mutex object. The SQLite core never looks
974 ** at the internal representation of an [sqlite3_mutex]. It only 1031 ** at the internal representation of an [sqlite3_mutex]. It only
975 ** deals with pointers to the [sqlite3_mutex] object. 1032 ** deals with pointers to the [sqlite3_mutex] object.
976 ** 1033 **
977 ** Mutexes are created using [sqlite3_mutex_alloc()]. 1034 ** Mutexes are created using [sqlite3_mutex_alloc()].
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 ** xShmLock method: 1266 ** xShmLock method:
1210 ** 1267 **
1211 ** <ul> 1268 ** <ul>
1212 ** <li> SQLITE_SHM_LOCK | SQLITE_SHM_SHARED 1269 ** <li> SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
1213 ** <li> SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE 1270 ** <li> SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
1214 ** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED 1271 ** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
1215 ** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE 1272 ** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
1216 ** </ul> 1273 ** </ul>
1217 ** 1274 **
1218 ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as 1275 ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
1219 ** was given no the corresponding lock. 1276 ** was given on the corresponding lock.
1220 ** 1277 **
1221 ** The xShmLock method can transition between unlocked and SHARED or 1278 ** The xShmLock method can transition between unlocked and SHARED or
1222 ** between unlocked and EXCLUSIVE. It cannot transition between SHARED 1279 ** between unlocked and EXCLUSIVE. It cannot transition between SHARED
1223 ** and EXCLUSIVE. 1280 ** and EXCLUSIVE.
1224 */ 1281 */
1225 #define SQLITE_SHM_UNLOCK 1 1282 #define SQLITE_SHM_UNLOCK 1
1226 #define SQLITE_SHM_LOCK 2 1283 #define SQLITE_SHM_LOCK 2
1227 #define SQLITE_SHM_SHARED 4 1284 #define SQLITE_SHM_SHARED 4
1228 #define SQLITE_SHM_EXCLUSIVE 8 1285 #define SQLITE_SHM_EXCLUSIVE 8
1229 1286
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 1377
1321 /* 1378 /*
1322 ** CAPI3REF: Configuring The SQLite Library 1379 ** CAPI3REF: Configuring The SQLite Library
1323 ** 1380 **
1324 ** The sqlite3_config() interface is used to make global configuration 1381 ** The sqlite3_config() interface is used to make global configuration
1325 ** changes to SQLite in order to tune SQLite to the specific needs of 1382 ** changes to SQLite in order to tune SQLite to the specific needs of
1326 ** the application. The default configuration is recommended for most 1383 ** the application. The default configuration is recommended for most
1327 ** applications and so this routine is usually not necessary. It is 1384 ** applications and so this routine is usually not necessary. It is
1328 ** provided to support rare applications with unusual needs. 1385 ** provided to support rare applications with unusual needs.
1329 ** 1386 **
1330 ** The sqlite3_config() interface is not threadsafe. The application 1387 ** <b>The sqlite3_config() interface is not threadsafe. The application
1331 ** must insure that no other SQLite interfaces are invoked by other 1388 ** must ensure that no other SQLite interfaces are invoked by other
1332 ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() 1389 ** threads while sqlite3_config() is running.</b>
1390 **
1391 ** The sqlite3_config() interface
1333 ** may only be invoked prior to library initialization using 1392 ** may only be invoked prior to library initialization using
1334 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. 1393 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1335 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before 1394 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1336 ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. 1395 ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1337 ** Note, however, that ^sqlite3_config() can be called as part of the 1396 ** Note, however, that ^sqlite3_config() can be called as part of the
1338 ** implementation of an application-defined [sqlite3_os_init()]. 1397 ** implementation of an application-defined [sqlite3_os_init()].
1339 ** 1398 **
1340 ** The first argument to sqlite3_config() is an integer 1399 ** The first argument to sqlite3_config() is an integer
1341 ** [configuration option] that determines 1400 ** [configuration option] that determines
1342 ** what property of SQLite is to be configured. Subsequent arguments 1401 ** what property of SQLite is to be configured. Subsequent arguments
1343 ** vary depending on the [configuration option] 1402 ** vary depending on the [configuration option]
1344 ** in the first argument. 1403 ** in the first argument.
1345 ** 1404 **
1346 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. 1405 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1347 ** ^If the option is unknown or SQLite is unable to set the option 1406 ** ^If the option is unknown or SQLite is unable to set the option
1348 ** then this routine returns a non-zero [error code]. 1407 ** then this routine returns a non-zero [error code].
1349 */ 1408 */
1350 int sqlite3_config(int, ...); 1409 int sqlite3_config(int, ...);
1351 1410
1352 /* 1411 /*
1353 ** CAPI3REF: Configure database connections 1412 ** CAPI3REF: Configure database connections
1413 ** METHOD: sqlite3
1354 ** 1414 **
1355 ** The sqlite3_db_config() interface is used to make configuration 1415 ** The sqlite3_db_config() interface is used to make configuration
1356 ** changes to a [database connection]. The interface is similar to 1416 ** changes to a [database connection]. The interface is similar to
1357 ** [sqlite3_config()] except that the changes apply to a single 1417 ** [sqlite3_config()] except that the changes apply to a single
1358 ** [database connection] (specified in the first argument). 1418 ** [database connection] (specified in the first argument).
1359 ** 1419 **
1360 ** The second argument to sqlite3_db_config(D,V,...) is the 1420 ** The second argument to sqlite3_db_config(D,V,...) is the
1361 ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code 1421 ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code
1362 ** that indicates what aspect of the [database connection] is being configured. 1422 ** that indicates what aspect of the [database connection] is being configured.
1363 ** Subsequent arguments vary depending on the configuration verb. 1423 ** Subsequent arguments vary depending on the configuration verb.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 ** to [database connections] and [prepared statements] so that the 1552 ** to [database connections] and [prepared statements] so that the
1493 ** application is free to use the same [database connection] or the 1553 ** application is free to use the same [database connection] or the
1494 ** same [prepared statement] in different threads at the same time. 1554 ** same [prepared statement] in different threads at the same time.
1495 ** ^If SQLite is compiled with 1555 ** ^If SQLite is compiled with
1496 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then 1556 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1497 ** it is not possible to set the Serialized [threading mode] and 1557 ** it is not possible to set the Serialized [threading mode] and
1498 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the 1558 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1499 ** SQLITE_CONFIG_SERIALIZED configuration option.</dd> 1559 ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
1500 ** 1560 **
1501 ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt> 1561 ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
1502 ** <dd> ^(This option takes a single argument which is a pointer to an 1562 ** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is
1503 ** instance of the [sqlite3_mem_methods] structure. The argument specifies 1563 ** a pointer to an instance of the [sqlite3_mem_methods] structure.
1564 ** The argument specifies
1504 ** alternative low-level memory allocation routines to be used in place of 1565 ** alternative low-level memory allocation routines to be used in place of
1505 ** the memory allocation routines built into SQLite.)^ ^SQLite makes 1566 ** the memory allocation routines built into SQLite.)^ ^SQLite makes
1506 ** its own private copy of the content of the [sqlite3_mem_methods] structure 1567 ** its own private copy of the content of the [sqlite3_mem_methods] structure
1507 ** before the [sqlite3_config()] call returns.</dd> 1568 ** before the [sqlite3_config()] call returns.</dd>
1508 ** 1569 **
1509 ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt> 1570 ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
1510 ** <dd> ^(This option takes a single argument which is a pointer to an 1571 ** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
1511 ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] 1572 ** is a pointer to an instance of the [sqlite3_mem_methods] structure.
1573 ** The [sqlite3_mem_methods]
1512 ** structure is filled with the currently defined memory allocation routines.)^ 1574 ** structure is filled with the currently defined memory allocation routines.)^
1513 ** This option can be used to overload the default memory allocation 1575 ** This option can be used to overload the default memory allocation
1514 ** routines with a wrapper that simulations memory allocation failure or 1576 ** routines with a wrapper that simulations memory allocation failure or
1515 ** tracks memory usage, for example. </dd> 1577 ** tracks memory usage, for example. </dd>
1516 ** 1578 **
1517 ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt> 1579 ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1518 ** <dd> ^This option takes single argument of type int, interpreted as a 1580 ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
1519 ** boolean, which enables or disables the collection of memory allocation 1581 ** interpreted as a boolean, which enables or disables the collection of
1520 ** statistics. ^(When memory allocation statistics are disabled, the 1582 ** memory allocation statistics. ^(When memory allocation statistics are
1521 ** following SQLite interfaces become non-operational: 1583 ** disabled, the following SQLite interfaces become non-operational:
1522 ** <ul> 1584 ** <ul>
1523 ** <li> [sqlite3_memory_used()] 1585 ** <li> [sqlite3_memory_used()]
1524 ** <li> [sqlite3_memory_highwater()] 1586 ** <li> [sqlite3_memory_highwater()]
1525 ** <li> [sqlite3_soft_heap_limit64()] 1587 ** <li> [sqlite3_soft_heap_limit64()]
1526 ** <li> [sqlite3_status()] 1588 ** <li> [sqlite3_status64()]
1527 ** </ul>)^ 1589 ** </ul>)^
1528 ** ^Memory allocation statistics are enabled by default unless SQLite is 1590 ** ^Memory allocation statistics are enabled by default unless SQLite is
1529 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory 1591 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1530 ** allocation statistics are disabled by default. 1592 ** allocation statistics are disabled by default.
1531 ** </dd> 1593 ** </dd>
1532 ** 1594 **
1533 ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt> 1595 ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
1534 ** <dd> ^This option specifies a static memory buffer that SQLite can use for 1596 ** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
1535 ** scratch memory. There are three arguments: A pointer an 8-byte 1597 ** that SQLite can use for scratch memory. ^(There are three arguments
1598 ** to SQLITE_CONFIG_SCRATCH: A pointer an 8-byte
1536 ** aligned memory buffer from which the scratch allocations will be 1599 ** aligned memory buffer from which the scratch allocations will be
1537 ** drawn, the size of each scratch allocation (sz), 1600 ** drawn, the size of each scratch allocation (sz),
1538 ** and the maximum number of scratch allocations (N). The sz 1601 ** and the maximum number of scratch allocations (N).)^
1539 ** argument must be a multiple of 16.
1540 ** The first argument must be a pointer to an 8-byte aligned buffer 1602 ** The first argument must be a pointer to an 8-byte aligned buffer
1541 ** of at least sz*N bytes of memory. 1603 ** of at least sz*N bytes of memory.
1542 ** ^SQLite will use no more than two scratch buffers per thread. So 1604 ** ^SQLite will not use more than one scratch buffers per thread.
1543 ** N should be set to twice the expected maximum number of threads. 1605 ** ^SQLite will never request a scratch buffer that is more than 6
1544 ** ^SQLite will never require a scratch buffer that is more than 6 1606 ** times the database page size.
1545 ** times the database page size. ^If SQLite needs needs additional 1607 ** ^If SQLite needs needs additional
1546 ** scratch memory beyond what is provided by this configuration option, then 1608 ** scratch memory beyond what is provided by this configuration option, then
1547 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> 1609 ** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
1610 ** ^When the application provides any amount of scratch memory using
1611 ** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
1612 ** [sqlite3_malloc|heap allocations].
1613 ** This can help [Robson proof|prevent memory allocation failures] due to heap
1614 ** fragmentation in low-memory embedded systems.
1615 ** </dd>
1548 ** 1616 **
1549 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> 1617 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1550 ** <dd> ^This option specifies a static memory buffer that SQLite can use for 1618 ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
1551 ** the database page cache with the default page cache implementation. 1619 ** that SQLite can use for the database page cache with the default page
1552 ** This configuration should not be used if an application-define page 1620 ** cache implementation.
1553 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option. 1621 ** This configuration option is a no-op if an application-define page
1554 ** There are three arguments to this option: A pointer to 8-byte aligned 1622 ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
1555 ** memory, the size of each page buffer (sz), and the number of pages (N). 1623 ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
1624 ** 8-byte aligned memory (pMem), the size of each page cache line (sz),
1625 ** and the number of cache lines (N).
1556 ** The sz argument should be the size of the largest database page 1626 ** The sz argument should be the size of the largest database page
1557 ** (a power of two between 512 and 32768) plus a little extra for each 1627 ** (a power of two between 512 and 65536) plus some extra bytes for each
1558 ** page header. ^The page header size is 20 to 40 bytes depending on 1628 ** page header. ^The number of extra bytes needed by the page header
1559 ** the host architecture. ^It is harmless, apart from the wasted memory, 1629 ** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].
1560 ** to make sz a little too large. The first 1630 ** ^It is harmless, apart from the wasted memory,
1561 ** argument should point to an allocation of at least sz*N bytes of memory. 1631 ** for the sz parameter to be larger than necessary. The pMem
1562 ** ^SQLite will use the memory provided by the first argument to satisfy its 1632 ** argument must be either a NULL pointer or a pointer to an 8-byte
1563 ** memory needs for the first N pages that it adds to cache. ^If additional 1633 ** aligned block of memory of at least sz*N bytes, otherwise
1564 ** page cache memory is needed beyond what is provided by this option, then 1634 ** subsequent behavior is undefined.
1565 ** SQLite goes to [sqlite3_malloc()] for the additional storage space. 1635 ** ^When pMem is not NULL, SQLite will strive to use the memory provided
1566 ** The pointer in the first argument must 1636 ** to satisfy page cache needs, falling back to [sqlite3_malloc()] if
1567 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite 1637 ** a page cache line is larger than sz bytes or if all of the pMem buffer
1568 ** will be undefined.</dd> 1638 ** is exhausted.
1639 ** ^If pMem is NULL and N is non-zero, then each database connection
1640 ** does an initial bulk allocation for page cache memory
1641 ** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
1642 ** of -1024*N bytes if N is negative, . ^If additional
1643 ** page cache memory is needed beyond what is provided by the initial
1644 ** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
1645 ** additional cache line. </dd>
1569 ** 1646 **
1570 ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt> 1647 ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
1571 ** <dd> ^This option specifies a static memory buffer that SQLite will use 1648 ** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer
1572 ** for all of its dynamic memory allocation needs beyond those provided 1649 ** that SQLite will use for all of its dynamic memory allocation needs
1573 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. 1650 ** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
1574 ** There are three arguments: An 8-byte aligned pointer to the memory, 1651 ** [SQLITE_CONFIG_PAGECACHE].
1652 ** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
1653 ** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
1654 ** [SQLITE_ERROR] if invoked otherwise.
1655 ** ^There are three arguments to SQLITE_CONFIG_HEAP:
1656 ** An 8-byte aligned pointer to the memory,
1575 ** the number of bytes in the memory buffer, and the minimum allocation size. 1657 ** the number of bytes in the memory buffer, and the minimum allocation size.
1576 ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts 1658 ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
1577 ** to using its default memory allocator (the system malloc() implementation), 1659 ** to using its default memory allocator (the system malloc() implementation),
1578 ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the 1660 ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
1579 ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or 1661 ** memory pointer is not NULL then the alternative memory
1580 ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
1581 ** allocator is engaged to handle all of SQLites memory allocation needs. 1662 ** allocator is engaged to handle all of SQLites memory allocation needs.
1582 ** The first pointer (the memory pointer) must be aligned to an 8-byte 1663 ** The first pointer (the memory pointer) must be aligned to an 8-byte
1583 ** boundary or subsequent behavior of SQLite will be undefined. 1664 ** boundary or subsequent behavior of SQLite will be undefined.
1584 ** The minimum allocation size is capped at 2**12. Reasonable values 1665 ** The minimum allocation size is capped at 2**12. Reasonable values
1585 ** for the minimum allocation size are 2**5 through 2**8.</dd> 1666 ** for the minimum allocation size are 2**5 through 2**8.</dd>
1586 ** 1667 **
1587 ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt> 1668 ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
1588 ** <dd> ^(This option takes a single argument which is a pointer to an 1669 ** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
1589 ** instance of the [sqlite3_mutex_methods] structure. The argument specifies 1670 ** pointer to an instance of the [sqlite3_mutex_methods] structure.
1590 ** alternative low-level mutex routines to be used in place 1671 ** The argument specifies alternative low-level mutex routines to be used
1591 ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the 1672 ** in place the mutex routines built into SQLite.)^ ^SQLite makes a copy of
1592 ** content of the [sqlite3_mutex_methods] structure before the call to 1673 ** the content of the [sqlite3_mutex_methods] structure before the call to
1593 ** [sqlite3_config()] returns. ^If SQLite is compiled with 1674 ** [sqlite3_config()] returns. ^If SQLite is compiled with
1594 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then 1675 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1595 ** the entire mutexing subsystem is omitted from the build and hence calls to 1676 ** the entire mutexing subsystem is omitted from the build and hence calls to
1596 ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will 1677 ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
1597 ** return [SQLITE_ERROR].</dd> 1678 ** return [SQLITE_ERROR].</dd>
1598 ** 1679 **
1599 ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt> 1680 ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
1600 ** <dd> ^(This option takes a single argument which is a pointer to an 1681 ** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
1601 ** instance of the [sqlite3_mutex_methods] structure. The 1682 ** is a pointer to an instance of the [sqlite3_mutex_methods] structure. The
1602 ** [sqlite3_mutex_methods] 1683 ** [sqlite3_mutex_methods]
1603 ** structure is filled with the currently defined mutex routines.)^ 1684 ** structure is filled with the currently defined mutex routines.)^
1604 ** This option can be used to overload the default mutex allocation 1685 ** This option can be used to overload the default mutex allocation
1605 ** routines with a wrapper used to track mutex usage for performance 1686 ** routines with a wrapper used to track mutex usage for performance
1606 ** profiling or testing, for example. ^If SQLite is compiled with 1687 ** profiling or testing, for example. ^If SQLite is compiled with
1607 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then 1688 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1608 ** the entire mutexing subsystem is omitted from the build and hence calls to 1689 ** the entire mutexing subsystem is omitted from the build and hence calls to
1609 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will 1690 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1610 ** return [SQLITE_ERROR].</dd> 1691 ** return [SQLITE_ERROR].</dd>
1611 ** 1692 **
1612 ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt> 1693 ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1613 ** <dd> ^(This option takes two arguments that determine the default 1694 ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
1614 ** memory allocation for the lookaside memory allocator on each 1695 ** the default size of lookaside memory on each [database connection].
1615 ** [database connection]. The first argument is the 1696 ** The first argument is the
1616 ** size of each lookaside buffer slot and the second is the number of 1697 ** size of each lookaside buffer slot and the second is the number of
1617 ** slots allocated to each database connection.)^ ^(This option sets the 1698 ** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
1618 ** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] 1699 ** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1619 ** verb to [sqlite3_db_config()] can be used to change the lookaside 1700 ** option to [sqlite3_db_config()] can be used to change the lookaside
1620 ** configuration on individual connections.)^ </dd> 1701 ** configuration on individual connections.)^ </dd>
1621 ** 1702 **
1622 ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt> 1703 ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
1623 ** <dd> ^(This option takes a single argument which is a pointer to 1704 ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
1624 ** an [sqlite3_pcache_methods2] object. This object specifies the interface 1705 ** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
1625 ** to a custom page cache implementation.)^ ^SQLite makes a copy of the 1706 ** the interface to a custom page cache implementation.)^
1626 ** object and uses it for page cache memory allocations.</dd> 1707 ** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
1627 ** 1708 **
1628 ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt> 1709 ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
1629 ** <dd> ^(This option takes a single argument which is a pointer to an 1710 ** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
1630 ** [sqlite3_pcache_methods2] object. SQLite copies of the current 1711 ** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of
1631 ** page cache implementation into that object.)^ </dd> 1712 ** the current page cache implementation into that object.)^ </dd>
1632 ** 1713 **
1633 ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt> 1714 ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
1634 ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite 1715 ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
1635 ** global [error log]. 1716 ** global [error log].
1636 ** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a 1717 ** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
1637 ** function with a call signature of void(*)(void*,int,const char*), 1718 ** function with a call signature of void(*)(void*,int,const char*),
1638 ** and a pointer to void. ^If the function pointer is not NULL, it is 1719 ** and a pointer to void. ^If the function pointer is not NULL, it is
1639 ** invoked by [sqlite3_log()] to process each logging event. ^If the 1720 ** invoked by [sqlite3_log()] to process each logging event. ^If the
1640 ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. 1721 ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
1641 ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is 1722 ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
1642 ** passed through as the first parameter to the application-defined logger 1723 ** passed through as the first parameter to the application-defined logger
1643 ** function whenever that function is invoked. ^The second parameter to 1724 ** function whenever that function is invoked. ^The second parameter to
1644 ** the logger function is a copy of the first parameter to the corresponding 1725 ** the logger function is a copy of the first parameter to the corresponding
1645 ** [sqlite3_log()] call and is intended to be a [result code] or an 1726 ** [sqlite3_log()] call and is intended to be a [result code] or an
1646 ** [extended result code]. ^The third parameter passed to the logger is 1727 ** [extended result code]. ^The third parameter passed to the logger is
1647 ** log message after formatting via [sqlite3_snprintf()]. 1728 ** log message after formatting via [sqlite3_snprintf()].
1648 ** The SQLite logging interface is not reentrant; the logger function 1729 ** The SQLite logging interface is not reentrant; the logger function
1649 ** supplied by the application must not invoke any SQLite interface. 1730 ** supplied by the application must not invoke any SQLite interface.
1650 ** In a multi-threaded application, the application-defined logger 1731 ** In a multi-threaded application, the application-defined logger
1651 ** function must be threadsafe. </dd> 1732 ** function must be threadsafe. </dd>
1652 ** 1733 **
1653 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI 1734 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1654 ** <dd>^(This option takes a single argument of type int. If non-zero, then 1735 ** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
1655 ** URI handling is globally enabled. If the parameter is zero, then URI handling 1736 ** If non-zero, then URI handling is globally enabled. If the parameter is zero,
1656 ** is globally disabled.)^ ^If URI handling is globally enabled, all filenames 1737 ** then URI handling is globally disabled.)^ ^If URI handling is globally
1657 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or 1738 ** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
1739 ** [sqlite3_open16()] or
1658 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless 1740 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1659 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database 1741 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1660 ** connection is opened. ^If it is globally disabled, filenames are 1742 ** connection is opened. ^If it is globally disabled, filenames are
1661 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the 1743 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1662 ** database connection is opened. ^(By default, URI handling is globally 1744 ** database connection is opened. ^(By default, URI handling is globally
1663 ** disabled. The default value may be changed by compiling with the 1745 ** disabled. The default value may be changed by compiling with the
1664 ** [SQLITE_USE_URI] symbol defined.)^ 1746 ** [SQLITE_USE_URI] symbol defined.)^
1665 ** 1747 **
1666 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN 1748 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1667 ** <dd>^This option takes a single integer argument which is interpreted as 1749 ** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
1668 ** a boolean in order to enable or disable the use of covering indices for 1750 ** argument which is interpreted as a boolean in order to enable or disable
1669 ** full table scans in the query optimizer. ^The default setting is determined 1751 ** the use of covering indices for full table scans in the query optimizer.
1752 ** ^The default setting is determined
1670 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" 1753 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1671 ** if that compile-time option is omitted. 1754 ** if that compile-time option is omitted.
1672 ** The ability to disable the use of covering indices for full table scans 1755 ** The ability to disable the use of covering indices for full table scans
1673 ** is because some incorrectly coded legacy applications might malfunction 1756 ** is because some incorrectly coded legacy applications might malfunction
1674 ** when the optimization is enabled. Providing the ability to 1757 ** when the optimization is enabled. Providing the ability to
1675 ** disable the optimization allows the older, buggy application code to work 1758 ** disable the optimization allows the older, buggy application code to work
1676 ** without change even with newer versions of SQLite. 1759 ** without change even with newer versions of SQLite.
1677 ** 1760 **
1678 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]] 1761 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1679 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE 1762 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
(...skipping 19 matching lines...) Expand all
1699 ** the canonical SQLite source tree.</dd> 1782 ** the canonical SQLite source tree.</dd>
1700 ** 1783 **
1701 ** [[SQLITE_CONFIG_MMAP_SIZE]] 1784 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1702 ** <dt>SQLITE_CONFIG_MMAP_SIZE 1785 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1703 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values 1786 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1704 ** that are the default mmap size limit (the default setting for 1787 ** that are the default mmap size limit (the default setting for
1705 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit. 1788 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1706 ** ^The default setting can be overridden by each database connection using 1789 ** ^The default setting can be overridden by each database connection using
1707 ** either the [PRAGMA mmap_size] command, or by using the 1790 ** either the [PRAGMA mmap_size] command, or by using the
1708 ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size 1791 ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
1709 ** cannot be changed at run-time. Nor may the maximum allowed mmap size 1792 ** will be silently truncated if necessary so that it does not exceed the
1710 ** exceed the compile-time maximum mmap size set by the 1793 ** compile-time maximum mmap size set by the
1711 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^ 1794 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1712 ** ^If either argument to this option is negative, then that argument is 1795 ** ^If either argument to this option is negative, then that argument is
1713 ** changed to its compile-time default. 1796 ** changed to its compile-time default.
1714 ** 1797 **
1715 ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]] 1798 ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
1716 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE 1799 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
1717 ** <dd>^This option is only available if SQLite is compiled for Windows 1800 ** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
1718 ** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined. 1801 ** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
1719 ** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value 1802 ** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
1720 ** that specifies the maximum size of the created heap. 1803 ** that specifies the maximum size of the created heap.
1804 **
1805 ** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
1806 ** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
1807 ** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
1808 ** is a pointer to an integer and writes into that integer the number of extra
1809 ** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
1810 ** The amount of extra space required can change depending on the compiler,
1811 ** target platform, and SQLite version.
1812 **
1813 ** [[SQLITE_CONFIG_PMASZ]]
1814 ** <dt>SQLITE_CONFIG_PMASZ
1815 ** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
1816 ** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
1817 ** sorter to that integer. The default minimum PMA Size is set by the
1818 ** [SQLITE_SORTER_PMASZ] compile-time option. New threads are launched
1819 ** to help with sort operations when multithreaded sorting
1820 ** is enabled (using the [PRAGMA threads] command) and the amount of content
1821 ** to be sorted exceeds the page size times the minimum of the
1822 ** [PRAGMA cache_size] setting and this value.
1721 ** </dl> 1823 ** </dl>
1722 */ 1824 */
1723 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ 1825 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1724 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ 1826 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1725 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ 1827 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */
1726 #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ 1828 #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
1727 #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ 1829 #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
1728 #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ 1830 #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */
1729 #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ 1831 #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
1730 #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ 1832 #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
1731 #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ 1833 #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
1732 #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ 1834 #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
1733 #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ 1835 #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
1734 /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ 1836 /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
1735 #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ 1837 #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
1736 #define SQLITE_CONFIG_PCACHE 14 /* no-op */ 1838 #define SQLITE_CONFIG_PCACHE 14 /* no-op */
1737 #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ 1839 #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
1738 #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ 1840 #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
1739 #define SQLITE_CONFIG_URI 17 /* int */ 1841 #define SQLITE_CONFIG_URI 17 /* int */
1740 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ 1842 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
1741 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ 1843 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
1742 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ 1844 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
1743 #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ 1845 #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
1744 #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ 1846 #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
1745 #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ 1847 #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
1848 #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
1849 #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
1746 1850
1747 /* 1851 /*
1748 ** CAPI3REF: Database Connection Configuration Options 1852 ** CAPI3REF: Database Connection Configuration Options
1749 ** 1853 **
1750 ** These constants are the available integer configuration options that 1854 ** These constants are the available integer configuration options that
1751 ** can be passed as the second argument to the [sqlite3_db_config()] interface. 1855 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
1752 ** 1856 **
1753 ** New configuration options may be added in future releases of SQLite. 1857 ** New configuration options may be added in future releases of SQLite.
1754 ** Existing configuration options might be discontinued. Applications 1858 ** Existing configuration options might be discontinued. Applications
1755 ** should check the return code from [sqlite3_db_config()] to make sure that 1859 ** should check the return code from [sqlite3_db_config()] to make sure that
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 ** 1906 **
1803 ** </dl> 1907 ** </dl>
1804 */ 1908 */
1805 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ 1909 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1806 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ 1910 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
1807 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ 1911 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
1808 1912
1809 1913
1810 /* 1914 /*
1811 ** CAPI3REF: Enable Or Disable Extended Result Codes 1915 ** CAPI3REF: Enable Or Disable Extended Result Codes
1916 ** METHOD: sqlite3
1812 ** 1917 **
1813 ** ^The sqlite3_extended_result_codes() routine enables or disables the 1918 ** ^The sqlite3_extended_result_codes() routine enables or disables the
1814 ** [extended result codes] feature of SQLite. ^The extended result 1919 ** [extended result codes] feature of SQLite. ^The extended result
1815 ** codes are disabled by default for historical compatibility. 1920 ** codes are disabled by default for historical compatibility.
1816 */ 1921 */
1817 int sqlite3_extended_result_codes(sqlite3*, int onoff); 1922 int sqlite3_extended_result_codes(sqlite3*, int onoff);
1818 1923
1819 /* 1924 /*
1820 ** CAPI3REF: Last Insert Rowid 1925 ** CAPI3REF: Last Insert Rowid
1926 ** METHOD: sqlite3
1821 ** 1927 **
1822 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) 1928 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
1823 ** has a unique 64-bit signed 1929 ** has a unique 64-bit signed
1824 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available 1930 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
1825 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those 1931 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1826 ** names are not also used by explicitly declared columns. ^If 1932 ** names are not also used by explicitly declared columns. ^If
1827 ** the table has a column of type [INTEGER PRIMARY KEY] then that column 1933 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
1828 ** is another alias for the rowid. 1934 ** is another alias for the rowid.
1829 ** 1935 **
1830 ** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the 1936 ** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 ** database connection while the [sqlite3_last_insert_rowid()] 1968 ** database connection while the [sqlite3_last_insert_rowid()]
1863 ** function is running and thus changes the last insert [rowid], 1969 ** function is running and thus changes the last insert [rowid],
1864 ** then the value returned by [sqlite3_last_insert_rowid()] is 1970 ** then the value returned by [sqlite3_last_insert_rowid()] is
1865 ** unpredictable and might not equal either the old or the new 1971 ** unpredictable and might not equal either the old or the new
1866 ** last insert [rowid]. 1972 ** last insert [rowid].
1867 */ 1973 */
1868 sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); 1974 sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1869 1975
1870 /* 1976 /*
1871 ** CAPI3REF: Count The Number Of Rows Modified 1977 ** CAPI3REF: Count The Number Of Rows Modified
1978 ** METHOD: sqlite3
1872 ** 1979 **
1873 ** ^This function returns the number of database rows that were changed 1980 ** ^This function returns the number of rows modified, inserted or
1874 ** or inserted or deleted by the most recently completed SQL statement 1981 ** deleted by the most recently completed INSERT, UPDATE or DELETE
1875 ** on the [database connection] specified by the first parameter. 1982 ** statement on the database connection specified by the only parameter.
1876 ** ^(Only changes that are directly specified by the [INSERT], [UPDATE], 1983 ** ^Executing any other type of SQL statement does not modify the value
1877 ** or [DELETE] statement are counted. Auxiliary changes caused by 1984 ** returned by this function.
1878 ** triggers or [foreign key actions] are not counted.)^ Use the
1879 ** [sqlite3_total_changes()] function to find the total number of changes
1880 ** including changes caused by triggers and foreign key actions.
1881 ** 1985 **
1882 ** ^Changes to a view that are simulated by an [INSTEAD OF trigger] 1986 ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
1883 ** are not counted. Only real table changes are counted. 1987 ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
1988 ** [foreign key actions] or [REPLACE] constraint resolution are not counted.
1989 **
1990 ** Changes to a view that are intercepted by
1991 ** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value
1992 ** returned by sqlite3_changes() immediately after an INSERT, UPDATE or
1993 ** DELETE statement run on a view is always zero. Only changes made to real
1994 ** tables are counted.
1884 ** 1995 **
1885 ** ^(A "row change" is a change to a single row of a single table 1996 ** Things are more complicated if the sqlite3_changes() function is
1886 ** caused by an INSERT, DELETE, or UPDATE statement. Rows that 1997 ** executed while a trigger program is running. This may happen if the
1887 ** are changed as side effects of [REPLACE] constraint resolution, 1998 ** program uses the [changes() SQL function], or if some other callback
1888 ** rollback, ABORT processing, [DROP TABLE], or by any other 1999 ** function invokes sqlite3_changes() directly. Essentially:
1889 ** mechanisms do not count as direct row changes.)^ 2000 **
1890 ** 2001 ** <ul>
1891 ** A "trigger context" is a scope of execution that begins and 2002 ** <li> ^(Before entering a trigger program the value returned by
1892 ** ends with the script of a [CREATE TRIGGER | trigger]. 2003 ** sqlite3_changes() function is saved. After the trigger program
1893 ** Most SQL statements are 2004 ** has finished, the original value is restored.)^
1894 ** evaluated outside of any trigger. This is the "top level" 2005 **
1895 ** trigger context. If a trigger fires from the top level, a 2006 ** <li> ^(Within a trigger program each INSERT, UPDATE and DELETE
1896 ** new trigger context is entered for the duration of that one 2007 ** statement sets the value returned by sqlite3_changes()
1897 ** trigger. Subtriggers create subcontexts for their duration. 2008 ** upon completion as normal. Of course, this value will not include
1898 ** 2009 ** any changes performed by sub-triggers, as the sqlite3_changes()
1899 ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does 2010 ** value will be saved and restored after each sub-trigger has run.)^
1900 ** not create a new trigger context. 2011 ** </ul>
1901 ** 2012 **
1902 ** ^This function returns the number of direct row changes in the 2013 ** ^This means that if the changes() SQL function (or similar) is used
1903 ** most recent INSERT, UPDATE, or DELETE statement within the same 2014 ** by the first INSERT, UPDATE or DELETE statement within a trigger, it
1904 ** trigger context. 2015 ** returns the value as set when the calling statement began executing.
1905 ** 2016 ** ^If it is used by the second or subsequent such statement within a trigger
1906 ** ^Thus, when called from the top level, this function returns the 2017 ** program, the value returned reflects the number of rows modified by the
1907 ** number of changes in the most recent INSERT, UPDATE, or DELETE 2018 ** previous INSERT, UPDATE or DELETE statement within the same trigger.
1908 ** that also occurred at the top level. ^(Within the body of a trigger,
1909 ** the sqlite3_changes() interface can be called to find the number of
1910 ** changes in the most recently completed INSERT, UPDATE, or DELETE
1911 ** statement within the body of the same trigger.
1912 ** However, the number returned does not include changes
1913 ** caused by subtriggers since those have their own context.)^
1914 ** 2019 **
1915 ** See also the [sqlite3_total_changes()] interface, the 2020 ** See also the [sqlite3_total_changes()] interface, the
1916 ** [count_changes pragma], and the [changes() SQL function]. 2021 ** [count_changes pragma], and the [changes() SQL function].
1917 ** 2022 **
1918 ** If a separate thread makes changes on the same database connection 2023 ** If a separate thread makes changes on the same database connection
1919 ** while [sqlite3_changes()] is running then the value returned 2024 ** while [sqlite3_changes()] is running then the value returned
1920 ** is unpredictable and not meaningful. 2025 ** is unpredictable and not meaningful.
1921 */ 2026 */
1922 int sqlite3_changes(sqlite3*); 2027 int sqlite3_changes(sqlite3*);
1923 2028
1924 /* 2029 /*
1925 ** CAPI3REF: Total Number Of Rows Modified 2030 ** CAPI3REF: Total Number Of Rows Modified
2031 ** METHOD: sqlite3
1926 ** 2032 **
1927 ** ^This function returns the number of row changes caused by [INSERT], 2033 ** ^This function returns the total number of rows inserted, modified or
1928 ** [UPDATE] or [DELETE] statements since the [database connection] was opened. 2034 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
1929 ** ^(The count returned by sqlite3_total_changes() includes all changes 2035 ** since the database connection was opened, including those executed as
1930 ** from all [CREATE TRIGGER | trigger] contexts and changes made by 2036 ** part of trigger programs. ^Executing any other type of SQL statement
1931 ** [foreign key actions]. However, 2037 ** does not affect the value returned by sqlite3_total_changes().
1932 ** the count does not include changes used to implement [REPLACE] constraints, 2038 **
1933 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The 2039 ** ^Changes made as part of [foreign key actions] are included in the
1934 ** count does not include rows of views that fire an [INSTEAD OF trigger], 2040 ** count, but those made as part of REPLACE constraint resolution are
1935 ** though if the INSTEAD OF trigger makes changes of its own, those changes 2041 ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
1936 ** are counted.)^ 2042 ** are not counted.
1937 ** ^The sqlite3_total_changes() function counts the changes as soon as 2043 **
1938 ** the statement that makes them is completed (when the statement handle
1939 ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
1940 **
1941 ** See also the [sqlite3_changes()] interface, the 2044 ** See also the [sqlite3_changes()] interface, the
1942 ** [count_changes pragma], and the [total_changes() SQL function]. 2045 ** [count_changes pragma], and the [total_changes() SQL function].
1943 ** 2046 **
1944 ** If a separate thread makes changes on the same database connection 2047 ** If a separate thread makes changes on the same database connection
1945 ** while [sqlite3_total_changes()] is running then the value 2048 ** while [sqlite3_total_changes()] is running then the value
1946 ** returned is unpredictable and not meaningful. 2049 ** returned is unpredictable and not meaningful.
1947 */ 2050 */
1948 int sqlite3_total_changes(sqlite3*); 2051 int sqlite3_total_changes(sqlite3*);
1949 2052
1950 /* 2053 /*
1951 ** CAPI3REF: Interrupt A Long-Running Query 2054 ** CAPI3REF: Interrupt A Long-Running Query
2055 ** METHOD: sqlite3
1952 ** 2056 **
1953 ** ^This function causes any pending database operation to abort and 2057 ** ^This function causes any pending database operation to abort and
1954 ** return at its earliest opportunity. This routine is typically 2058 ** return at its earliest opportunity. This routine is typically
1955 ** called in response to a user action such as pressing "Cancel" 2059 ** called in response to a user action such as pressing "Cancel"
1956 ** or Ctrl-C where the user wants a long query operation to halt 2060 ** or Ctrl-C where the user wants a long query operation to halt
1957 ** immediately. 2061 ** immediately.
1958 ** 2062 **
1959 ** ^It is safe to call this routine from a thread different from the 2063 ** ^It is safe to call this routine from a thread different from the
1960 ** thread that is currently running the database operation. But it 2064 ** thread that is currently running the database operation. But it
1961 ** is not safe to call this routine with a [database connection] that 2065 ** is not safe to call this routine with a [database connection] that
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 ** UTF-8 string. 2121 ** UTF-8 string.
2018 ** 2122 **
2019 ** The input to [sqlite3_complete16()] must be a zero-terminated 2123 ** The input to [sqlite3_complete16()] must be a zero-terminated
2020 ** UTF-16 string in native byte order. 2124 ** UTF-16 string in native byte order.
2021 */ 2125 */
2022 int sqlite3_complete(const char *sql); 2126 int sqlite3_complete(const char *sql);
2023 int sqlite3_complete16(const void *sql); 2127 int sqlite3_complete16(const void *sql);
2024 2128
2025 /* 2129 /*
2026 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors 2130 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2131 ** KEYWORDS: {busy-handler callback} {busy handler}
2132 ** METHOD: sqlite3
2027 ** 2133 **
2028 ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X 2134 ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
2029 ** that might be invoked with argument P whenever 2135 ** that might be invoked with argument P whenever
2030 ** an attempt is made to access a database table associated with 2136 ** an attempt is made to access a database table associated with
2031 ** [database connection] D when another thread 2137 ** [database connection] D when another thread
2032 ** or process has the table locked. 2138 ** or process has the table locked.
2033 ** The sqlite3_busy_handler() interface is used to implement 2139 ** The sqlite3_busy_handler() interface is used to implement
2034 ** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. 2140 ** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].
2035 ** 2141 **
2036 ** ^If the busy callback is NULL, then [SQLITE_BUSY] 2142 ** ^If the busy callback is NULL, then [SQLITE_BUSY]
2037 ** is returned immediately upon encountering the lock. ^If the busy callback 2143 ** is returned immediately upon encountering the lock. ^If the busy callback
2038 ** is not NULL, then the callback might be invoked with two arguments. 2144 ** is not NULL, then the callback might be invoked with two arguments.
2039 ** 2145 **
2040 ** ^The first argument to the busy handler is a copy of the void* pointer which 2146 ** ^The first argument to the busy handler is a copy of the void* pointer which
2041 ** is the third argument to sqlite3_busy_handler(). ^The second argument to 2147 ** is the third argument to sqlite3_busy_handler(). ^The second argument to
2042 ** the busy handler callback is the number of times that the busy handler has 2148 ** the busy handler callback is the number of times that the busy handler has
2043 ** been invoked for the same locking event. ^If the 2149 ** been invoked previously for the same locking event. ^If the
2044 ** busy callback returns 0, then no additional attempts are made to 2150 ** busy callback returns 0, then no additional attempts are made to
2045 ** access the database and [SQLITE_BUSY] is returned 2151 ** access the database and [SQLITE_BUSY] is returned
2046 ** to the application. 2152 ** to the application.
2047 ** ^If the callback returns non-zero, then another attempt 2153 ** ^If the callback returns non-zero, then another attempt
2048 ** is made to access the database and the cycle repeats. 2154 ** is made to access the database and the cycle repeats.
2049 ** 2155 **
2050 ** The presence of a busy handler does not guarantee that it will be invoked 2156 ** The presence of a busy handler does not guarantee that it will be invoked
2051 ** when there is lock contention. ^If SQLite determines that invoking the busy 2157 ** when there is lock contention. ^If SQLite determines that invoking the busy
2052 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] 2158 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
2053 ** to the application instead of invoking the 2159 ** to the application instead of invoking the
(...skipping 22 matching lines...) Expand all
2076 ** the busy handler is not reentrant. Any such actions 2182 ** the busy handler is not reentrant. Any such actions
2077 ** result in undefined behavior. 2183 ** result in undefined behavior.
2078 ** 2184 **
2079 ** A busy handler must not close the database connection 2185 ** A busy handler must not close the database connection
2080 ** or [prepared statement] that invoked the busy handler. 2186 ** or [prepared statement] that invoked the busy handler.
2081 */ 2187 */
2082 int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); 2188 int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2083 2189
2084 /* 2190 /*
2085 ** CAPI3REF: Set A Busy Timeout 2191 ** CAPI3REF: Set A Busy Timeout
2192 ** METHOD: sqlite3
2086 ** 2193 **
2087 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps 2194 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2088 ** for a specified amount of time when a table is locked. ^The handler 2195 ** for a specified amount of time when a table is locked. ^The handler
2089 ** will sleep multiple times until at least "ms" milliseconds of sleeping 2196 ** will sleep multiple times until at least "ms" milliseconds of sleeping
2090 ** have accumulated. ^After at least "ms" milliseconds of sleeping, 2197 ** have accumulated. ^After at least "ms" milliseconds of sleeping,
2091 ** the handler returns 0 which causes [sqlite3_step()] to return 2198 ** the handler returns 0 which causes [sqlite3_step()] to return
2092 ** [SQLITE_BUSY]. 2199 ** [SQLITE_BUSY].
2093 ** 2200 **
2094 ** ^Calling this routine with an argument less than or equal to zero 2201 ** ^Calling this routine with an argument less than or equal to zero
2095 ** turns off all busy handlers. 2202 ** turns off all busy handlers.
2096 ** 2203 **
2097 ** ^(There can only be a single busy handler for a particular 2204 ** ^(There can only be a single busy handler for a particular
2098 ** [database connection] at any given moment. If another busy handler 2205 ** [database connection] at any given moment. If another busy handler
2099 ** was defined (using [sqlite3_busy_handler()]) prior to calling 2206 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2100 ** this routine, that other busy handler is cleared.)^ 2207 ** this routine, that other busy handler is cleared.)^
2101 ** 2208 **
2102 ** See also: [PRAGMA busy_timeout] 2209 ** See also: [PRAGMA busy_timeout]
2103 */ 2210 */
2104 int sqlite3_busy_timeout(sqlite3*, int ms); 2211 int sqlite3_busy_timeout(sqlite3*, int ms);
2105 2212
2106 /* 2213 /*
2107 ** CAPI3REF: Convenience Routines For Running Queries 2214 ** CAPI3REF: Convenience Routines For Running Queries
2215 ** METHOD: sqlite3
2108 ** 2216 **
2109 ** This is a legacy interface that is preserved for backwards compatibility. 2217 ** This is a legacy interface that is preserved for backwards compatibility.
2110 ** Use of this interface is not recommended. 2218 ** Use of this interface is not recommended.
2111 ** 2219 **
2112 ** Definition: A <b>result table</b> is memory data structure created by the 2220 ** Definition: A <b>result table</b> is memory data structure created by the
2113 ** [sqlite3_get_table()] interface. A result table records the 2221 ** [sqlite3_get_table()] interface. A result table records the
2114 ** complete query results from one or more queries. 2222 ** complete query results from one or more queries.
2115 ** 2223 **
2116 ** The table conceptually has a number of rows and columns. But 2224 ** The table conceptually has a number of rows and columns. But
2117 ** these numbers are not part of the result table itself. These 2225 ** these numbers are not part of the result table itself. These
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2183 int *pnColumn, /* Number of result columns written here */ 2291 int *pnColumn, /* Number of result columns written here */
2184 char **pzErrmsg /* Error msg written here */ 2292 char **pzErrmsg /* Error msg written here */
2185 ); 2293 );
2186 void sqlite3_free_table(char **result); 2294 void sqlite3_free_table(char **result);
2187 2295
2188 /* 2296 /*
2189 ** CAPI3REF: Formatted String Printing Functions 2297 ** CAPI3REF: Formatted String Printing Functions
2190 ** 2298 **
2191 ** These routines are work-alikes of the "printf()" family of functions 2299 ** These routines are work-alikes of the "printf()" family of functions
2192 ** from the standard C library. 2300 ** from the standard C library.
2301 ** These routines understand most of the common K&R formatting options,
2302 ** plus some additional non-standard formats, detailed below.
2303 ** Note that some of the more obscure formatting options from recent
2304 ** C-library standards are omitted from this implementation.
2193 ** 2305 **
2194 ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their 2306 ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
2195 ** results into memory obtained from [sqlite3_malloc()]. 2307 ** results into memory obtained from [sqlite3_malloc()].
2196 ** The strings returned by these two routines should be 2308 ** The strings returned by these two routines should be
2197 ** released by [sqlite3_free()]. ^Both routines return a 2309 ** released by [sqlite3_free()]. ^Both routines return a
2198 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough 2310 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
2199 ** memory to hold the resulting string. 2311 ** memory to hold the resulting string.
2200 ** 2312 **
2201 ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from 2313 ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from
2202 ** the standard C library. The result is written into the 2314 ** the standard C library. The result is written into the
(...skipping 12 matching lines...) Expand all
2215 ** guarantees that the buffer is always zero-terminated. ^The first 2327 ** guarantees that the buffer is always zero-terminated. ^The first
2216 ** parameter "n" is the total size of the buffer, including space for 2328 ** parameter "n" is the total size of the buffer, including space for
2217 ** the zero terminator. So the longest string that can be completely 2329 ** the zero terminator. So the longest string that can be completely
2218 ** written will be n-1 characters. 2330 ** written will be n-1 characters.
2219 ** 2331 **
2220 ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). 2332 ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().
2221 ** 2333 **
2222 ** These routines all implement some additional formatting 2334 ** These routines all implement some additional formatting
2223 ** options that are useful for constructing SQL statements. 2335 ** options that are useful for constructing SQL statements.
2224 ** All of the usual printf() formatting options apply. In addition, there 2336 ** All of the usual printf() formatting options apply. In addition, there
2225 ** is are "%q", "%Q", and "%z" options. 2337 ** is are "%q", "%Q", "%w" and "%z" options.
2226 ** 2338 **
2227 ** ^(The %q option works like %s in that it substitutes a nul-terminated 2339 ** ^(The %q option works like %s in that it substitutes a nul-terminated
2228 ** string from the argument list. But %q also doubles every '\'' character. 2340 ** string from the argument list. But %q also doubles every '\'' character.
2229 ** %q is designed for use inside a string literal.)^ By doubling each '\'' 2341 ** %q is designed for use inside a string literal.)^ By doubling each '\''
2230 ** character it escapes that character and allows it to be inserted into 2342 ** character it escapes that character and allows it to be inserted into
2231 ** the string. 2343 ** the string.
2232 ** 2344 **
2233 ** For example, assume the string variable zText contains text as follows: 2345 ** For example, assume the string variable zText contains text as follows:
2234 ** 2346 **
2235 ** <blockquote><pre> 2347 ** <blockquote><pre>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 ** 2380 **
2269 ** <blockquote><pre> 2381 ** <blockquote><pre>
2270 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText); 2382 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
2271 ** sqlite3_exec(db, zSQL, 0, 0, 0); 2383 ** sqlite3_exec(db, zSQL, 0, 0, 0);
2272 ** sqlite3_free(zSQL); 2384 ** sqlite3_free(zSQL);
2273 ** </pre></blockquote> 2385 ** </pre></blockquote>
2274 ** 2386 **
2275 ** The code above will render a correct SQL statement in the zSQL 2387 ** The code above will render a correct SQL statement in the zSQL
2276 ** variable even if the zText variable is a NULL pointer. 2388 ** variable even if the zText variable is a NULL pointer.
2277 ** 2389 **
2390 ** ^(The "%w" formatting option is like "%q" except that it expects to
2391 ** be contained within double-quotes instead of single quotes, and it
2392 ** escapes the double-quote character instead of the single-quote
2393 ** character.)^ The "%w" formatting option is intended for safely inserting
2394 ** table and column names into a constructed SQL statement.
2395 **
2278 ** ^(The "%z" formatting option works like "%s" but with the 2396 ** ^(The "%z" formatting option works like "%s" but with the
2279 ** addition that after the string has been read and copied into 2397 ** addition that after the string has been read and copied into
2280 ** the result, [sqlite3_free()] is called on the input string.)^ 2398 ** the result, [sqlite3_free()] is called on the input string.)^
2281 */ 2399 */
2282 char *sqlite3_mprintf(const char*,...); 2400 char *sqlite3_mprintf(const char*,...);
2283 char *sqlite3_vmprintf(const char*, va_list); 2401 char *sqlite3_vmprintf(const char*, va_list);
2284 char *sqlite3_snprintf(int,char*,const char*, ...); 2402 char *sqlite3_snprintf(int,char*,const char*, ...);
2285 char *sqlite3_vsnprintf(int,char*,const char*, va_list); 2403 char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2286 2404
2287 /* 2405 /*
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 /* 2526 /*
2409 ** CAPI3REF: Pseudo-Random Number Generator 2527 ** CAPI3REF: Pseudo-Random Number Generator
2410 ** 2528 **
2411 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to 2529 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
2412 ** select random [ROWID | ROWIDs] when inserting new records into a table that 2530 ** select random [ROWID | ROWIDs] when inserting new records into a table that
2413 ** already uses the largest possible [ROWID]. The PRNG is also used for 2531 ** already uses the largest possible [ROWID]. The PRNG is also used for
2414 ** the build-in random() and randomblob() SQL functions. This interface allows 2532 ** the build-in random() and randomblob() SQL functions. This interface allows
2415 ** applications to access the same PRNG for other purposes. 2533 ** applications to access the same PRNG for other purposes.
2416 ** 2534 **
2417 ** ^A call to this routine stores N bytes of randomness into buffer P. 2535 ** ^A call to this routine stores N bytes of randomness into buffer P.
2418 ** ^If N is less than one, then P can be a NULL pointer. 2536 ** ^The P parameter can be a NULL pointer.
2419 ** 2537 **
2420 ** ^If this routine has not been previously called or if the previous 2538 ** ^If this routine has not been previously called or if the previous
2421 ** call had N less than one, then the PRNG is seeded using randomness 2539 ** call had N less than one or a NULL pointer for P, then the PRNG is
2422 ** obtained from the xRandomness method of the default [sqlite3_vfs] object. 2540 ** seeded using randomness obtained from the xRandomness method of
2423 ** ^If the previous call to this routine had an N of 1 or more then 2541 ** the default [sqlite3_vfs] object.
2424 ** the pseudo-randomness is generated 2542 ** ^If the previous call to this routine had an N of 1 or more and a
2543 ** non-NULL P then the pseudo-randomness is generated
2425 ** internally and without recourse to the [sqlite3_vfs] xRandomness 2544 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2426 ** method. 2545 ** method.
2427 */ 2546 */
2428 void sqlite3_randomness(int N, void *P); 2547 void sqlite3_randomness(int N, void *P);
2429 2548
2430 /* 2549 /*
2431 ** CAPI3REF: Compile-Time Authorization Callbacks 2550 ** CAPI3REF: Compile-Time Authorization Callbacks
2551 ** METHOD: sqlite3
2432 ** 2552 **
2433 ** ^This routine registers an authorizer callback with a particular 2553 ** ^This routine registers an authorizer callback with a particular
2434 ** [database connection], supplied in the first argument. 2554 ** [database connection], supplied in the first argument.
2435 ** ^The authorizer callback is invoked as SQL statements are being compiled 2555 ** ^The authorizer callback is invoked as SQL statements are being compiled
2436 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], 2556 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2437 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various 2557 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
2438 ** points during the compilation process, as logic is being created 2558 ** points during the compilation process, as logic is being created
2439 ** to perform various actions, the authorizer callback is invoked to 2559 ** to perform various actions, the authorizer callback is invoked to
2440 ** see if those actions are allowed. ^The authorizer callback should 2560 ** see if those actions are allowed. ^The authorizer callback should
2441 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the 2561 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 #define SQLITE_ANALYZE 28 /* Table Name NULL */ 2698 #define SQLITE_ANALYZE 28 /* Table Name NULL */
2579 #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ 2699 #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
2580 #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ 2700 #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
2581 #define SQLITE_FUNCTION 31 /* NULL Function Name */ 2701 #define SQLITE_FUNCTION 31 /* NULL Function Name */
2582 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ 2702 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
2583 #define SQLITE_COPY 0 /* No longer used */ 2703 #define SQLITE_COPY 0 /* No longer used */
2584 #define SQLITE_RECURSIVE 33 /* NULL NULL */ 2704 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2585 2705
2586 /* 2706 /*
2587 ** CAPI3REF: Tracing And Profiling Functions 2707 ** CAPI3REF: Tracing And Profiling Functions
2708 ** METHOD: sqlite3
2588 ** 2709 **
2589 ** These routines register callback functions that can be used for 2710 ** These routines register callback functions that can be used for
2590 ** tracing and profiling the execution of SQL statements. 2711 ** tracing and profiling the execution of SQL statements.
2591 ** 2712 **
2592 ** ^The callback function registered by sqlite3_trace() is invoked at 2713 ** ^The callback function registered by sqlite3_trace() is invoked at
2593 ** various times when an SQL statement is being run by [sqlite3_step()]. 2714 ** various times when an SQL statement is being run by [sqlite3_step()].
2594 ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the 2715 ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
2595 ** SQL statement text as the statement first begins executing. 2716 ** SQL statement text as the statement first begins executing.
2596 ** ^(Additional sqlite3_trace() callbacks might occur 2717 ** ^(Additional sqlite3_trace() callbacks might occur
2597 ** as each triggered subprogram is entered. The callbacks for triggers 2718 ** as each triggered subprogram is entered. The callbacks for triggers
(...skipping 12 matching lines...) Expand all
2610 ** might provide greater resolution on the profiler callback. The 2731 ** might provide greater resolution on the profiler callback. The
2611 ** sqlite3_profile() function is considered experimental and is 2732 ** sqlite3_profile() function is considered experimental and is
2612 ** subject to change in future versions of SQLite. 2733 ** subject to change in future versions of SQLite.
2613 */ 2734 */
2614 void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); 2735 void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2615 SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, 2736 SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2616 void(*xProfile)(void*,const char*,sqlite3_uint64), void*); 2737 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2617 2738
2618 /* 2739 /*
2619 ** CAPI3REF: Query Progress Callbacks 2740 ** CAPI3REF: Query Progress Callbacks
2741 ** METHOD: sqlite3
2620 ** 2742 **
2621 ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback 2743 ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
2622 ** function X to be invoked periodically during long running calls to 2744 ** function X to be invoked periodically during long running calls to
2623 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for 2745 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
2624 ** database connection D. An example use for this 2746 ** database connection D. An example use for this
2625 ** interface is to keep a GUI updated during a large query. 2747 ** interface is to keep a GUI updated during a large query.
2626 ** 2748 **
2627 ** ^The parameter P is passed through as the only parameter to the 2749 ** ^The parameter P is passed through as the only parameter to the
2628 ** callback function X. ^The parameter N is the approximate number of 2750 ** callback function X. ^The parameter N is the approximate number of
2629 ** [virtual machine instructions] that are evaluated between successive 2751 ** [virtual machine instructions] that are evaluated between successive
(...skipping 13 matching lines...) Expand all
2643 ** The progress handler callback must not do anything that will modify 2765 ** The progress handler callback must not do anything that will modify
2644 ** the database connection that invoked the progress handler. 2766 ** the database connection that invoked the progress handler.
2645 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their 2767 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2646 ** database connections for the meaning of "modify" in this paragraph. 2768 ** database connections for the meaning of "modify" in this paragraph.
2647 ** 2769 **
2648 */ 2770 */
2649 void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); 2771 void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2650 2772
2651 /* 2773 /*
2652 ** CAPI3REF: Opening A New Database Connection 2774 ** CAPI3REF: Opening A New Database Connection
2775 ** CONSTRUCTOR: sqlite3
2653 ** 2776 **
2654 ** ^These routines open an SQLite database file as specified by the 2777 ** ^These routines open an SQLite database file as specified by the
2655 ** filename argument. ^The filename argument is interpreted as UTF-8 for 2778 ** filename argument. ^The filename argument is interpreted as UTF-8 for
2656 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte 2779 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2657 ** order for sqlite3_open16(). ^(A [database connection] handle is usually 2780 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
2658 ** returned in *ppDb, even if an error occurs. The only exception is that 2781 ** returned in *ppDb, even if an error occurs. The only exception is that
2659 ** if SQLite is unable to allocate memory to hold the [sqlite3] object, 2782 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
2660 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] 2783 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2661 ** object.)^ ^(If the database is opened (and/or created) successfully, then 2784 ** object.)^ ^(If the database is opened (and/or created) successfully, then
2662 ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The 2785 ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 ** VFS method, then the behavior of this routine is undefined and probably 3051 ** VFS method, then the behavior of this routine is undefined and probably
2929 ** undesirable. 3052 ** undesirable.
2930 */ 3053 */
2931 const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); 3054 const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
2932 int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); 3055 int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
2933 sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); 3056 sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
2934 3057
2935 3058
2936 /* 3059 /*
2937 ** CAPI3REF: Error Codes And Messages 3060 ** CAPI3REF: Error Codes And Messages
3061 ** METHOD: sqlite3
2938 ** 3062 **
2939 ** ^The sqlite3_errcode() interface returns the numeric [result code] or 3063 ** ^If the most recent sqlite3_* API call associated with
2940 ** [extended result code] for the most recent failed sqlite3_* API call 3064 ** [database connection] D failed, then the sqlite3_errcode(D) interface
2941 ** associated with a [database connection]. If a prior API call failed 3065 ** returns the numeric [result code] or [extended result code] for that
2942 ** but the most recent API call succeeded, the return value from 3066 ** API call.
2943 ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() 3067 ** If the most recent API call was successful,
3068 ** then the return value from sqlite3_errcode() is undefined.
3069 ** ^The sqlite3_extended_errcode()
2944 ** interface is the same except that it always returns the 3070 ** interface is the same except that it always returns the
2945 ** [extended result code] even when extended result codes are 3071 ** [extended result code] even when extended result codes are
2946 ** disabled. 3072 ** disabled.
2947 ** 3073 **
2948 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language 3074 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
2949 ** text that describes the error, as either UTF-8 or UTF-16 respectively. 3075 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
2950 ** ^(Memory to hold the error message string is managed internally. 3076 ** ^(Memory to hold the error message string is managed internally.
2951 ** The application does not need to worry about freeing the result. 3077 ** The application does not need to worry about freeing the result.
2952 ** However, the error string might be overwritten or deallocated by 3078 ** However, the error string might be overwritten or deallocated by
2953 ** subsequent calls to other SQLite interface functions.)^ 3079 ** subsequent calls to other SQLite interface functions.)^
(...skipping 17 matching lines...) Expand all
2971 ** was invoked incorrectly by the application. In that case, the 3097 ** was invoked incorrectly by the application. In that case, the
2972 ** error code and message may or may not be set. 3098 ** error code and message may or may not be set.
2973 */ 3099 */
2974 int sqlite3_errcode(sqlite3 *db); 3100 int sqlite3_errcode(sqlite3 *db);
2975 int sqlite3_extended_errcode(sqlite3 *db); 3101 int sqlite3_extended_errcode(sqlite3 *db);
2976 const char *sqlite3_errmsg(sqlite3*); 3102 const char *sqlite3_errmsg(sqlite3*);
2977 const void *sqlite3_errmsg16(sqlite3*); 3103 const void *sqlite3_errmsg16(sqlite3*);
2978 const char *sqlite3_errstr(int); 3104 const char *sqlite3_errstr(int);
2979 3105
2980 /* 3106 /*
2981 ** CAPI3REF: SQL Statement Object 3107 ** CAPI3REF: Prepared Statement Object
2982 ** KEYWORDS: {prepared statement} {prepared statements} 3108 ** KEYWORDS: {prepared statement} {prepared statements}
2983 ** 3109 **
2984 ** An instance of this object represents a single SQL statement. 3110 ** An instance of this object represents a single SQL statement that
2985 ** This object is variously known as a "prepared statement" or a 3111 ** has been compiled into binary form and is ready to be evaluated.
2986 ** "compiled SQL statement" or simply as a "statement".
2987 ** 3112 **
2988 ** The life of a statement object goes something like this: 3113 ** Think of each SQL statement as a separate computer program. The
3114 ** original SQL text is source code. A prepared statement object
3115 ** is the compiled object code. All SQL must be converted into a
3116 ** prepared statement before it can be run.
3117 **
3118 ** The life-cycle of a prepared statement object usually goes like this:
2989 ** 3119 **
2990 ** <ol> 3120 ** <ol>
2991 ** <li> Create the object using [sqlite3_prepare_v2()] or a related 3121 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
2992 ** function. 3122 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
2993 ** <li> Bind values to [host parameters] using the sqlite3_bind_*()
2994 ** interfaces. 3123 ** interfaces.
2995 ** <li> Run the SQL by calling [sqlite3_step()] one or more times. 3124 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
2996 ** <li> Reset the statement using [sqlite3_reset()] then go back 3125 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
2997 ** to step 2. Do this zero or more times. 3126 ** to step 2. Do this zero or more times.
2998 ** <li> Destroy the object using [sqlite3_finalize()]. 3127 ** <li> Destroy the object using [sqlite3_finalize()].
2999 ** </ol> 3128 ** </ol>
3000 **
3001 ** Refer to documentation on individual methods above for additional
3002 ** information.
3003 */ 3129 */
3004 typedef struct sqlite3_stmt sqlite3_stmt; 3130 typedef struct sqlite3_stmt sqlite3_stmt;
3005 3131
3006 /* 3132 /*
3007 ** CAPI3REF: Run-time Limits 3133 ** CAPI3REF: Run-time Limits
3134 ** METHOD: sqlite3
3008 ** 3135 **
3009 ** ^(This interface allows the size of various constructs to be limited 3136 ** ^(This interface allows the size of various constructs to be limited
3010 ** on a connection by connection basis. The first parameter is the 3137 ** on a connection by connection basis. The first parameter is the
3011 ** [database connection] whose limit is to be set or queried. The 3138 ** [database connection] whose limit is to be set or queried. The
3012 ** second parameter is one of the [limit categories] that define a 3139 ** second parameter is one of the [limit categories] that define a
3013 ** class of constructs to be size limited. The third parameter is the 3140 ** class of constructs to be size limited. The third parameter is the
3014 ** new limit for that construct.)^ 3141 ** new limit for that construct.)^
3015 ** 3142 **
3016 ** ^If the new limit is a negative number, the limit is unchanged. 3143 ** ^If the new limit is a negative number, the limit is unchanged.
3017 ** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a 3144 ** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 #define SQLITE_LIMIT_FUNCTION_ARG 6 3236 #define SQLITE_LIMIT_FUNCTION_ARG 6
3110 #define SQLITE_LIMIT_ATTACHED 7 3237 #define SQLITE_LIMIT_ATTACHED 7
3111 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 3238 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3112 #define SQLITE_LIMIT_VARIABLE_NUMBER 9 3239 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3113 #define SQLITE_LIMIT_TRIGGER_DEPTH 10 3240 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3114 #define SQLITE_LIMIT_WORKER_THREADS 11 3241 #define SQLITE_LIMIT_WORKER_THREADS 11
3115 3242
3116 /* 3243 /*
3117 ** CAPI3REF: Compiling An SQL Statement 3244 ** CAPI3REF: Compiling An SQL Statement
3118 ** KEYWORDS: {SQL statement compiler} 3245 ** KEYWORDS: {SQL statement compiler}
3246 ** METHOD: sqlite3
3247 ** CONSTRUCTOR: sqlite3_stmt
3119 ** 3248 **
3120 ** To execute an SQL query, it must first be compiled into a byte-code 3249 ** To execute an SQL query, it must first be compiled into a byte-code
3121 ** program using one of these routines. 3250 ** program using one of these routines.
3122 ** 3251 **
3123 ** The first argument, "db", is a [database connection] obtained from a 3252 ** The first argument, "db", is a [database connection] obtained from a
3124 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or 3253 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
3125 ** [sqlite3_open16()]. The database connection must not have been closed. 3254 ** [sqlite3_open16()]. The database connection must not have been closed.
3126 ** 3255 **
3127 ** The second argument, "zSql", is the statement to be compiled, encoded 3256 ** The second argument, "zSql", is the statement to be compiled, encoded
3128 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() 3257 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3129 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() 3258 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3130 ** use UTF-16. 3259 ** use UTF-16.
3131 ** 3260 **
3132 ** ^If the nByte argument is less than zero, then zSql is read up to the 3261 ** ^If the nByte argument is negative, then zSql is read up to the
3133 ** first zero terminator. ^If nByte is non-negative, then it is the maximum 3262 ** first zero terminator. ^If nByte is positive, then it is the
3134 ** number of bytes read from zSql. ^When nByte is non-negative, the 3263 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3135 ** zSql string ends at either the first '\000' or '\u0000' character or 3264 ** statement is generated.
3136 ** the nByte-th byte, whichever comes first. If the caller knows 3265 ** If the caller knows that the supplied string is nul-terminated, then
3137 ** that the supplied string is nul-terminated, then there is a small 3266 ** there is a small performance advantage to passing an nByte parameter that
3138 ** performance advantage to be gained by passing an nByte parameter that 3267 ** is the number of bytes in the input string <i>including</i>
3139 ** is equal to the number of bytes in the input string <i>including</i> 3268 ** the nul-terminator.
3140 ** the nul-terminator bytes as this saves SQLite from having to
3141 ** make a copy of the input string.
3142 ** 3269 **
3143 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte 3270 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
3144 ** past the end of the first SQL statement in zSql. These routines only 3271 ** past the end of the first SQL statement in zSql. These routines only
3145 ** compile the first statement in zSql, so *pzTail is left pointing to 3272 ** compile the first statement in zSql, so *pzTail is left pointing to
3146 ** what remains uncompiled. 3273 ** what remains uncompiled.
3147 ** 3274 **
3148 ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be 3275 ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
3149 ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set 3276 ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set
3150 ** to NULL. ^If the input text contains no SQL (if the input is an empty 3277 ** to NULL. ^If the input text contains no SQL (if the input is an empty
3151 ** string or a comment) then *ppStmt is set to NULL. 3278 ** string or a comment) then *ppStmt is set to NULL.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3218 int sqlite3_prepare16_v2( 3345 int sqlite3_prepare16_v2(
3219 sqlite3 *db, /* Database handle */ 3346 sqlite3 *db, /* Database handle */
3220 const void *zSql, /* SQL statement, UTF-16 encoded */ 3347 const void *zSql, /* SQL statement, UTF-16 encoded */
3221 int nByte, /* Maximum length of zSql in bytes. */ 3348 int nByte, /* Maximum length of zSql in bytes. */
3222 sqlite3_stmt **ppStmt, /* OUT: Statement handle */ 3349 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3223 const void **pzTail /* OUT: Pointer to unused portion of zSql */ 3350 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3224 ); 3351 );
3225 3352
3226 /* 3353 /*
3227 ** CAPI3REF: Retrieving Statement SQL 3354 ** CAPI3REF: Retrieving Statement SQL
3355 ** METHOD: sqlite3_stmt
3228 ** 3356 **
3229 ** ^This interface can be used to retrieve a saved copy of the original 3357 ** ^This interface can be used to retrieve a saved copy of the original
3230 ** SQL text used to create a [prepared statement] if that statement was 3358 ** SQL text used to create a [prepared statement] if that statement was
3231 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. 3359 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3232 */ 3360 */
3233 const char *sqlite3_sql(sqlite3_stmt *pStmt); 3361 const char *sqlite3_sql(sqlite3_stmt *pStmt);
3234 3362
3235 /* 3363 /*
3236 ** CAPI3REF: Determine If An SQL Statement Writes The Database 3364 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3365 ** METHOD: sqlite3_stmt
3237 ** 3366 **
3238 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if 3367 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
3239 ** and only if the [prepared statement] X makes no direct changes to 3368 ** and only if the [prepared statement] X makes no direct changes to
3240 ** the content of the database file. 3369 ** the content of the database file.
3241 ** 3370 **
3242 ** Note that [application-defined SQL functions] or 3371 ** Note that [application-defined SQL functions] or
3243 ** [virtual tables] might change the database indirectly as a side effect. 3372 ** [virtual tables] might change the database indirectly as a side effect.
3244 ** ^(For example, if an application defines a function "eval()" that 3373 ** ^(For example, if an application defines a function "eval()" that
3245 ** calls [sqlite3_exec()], then the following SQL statement would 3374 ** calls [sqlite3_exec()], then the following SQL statement would
3246 ** change the database file through side-effects: 3375 ** change the database file through side-effects:
(...skipping 11 matching lines...) Expand all
3258 ** rather they control the timing of when other statements modify the 3387 ** rather they control the timing of when other statements modify the
3259 ** database. ^The [ATTACH] and [DETACH] statements also cause 3388 ** database. ^The [ATTACH] and [DETACH] statements also cause
3260 ** sqlite3_stmt_readonly() to return true since, while those statements 3389 ** sqlite3_stmt_readonly() to return true since, while those statements
3261 ** change the configuration of a database connection, they do not make 3390 ** change the configuration of a database connection, they do not make
3262 ** changes to the content of the database files on disk. 3391 ** changes to the content of the database files on disk.
3263 */ 3392 */
3264 int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); 3393 int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3265 3394
3266 /* 3395 /*
3267 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset 3396 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3397 ** METHOD: sqlite3_stmt
3268 ** 3398 **
3269 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the 3399 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3270 ** [prepared statement] S has been stepped at least once using 3400 ** [prepared statement] S has been stepped at least once using
3271 ** [sqlite3_step(S)] but has not run to completion and/or has not 3401 ** [sqlite3_step(S)] but has neither run to completion (returned
3402 ** [SQLITE_DONE] from [sqlite3_step(S)]) nor
3272 ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) 3403 ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
3273 ** interface returns false if S is a NULL pointer. If S is not a 3404 ** interface returns false if S is a NULL pointer. If S is not a
3274 ** NULL pointer and is not a pointer to a valid [prepared statement] 3405 ** NULL pointer and is not a pointer to a valid [prepared statement]
3275 ** object, then the behavior is undefined and probably undesirable. 3406 ** object, then the behavior is undefined and probably undesirable.
3276 ** 3407 **
3277 ** This interface can be used in combination [sqlite3_next_stmt()] 3408 ** This interface can be used in combination [sqlite3_next_stmt()]
3278 ** to locate all prepared statements associated with a database 3409 ** to locate all prepared statements associated with a database
3279 ** connection that are in need of being reset. This can be used, 3410 ** connection that are in need of being reset. This can be used,
3280 ** for example, in diagnostic routines to search for prepared 3411 ** for example, in diagnostic routines to search for prepared
3281 ** statements that are holding a transaction open. 3412 ** statements that are holding a transaction open.
3282 */ 3413 */
3283 int sqlite3_stmt_busy(sqlite3_stmt*); 3414 int sqlite3_stmt_busy(sqlite3_stmt*);
3284 3415
3285 /* 3416 /*
3286 ** CAPI3REF: Dynamically Typed Value Object 3417 ** CAPI3REF: Dynamically Typed Value Object
3287 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} 3418 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3288 ** 3419 **
3289 ** SQLite uses the sqlite3_value object to represent all values 3420 ** SQLite uses the sqlite3_value object to represent all values
3290 ** that can be stored in a database table. SQLite uses dynamic typing 3421 ** that can be stored in a database table. SQLite uses dynamic typing
3291 ** for the values it stores. ^Values stored in sqlite3_value objects 3422 ** for the values it stores. ^Values stored in sqlite3_value objects
3292 ** can be integers, floating point values, strings, BLOBs, or NULL. 3423 ** can be integers, floating point values, strings, BLOBs, or NULL.
3293 ** 3424 **
3294 ** An sqlite3_value object may be either "protected" or "unprotected". 3425 ** An sqlite3_value object may be either "protected" or "unprotected".
3295 ** Some interfaces require a protected sqlite3_value. Other interfaces 3426 ** Some interfaces require a protected sqlite3_value. Other interfaces
3296 ** will accept either a protected or an unprotected sqlite3_value. 3427 ** will accept either a protected or an unprotected sqlite3_value.
3297 ** Every interface that accepts sqlite3_value arguments specifies 3428 ** Every interface that accepts sqlite3_value arguments specifies
3298 ** whether or not it requires a protected sqlite3_value. 3429 ** whether or not it requires a protected sqlite3_value. The
3430 ** [sqlite3_value_dup()] interface can be used to construct a new
3431 ** protected sqlite3_value from an unprotected sqlite3_value.
3299 ** 3432 **
3300 ** The terms "protected" and "unprotected" refer to whether or not 3433 ** The terms "protected" and "unprotected" refer to whether or not
3301 ** a mutex is held. An internal mutex is held for a protected 3434 ** a mutex is held. An internal mutex is held for a protected
3302 ** sqlite3_value object but no mutex is held for an unprotected 3435 ** sqlite3_value object but no mutex is held for an unprotected
3303 ** sqlite3_value object. If SQLite is compiled to be single-threaded 3436 ** sqlite3_value object. If SQLite is compiled to be single-threaded
3304 ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) 3437 ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
3305 ** or if SQLite is run in one of reduced mutex modes 3438 ** or if SQLite is run in one of reduced mutex modes
3306 ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] 3439 ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]
3307 ** then there is no distinction between protected and unprotected 3440 ** then there is no distinction between protected and unprotected
3308 ** sqlite3_value objects and they can be used interchangeably. However, 3441 ** sqlite3_value objects and they can be used interchangeably. However,
(...skipping 23 matching lines...) Expand all
3332 ** [sqlite3_aggregate_context()], [sqlite3_user_data()], 3465 ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
3333 ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], 3466 ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
3334 ** and/or [sqlite3_set_auxdata()]. 3467 ** and/or [sqlite3_set_auxdata()].
3335 */ 3468 */
3336 typedef struct sqlite3_context sqlite3_context; 3469 typedef struct sqlite3_context sqlite3_context;
3337 3470
3338 /* 3471 /*
3339 ** CAPI3REF: Binding Values To Prepared Statements 3472 ** CAPI3REF: Binding Values To Prepared Statements
3340 ** KEYWORDS: {host parameter} {host parameters} {host parameter name} 3473 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3341 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} 3474 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3475 ** METHOD: sqlite3_stmt
3342 ** 3476 **
3343 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, 3477 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3344 ** literals may be replaced by a [parameter] that matches one of following 3478 ** literals may be replaced by a [parameter] that matches one of following
3345 ** templates: 3479 ** templates:
3346 ** 3480 **
3347 ** <ul> 3481 ** <ul>
3348 ** <li> ? 3482 ** <li> ?
3349 ** <li> ?NNN 3483 ** <li> ?NNN
3350 ** <li> :VVV 3484 ** <li> :VVV
3351 ** <li> @VVV 3485 ** <li> @VVV
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3447 int sqlite3_bind_double(sqlite3_stmt*, int, double); 3581 int sqlite3_bind_double(sqlite3_stmt*, int, double);
3448 int sqlite3_bind_int(sqlite3_stmt*, int, int); 3582 int sqlite3_bind_int(sqlite3_stmt*, int, int);
3449 int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); 3583 int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3450 int sqlite3_bind_null(sqlite3_stmt*, int); 3584 int sqlite3_bind_null(sqlite3_stmt*, int);
3451 int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); 3585 int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3452 int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); 3586 int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3453 int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, 3587 int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3454 void(*)(void*), unsigned char encoding); 3588 void(*)(void*), unsigned char encoding);
3455 int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); 3589 int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3456 int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); 3590 int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3591 int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
3457 3592
3458 /* 3593 /*
3459 ** CAPI3REF: Number Of SQL Parameters 3594 ** CAPI3REF: Number Of SQL Parameters
3595 ** METHOD: sqlite3_stmt
3460 ** 3596 **
3461 ** ^This routine can be used to find the number of [SQL parameters] 3597 ** ^This routine can be used to find the number of [SQL parameters]
3462 ** in a [prepared statement]. SQL parameters are tokens of the 3598 ** in a [prepared statement]. SQL parameters are tokens of the
3463 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as 3599 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
3464 ** placeholders for values that are [sqlite3_bind_blob | bound] 3600 ** placeholders for values that are [sqlite3_bind_blob | bound]
3465 ** to the parameters at a later time. 3601 ** to the parameters at a later time.
3466 ** 3602 **
3467 ** ^(This routine actually returns the index of the largest (rightmost) 3603 ** ^(This routine actually returns the index of the largest (rightmost)
3468 ** parameter. For all forms except ?NNN, this will correspond to the 3604 ** parameter. For all forms except ?NNN, this will correspond to the
3469 ** number of unique parameters. If parameters of the ?NNN form are used, 3605 ** number of unique parameters. If parameters of the ?NNN form are used,
3470 ** there may be gaps in the list.)^ 3606 ** there may be gaps in the list.)^
3471 ** 3607 **
3472 ** See also: [sqlite3_bind_blob|sqlite3_bind()], 3608 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3473 ** [sqlite3_bind_parameter_name()], and 3609 ** [sqlite3_bind_parameter_name()], and
3474 ** [sqlite3_bind_parameter_index()]. 3610 ** [sqlite3_bind_parameter_index()].
3475 */ 3611 */
3476 int sqlite3_bind_parameter_count(sqlite3_stmt*); 3612 int sqlite3_bind_parameter_count(sqlite3_stmt*);
3477 3613
3478 /* 3614 /*
3479 ** CAPI3REF: Name Of A Host Parameter 3615 ** CAPI3REF: Name Of A Host Parameter
3616 ** METHOD: sqlite3_stmt
3480 ** 3617 **
3481 ** ^The sqlite3_bind_parameter_name(P,N) interface returns 3618 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
3482 ** the name of the N-th [SQL parameter] in the [prepared statement] P. 3619 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
3483 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" 3620 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3484 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" 3621 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
3485 ** respectively. 3622 ** respectively.
3486 ** In other words, the initial ":" or "$" or "@" or "?" 3623 ** In other words, the initial ":" or "$" or "@" or "?"
3487 ** is included as part of the name.)^ 3624 ** is included as part of the name.)^
3488 ** ^Parameters of the form "?" without a following integer have no name 3625 ** ^Parameters of the form "?" without a following integer have no name
3489 ** and are referred to as "nameless" or "anonymous parameters". 3626 ** and are referred to as "nameless" or "anonymous parameters".
3490 ** 3627 **
3491 ** ^The first host parameter has an index of 1, not 0. 3628 ** ^The first host parameter has an index of 1, not 0.
3492 ** 3629 **
3493 ** ^If the value N is out of range or if the N-th parameter is 3630 ** ^If the value N is out of range or if the N-th parameter is
3494 ** nameless, then NULL is returned. ^The returned string is 3631 ** nameless, then NULL is returned. ^The returned string is
3495 ** always in UTF-8 encoding even if the named parameter was 3632 ** always in UTF-8 encoding even if the named parameter was
3496 ** originally specified as UTF-16 in [sqlite3_prepare16()] or 3633 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
3497 ** [sqlite3_prepare16_v2()]. 3634 ** [sqlite3_prepare16_v2()].
3498 ** 3635 **
3499 ** See also: [sqlite3_bind_blob|sqlite3_bind()], 3636 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3500 ** [sqlite3_bind_parameter_count()], and 3637 ** [sqlite3_bind_parameter_count()], and
3501 ** [sqlite3_bind_parameter_index()]. 3638 ** [sqlite3_bind_parameter_index()].
3502 */ 3639 */
3503 const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); 3640 const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3504 3641
3505 /* 3642 /*
3506 ** CAPI3REF: Index Of A Parameter With A Given Name 3643 ** CAPI3REF: Index Of A Parameter With A Given Name
3644 ** METHOD: sqlite3_stmt
3507 ** 3645 **
3508 ** ^Return the index of an SQL parameter given its name. ^The 3646 ** ^Return the index of an SQL parameter given its name. ^The
3509 ** index value returned is suitable for use as the second 3647 ** index value returned is suitable for use as the second
3510 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero 3648 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3511 ** is returned if no matching parameter is found. ^The parameter 3649 ** is returned if no matching parameter is found. ^The parameter
3512 ** name must be given in UTF-8 even if the original statement 3650 ** name must be given in UTF-8 even if the original statement
3513 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. 3651 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
3514 ** 3652 **
3515 ** See also: [sqlite3_bind_blob|sqlite3_bind()], 3653 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3516 ** [sqlite3_bind_parameter_count()], and 3654 ** [sqlite3_bind_parameter_count()], and
3517 ** [sqlite3_bind_parameter_index()]. 3655 ** [sqlite3_bind_parameter_name()].
3518 */ 3656 */
3519 int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); 3657 int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3520 3658
3521 /* 3659 /*
3522 ** CAPI3REF: Reset All Bindings On A Prepared Statement 3660 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3661 ** METHOD: sqlite3_stmt
3523 ** 3662 **
3524 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset 3663 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3525 ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. 3664 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3526 ** ^Use this routine to reset all host parameters to NULL. 3665 ** ^Use this routine to reset all host parameters to NULL.
3527 */ 3666 */
3528 int sqlite3_clear_bindings(sqlite3_stmt*); 3667 int sqlite3_clear_bindings(sqlite3_stmt*);
3529 3668
3530 /* 3669 /*
3531 ** CAPI3REF: Number Of Columns In A Result Set 3670 ** CAPI3REF: Number Of Columns In A Result Set
3671 ** METHOD: sqlite3_stmt
3532 ** 3672 **
3533 ** ^Return the number of columns in the result set returned by the 3673 ** ^Return the number of columns in the result set returned by the
3534 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL 3674 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3535 ** statement that does not return data (for example an [UPDATE]). 3675 ** statement that does not return data (for example an [UPDATE]).
3536 ** 3676 **
3537 ** See also: [sqlite3_data_count()] 3677 ** See also: [sqlite3_data_count()]
3538 */ 3678 */
3539 int sqlite3_column_count(sqlite3_stmt *pStmt); 3679 int sqlite3_column_count(sqlite3_stmt *pStmt);
3540 3680
3541 /* 3681 /*
3542 ** CAPI3REF: Column Names In A Result Set 3682 ** CAPI3REF: Column Names In A Result Set
3683 ** METHOD: sqlite3_stmt
3543 ** 3684 **
3544 ** ^These routines return the name assigned to a particular column 3685 ** ^These routines return the name assigned to a particular column
3545 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() 3686 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
3546 ** interface returns a pointer to a zero-terminated UTF-8 string 3687 ** interface returns a pointer to a zero-terminated UTF-8 string
3547 ** and sqlite3_column_name16() returns a pointer to a zero-terminated 3688 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
3548 ** UTF-16 string. ^The first parameter is the [prepared statement] 3689 ** UTF-16 string. ^The first parameter is the [prepared statement]
3549 ** that implements the [SELECT] statement. ^The second parameter is the 3690 ** that implements the [SELECT] statement. ^The second parameter is the
3550 ** column number. ^The leftmost column is number 0. 3691 ** column number. ^The leftmost column is number 0.
3551 ** 3692 **
3552 ** ^The returned string pointer is valid until either the [prepared statement] 3693 ** ^The returned string pointer is valid until either the [prepared statement]
3553 ** is destroyed by [sqlite3_finalize()] or until the statement is automatically 3694 ** is destroyed by [sqlite3_finalize()] or until the statement is automatically
3554 ** reprepared by the first call to [sqlite3_step()] for a particular run 3695 ** reprepared by the first call to [sqlite3_step()] for a particular run
3555 ** or until the next call to 3696 ** or until the next call to
3556 ** sqlite3_column_name() or sqlite3_column_name16() on the same column. 3697 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
3557 ** 3698 **
3558 ** ^If sqlite3_malloc() fails during the processing of either routine 3699 ** ^If sqlite3_malloc() fails during the processing of either routine
3559 ** (for example during a conversion from UTF-8 to UTF-16) then a 3700 ** (for example during a conversion from UTF-8 to UTF-16) then a
3560 ** NULL pointer is returned. 3701 ** NULL pointer is returned.
3561 ** 3702 **
3562 ** ^The name of a result column is the value of the "AS" clause for 3703 ** ^The name of a result column is the value of the "AS" clause for
3563 ** that column, if there is an AS clause. If there is no AS clause 3704 ** that column, if there is an AS clause. If there is no AS clause
3564 ** then the name of the column is unspecified and may change from 3705 ** then the name of the column is unspecified and may change from
3565 ** one release of SQLite to the next. 3706 ** one release of SQLite to the next.
3566 */ 3707 */
3567 const char *sqlite3_column_name(sqlite3_stmt*, int N); 3708 const char *sqlite3_column_name(sqlite3_stmt*, int N);
3568 const void *sqlite3_column_name16(sqlite3_stmt*, int N); 3709 const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3569 3710
3570 /* 3711 /*
3571 ** CAPI3REF: Source Of Data In A Query Result 3712 ** CAPI3REF: Source Of Data In A Query Result
3713 ** METHOD: sqlite3_stmt
3572 ** 3714 **
3573 ** ^These routines provide a means to determine the database, table, and 3715 ** ^These routines provide a means to determine the database, table, and
3574 ** table column that is the origin of a particular result column in 3716 ** table column that is the origin of a particular result column in
3575 ** [SELECT] statement. 3717 ** [SELECT] statement.
3576 ** ^The name of the database or table or column can be returned as 3718 ** ^The name of the database or table or column can be returned as
3577 ** either a UTF-8 or UTF-16 string. ^The _database_ routines return 3719 ** either a UTF-8 or UTF-16 string. ^The _database_ routines return
3578 ** the database name, the _table_ routines return the table name, and 3720 ** the database name, the _table_ routines return the table name, and
3579 ** the origin_ routines return the column name. 3721 ** the origin_ routines return the column name.
3580 ** ^The returned string is valid until the [prepared statement] is destroyed 3722 ** ^The returned string is valid until the [prepared statement] is destroyed
3581 ** using [sqlite3_finalize()] or until the statement is automatically 3723 ** using [sqlite3_finalize()] or until the statement is automatically
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 */ 3756 */
3615 const char *sqlite3_column_database_name(sqlite3_stmt*,int); 3757 const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3616 const void *sqlite3_column_database_name16(sqlite3_stmt*,int); 3758 const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3617 const char *sqlite3_column_table_name(sqlite3_stmt*,int); 3759 const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3618 const void *sqlite3_column_table_name16(sqlite3_stmt*,int); 3760 const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3619 const char *sqlite3_column_origin_name(sqlite3_stmt*,int); 3761 const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3620 const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); 3762 const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3621 3763
3622 /* 3764 /*
3623 ** CAPI3REF: Declared Datatype Of A Query Result 3765 ** CAPI3REF: Declared Datatype Of A Query Result
3766 ** METHOD: sqlite3_stmt
3624 ** 3767 **
3625 ** ^(The first parameter is a [prepared statement]. 3768 ** ^(The first parameter is a [prepared statement].
3626 ** If this statement is a [SELECT] statement and the Nth column of the 3769 ** If this statement is a [SELECT] statement and the Nth column of the
3627 ** returned result set of that [SELECT] is a table column (not an 3770 ** returned result set of that [SELECT] is a table column (not an
3628 ** expression or subquery) then the declared type of the table 3771 ** expression or subquery) then the declared type of the table
3629 ** column is returned.)^ ^If the Nth column of the result set is an 3772 ** column is returned.)^ ^If the Nth column of the result set is an
3630 ** expression or subquery, then a NULL pointer is returned. 3773 ** expression or subquery, then a NULL pointer is returned.
3631 ** ^The returned string is always UTF-8 encoded. 3774 ** ^The returned string is always UTF-8 encoded.
3632 ** 3775 **
3633 ** ^(For example, given the database schema: 3776 ** ^(For example, given the database schema:
(...skipping 12 matching lines...) Expand all
3646 ** data stored in that column is of the declared type. SQLite is 3789 ** data stored in that column is of the declared type. SQLite is
3647 ** strongly typed, but the typing is dynamic not static. ^Type 3790 ** strongly typed, but the typing is dynamic not static. ^Type
3648 ** is associated with individual values, not with the containers 3791 ** is associated with individual values, not with the containers
3649 ** used to hold those values. 3792 ** used to hold those values.
3650 */ 3793 */
3651 const char *sqlite3_column_decltype(sqlite3_stmt*,int); 3794 const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3652 const void *sqlite3_column_decltype16(sqlite3_stmt*,int); 3795 const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3653 3796
3654 /* 3797 /*
3655 ** CAPI3REF: Evaluate An SQL Statement 3798 ** CAPI3REF: Evaluate An SQL Statement
3799 ** METHOD: sqlite3_stmt
3656 ** 3800 **
3657 ** After a [prepared statement] has been prepared using either 3801 ** After a [prepared statement] has been prepared using either
3658 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy 3802 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
3659 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function 3803 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
3660 ** must be called one or more times to evaluate the statement. 3804 ** must be called one or more times to evaluate the statement.
3661 ** 3805 **
3662 ** The details of the behavior of the sqlite3_step() interface depend 3806 ** The details of the behavior of the sqlite3_step() interface depend
3663 ** on whether the statement was prepared using the newer "v2" interface 3807 ** on whether the statement was prepared using the newer "v2" interface
3664 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy 3808 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
3665 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the 3809 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 ** with the "v2" interface. If you prepare all of your SQL statements 3869 ** with the "v2" interface. If you prepare all of your SQL statements
3726 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead 3870 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3727 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, 3871 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3728 ** then the more specific [error codes] are returned directly 3872 ** then the more specific [error codes] are returned directly
3729 ** by sqlite3_step(). The use of the "v2" interface is recommended. 3873 ** by sqlite3_step(). The use of the "v2" interface is recommended.
3730 */ 3874 */
3731 int sqlite3_step(sqlite3_stmt*); 3875 int sqlite3_step(sqlite3_stmt*);
3732 3876
3733 /* 3877 /*
3734 ** CAPI3REF: Number of columns in a result set 3878 ** CAPI3REF: Number of columns in a result set
3879 ** METHOD: sqlite3_stmt
3735 ** 3880 **
3736 ** ^The sqlite3_data_count(P) interface returns the number of columns in the 3881 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
3737 ** current row of the result set of [prepared statement] P. 3882 ** current row of the result set of [prepared statement] P.
3738 ** ^If prepared statement P does not have results ready to return 3883 ** ^If prepared statement P does not have results ready to return
3739 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of 3884 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
3740 ** interfaces) then sqlite3_data_count(P) returns 0. 3885 ** interfaces) then sqlite3_data_count(P) returns 0.
3741 ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. 3886 ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
3742 ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to 3887 ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
3743 ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) 3888 ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
3744 ** will return non-zero if previous call to [sqlite3_step](P) returned 3889 ** will return non-zero if previous call to [sqlite3_step](P) returned
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3778 #ifdef SQLITE_TEXT 3923 #ifdef SQLITE_TEXT
3779 # undef SQLITE_TEXT 3924 # undef SQLITE_TEXT
3780 #else 3925 #else
3781 # define SQLITE_TEXT 3 3926 # define SQLITE_TEXT 3
3782 #endif 3927 #endif
3783 #define SQLITE3_TEXT 3 3928 #define SQLITE3_TEXT 3
3784 3929
3785 /* 3930 /*
3786 ** CAPI3REF: Result Values From A Query 3931 ** CAPI3REF: Result Values From A Query
3787 ** KEYWORDS: {column access functions} 3932 ** KEYWORDS: {column access functions}
3788 ** 3933 ** METHOD: sqlite3_stmt
3789 ** These routines form the "result set" interface.
3790 ** 3934 **
3791 ** ^These routines return information about a single column of the current 3935 ** ^These routines return information about a single column of the current
3792 ** result row of a query. ^In every case the first argument is a pointer 3936 ** result row of a query. ^In every case the first argument is a pointer
3793 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] 3937 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
3794 ** that was returned from [sqlite3_prepare_v2()] or one of its variants) 3938 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
3795 ** and the second argument is the index of the column for which information 3939 ** and the second argument is the index of the column for which information
3796 ** should be returned. ^The leftmost column of the result set has the index 0. 3940 ** should be returned. ^The leftmost column of the result set has the index 0.
3797 ** ^The number of columns in the result can be determined using 3941 ** ^The number of columns in the result can be determined using
3798 ** [sqlite3_column_count()]. 3942 ** [sqlite3_column_count()].
3799 ** 3943 **
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3840 ** ^The values returned by [sqlite3_column_bytes()] and 3984 ** ^The values returned by [sqlite3_column_bytes()] and
3841 ** [sqlite3_column_bytes16()] do not include the zero terminators at the end 3985 ** [sqlite3_column_bytes16()] do not include the zero terminators at the end
3842 ** of the string. ^For clarity: the values returned by 3986 ** of the string. ^For clarity: the values returned by
3843 ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of 3987 ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
3844 ** bytes in the string, not the number of characters. 3988 ** bytes in the string, not the number of characters.
3845 ** 3989 **
3846 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), 3990 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3847 ** even empty strings, are always zero-terminated. ^The return 3991 ** even empty strings, are always zero-terminated. ^The return
3848 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. 3992 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
3849 ** 3993 **
3850 ** ^The object returned by [sqlite3_column_value()] is an 3994 ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
3851 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object 3995 ** [unprotected sqlite3_value] object. In a multithreaded environment,
3852 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. 3996 ** an unprotected sqlite3_value object may only be used safely with
3997 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
3853 ** If the [unprotected sqlite3_value] object returned by 3998 ** If the [unprotected sqlite3_value] object returned by
3854 ** [sqlite3_column_value()] is used in any other way, including calls 3999 ** [sqlite3_column_value()] is used in any other way, including calls
3855 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], 4000 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
3856 ** or [sqlite3_value_bytes()], then the behavior is undefined. 4001 ** or [sqlite3_value_bytes()], the behavior is not threadsafe.
3857 ** 4002 **
3858 ** These routines attempt to convert the value where appropriate. ^For 4003 ** These routines attempt to convert the value where appropriate. ^For
3859 ** example, if the internal representation is FLOAT and a text result 4004 ** example, if the internal representation is FLOAT and a text result
3860 ** is requested, [sqlite3_snprintf()] is used internally to perform the 4005 ** is requested, [sqlite3_snprintf()] is used internally to perform the
3861 ** conversion automatically. ^(The following table details the conversions 4006 ** conversion automatically. ^(The following table details the conversions
3862 ** that are applied: 4007 ** that are applied:
3863 ** 4008 **
3864 ** <blockquote> 4009 ** <blockquote>
3865 ** <table border="1"> 4010 ** <table border="1">
3866 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion 4011 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
(...skipping 10 matching lines...) Expand all
3877 ** <tr><td> FLOAT <td> BLOB <td> [CAST] to BLOB 4022 ** <tr><td> FLOAT <td> BLOB <td> [CAST] to BLOB
3878 ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER 4023 ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
3879 ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL 4024 ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
3880 ** <tr><td> TEXT <td> BLOB <td> No change 4025 ** <tr><td> TEXT <td> BLOB <td> No change
3881 ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER 4026 ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
3882 ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL 4027 ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
3883 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed 4028 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
3884 ** </table> 4029 ** </table>
3885 ** </blockquote>)^ 4030 ** </blockquote>)^
3886 ** 4031 **
3887 ** The table above makes reference to standard C library functions atoi()
3888 ** and atof(). SQLite does not really use these functions. It has its
3889 ** own equivalent internal routines. The atoi() and atof() names are
3890 ** used in the table for brevity and because they are familiar to most
3891 ** C programmers.
3892 **
3893 ** Note that when type conversions occur, pointers returned by prior 4032 ** Note that when type conversions occur, pointers returned by prior
3894 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or 4033 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
3895 ** sqlite3_column_text16() may be invalidated. 4034 ** sqlite3_column_text16() may be invalidated.
3896 ** Type conversions and pointer invalidations might occur 4035 ** Type conversions and pointer invalidations might occur
3897 ** in the following cases: 4036 ** in the following cases:
3898 ** 4037 **
3899 ** <ul> 4038 ** <ul>
3900 ** <li> The initial content is a BLOB and sqlite3_column_text() or 4039 ** <li> The initial content is a BLOB and sqlite3_column_text() or
3901 ** sqlite3_column_text16() is called. A zero-terminator might 4040 ** sqlite3_column_text16() is called. A zero-terminator might
3902 ** need to be added to the string.</li> 4041 ** need to be added to the string.</li>
3903 ** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or 4042 ** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or
3904 ** sqlite3_column_text16() is called. The content must be converted 4043 ** sqlite3_column_text16() is called. The content must be converted
3905 ** to UTF-16.</li> 4044 ** to UTF-16.</li>
3906 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or 4045 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
3907 ** sqlite3_column_text() is called. The content must be converted 4046 ** sqlite3_column_text() is called. The content must be converted
3908 ** to UTF-8.</li> 4047 ** to UTF-8.</li>
3909 ** </ul> 4048 ** </ul>
3910 ** 4049 **
3911 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do 4050 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
3912 ** not invalidate a prior pointer, though of course the content of the buffer 4051 ** not invalidate a prior pointer, though of course the content of the buffer
3913 ** that the prior pointer references will have been modified. Other kinds 4052 ** that the prior pointer references will have been modified. Other kinds
3914 ** of conversion are done in place when it is possible, but sometimes they 4053 ** of conversion are done in place when it is possible, but sometimes they
3915 ** are not possible and in those cases prior pointers are invalidated. 4054 ** are not possible and in those cases prior pointers are invalidated.
3916 ** 4055 **
3917 ** The safest and easiest to remember policy is to invoke these routines 4056 ** The safest policy is to invoke these routines
3918 ** in one of the following ways: 4057 ** in one of the following ways:
3919 ** 4058 **
3920 ** <ul> 4059 ** <ul>
3921 ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li> 4060 ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
3922 ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li> 4061 ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
3923 ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li> 4062 ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
3924 ** </ul> 4063 ** </ul>
3925 ** 4064 **
3926 ** In other words, you should call sqlite3_column_text(), 4065 ** In other words, you should call sqlite3_column_text(),
3927 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result 4066 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
3928 ** into the desired format, then invoke sqlite3_column_bytes() or 4067 ** into the desired format, then invoke sqlite3_column_bytes() or
3929 ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls 4068 ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
3930 ** to sqlite3_column_text() or sqlite3_column_blob() with calls to 4069 ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
3931 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() 4070 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
3932 ** with calls to sqlite3_column_bytes(). 4071 ** with calls to sqlite3_column_bytes().
3933 ** 4072 **
3934 ** ^The pointers returned are valid until a type conversion occurs as 4073 ** ^The pointers returned are valid until a type conversion occurs as
3935 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or 4074 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3936 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings 4075 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
3937 ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned 4076 ** and BLOBs is freed automatically. Do <em>not</em> pass the pointers returned
3938 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into 4077 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
3939 ** [sqlite3_free()]. 4078 ** [sqlite3_free()].
3940 ** 4079 **
3941 ** ^(If a memory allocation error occurs during the evaluation of any 4080 ** ^(If a memory allocation error occurs during the evaluation of any
3942 ** of these routines, a default value is returned. The default value 4081 ** of these routines, a default value is returned. The default value
3943 ** is either the integer 0, the floating point number 0.0, or a NULL 4082 ** is either the integer 0, the floating point number 0.0, or a NULL
3944 ** pointer. Subsequent calls to [sqlite3_errcode()] will return 4083 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
3945 ** [SQLITE_NOMEM].)^ 4084 ** [SQLITE_NOMEM].)^
3946 */ 4085 */
3947 const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); 4086 const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
3948 int sqlite3_column_bytes(sqlite3_stmt*, int iCol); 4087 int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
3949 int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); 4088 int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
3950 double sqlite3_column_double(sqlite3_stmt*, int iCol); 4089 double sqlite3_column_double(sqlite3_stmt*, int iCol);
3951 int sqlite3_column_int(sqlite3_stmt*, int iCol); 4090 int sqlite3_column_int(sqlite3_stmt*, int iCol);
3952 sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); 4091 sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
3953 const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); 4092 const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
3954 const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); 4093 const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
3955 int sqlite3_column_type(sqlite3_stmt*, int iCol); 4094 int sqlite3_column_type(sqlite3_stmt*, int iCol);
3956 sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); 4095 sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
3957 4096
3958 /* 4097 /*
3959 ** CAPI3REF: Destroy A Prepared Statement Object 4098 ** CAPI3REF: Destroy A Prepared Statement Object
4099 ** DESTRUCTOR: sqlite3_stmt
3960 ** 4100 **
3961 ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. 4101 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3962 ** ^If the most recent evaluation of the statement encountered no errors 4102 ** ^If the most recent evaluation of the statement encountered no errors
3963 ** or if the statement is never been evaluated, then sqlite3_finalize() returns 4103 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
3964 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then 4104 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
3965 ** sqlite3_finalize(S) returns the appropriate [error code] or 4105 ** sqlite3_finalize(S) returns the appropriate [error code] or
3966 ** [extended error code]. 4106 ** [extended error code].
3967 ** 4107 **
3968 ** ^The sqlite3_finalize(S) routine can be called at any point during 4108 ** ^The sqlite3_finalize(S) routine can be called at any point during
3969 ** the life cycle of [prepared statement] S: 4109 ** the life cycle of [prepared statement] S:
3970 ** before statement S is ever evaluated, after 4110 ** before statement S is ever evaluated, after
3971 ** one or more calls to [sqlite3_reset()], or after any call 4111 ** one or more calls to [sqlite3_reset()], or after any call
3972 ** to [sqlite3_step()] regardless of whether or not the statement has 4112 ** to [sqlite3_step()] regardless of whether or not the statement has
3973 ** completed execution. 4113 ** completed execution.
3974 ** 4114 **
3975 ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. 4115 ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.
3976 ** 4116 **
3977 ** The application must finalize every [prepared statement] in order to avoid 4117 ** The application must finalize every [prepared statement] in order to avoid
3978 ** resource leaks. It is a grievous error for the application to try to use 4118 ** resource leaks. It is a grievous error for the application to try to use
3979 ** a prepared statement after it has been finalized. Any use of a prepared 4119 ** a prepared statement after it has been finalized. Any use of a prepared
3980 ** statement after it has been finalized can result in undefined and 4120 ** statement after it has been finalized can result in undefined and
3981 ** undesirable behavior such as segfaults and heap corruption. 4121 ** undesirable behavior such as segfaults and heap corruption.
3982 */ 4122 */
3983 int sqlite3_finalize(sqlite3_stmt *pStmt); 4123 int sqlite3_finalize(sqlite3_stmt *pStmt);
3984 4124
3985 /* 4125 /*
3986 ** CAPI3REF: Reset A Prepared Statement Object 4126 ** CAPI3REF: Reset A Prepared Statement Object
4127 ** METHOD: sqlite3_stmt
3987 ** 4128 **
3988 ** The sqlite3_reset() function is called to reset a [prepared statement] 4129 ** The sqlite3_reset() function is called to reset a [prepared statement]
3989 ** object back to its initial state, ready to be re-executed. 4130 ** object back to its initial state, ready to be re-executed.
3990 ** ^Any SQL statement variables that had values bound to them using 4131 ** ^Any SQL statement variables that had values bound to them using
3991 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. 4132 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
3992 ** Use [sqlite3_clear_bindings()] to reset the bindings. 4133 ** Use [sqlite3_clear_bindings()] to reset the bindings.
3993 ** 4134 **
3994 ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S 4135 ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
3995 ** back to the beginning of its program. 4136 ** back to the beginning of its program.
3996 ** 4137 **
3997 ** ^If the most recent call to [sqlite3_step(S)] for the 4138 ** ^If the most recent call to [sqlite3_step(S)] for the
3998 ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], 4139 ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3999 ** or if [sqlite3_step(S)] has never before been called on S, 4140 ** or if [sqlite3_step(S)] has never before been called on S,
4000 ** then [sqlite3_reset(S)] returns [SQLITE_OK]. 4141 ** then [sqlite3_reset(S)] returns [SQLITE_OK].
4001 ** 4142 **
4002 ** ^If the most recent call to [sqlite3_step(S)] for the 4143 ** ^If the most recent call to [sqlite3_step(S)] for the
4003 ** [prepared statement] S indicated an error, then 4144 ** [prepared statement] S indicated an error, then
4004 ** [sqlite3_reset(S)] returns an appropriate [error code]. 4145 ** [sqlite3_reset(S)] returns an appropriate [error code].
4005 ** 4146 **
4006 ** ^The [sqlite3_reset(S)] interface does not change the values 4147 ** ^The [sqlite3_reset(S)] interface does not change the values
4007 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. 4148 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4008 */ 4149 */
4009 int sqlite3_reset(sqlite3_stmt *pStmt); 4150 int sqlite3_reset(sqlite3_stmt *pStmt);
4010 4151
4011 /* 4152 /*
4012 ** CAPI3REF: Create Or Redefine SQL Functions 4153 ** CAPI3REF: Create Or Redefine SQL Functions
4013 ** KEYWORDS: {function creation routines} 4154 ** KEYWORDS: {function creation routines}
4014 ** KEYWORDS: {application-defined SQL function} 4155 ** KEYWORDS: {application-defined SQL function}
4015 ** KEYWORDS: {application-defined SQL functions} 4156 ** KEYWORDS: {application-defined SQL functions}
4157 ** METHOD: sqlite3
4016 ** 4158 **
4017 ** ^These functions (collectively known as "function creation routines") 4159 ** ^These functions (collectively known as "function creation routines")
4018 ** are used to add SQL functions or aggregates or to redefine the behavior 4160 ** are used to add SQL functions or aggregates or to redefine the behavior
4019 ** of existing SQL functions or aggregates. The only differences between 4161 ** of existing SQL functions or aggregates. The only differences between
4020 ** these routines are the text encoding expected for 4162 ** these routines are the text encoding expected for
4021 ** the second parameter (the name of the function being created) 4163 ** the second parameter (the name of the function being created)
4022 ** and the presence or absence of a destructor callback for 4164 ** and the presence or absence of a destructor callback for
4023 ** the application data pointer. 4165 ** the application data pointer.
4024 ** 4166 **
4025 ** ^The first parameter is the [database connection] to which the SQL 4167 ** ^The first parameter is the [database connection] to which the SQL
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4136 void (*xFinal)(sqlite3_context*), 4278 void (*xFinal)(sqlite3_context*),
4137 void(*xDestroy)(void*) 4279 void(*xDestroy)(void*)
4138 ); 4280 );
4139 4281
4140 /* 4282 /*
4141 ** CAPI3REF: Text Encodings 4283 ** CAPI3REF: Text Encodings
4142 ** 4284 **
4143 ** These constant define integer codes that represent the various 4285 ** These constant define integer codes that represent the various
4144 ** text encodings supported by SQLite. 4286 ** text encodings supported by SQLite.
4145 */ 4287 */
4146 #define SQLITE_UTF8 1 4288 #define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
4147 #define SQLITE_UTF16LE 2 4289 #define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
4148 #define SQLITE_UTF16BE 3 4290 #define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */
4149 #define SQLITE_UTF16 4 /* Use native byte order */ 4291 #define SQLITE_UTF16 4 /* Use native byte order */
4150 #define SQLITE_ANY 5 /* Deprecated */ 4292 #define SQLITE_ANY 5 /* Deprecated */
4151 #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ 4293 #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
4152 4294
4153 /* 4295 /*
4154 ** CAPI3REF: Function Flags 4296 ** CAPI3REF: Function Flags
4155 ** 4297 **
4156 ** These constants may be ORed together with the 4298 ** These constants may be ORed together with the
4157 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument 4299 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
4158 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or 4300 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
4159 ** [sqlite3_create_function_v2()]. 4301 ** [sqlite3_create_function_v2()].
4160 */ 4302 */
4161 #define SQLITE_DETERMINISTIC 0x800 4303 #define SQLITE_DETERMINISTIC 0x800
4162 4304
4163 /* 4305 /*
4164 ** CAPI3REF: Deprecated Functions 4306 ** CAPI3REF: Deprecated Functions
4165 ** DEPRECATED 4307 ** DEPRECATED
4166 ** 4308 **
4167 ** These functions are [deprecated]. In order to maintain 4309 ** These functions are [deprecated]. In order to maintain
4168 ** backwards compatibility with older code, these functions continue 4310 ** backwards compatibility with older code, these functions continue
4169 ** to be supported. However, new applications should avoid 4311 ** to be supported. However, new applications should avoid
4170 ** the use of these functions. To help encourage people to avoid 4312 ** the use of these functions. To encourage programmers to avoid
4171 ** using these functions, we are not going to tell you what they do. 4313 ** these functions, we will not explain what they do.
4172 */ 4314 */
4173 #ifndef SQLITE_OMIT_DEPRECATED 4315 #ifndef SQLITE_OMIT_DEPRECATED
4174 SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); 4316 SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4175 SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); 4317 SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4176 SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); 4318 SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4177 SQLITE_DEPRECATED int sqlite3_global_recover(void); 4319 SQLITE_DEPRECATED int sqlite3_global_recover(void);
4178 SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); 4320 SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4179 SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), 4321 SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4180 void*,sqlite3_int64); 4322 void*,sqlite3_int64);
4181 #endif 4323 #endif
4182 4324
4183 /* 4325 /*
4184 ** CAPI3REF: Obtaining SQL Function Parameter Values 4326 ** CAPI3REF: Obtaining SQL Values
4327 ** METHOD: sqlite3_value
4185 ** 4328 **
4186 ** The C-language implementation of SQL functions and aggregates uses 4329 ** The C-language implementation of SQL functions and aggregates uses
4187 ** this set of interface routines to access the parameter values on 4330 ** this set of interface routines to access the parameter values on
4188 ** the function or aggregate. 4331 ** the function or aggregate.
4189 ** 4332 **
4190 ** The xFunc (for scalar functions) or xStep (for aggregates) parameters 4333 ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
4191 ** to [sqlite3_create_function()] and [sqlite3_create_function16()] 4334 ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
4192 ** define callbacks that implement the SQL functions and aggregates. 4335 ** define callbacks that implement the SQL functions and aggregates.
4193 ** The 3rd parameter to these callbacks is an array of pointers to 4336 ** The 3rd parameter to these callbacks is an array of pointers to
4194 ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for 4337 ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for
4195 ** each parameter to the SQL function. These routines are used to 4338 ** each parameter to the SQL function. These routines are used to
4196 ** extract values from the [sqlite3_value] objects. 4339 ** extract values from the [sqlite3_value] objects.
4197 ** 4340 **
4198 ** These routines work only with [protected sqlite3_value] objects. 4341 ** These routines work only with [protected sqlite3_value] objects.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4232 int sqlite3_value_int(sqlite3_value*); 4375 int sqlite3_value_int(sqlite3_value*);
4233 sqlite3_int64 sqlite3_value_int64(sqlite3_value*); 4376 sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4234 const unsigned char *sqlite3_value_text(sqlite3_value*); 4377 const unsigned char *sqlite3_value_text(sqlite3_value*);
4235 const void *sqlite3_value_text16(sqlite3_value*); 4378 const void *sqlite3_value_text16(sqlite3_value*);
4236 const void *sqlite3_value_text16le(sqlite3_value*); 4379 const void *sqlite3_value_text16le(sqlite3_value*);
4237 const void *sqlite3_value_text16be(sqlite3_value*); 4380 const void *sqlite3_value_text16be(sqlite3_value*);
4238 int sqlite3_value_type(sqlite3_value*); 4381 int sqlite3_value_type(sqlite3_value*);
4239 int sqlite3_value_numeric_type(sqlite3_value*); 4382 int sqlite3_value_numeric_type(sqlite3_value*);
4240 4383
4241 /* 4384 /*
4385 ** CAPI3REF: Finding The Subtype Of SQL Values
4386 ** METHOD: sqlite3_value
4387 **
4388 ** The sqlite3_value_subtype(V) function returns the subtype for
4389 ** an [application-defined SQL function] argument V. The subtype
4390 ** information can be used to pass a limited amount of context from
4391 ** one SQL function to another. Use the [sqlite3_result_subtype()]
4392 ** routine to set the subtype for the return value of an SQL function.
4393 **
4394 ** SQLite makes no use of subtype itself. It merely passes the subtype
4395 ** from the result of one [application-defined SQL function] into the
4396 ** input of another.
4397 */
4398 unsigned int sqlite3_value_subtype(sqlite3_value*);
4399
4400 /*
4401 ** CAPI3REF: Copy And Free SQL Values
4402 ** METHOD: sqlite3_value
4403 **
4404 ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
4405 ** object D and returns a pointer to that copy. ^The [sqlite3_value] returned
4406 ** is a [protected sqlite3_value] object even if the input is not.
4407 ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
4408 ** memory allocation fails.
4409 **
4410 ** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
4411 ** previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer
4412 ** then sqlite3_value_free(V) is a harmless no-op.
4413 */
4414 sqlite3_value *sqlite3_value_dup(const sqlite3_value*);
4415 void sqlite3_value_free(sqlite3_value*);
4416
4417 /*
4242 ** CAPI3REF: Obtain Aggregate Function Context 4418 ** CAPI3REF: Obtain Aggregate Function Context
4419 ** METHOD: sqlite3_context
4243 ** 4420 **
4244 ** Implementations of aggregate SQL functions use this 4421 ** Implementations of aggregate SQL functions use this
4245 ** routine to allocate memory for storing their state. 4422 ** routine to allocate memory for storing their state.
4246 ** 4423 **
4247 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called 4424 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
4248 ** for a particular aggregate function, SQLite 4425 ** for a particular aggregate function, SQLite
4249 ** allocates N of memory, zeroes out that memory, and returns a pointer 4426 ** allocates N of memory, zeroes out that memory, and returns a pointer
4250 ** to the new memory. ^On second and subsequent calls to 4427 ** to the new memory. ^On second and subsequent calls to
4251 ** sqlite3_aggregate_context() for the same aggregate function instance, 4428 ** sqlite3_aggregate_context() for the same aggregate function instance,
4252 ** the same buffer is returned. Sqlite3_aggregate_context() is normally 4429 ** the same buffer is returned. Sqlite3_aggregate_context() is normally
(...skipping 24 matching lines...) Expand all
4277 ** to the xStep or xFinal callback routine that implements the aggregate 4454 ** to the xStep or xFinal callback routine that implements the aggregate
4278 ** function. 4455 ** function.
4279 ** 4456 **
4280 ** This routine must be called from the same thread in which 4457 ** This routine must be called from the same thread in which
4281 ** the aggregate SQL function is running. 4458 ** the aggregate SQL function is running.
4282 */ 4459 */
4283 void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); 4460 void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4284 4461
4285 /* 4462 /*
4286 ** CAPI3REF: User Data For Functions 4463 ** CAPI3REF: User Data For Functions
4464 ** METHOD: sqlite3_context
4287 ** 4465 **
4288 ** ^The sqlite3_user_data() interface returns a copy of 4466 ** ^The sqlite3_user_data() interface returns a copy of
4289 ** the pointer that was the pUserData parameter (the 5th parameter) 4467 ** the pointer that was the pUserData parameter (the 5th parameter)
4290 ** of the [sqlite3_create_function()] 4468 ** of the [sqlite3_create_function()]
4291 ** and [sqlite3_create_function16()] routines that originally 4469 ** and [sqlite3_create_function16()] routines that originally
4292 ** registered the application defined function. 4470 ** registered the application defined function.
4293 ** 4471 **
4294 ** This routine must be called from the same thread in which 4472 ** This routine must be called from the same thread in which
4295 ** the application-defined function is running. 4473 ** the application-defined function is running.
4296 */ 4474 */
4297 void *sqlite3_user_data(sqlite3_context*); 4475 void *sqlite3_user_data(sqlite3_context*);
4298 4476
4299 /* 4477 /*
4300 ** CAPI3REF: Database Connection For Functions 4478 ** CAPI3REF: Database Connection For Functions
4479 ** METHOD: sqlite3_context
4301 ** 4480 **
4302 ** ^The sqlite3_context_db_handle() interface returns a copy of 4481 ** ^The sqlite3_context_db_handle() interface returns a copy of
4303 ** the pointer to the [database connection] (the 1st parameter) 4482 ** the pointer to the [database connection] (the 1st parameter)
4304 ** of the [sqlite3_create_function()] 4483 ** of the [sqlite3_create_function()]
4305 ** and [sqlite3_create_function16()] routines that originally 4484 ** and [sqlite3_create_function16()] routines that originally
4306 ** registered the application defined function. 4485 ** registered the application defined function.
4307 */ 4486 */
4308 sqlite3 *sqlite3_context_db_handle(sqlite3_context*); 4487 sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4309 4488
4310 /* 4489 /*
4311 ** CAPI3REF: Function Auxiliary Data 4490 ** CAPI3REF: Function Auxiliary Data
4491 ** METHOD: sqlite3_context
4312 ** 4492 **
4313 ** These functions may be used by (non-aggregate) SQL functions to 4493 ** These functions may be used by (non-aggregate) SQL functions to
4314 ** associate metadata with argument values. If the same value is passed to 4494 ** associate metadata with argument values. If the same value is passed to
4315 ** multiple invocations of the same SQL function during query execution, under 4495 ** multiple invocations of the same SQL function during query execution, under
4316 ** some circumstances the associated metadata may be preserved. An example 4496 ** some circumstances the associated metadata may be preserved. An example
4317 ** of where this might be useful is in a regular-expression matching 4497 ** of where this might be useful is in a regular-expression matching
4318 ** function. The compiled version of the regular expression can be stored as 4498 ** function. The compiled version of the regular expression can be stored as
4319 ** metadata associated with the pattern string. 4499 ** metadata associated with the pattern string.
4320 ** Then as long as the pattern string remains the same, 4500 ** Then as long as the pattern string remains the same,
4321 ** the compiled regular expression can be reused on multiple 4501 ** the compiled regular expression can be reused on multiple
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4374 ** 4554 **
4375 ** The typedef is necessary to work around problems in certain 4555 ** The typedef is necessary to work around problems in certain
4376 ** C++ compilers. 4556 ** C++ compilers.
4377 */ 4557 */
4378 typedef void (*sqlite3_destructor_type)(void*); 4558 typedef void (*sqlite3_destructor_type)(void*);
4379 #define SQLITE_STATIC ((sqlite3_destructor_type)0) 4559 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
4380 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) 4560 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
4381 4561
4382 /* 4562 /*
4383 ** CAPI3REF: Setting The Result Of An SQL Function 4563 ** CAPI3REF: Setting The Result Of An SQL Function
4564 ** METHOD: sqlite3_context
4384 ** 4565 **
4385 ** These routines are used by the xFunc or xFinal callbacks that 4566 ** These routines are used by the xFunc or xFinal callbacks that
4386 ** implement SQL functions and aggregates. See 4567 ** implement SQL functions and aggregates. See
4387 ** [sqlite3_create_function()] and [sqlite3_create_function16()] 4568 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
4388 ** for additional information. 4569 ** for additional information.
4389 ** 4570 **
4390 ** These functions work very much like the [parameter binding] family of 4571 ** These functions work very much like the [parameter binding] family of
4391 ** functions used to bind values to host parameters in prepared statements. 4572 ** functions used to bind values to host parameters in prepared statements.
4392 ** Refer to the [SQL parameter] documentation for additional information. 4573 ** Refer to the [SQL parameter] documentation for additional information.
4393 ** 4574 **
4394 ** ^The sqlite3_result_blob() interface sets the result from 4575 ** ^The sqlite3_result_blob() interface sets the result from
4395 ** an application-defined function to be the BLOB whose content is pointed 4576 ** an application-defined function to be the BLOB whose content is pointed
4396 ** to by the second parameter and which is N bytes long where N is the 4577 ** to by the second parameter and which is N bytes long where N is the
4397 ** third parameter. 4578 ** third parameter.
4398 ** 4579 **
4399 ** ^The sqlite3_result_zeroblob() interfaces set the result of 4580 ** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
4400 ** the application-defined function to be a BLOB containing all zero 4581 ** interfaces set the result of the application-defined function to be
4401 ** bytes and N bytes in size, where N is the value of the 2nd parameter. 4582 ** a BLOB containing all zero bytes and N bytes in size.
4402 ** 4583 **
4403 ** ^The sqlite3_result_double() interface sets the result from 4584 ** ^The sqlite3_result_double() interface sets the result from
4404 ** an application-defined function to be a floating point value specified 4585 ** an application-defined function to be a floating point value specified
4405 ** by its 2nd argument. 4586 ** by its 2nd argument.
4406 ** 4587 **
4407 ** ^The sqlite3_result_error() and sqlite3_result_error16() functions 4588 ** ^The sqlite3_result_error() and sqlite3_result_error16() functions
4408 ** cause the implemented SQL function to throw an exception. 4589 ** cause the implemented SQL function to throw an exception.
4409 ** ^SQLite uses the string pointed to by the 4590 ** ^SQLite uses the string pointed to by the
4410 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() 4591 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
4411 ** as the text of an error message. ^SQLite interprets the error 4592 ** as the text of an error message. ^SQLite interprets the error
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
4473 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite 4654 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
4474 ** assumes that the text or BLOB result is in constant space and does not 4655 ** assumes that the text or BLOB result is in constant space and does not
4475 ** copy the content of the parameter nor call a destructor on the content 4656 ** copy the content of the parameter nor call a destructor on the content
4476 ** when it has finished using that result. 4657 ** when it has finished using that result.
4477 ** ^If the 4th parameter to the sqlite3_result_text* interfaces 4658 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
4478 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT 4659 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
4479 ** then SQLite makes a copy of the result into space obtained from 4660 ** then SQLite makes a copy of the result into space obtained from
4480 ** from [sqlite3_malloc()] before it returns. 4661 ** from [sqlite3_malloc()] before it returns.
4481 ** 4662 **
4482 ** ^The sqlite3_result_value() interface sets the result of 4663 ** ^The sqlite3_result_value() interface sets the result of
4483 ** the application-defined function to be a copy the 4664 ** the application-defined function to be a copy of the
4484 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The 4665 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
4485 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] 4666 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
4486 ** so that the [sqlite3_value] specified in the parameter may change or 4667 ** so that the [sqlite3_value] specified in the parameter may change or
4487 ** be deallocated after sqlite3_result_value() returns without harm. 4668 ** be deallocated after sqlite3_result_value() returns without harm.
4488 ** ^A [protected sqlite3_value] object may always be used where an 4669 ** ^A [protected sqlite3_value] object may always be used where an
4489 ** [unprotected sqlite3_value] object is required, so either 4670 ** [unprotected sqlite3_value] object is required, so either
4490 ** kind of [sqlite3_value] object can be used with this interface. 4671 ** kind of [sqlite3_value] object can be used with this interface.
4491 ** 4672 **
4492 ** If these routines are called from within the different thread 4673 ** If these routines are called from within the different thread
4493 ** than the one containing the application-defined function that received 4674 ** than the one containing the application-defined function that received
4494 ** the [sqlite3_context] pointer, the results are undefined. 4675 ** the [sqlite3_context] pointer, the results are undefined.
4495 */ 4676 */
4496 void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); 4677 void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4497 void sqlite3_result_blob64(sqlite3_context*,const void*,sqlite3_uint64,void(*)(v oid*)); 4678 void sqlite3_result_blob64(sqlite3_context*,const void*,
4679 sqlite3_uint64,void(*)(void*));
4498 void sqlite3_result_double(sqlite3_context*, double); 4680 void sqlite3_result_double(sqlite3_context*, double);
4499 void sqlite3_result_error(sqlite3_context*, const char*, int); 4681 void sqlite3_result_error(sqlite3_context*, const char*, int);
4500 void sqlite3_result_error16(sqlite3_context*, const void*, int); 4682 void sqlite3_result_error16(sqlite3_context*, const void*, int);
4501 void sqlite3_result_error_toobig(sqlite3_context*); 4683 void sqlite3_result_error_toobig(sqlite3_context*);
4502 void sqlite3_result_error_nomem(sqlite3_context*); 4684 void sqlite3_result_error_nomem(sqlite3_context*);
4503 void sqlite3_result_error_code(sqlite3_context*, int); 4685 void sqlite3_result_error_code(sqlite3_context*, int);
4504 void sqlite3_result_int(sqlite3_context*, int); 4686 void sqlite3_result_int(sqlite3_context*, int);
4505 void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); 4687 void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4506 void sqlite3_result_null(sqlite3_context*); 4688 void sqlite3_result_null(sqlite3_context*);
4507 void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); 4689 void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4508 void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, 4690 void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4509 void(*)(void*), unsigned char encoding); 4691 void(*)(void*), unsigned char encoding);
4510 void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); 4692 void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4511 void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); 4693 void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4512 void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); 4694 void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4513 void sqlite3_result_value(sqlite3_context*, sqlite3_value*); 4695 void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4514 void sqlite3_result_zeroblob(sqlite3_context*, int n); 4696 void sqlite3_result_zeroblob(sqlite3_context*, int n);
4697 int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
4698
4699
4700 /*
4701 ** CAPI3REF: Setting The Subtype Of An SQL Function
4702 ** METHOD: sqlite3_context
4703 **
4704 ** The sqlite3_result_subtype(C,T) function causes the subtype of
4705 ** the result from the [application-defined SQL function] with
4706 ** [sqlite3_context] C to be the value T. Only the lower 8 bits
4707 ** of the subtype T are preserved in current versions of SQLite;
4708 ** higher order bits are discarded.
4709 ** The number of subtype bytes preserved by SQLite might increase
4710 ** in future releases of SQLite.
4711 */
4712 void sqlite3_result_subtype(sqlite3_context*,unsigned int);
4515 4713
4516 /* 4714 /*
4517 ** CAPI3REF: Define New Collating Sequences 4715 ** CAPI3REF: Define New Collating Sequences
4716 ** METHOD: sqlite3
4518 ** 4717 **
4519 ** ^These functions add, remove, or modify a [collation] associated 4718 ** ^These functions add, remove, or modify a [collation] associated
4520 ** with the [database connection] specified as the first argument. 4719 ** with the [database connection] specified as the first argument.
4521 ** 4720 **
4522 ** ^The name of the collation is a UTF-8 string 4721 ** ^The name of the collation is a UTF-8 string
4523 ** for sqlite3_create_collation() and sqlite3_create_collation_v2() 4722 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
4524 ** and a UTF-16 string in native byte order for sqlite3_create_collation16(). 4723 ** and a UTF-16 string in native byte order for sqlite3_create_collation16().
4525 ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are 4724 ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are
4526 ** considered to be the same name. 4725 ** considered to be the same name.
4527 ** 4726 **
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4610 int sqlite3_create_collation16( 4809 int sqlite3_create_collation16(
4611 sqlite3*, 4810 sqlite3*,
4612 const void *zName, 4811 const void *zName,
4613 int eTextRep, 4812 int eTextRep,
4614 void *pArg, 4813 void *pArg,
4615 int(*xCompare)(void*,int,const void*,int,const void*) 4814 int(*xCompare)(void*,int,const void*,int,const void*)
4616 ); 4815 );
4617 4816
4618 /* 4817 /*
4619 ** CAPI3REF: Collation Needed Callbacks 4818 ** CAPI3REF: Collation Needed Callbacks
4819 ** METHOD: sqlite3
4620 ** 4820 **
4621 ** ^To avoid having to register all collation sequences before a database 4821 ** ^To avoid having to register all collation sequences before a database
4622 ** can be used, a single callback function may be registered with the 4822 ** can be used, a single callback function may be registered with the
4623 ** [database connection] to be invoked whenever an undefined collation 4823 ** [database connection] to be invoked whenever an undefined collation
4624 ** sequence is required. 4824 ** sequence is required.
4625 ** 4825 **
4626 ** ^If the function is registered using the sqlite3_collation_needed() API, 4826 ** ^If the function is registered using the sqlite3_collation_needed() API,
4627 ** then it is passed the names of undefined collation sequences as strings 4827 ** then it is passed the names of undefined collation sequences as strings
4628 ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, 4828 ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
4629 ** the names are passed as UTF-16 in machine native byte order. 4829 ** the names are passed as UTF-16 in machine native byte order.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4817 ** using [sqlite3_free]. 5017 ** using [sqlite3_free].
4818 ** Hence, if this variable is modified directly, either it should be 5018 ** Hence, if this variable is modified directly, either it should be
4819 ** made NULL or made to point to memory obtained from [sqlite3_malloc] 5019 ** made NULL or made to point to memory obtained from [sqlite3_malloc]
4820 ** or else the use of the [data_store_directory pragma] should be avoided. 5020 ** or else the use of the [data_store_directory pragma] should be avoided.
4821 */ 5021 */
4822 SQLITE_EXTERN char *sqlite3_data_directory; 5022 SQLITE_EXTERN char *sqlite3_data_directory;
4823 5023
4824 /* 5024 /*
4825 ** CAPI3REF: Test For Auto-Commit Mode 5025 ** CAPI3REF: Test For Auto-Commit Mode
4826 ** KEYWORDS: {autocommit mode} 5026 ** KEYWORDS: {autocommit mode}
5027 ** METHOD: sqlite3
4827 ** 5028 **
4828 ** ^The sqlite3_get_autocommit() interface returns non-zero or 5029 ** ^The sqlite3_get_autocommit() interface returns non-zero or
4829 ** zero if the given database connection is or is not in autocommit mode, 5030 ** zero if the given database connection is or is not in autocommit mode,
4830 ** respectively. ^Autocommit mode is on by default. 5031 ** respectively. ^Autocommit mode is on by default.
4831 ** ^Autocommit mode is disabled by a [BEGIN] statement. 5032 ** ^Autocommit mode is disabled by a [BEGIN] statement.
4832 ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. 5033 ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
4833 ** 5034 **
4834 ** If certain kinds of errors occur on a statement within a multi-statement 5035 ** If certain kinds of errors occur on a statement within a multi-statement
4835 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], 5036 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
4836 ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the 5037 ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
4837 ** transaction might be rolled back automatically. The only way to 5038 ** transaction might be rolled back automatically. The only way to
4838 ** find out whether SQLite automatically rolled back the transaction after 5039 ** find out whether SQLite automatically rolled back the transaction after
4839 ** an error is to use this function. 5040 ** an error is to use this function.
4840 ** 5041 **
4841 ** If another thread changes the autocommit status of the database 5042 ** If another thread changes the autocommit status of the database
4842 ** connection while this routine is running, then the return value 5043 ** connection while this routine is running, then the return value
4843 ** is undefined. 5044 ** is undefined.
4844 */ 5045 */
4845 int sqlite3_get_autocommit(sqlite3*); 5046 int sqlite3_get_autocommit(sqlite3*);
4846 5047
4847 /* 5048 /*
4848 ** CAPI3REF: Find The Database Handle Of A Prepared Statement 5049 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
5050 ** METHOD: sqlite3_stmt
4849 ** 5051 **
4850 ** ^The sqlite3_db_handle interface returns the [database connection] handle 5052 ** ^The sqlite3_db_handle interface returns the [database connection] handle
4851 ** to which a [prepared statement] belongs. ^The [database connection] 5053 ** to which a [prepared statement] belongs. ^The [database connection]
4852 ** returned by sqlite3_db_handle is the same [database connection] 5054 ** returned by sqlite3_db_handle is the same [database connection]
4853 ** that was the first argument 5055 ** that was the first argument
4854 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to 5056 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
4855 ** create the statement in the first place. 5057 ** create the statement in the first place.
4856 */ 5058 */
4857 sqlite3 *sqlite3_db_handle(sqlite3_stmt*); 5059 sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4858 5060
4859 /* 5061 /*
4860 ** CAPI3REF: Return The Filename For A Database Connection 5062 ** CAPI3REF: Return The Filename For A Database Connection
5063 ** METHOD: sqlite3
4861 ** 5064 **
4862 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename 5065 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
4863 ** associated with database N of connection D. ^The main database file 5066 ** associated with database N of connection D. ^The main database file
4864 ** has the name "main". If there is no attached database N on the database 5067 ** has the name "main". If there is no attached database N on the database
4865 ** connection D, or if database N is a temporary or in-memory database, then 5068 ** connection D, or if database N is a temporary or in-memory database, then
4866 ** a NULL pointer is returned. 5069 ** a NULL pointer is returned.
4867 ** 5070 **
4868 ** ^The filename returned by this function is the output of the 5071 ** ^The filename returned by this function is the output of the
4869 ** xFullPathname method of the [VFS]. ^In other words, the filename 5072 ** xFullPathname method of the [VFS]. ^In other words, the filename
4870 ** will be an absolute pathname, even if the filename used 5073 ** will be an absolute pathname, even if the filename used
4871 ** to open the database originally was a URI or relative pathname. 5074 ** to open the database originally was a URI or relative pathname.
4872 */ 5075 */
4873 const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); 5076 const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4874 5077
4875 /* 5078 /*
4876 ** CAPI3REF: Determine if a database is read-only 5079 ** CAPI3REF: Determine if a database is read-only
5080 ** METHOD: sqlite3
4877 ** 5081 **
4878 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N 5082 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
4879 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not 5083 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
4880 ** the name of a database on connection D. 5084 ** the name of a database on connection D.
4881 */ 5085 */
4882 int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); 5086 int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
4883 5087
4884 /* 5088 /*
4885 ** CAPI3REF: Find the next prepared statement 5089 ** CAPI3REF: Find the next prepared statement
5090 ** METHOD: sqlite3
4886 ** 5091 **
4887 ** ^This interface returns a pointer to the next [prepared statement] after 5092 ** ^This interface returns a pointer to the next [prepared statement] after
4888 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL 5093 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
4889 ** then this interface returns a pointer to the first prepared statement 5094 ** then this interface returns a pointer to the first prepared statement
4890 ** associated with the database connection pDb. ^If no prepared statement 5095 ** associated with the database connection pDb. ^If no prepared statement
4891 ** satisfies the conditions of this routine, it returns NULL. 5096 ** satisfies the conditions of this routine, it returns NULL.
4892 ** 5097 **
4893 ** The [database connection] pointer D in a call to 5098 ** The [database connection] pointer D in a call to
4894 ** [sqlite3_next_stmt(D,S)] must refer to an open database 5099 ** [sqlite3_next_stmt(D,S)] must refer to an open database
4895 ** connection and in particular must not be a NULL pointer. 5100 ** connection and in particular must not be a NULL pointer.
4896 */ 5101 */
4897 sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); 5102 sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4898 5103
4899 /* 5104 /*
4900 ** CAPI3REF: Commit And Rollback Notification Callbacks 5105 ** CAPI3REF: Commit And Rollback Notification Callbacks
5106 ** METHOD: sqlite3
4901 ** 5107 **
4902 ** ^The sqlite3_commit_hook() interface registers a callback 5108 ** ^The sqlite3_commit_hook() interface registers a callback
4903 ** function to be invoked whenever a transaction is [COMMIT | committed]. 5109 ** function to be invoked whenever a transaction is [COMMIT | committed].
4904 ** ^Any callback set by a previous call to sqlite3_commit_hook() 5110 ** ^Any callback set by a previous call to sqlite3_commit_hook()
4905 ** for the same database connection is overridden. 5111 ** for the same database connection is overridden.
4906 ** ^The sqlite3_rollback_hook() interface registers a callback 5112 ** ^The sqlite3_rollback_hook() interface registers a callback
4907 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. 5113 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
4908 ** ^Any callback set by a previous call to sqlite3_rollback_hook() 5114 ** ^Any callback set by a previous call to sqlite3_rollback_hook()
4909 ** for the same database connection is overridden. 5115 ** for the same database connection is overridden.
4910 ** ^The pArg argument is passed through to the callback. 5116 ** ^The pArg argument is passed through to the callback.
(...skipping 29 matching lines...) Expand all
4940 ** ^The rollback callback is not invoked if a transaction is 5146 ** ^The rollback callback is not invoked if a transaction is
4941 ** automatically rolled back because the database connection is closed. 5147 ** automatically rolled back because the database connection is closed.
4942 ** 5148 **
4943 ** See also the [sqlite3_update_hook()] interface. 5149 ** See also the [sqlite3_update_hook()] interface.
4944 */ 5150 */
4945 void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); 5151 void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
4946 void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); 5152 void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
4947 5153
4948 /* 5154 /*
4949 ** CAPI3REF: Data Change Notification Callbacks 5155 ** CAPI3REF: Data Change Notification Callbacks
5156 ** METHOD: sqlite3
4950 ** 5157 **
4951 ** ^The sqlite3_update_hook() interface registers a callback function 5158 ** ^The sqlite3_update_hook() interface registers a callback function
4952 ** with the [database connection] identified by the first argument 5159 ** with the [database connection] identified by the first argument
4953 ** to be invoked whenever a row is updated, inserted or deleted in 5160 ** to be invoked whenever a row is updated, inserted or deleted in
4954 ** a rowid table. 5161 ** a rowid table.
4955 ** ^Any callback set by a previous call to this function 5162 ** ^Any callback set by a previous call to this function
4956 ** for the same database connection is overridden. 5163 ** for the same database connection is overridden.
4957 ** 5164 **
4958 ** ^The second argument is a pointer to the function to invoke when a 5165 ** ^The second argument is a pointer to the function to invoke when a
4959 ** row is updated, inserted or deleted in a rowid table. 5166 ** row is updated, inserted or deleted in a rowid table.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5016 ** Existing database connections continue use the sharing mode 5223 ** Existing database connections continue use the sharing mode
5017 ** that was in effect at the time they were opened.)^ 5224 ** that was in effect at the time they were opened.)^
5018 ** 5225 **
5019 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled 5226 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
5020 ** successfully. An [error code] is returned otherwise.)^ 5227 ** successfully. An [error code] is returned otherwise.)^
5021 ** 5228 **
5022 ** ^Shared cache is disabled by default. But this might change in 5229 ** ^Shared cache is disabled by default. But this might change in
5023 ** future releases of SQLite. Applications that care about shared 5230 ** future releases of SQLite. Applications that care about shared
5024 ** cache setting should set it explicitly. 5231 ** cache setting should set it explicitly.
5025 ** 5232 **
5233 ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
5234 ** and will always return SQLITE_MISUSE. On those systems,
5235 ** shared cache mode should be enabled per-database connection via
5236 ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
5237 **
5026 ** This interface is threadsafe on processors where writing a 5238 ** This interface is threadsafe on processors where writing a
5027 ** 32-bit integer is atomic. 5239 ** 32-bit integer is atomic.
5028 ** 5240 **
5029 ** See Also: [SQLite Shared-Cache Mode] 5241 ** See Also: [SQLite Shared-Cache Mode]
5030 */ 5242 */
5031 int sqlite3_enable_shared_cache(int); 5243 int sqlite3_enable_shared_cache(int);
5032 5244
5033 /* 5245 /*
5034 ** CAPI3REF: Attempt To Free Heap Memory 5246 ** CAPI3REF: Attempt To Free Heap Memory
5035 ** 5247 **
5036 ** ^The sqlite3_release_memory() interface attempts to free N bytes 5248 ** ^The sqlite3_release_memory() interface attempts to free N bytes
5037 ** of heap memory by deallocating non-essential memory allocations 5249 ** of heap memory by deallocating non-essential memory allocations
5038 ** held by the database library. Memory used to cache database 5250 ** held by the database library. Memory used to cache database
5039 ** pages to improve performance is an example of non-essential memory. 5251 ** pages to improve performance is an example of non-essential memory.
5040 ** ^sqlite3_release_memory() returns the number of bytes actually freed, 5252 ** ^sqlite3_release_memory() returns the number of bytes actually freed,
5041 ** which might be more or less than the amount requested. 5253 ** which might be more or less than the amount requested.
5042 ** ^The sqlite3_release_memory() routine is a no-op returning zero 5254 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5043 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. 5255 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5044 ** 5256 **
5045 ** See also: [sqlite3_db_release_memory()] 5257 ** See also: [sqlite3_db_release_memory()]
5046 */ 5258 */
5047 int sqlite3_release_memory(int); 5259 int sqlite3_release_memory(int);
5048 5260
5049 /* 5261 /*
5050 ** CAPI3REF: Free Memory Used By A Database Connection 5262 ** CAPI3REF: Free Memory Used By A Database Connection
5263 ** METHOD: sqlite3
5051 ** 5264 **
5052 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap 5265 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
5053 ** memory as possible from database connection D. Unlike the 5266 ** memory as possible from database connection D. Unlike the
5054 ** [sqlite3_release_memory()] interface, this interface is in effect even 5267 ** [sqlite3_release_memory()] interface, this interface is in effect even
5055 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is 5268 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5056 ** omitted. 5269 ** omitted.
5057 ** 5270 **
5058 ** See also: [sqlite3_release_memory()] 5271 ** See also: [sqlite3_release_memory()]
5059 */ 5272 */
5060 int sqlite3_db_release_memory(sqlite3*); 5273 int sqlite3_db_release_memory(sqlite3*);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5118 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()] 5331 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5119 ** interface. This routine is provided for historical compatibility 5332 ** interface. This routine is provided for historical compatibility
5120 ** only. All new applications should use the 5333 ** only. All new applications should use the
5121 ** [sqlite3_soft_heap_limit64()] interface rather than this one. 5334 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5122 */ 5335 */
5123 SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); 5336 SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5124 5337
5125 5338
5126 /* 5339 /*
5127 ** CAPI3REF: Extract Metadata About A Column Of A Table 5340 ** CAPI3REF: Extract Metadata About A Column Of A Table
5341 ** METHOD: sqlite3
5128 ** 5342 **
5129 ** ^This routine returns metadata about a specific column of a specific 5343 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5130 ** database table accessible using the [database connection] handle 5344 ** information about column C of table T in database D
5131 ** passed as the first function argument. 5345 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5346 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
5347 ** the final five arguments with appropriate values if the specified
5348 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5349 ** SQLITE_ERROR and if the specified column does not exist.
5350 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5351 ** NULL pointer, then this routine simply checks for the existance of the
5352 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5353 ** does not.
5132 ** 5354 **
5133 ** ^The column is identified by the second, third and fourth parameters to 5355 ** ^The column is identified by the second, third and fourth parameters to
5134 ** this function. ^The second parameter is either the name of the database 5356 ** this function. ^(The second parameter is either the name of the database
5135 ** (i.e. "main", "temp", or an attached database) containing the specified 5357 ** (i.e. "main", "temp", or an attached database) containing the specified
5136 ** table or NULL. ^If it is NULL, then all attached databases are searched 5358 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
5137 ** for the table using the same algorithm used by the database engine to 5359 ** for the table using the same algorithm used by the database engine to
5138 ** resolve unqualified table references. 5360 ** resolve unqualified table references.
5139 ** 5361 **
5140 ** ^The third and fourth parameters to this function are the table and column 5362 ** ^The third and fourth parameters to this function are the table and column
5141 ** name of the desired column, respectively. Neither of these parameters 5363 ** name of the desired column, respectively.
5142 ** may be NULL.
5143 ** 5364 **
5144 ** ^Metadata is returned by writing to the memory locations passed as the 5th 5365 ** ^Metadata is returned by writing to the memory locations passed as the 5th
5145 ** and subsequent parameters to this function. ^Any of these arguments may be 5366 ** and subsequent parameters to this function. ^Any of these arguments may be
5146 ** NULL, in which case the corresponding element of metadata is omitted. 5367 ** NULL, in which case the corresponding element of metadata is omitted.
5147 ** 5368 **
5148 ** ^(<blockquote> 5369 ** ^(<blockquote>
5149 ** <table border="1"> 5370 ** <table border="1">
5150 ** <tr><th> Parameter <th> Output<br>Type <th> Description 5371 ** <tr><th> Parameter <th> Output<br>Type <th> Description
5151 ** 5372 **
5152 ** <tr><td> 5th <td> const char* <td> Data type 5373 ** <tr><td> 5th <td> const char* <td> Data type
5153 ** <tr><td> 6th <td> const char* <td> Name of default collation sequence 5374 ** <tr><td> 6th <td> const char* <td> Name of default collation sequence
5154 ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint 5375 ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
5155 ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY 5376 ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
5156 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT] 5377 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
5157 ** </table> 5378 ** </table>
5158 ** </blockquote>)^ 5379 ** </blockquote>)^
5159 ** 5380 **
5160 ** ^The memory pointed to by the character pointers returned for the 5381 ** ^The memory pointed to by the character pointers returned for the
5161 ** declaration type and collation sequence is valid only until the next 5382 ** declaration type and collation sequence is valid until the next
5162 ** call to any SQLite API function. 5383 ** call to any SQLite API function.
5163 ** 5384 **
5164 ** ^If the specified table is actually a view, an [error code] is returned. 5385 ** ^If the specified table is actually a view, an [error code] is returned.
5165 ** 5386 **
5166 ** ^If the specified column is "rowid", "oid" or "_rowid_" and an 5387 ** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
5388 ** is not a [WITHOUT ROWID] table and an
5167 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output 5389 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
5168 ** parameters are set for the explicitly declared column. ^(If there is no 5390 ** parameters are set for the explicitly declared column. ^(If there is no
5169 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output 5391 ** [INTEGER PRIMARY KEY] column, then the outputs
5170 ** parameters are set as follows: 5392 ** for the [rowid] are set as follows:
5171 ** 5393 **
5172 ** <pre> 5394 ** <pre>
5173 ** data type: "INTEGER" 5395 ** data type: "INTEGER"
5174 ** collation sequence: "BINARY" 5396 ** collation sequence: "BINARY"
5175 ** not null: 0 5397 ** not null: 0
5176 ** primary key: 1 5398 ** primary key: 1
5177 ** auto increment: 0 5399 ** auto increment: 0
5178 ** </pre>)^ 5400 ** </pre>)^
5179 ** 5401 **
5180 ** ^(This function may load one or more schemas from database files. If an 5402 ** ^This function causes all database schemas to be read from disk and
5181 ** error occurs during this process, or if the requested table or column 5403 ** parsed, if that has not already been done, and returns an error if
5182 ** cannot be found, an [error code] is returned and an error message left 5404 ** any errors are encountered while loading the schema.
5183 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
5184 **
5185 ** ^This API is only available if the library was compiled with the
5186 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
5187 */ 5405 */
5188 int sqlite3_table_column_metadata( 5406 int sqlite3_table_column_metadata(
5189 sqlite3 *db, /* Connection handle */ 5407 sqlite3 *db, /* Connection handle */
5190 const char *zDbName, /* Database name or NULL */ 5408 const char *zDbName, /* Database name or NULL */
5191 const char *zTableName, /* Table name */ 5409 const char *zTableName, /* Table name */
5192 const char *zColumnName, /* Column name */ 5410 const char *zColumnName, /* Column name */
5193 char const **pzDataType, /* OUTPUT: Declared data type */ 5411 char const **pzDataType, /* OUTPUT: Declared data type */
5194 char const **pzCollSeq, /* OUTPUT: Collation sequence name */ 5412 char const **pzCollSeq, /* OUTPUT: Collation sequence name */
5195 int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ 5413 int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */
5196 int *pPrimaryKey, /* OUTPUT: True if column part of PK */ 5414 int *pPrimaryKey, /* OUTPUT: True if column part of PK */
5197 int *pAutoinc /* OUTPUT: True if column is auto-increment */ 5415 int *pAutoinc /* OUTPUT: True if column is auto-increment */
5198 ); 5416 );
5199 5417
5200 /* 5418 /*
5201 ** CAPI3REF: Load An Extension 5419 ** CAPI3REF: Load An Extension
5420 ** METHOD: sqlite3
5202 ** 5421 **
5203 ** ^This interface loads an SQLite extension library from the named file. 5422 ** ^This interface loads an SQLite extension library from the named file.
5204 ** 5423 **
5205 ** ^The sqlite3_load_extension() interface attempts to load an 5424 ** ^The sqlite3_load_extension() interface attempts to load an
5206 ** [SQLite extension] library contained in the file zFile. If 5425 ** [SQLite extension] library contained in the file zFile. If
5207 ** the file cannot be loaded directly, attempts are made to load 5426 ** the file cannot be loaded directly, attempts are made to load
5208 ** with various operating-system specific extensions added. 5427 ** with various operating-system specific extensions added.
5209 ** So for example, if "samplelib" cannot be loaded, then names like 5428 ** So for example, if "samplelib" cannot be loaded, then names like
5210 ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might 5429 ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
5211 ** be tried also. 5430 ** be tried also.
(...skipping 21 matching lines...) Expand all
5233 */ 5452 */
5234 int sqlite3_load_extension( 5453 int sqlite3_load_extension(
5235 sqlite3 *db, /* Load the extension into this database connection */ 5454 sqlite3 *db, /* Load the extension into this database connection */
5236 const char *zFile, /* Name of the shared library containing extension */ 5455 const char *zFile, /* Name of the shared library containing extension */
5237 const char *zProc, /* Entry point. Derived from zFile if 0 */ 5456 const char *zProc, /* Entry point. Derived from zFile if 0 */
5238 char **pzErrMsg /* Put error message here if not 0 */ 5457 char **pzErrMsg /* Put error message here if not 0 */
5239 ); 5458 );
5240 5459
5241 /* 5460 /*
5242 ** CAPI3REF: Enable Or Disable Extension Loading 5461 ** CAPI3REF: Enable Or Disable Extension Loading
5462 ** METHOD: sqlite3
5243 ** 5463 **
5244 ** ^So as not to open security holes in older applications that are 5464 ** ^So as not to open security holes in older applications that are
5245 ** unprepared to deal with [extension loading], and as a means of disabling 5465 ** unprepared to deal with [extension loading], and as a means of disabling
5246 ** [extension loading] while evaluating user-entered SQL, the following API 5466 ** [extension loading] while evaluating user-entered SQL, the following API
5247 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. 5467 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
5248 ** 5468 **
5249 ** ^Extension loading is off by default. 5469 ** ^Extension loading is off by default.
5250 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 5470 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5251 ** to turn extension loading on and call it with onoff==0 to turn 5471 ** to turn extension loading on and call it with onoff==0 to turn
5252 ** it back off again. 5472 ** it back off again.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
5404 ** 5624 **
5405 ** ^The optimizer automatically inverts terms of the form "expr OP column" 5625 ** ^The optimizer automatically inverts terms of the form "expr OP column"
5406 ** and makes other simplifications to the WHERE clause in an attempt to 5626 ** and makes other simplifications to the WHERE clause in an attempt to
5407 ** get as many WHERE clause terms into the form shown above as possible. 5627 ** get as many WHERE clause terms into the form shown above as possible.
5408 ** ^The aConstraint[] array only reports WHERE clause terms that are 5628 ** ^The aConstraint[] array only reports WHERE clause terms that are
5409 ** relevant to the particular virtual table being queried. 5629 ** relevant to the particular virtual table being queried.
5410 ** 5630 **
5411 ** ^Information about the ORDER BY clause is stored in aOrderBy[]. 5631 ** ^Information about the ORDER BY clause is stored in aOrderBy[].
5412 ** ^Each term of aOrderBy records a column of the ORDER BY clause. 5632 ** ^Each term of aOrderBy records a column of the ORDER BY clause.
5413 ** 5633 **
5634 ** The colUsed field indicates which columns of the virtual table may be
5635 ** required by the current scan. Virtual table columns are numbered from
5636 ** zero in the order in which they appear within the CREATE TABLE statement
5637 ** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
5638 ** the corresponding bit is set within the colUsed mask if the column may be
5639 ** required by SQLite. If the table has at least 64 columns and any column
5640 ** to the right of the first 63 is required, then bit 63 of colUsed is also
5641 ** set. In other words, column iCol may be required if the expression
5642 ** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to
5643 ** non-zero.
5644 **
5414 ** The [xBestIndex] method must fill aConstraintUsage[] with information 5645 ** The [xBestIndex] method must fill aConstraintUsage[] with information
5415 ** about what parameters to pass to xFilter. ^If argvIndex>0 then 5646 ** about what parameters to pass to xFilter. ^If argvIndex>0 then
5416 ** the right-hand side of the corresponding aConstraint[] is evaluated 5647 ** the right-hand side of the corresponding aConstraint[] is evaluated
5417 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit 5648 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
5418 ** is true, then the constraint is assumed to be fully handled by the 5649 ** is true, then the constraint is assumed to be fully handled by the
5419 ** virtual table and is not checked again by SQLite.)^ 5650 ** virtual table and is not checked again by SQLite.)^
5420 ** 5651 **
5421 ** ^The idxNum and idxPtr values are recorded and passed into the 5652 ** ^The idxNum and idxPtr values are recorded and passed into the
5422 ** [xFilter] method. 5653 ** [xFilter] method.
5423 ** ^[sqlite3_free()] is used to free idxPtr if and only if 5654 ** ^[sqlite3_free()] is used to free idxPtr if and only if
5424 ** needToFreeIdxPtr is true. 5655 ** needToFreeIdxPtr is true.
5425 ** 5656 **
5426 ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in 5657 ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
5427 ** the correct order to satisfy the ORDER BY clause so that no separate 5658 ** the correct order to satisfy the ORDER BY clause so that no separate
5428 ** sorting step is required. 5659 ** sorting step is required.
5429 ** 5660 **
5430 ** ^The estimatedCost value is an estimate of the cost of a particular 5661 ** ^The estimatedCost value is an estimate of the cost of a particular
5431 ** strategy. A cost of N indicates that the cost of the strategy is similar 5662 ** strategy. A cost of N indicates that the cost of the strategy is similar
5432 ** to a linear scan of an SQLite table with N rows. A cost of log(N) 5663 ** to a linear scan of an SQLite table with N rows. A cost of log(N)
5433 ** indicates that the expense of the operation is similar to that of a 5664 ** indicates that the expense of the operation is similar to that of a
5434 ** binary search on a unique indexed field of an SQLite table with N rows. 5665 ** binary search on a unique indexed field of an SQLite table with N rows.
5435 ** 5666 **
5436 ** ^The estimatedRows value is an estimate of the number of rows that 5667 ** ^The estimatedRows value is an estimate of the number of rows that
5437 ** will be returned by the strategy. 5668 ** will be returned by the strategy.
5438 ** 5669 **
5670 ** The xBestIndex method may optionally populate the idxFlags field with a
5671 ** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -
5672 ** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
5673 ** assumes that the strategy may visit at most one row.
5674 **
5675 ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
5676 ** SQLite also assumes that if a call to the xUpdate() method is made as
5677 ** part of the same statement to delete or update a virtual table row and the
5678 ** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback
5679 ** any database changes. In other words, if the xUpdate() returns
5680 ** SQLITE_CONSTRAINT, the database contents must be exactly as they were
5681 ** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not
5682 ** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by
5683 ** the xUpdate method are automatically rolled back by SQLite.
5684 **
5439 ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info 5685 ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
5440 ** structure for SQLite version 3.8.2. If a virtual table extension is 5686 ** structure for SQLite version 3.8.2. If a virtual table extension is
5441 ** used with an SQLite version earlier than 3.8.2, the results of attempting 5687 ** used with an SQLite version earlier than 3.8.2, the results of attempting
5442 ** to read or write the estimatedRows field are undefined (but are likely 5688 ** to read or write the estimatedRows field are undefined (but are likely
5443 ** to included crashing the application). The estimatedRows field should 5689 ** to included crashing the application). The estimatedRows field should
5444 ** therefore only be used if [sqlite3_libversion_number()] returns a 5690 ** therefore only be used if [sqlite3_libversion_number()] returns a
5445 ** value greater than or equal to 3008002. 5691 ** value greater than or equal to 3008002. Similarly, the idxFlags field
5692 ** was added for version 3.9.0. It may therefore only be used if
5693 ** sqlite3_libversion_number() returns a value greater than or equal to
5694 ** 3009000.
5446 */ 5695 */
5447 struct sqlite3_index_info { 5696 struct sqlite3_index_info {
5448 /* Inputs */ 5697 /* Inputs */
5449 int nConstraint; /* Number of entries in aConstraint */ 5698 int nConstraint; /* Number of entries in aConstraint */
5450 struct sqlite3_index_constraint { 5699 struct sqlite3_index_constraint {
5451 int iColumn; /* Column on left-hand side of constraint */ 5700 int iColumn; /* Column on left-hand side of constraint */
5452 unsigned char op; /* Constraint operator */ 5701 unsigned char op; /* Constraint operator */
5453 unsigned char usable; /* True if this constraint is usable */ 5702 unsigned char usable; /* True if this constraint is usable */
5454 int iTermOffset; /* Used internally - xBestIndex should ignore */ 5703 int iTermOffset; /* Used internally - xBestIndex should ignore */
5455 } *aConstraint; /* Table of WHERE clause constraints */ 5704 } *aConstraint; /* Table of WHERE clause constraints */
5456 int nOrderBy; /* Number of terms in the ORDER BY clause */ 5705 int nOrderBy; /* Number of terms in the ORDER BY clause */
5457 struct sqlite3_index_orderby { 5706 struct sqlite3_index_orderby {
5458 int iColumn; /* Column number */ 5707 int iColumn; /* Column number */
5459 unsigned char desc; /* True for DESC. False for ASC. */ 5708 unsigned char desc; /* True for DESC. False for ASC. */
5460 } *aOrderBy; /* The ORDER BY clause */ 5709 } *aOrderBy; /* The ORDER BY clause */
5461 /* Outputs */ 5710 /* Outputs */
5462 struct sqlite3_index_constraint_usage { 5711 struct sqlite3_index_constraint_usage {
5463 int argvIndex; /* if >0, constraint is part of argv to xFilter */ 5712 int argvIndex; /* if >0, constraint is part of argv to xFilter */
5464 unsigned char omit; /* Do not code a test for this constraint */ 5713 unsigned char omit; /* Do not code a test for this constraint */
5465 } *aConstraintUsage; 5714 } *aConstraintUsage;
5466 int idxNum; /* Number used to identify the index */ 5715 int idxNum; /* Number used to identify the index */
5467 char *idxStr; /* String, possibly obtained from sqlite3_malloc */ 5716 char *idxStr; /* String, possibly obtained from sqlite3_malloc */
5468 int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ 5717 int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
5469 int orderByConsumed; /* True if output is already ordered */ 5718 int orderByConsumed; /* True if output is already ordered */
5470 double estimatedCost; /* Estimated cost of using this index */ 5719 double estimatedCost; /* Estimated cost of using this index */
5471 /* Fields below are only available in SQLite 3.8.2 and later */ 5720 /* Fields below are only available in SQLite 3.8.2 and later */
5472 sqlite3_int64 estimatedRows; /* Estimated number of rows returned */ 5721 sqlite3_int64 estimatedRows; /* Estimated number of rows returned */
5722 /* Fields below are only available in SQLite 3.9.0 and later */
5723 int idxFlags; /* Mask of SQLITE_INDEX_SCAN_* flags */
5724 /* Fields below are only available in SQLite 3.10.0 and later */
5725 sqlite3_uint64 colUsed; /* Input: Mask of columns used by statement */
5473 }; 5726 };
5474 5727
5475 /* 5728 /*
5729 ** CAPI3REF: Virtual Table Scan Flags
5730 */
5731 #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
5732
5733 /*
5476 ** CAPI3REF: Virtual Table Constraint Operator Codes 5734 ** CAPI3REF: Virtual Table Constraint Operator Codes
5477 ** 5735 **
5478 ** These macros defined the allowed values for the 5736 ** These macros defined the allowed values for the
5479 ** [sqlite3_index_info].aConstraint[].op field. Each value represents 5737 ** [sqlite3_index_info].aConstraint[].op field. Each value represents
5480 ** an operator that is part of a constraint term in the wHERE clause of 5738 ** an operator that is part of a constraint term in the wHERE clause of
5481 ** a query that uses a [virtual table]. 5739 ** a query that uses a [virtual table].
5482 */ 5740 */
5483 #define SQLITE_INDEX_CONSTRAINT_EQ 2 5741 #define SQLITE_INDEX_CONSTRAINT_EQ 2
5484 #define SQLITE_INDEX_CONSTRAINT_GT 4 5742 #define SQLITE_INDEX_CONSTRAINT_GT 4
5485 #define SQLITE_INDEX_CONSTRAINT_LE 8 5743 #define SQLITE_INDEX_CONSTRAINT_LE 8
5486 #define SQLITE_INDEX_CONSTRAINT_LT 16 5744 #define SQLITE_INDEX_CONSTRAINT_LT 16
5487 #define SQLITE_INDEX_CONSTRAINT_GE 32 5745 #define SQLITE_INDEX_CONSTRAINT_GE 32
5488 #define SQLITE_INDEX_CONSTRAINT_MATCH 64 5746 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
5747 #define SQLITE_INDEX_CONSTRAINT_LIKE 65
5748 #define SQLITE_INDEX_CONSTRAINT_GLOB 66
5749 #define SQLITE_INDEX_CONSTRAINT_REGEXP 67
5489 5750
5490 /* 5751 /*
5491 ** CAPI3REF: Register A Virtual Table Implementation 5752 ** CAPI3REF: Register A Virtual Table Implementation
5753 ** METHOD: sqlite3
5492 ** 5754 **
5493 ** ^These routines are used to register a new [virtual table module] name. 5755 ** ^These routines are used to register a new [virtual table module] name.
5494 ** ^Module names must be registered before 5756 ** ^Module names must be registered before
5495 ** creating a new [virtual table] using the module and before using a 5757 ** creating a new [virtual table] using the module and before using a
5496 ** preexisting [virtual table] for the module. 5758 ** preexisting [virtual table] for the module.
5497 ** 5759 **
5498 ** ^The module name is registered on the [database connection] specified 5760 ** ^The module name is registered on the [database connection] specified
5499 ** by the first parameter. ^The name of the module is given by the 5761 ** by the first parameter. ^The name of the module is given by the
5500 ** second parameter. ^The third parameter is a pointer to 5762 ** second parameter. ^The third parameter is a pointer to
5501 ** the implementation of the [virtual table module]. ^The fourth 5763 ** the implementation of the [virtual table module]. ^The fourth
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5539 ** 5801 **
5540 ** ^Virtual tables methods can set an error message by assigning a 5802 ** ^Virtual tables methods can set an error message by assigning a
5541 ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should 5803 ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
5542 ** take care that any prior string is freed by a call to [sqlite3_free()] 5804 ** take care that any prior string is freed by a call to [sqlite3_free()]
5543 ** prior to assigning a new string to zErrMsg. ^After the error message 5805 ** prior to assigning a new string to zErrMsg. ^After the error message
5544 ** is delivered up to the client application, the string will be automatically 5806 ** is delivered up to the client application, the string will be automatically
5545 ** freed by sqlite3_free() and the zErrMsg field will be zeroed. 5807 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
5546 */ 5808 */
5547 struct sqlite3_vtab { 5809 struct sqlite3_vtab {
5548 const sqlite3_module *pModule; /* The module for this virtual table */ 5810 const sqlite3_module *pModule; /* The module for this virtual table */
5549 int nRef; /* NO LONGER USED */ 5811 int nRef; /* Number of open cursors */
5550 char *zErrMsg; /* Error message from sqlite3_mprintf() */ 5812 char *zErrMsg; /* Error message from sqlite3_mprintf() */
5551 /* Virtual table implementations will typically add additional fields */ 5813 /* Virtual table implementations will typically add additional fields */
5552 }; 5814 };
5553 5815
5554 /* 5816 /*
5555 ** CAPI3REF: Virtual Table Cursor Object 5817 ** CAPI3REF: Virtual Table Cursor Object
5556 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} 5818 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
5557 ** 5819 **
5558 ** Every [virtual table module] implementation uses a subclass of the 5820 ** Every [virtual table module] implementation uses a subclass of the
5559 ** following structure to describe cursors that point into the 5821 ** following structure to describe cursors that point into the
(...skipping 18 matching lines...) Expand all
5578 ** 5840 **
5579 ** ^The [xCreate] and [xConnect] methods of a 5841 ** ^The [xCreate] and [xConnect] methods of a
5580 ** [virtual table module] call this interface 5842 ** [virtual table module] call this interface
5581 ** to declare the format (the names and datatypes of the columns) of 5843 ** to declare the format (the names and datatypes of the columns) of
5582 ** the virtual tables they implement. 5844 ** the virtual tables they implement.
5583 */ 5845 */
5584 int sqlite3_declare_vtab(sqlite3*, const char *zSQL); 5846 int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5585 5847
5586 /* 5848 /*
5587 ** CAPI3REF: Overload A Function For A Virtual Table 5849 ** CAPI3REF: Overload A Function For A Virtual Table
5850 ** METHOD: sqlite3
5588 ** 5851 **
5589 ** ^(Virtual tables can provide alternative implementations of functions 5852 ** ^(Virtual tables can provide alternative implementations of functions
5590 ** using the [xFindFunction] method of the [virtual table module]. 5853 ** using the [xFindFunction] method of the [virtual table module].
5591 ** But global versions of those functions 5854 ** But global versions of those functions
5592 ** must exist in order to be overloaded.)^ 5855 ** must exist in order to be overloaded.)^
5593 ** 5856 **
5594 ** ^(This API makes sure a global version of a function with a particular 5857 ** ^(This API makes sure a global version of a function with a particular
5595 ** name and number of parameters exists. If no such function exists 5858 ** name and number of parameters exists. If no such function exists
5596 ** before this API is called, a new function is created.)^ ^The implementation 5859 ** before this API is called, a new function is created.)^ ^The implementation
5597 ** of the new function always causes an exception to be thrown. So 5860 ** of the new function always causes an exception to be thrown. So
(...skipping 22 matching lines...) Expand all
5620 ** ^Objects of this type are created by [sqlite3_blob_open()] 5883 ** ^Objects of this type are created by [sqlite3_blob_open()]
5621 ** and destroyed by [sqlite3_blob_close()]. 5884 ** and destroyed by [sqlite3_blob_close()].
5622 ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces 5885 ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
5623 ** can be used to read or write small subsections of the BLOB. 5886 ** can be used to read or write small subsections of the BLOB.
5624 ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. 5887 ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
5625 */ 5888 */
5626 typedef struct sqlite3_blob sqlite3_blob; 5889 typedef struct sqlite3_blob sqlite3_blob;
5627 5890
5628 /* 5891 /*
5629 ** CAPI3REF: Open A BLOB For Incremental I/O 5892 ** CAPI3REF: Open A BLOB For Incremental I/O
5893 ** METHOD: sqlite3
5894 ** CONSTRUCTOR: sqlite3_blob
5630 ** 5895 **
5631 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located 5896 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
5632 ** in row iRow, column zColumn, table zTable in database zDb; 5897 ** in row iRow, column zColumn, table zTable in database zDb;
5633 ** in other words, the same BLOB that would be selected by: 5898 ** in other words, the same BLOB that would be selected by:
5634 ** 5899 **
5635 ** <pre> 5900 ** <pre>
5636 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow; 5901 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
5637 ** </pre>)^ 5902 ** </pre>)^
5638 ** 5903 **
5904 ** ^(Parameter zDb is not the filename that contains the database, but
5905 ** rather the symbolic name of the database. For attached databases, this is
5906 ** the name that appears after the AS keyword in the [ATTACH] statement.
5907 ** For the main database file, the database name is "main". For TEMP
5908 ** tables, the database name is "temp".)^
5909 **
5639 ** ^If the flags parameter is non-zero, then the BLOB is opened for read 5910 ** ^If the flags parameter is non-zero, then the BLOB is opened for read
5640 ** and write access. ^If it is zero, the BLOB is opened for read access. 5911 ** and write access. ^If the flags parameter is zero, the BLOB is opened for
5641 ** ^It is not possible to open a column that is part of an index or primary 5912 ** read-only access.
5642 ** key for writing. ^If [foreign key constraints] are enabled, it is
5643 ** not possible to open a column that is part of a [child key] for writing.
5644 ** 5913 **
5645 ** ^Note that the database name is not the filename that contains 5914 ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored
5646 ** the database but rather the symbolic name of the database that 5915 ** in *ppBlob. Otherwise an [error code] is returned and, unless the error
5647 ** appears after the AS keyword when the database is connected using [ATTACH]. 5916 ** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
5648 ** ^For the main database file, the database name is "main". 5917 ** the API is not misused, it is always safe to call [sqlite3_blob_close()]
5649 ** ^For TEMP tables, the database name is "temp". 5918 ** on *ppBlob after this function it returns.
5650 ** 5919 **
5651 ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written 5920 ** This function fails with SQLITE_ERROR if any of the following are true:
5652 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set 5921 ** <ul>
5653 ** to be a null pointer.)^ 5922 ** <li> ^(Database zDb does not exist)^,
5654 ** ^This function sets the [database connection] error code and message 5923 ** <li> ^(Table zTable does not exist within database zDb)^,
5655 ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related 5924 ** <li> ^(Table zTable is a WITHOUT ROWID table)^,
5656 ** functions. ^Note that the *ppBlob variable is always initialized in a 5925 ** <li> ^(Column zColumn does not exist)^,
5657 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob 5926 ** <li> ^(Row iRow is not present in the table)^,
5658 ** regardless of the success or failure of this routine. 5927 ** <li> ^(The specified column of row iRow contains a value that is not
5928 ** a TEXT or BLOB value)^,
5929 ** <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE
5930 ** constraint and the blob is being opened for read/write access)^,
5931 ** <li> ^([foreign key constraints | Foreign key constraints] are enabled,
5932 ** column zColumn is part of a [child key] definition and the blob is
5933 ** being opened for read/write access)^.
5934 ** </ul>
5935 **
5936 ** ^Unless it returns SQLITE_MISUSE, this function sets the
5937 ** [database connection] error code and message accessible via
5938 ** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions.
5939 **
5659 ** 5940 **
5660 ** ^(If the row that a BLOB handle points to is modified by an 5941 ** ^(If the row that a BLOB handle points to is modified by an
5661 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects 5942 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
5662 ** then the BLOB handle is marked as "expired". 5943 ** then the BLOB handle is marked as "expired".
5663 ** This is true if any column of the row is changed, even a column 5944 ** This is true if any column of the row is changed, even a column
5664 ** other than the one the BLOB handle is open on.)^ 5945 ** other than the one the BLOB handle is open on.)^
5665 ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for 5946 ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
5666 ** an expired BLOB handle fail with a return code of [SQLITE_ABORT]. 5947 ** an expired BLOB handle fail with a return code of [SQLITE_ABORT].
5667 ** ^(Changes written into a BLOB prior to the BLOB expiring are not 5948 ** ^(Changes written into a BLOB prior to the BLOB expiring are not
5668 ** rolled back by the expiration of the BLOB. Such changes will eventually 5949 ** rolled back by the expiration of the BLOB. Such changes will eventually
5669 ** commit if the transaction continues to completion.)^ 5950 ** commit if the transaction continues to completion.)^
5670 ** 5951 **
5671 ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of 5952 ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
5672 ** the opened blob. ^The size of a blob may not be changed by this 5953 ** the opened blob. ^The size of a blob may not be changed by this
5673 ** interface. Use the [UPDATE] SQL command to change the size of a 5954 ** interface. Use the [UPDATE] SQL command to change the size of a
5674 ** blob. 5955 ** blob.
5675 ** 5956 **
5676 ** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
5677 ** table. Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
5678 **
5679 ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces 5957 ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
5680 ** and the built-in [zeroblob] SQL function can be used, if desired, 5958 ** and the built-in [zeroblob] SQL function may be used to create a
5681 ** to create an empty, zero-filled blob in which to read or write using 5959 ** zero-filled blob to read or write using the incremental-blob interface.
5682 ** this interface.
5683 ** 5960 **
5684 ** To avoid a resource leak, every open [BLOB handle] should eventually 5961 ** To avoid a resource leak, every open [BLOB handle] should eventually
5685 ** be released by a call to [sqlite3_blob_close()]. 5962 ** be released by a call to [sqlite3_blob_close()].
5686 */ 5963 */
5687 int sqlite3_blob_open( 5964 int sqlite3_blob_open(
5688 sqlite3*, 5965 sqlite3*,
5689 const char *zDb, 5966 const char *zDb,
5690 const char *zTable, 5967 const char *zTable,
5691 const char *zColumn, 5968 const char *zColumn,
5692 sqlite3_int64 iRow, 5969 sqlite3_int64 iRow,
5693 int flags, 5970 int flags,
5694 sqlite3_blob **ppBlob 5971 sqlite3_blob **ppBlob
5695 ); 5972 );
5696 5973
5697 /* 5974 /*
5698 ** CAPI3REF: Move a BLOB Handle to a New Row 5975 ** CAPI3REF: Move a BLOB Handle to a New Row
5976 ** METHOD: sqlite3_blob
5699 ** 5977 **
5700 ** ^This function is used to move an existing blob handle so that it points 5978 ** ^This function is used to move an existing blob handle so that it points
5701 ** to a different row of the same database table. ^The new row is identified 5979 ** to a different row of the same database table. ^The new row is identified
5702 ** by the rowid value passed as the second argument. Only the row can be 5980 ** by the rowid value passed as the second argument. Only the row can be
5703 ** changed. ^The database, table and column on which the blob handle is open 5981 ** changed. ^The database, table and column on which the blob handle is open
5704 ** remain the same. Moving an existing blob handle to a new row can be 5982 ** remain the same. Moving an existing blob handle to a new row can be
5705 ** faster than closing the existing handle and opening a new one. 5983 ** faster than closing the existing handle and opening a new one.
5706 ** 5984 **
5707 ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - 5985 ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -
5708 ** it must exist and there must be either a blob or text value stored in 5986 ** it must exist and there must be either a blob or text value stored in
5709 ** the nominated column.)^ ^If the new row is not present in the table, or if 5987 ** the nominated column.)^ ^If the new row is not present in the table, or if
5710 ** it does not contain a blob or text value, or if another error occurs, an 5988 ** it does not contain a blob or text value, or if another error occurs, an
5711 ** SQLite error code is returned and the blob handle is considered aborted. 5989 ** SQLite error code is returned and the blob handle is considered aborted.
5712 ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or 5990 ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or
5713 ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return 5991 ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return
5714 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle 5992 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
5715 ** always returns zero. 5993 ** always returns zero.
5716 ** 5994 **
5717 ** ^This function sets the database handle error code and message. 5995 ** ^This function sets the database handle error code and message.
5718 */ 5996 */
5719 SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); 5997 int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
5720 5998
5721 /* 5999 /*
5722 ** CAPI3REF: Close A BLOB Handle 6000 ** CAPI3REF: Close A BLOB Handle
6001 ** DESTRUCTOR: sqlite3_blob
5723 ** 6002 **
5724 ** ^Closes an open [BLOB handle]. 6003 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
6004 ** unconditionally. Even if this routine returns an error code, the
6005 ** handle is still closed.)^
5725 ** 6006 **
5726 ** ^Closing a BLOB shall cause the current transaction to commit 6007 ** ^If the blob handle being closed was opened for read-write access, and if
5727 ** if there are no other BLOBs, no pending prepared statements, and the 6008 ** the database is in auto-commit mode and there are no other open read-write
5728 ** database connection is in [autocommit mode]. 6009 ** blob handles or active write statements, the current transaction is
5729 ** ^If any writes were made to the BLOB, they might be held in cache 6010 ** committed. ^If an error occurs while committing the transaction, an error
5730 ** until the close operation if they will fit. 6011 ** code is returned and the transaction rolled back.
5731 ** 6012 **
5732 ** ^(Closing the BLOB often forces the changes 6013 ** Calling this function with an argument that is not a NULL pointer or an
5733 ** out to disk and so if any I/O errors occur, they will likely occur 6014 ** open blob handle results in undefined behaviour. ^Calling this routine
5734 ** at the time when the BLOB is closed. Any errors that occur during 6015 ** with a null pointer (such as would be returned by a failed call to
5735 ** closing are reported as a non-zero return value.)^ 6016 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
5736 ** 6017 ** is passed a valid open blob handle, the values returned by the
5737 ** ^(The BLOB is closed unconditionally. Even if this routine returns 6018 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
5738 ** an error code, the BLOB is still closed.)^
5739 **
5740 ** ^Calling this routine with a null pointer (such as would be returned
5741 ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
5742 */ 6019 */
5743 int sqlite3_blob_close(sqlite3_blob *); 6020 int sqlite3_blob_close(sqlite3_blob *);
5744 6021
5745 /* 6022 /*
5746 ** CAPI3REF: Return The Size Of An Open BLOB 6023 ** CAPI3REF: Return The Size Of An Open BLOB
6024 ** METHOD: sqlite3_blob
5747 ** 6025 **
5748 ** ^Returns the size in bytes of the BLOB accessible via the 6026 ** ^Returns the size in bytes of the BLOB accessible via the
5749 ** successfully opened [BLOB handle] in its only argument. ^The 6027 ** successfully opened [BLOB handle] in its only argument. ^The
5750 ** incremental blob I/O routines can only read or overwriting existing 6028 ** incremental blob I/O routines can only read or overwriting existing
5751 ** blob content; they cannot change the size of a blob. 6029 ** blob content; they cannot change the size of a blob.
5752 ** 6030 **
5753 ** This routine only works on a [BLOB handle] which has been created 6031 ** This routine only works on a [BLOB handle] which has been created
5754 ** by a prior successful call to [sqlite3_blob_open()] and which has not 6032 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5755 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in 6033 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5756 ** to this routine results in undefined and probably undesirable behavior. 6034 ** to this routine results in undefined and probably undesirable behavior.
5757 */ 6035 */
5758 int sqlite3_blob_bytes(sqlite3_blob *); 6036 int sqlite3_blob_bytes(sqlite3_blob *);
5759 6037
5760 /* 6038 /*
5761 ** CAPI3REF: Read Data From A BLOB Incrementally 6039 ** CAPI3REF: Read Data From A BLOB Incrementally
6040 ** METHOD: sqlite3_blob
5762 ** 6041 **
5763 ** ^(This function is used to read data from an open [BLOB handle] into a 6042 ** ^(This function is used to read data from an open [BLOB handle] into a
5764 ** caller-supplied buffer. N bytes of data are copied into buffer Z 6043 ** caller-supplied buffer. N bytes of data are copied into buffer Z
5765 ** from the open BLOB, starting at offset iOffset.)^ 6044 ** from the open BLOB, starting at offset iOffset.)^
5766 ** 6045 **
5767 ** ^If offset iOffset is less than N bytes from the end of the BLOB, 6046 ** ^If offset iOffset is less than N bytes from the end of the BLOB,
5768 ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is 6047 ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is
5769 ** less than zero, [SQLITE_ERROR] is returned and no data is read. 6048 ** less than zero, [SQLITE_ERROR] is returned and no data is read.
5770 ** ^The size of the blob (and hence the maximum value of N+iOffset) 6049 ** ^The size of the blob (and hence the maximum value of N+iOffset)
5771 ** can be determined using the [sqlite3_blob_bytes()] interface. 6050 ** can be determined using the [sqlite3_blob_bytes()] interface.
5772 ** 6051 **
5773 ** ^An attempt to read from an expired [BLOB handle] fails with an 6052 ** ^An attempt to read from an expired [BLOB handle] fails with an
5774 ** error code of [SQLITE_ABORT]. 6053 ** error code of [SQLITE_ABORT].
5775 ** 6054 **
5776 ** ^(On success, sqlite3_blob_read() returns SQLITE_OK. 6055 ** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
5777 ** Otherwise, an [error code] or an [extended error code] is returned.)^ 6056 ** Otherwise, an [error code] or an [extended error code] is returned.)^
5778 ** 6057 **
5779 ** This routine only works on a [BLOB handle] which has been created 6058 ** This routine only works on a [BLOB handle] which has been created
5780 ** by a prior successful call to [sqlite3_blob_open()] and which has not 6059 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5781 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in 6060 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5782 ** to this routine results in undefined and probably undesirable behavior. 6061 ** to this routine results in undefined and probably undesirable behavior.
5783 ** 6062 **
5784 ** See also: [sqlite3_blob_write()]. 6063 ** See also: [sqlite3_blob_write()].
5785 */ 6064 */
5786 int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); 6065 int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5787 6066
5788 /* 6067 /*
5789 ** CAPI3REF: Write Data Into A BLOB Incrementally 6068 ** CAPI3REF: Write Data Into A BLOB Incrementally
6069 ** METHOD: sqlite3_blob
5790 ** 6070 **
5791 ** ^This function is used to write data into an open [BLOB handle] from a 6071 ** ^(This function is used to write data into an open [BLOB handle] from a
5792 ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z 6072 ** caller-supplied buffer. N bytes of data are copied from the buffer Z
5793 ** into the open BLOB, starting at offset iOffset. 6073 ** into the open BLOB, starting at offset iOffset.)^
6074 **
6075 ** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
6076 ** Otherwise, an [error code] or an [extended error code] is returned.)^
6077 ** ^Unless SQLITE_MISUSE is returned, this function sets the
6078 ** [database connection] error code and message accessible via
6079 ** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions.
5794 ** 6080 **
5795 ** ^If the [BLOB handle] passed as the first argument was not opened for 6081 ** ^If the [BLOB handle] passed as the first argument was not opened for
5796 ** writing (the flags parameter to [sqlite3_blob_open()] was zero), 6082 ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
5797 ** this function returns [SQLITE_READONLY]. 6083 ** this function returns [SQLITE_READONLY].
5798 ** 6084 **
5799 ** ^This function may only modify the contents of the BLOB; it is 6085 ** This function may only modify the contents of the BLOB; it is
5800 ** not possible to increase the size of a BLOB using this API. 6086 ** not possible to increase the size of a BLOB using this API.
5801 ** ^If offset iOffset is less than N bytes from the end of the BLOB, 6087 ** ^If offset iOffset is less than N bytes from the end of the BLOB,
5802 ** [SQLITE_ERROR] is returned and no data is written. ^If N is 6088 ** [SQLITE_ERROR] is returned and no data is written. The size of the
5803 ** less than zero [SQLITE_ERROR] is returned and no data is written. 6089 ** BLOB (and hence the maximum value of N+iOffset) can be determined
5804 ** The size of the BLOB (and hence the maximum value of N+iOffset) 6090 ** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less
5805 ** can be determined using the [sqlite3_blob_bytes()] interface. 6091 ** than zero [SQLITE_ERROR] is returned and no data is written.
5806 ** 6092 **
5807 ** ^An attempt to write to an expired [BLOB handle] fails with an 6093 ** ^An attempt to write to an expired [BLOB handle] fails with an
5808 ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred 6094 ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
5809 ** before the [BLOB handle] expired are not rolled back by the 6095 ** before the [BLOB handle] expired are not rolled back by the
5810 ** expiration of the handle, though of course those changes might 6096 ** expiration of the handle, though of course those changes might
5811 ** have been overwritten by the statement that expired the BLOB handle 6097 ** have been overwritten by the statement that expired the BLOB handle
5812 ** or by other independent statements. 6098 ** or by other independent statements.
5813 ** 6099 **
5814 ** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
5815 ** Otherwise, an [error code] or an [extended error code] is returned.)^
5816 **
5817 ** This routine only works on a [BLOB handle] which has been created 6100 ** This routine only works on a [BLOB handle] which has been created
5818 ** by a prior successful call to [sqlite3_blob_open()] and which has not 6101 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5819 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in 6102 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5820 ** to this routine results in undefined and probably undesirable behavior. 6103 ** to this routine results in undefined and probably undesirable behavior.
5821 ** 6104 **
5822 ** See also: [sqlite3_blob_read()]. 6105 ** See also: [sqlite3_blob_read()].
5823 */ 6106 */
5824 int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); 6107 int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5825 6108
5826 /* 6109 /*
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5859 /* 6142 /*
5860 ** CAPI3REF: Mutexes 6143 ** CAPI3REF: Mutexes
5861 ** 6144 **
5862 ** The SQLite core uses these routines for thread 6145 ** The SQLite core uses these routines for thread
5863 ** synchronization. Though they are intended for internal 6146 ** synchronization. Though they are intended for internal
5864 ** use by SQLite, code that links against SQLite is 6147 ** use by SQLite, code that links against SQLite is
5865 ** permitted to use any of these routines. 6148 ** permitted to use any of these routines.
5866 ** 6149 **
5867 ** The SQLite source code contains multiple implementations 6150 ** The SQLite source code contains multiple implementations
5868 ** of these mutex routines. An appropriate implementation 6151 ** of these mutex routines. An appropriate implementation
5869 ** is selected automatically at compile-time. ^(The following 6152 ** is selected automatically at compile-time. The following
5870 ** implementations are available in the SQLite core: 6153 ** implementations are available in the SQLite core:
5871 ** 6154 **
5872 ** <ul> 6155 ** <ul>
5873 ** <li> SQLITE_MUTEX_PTHREADS 6156 ** <li> SQLITE_MUTEX_PTHREADS
5874 ** <li> SQLITE_MUTEX_W32 6157 ** <li> SQLITE_MUTEX_W32
5875 ** <li> SQLITE_MUTEX_NOOP 6158 ** <li> SQLITE_MUTEX_NOOP
5876 ** </ul>)^ 6159 ** </ul>
5877 ** 6160 **
5878 ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines 6161 ** The SQLITE_MUTEX_NOOP implementation is a set of routines
5879 ** that does no real locking and is appropriate for use in 6162 ** that does no real locking and is appropriate for use in
5880 ** a single-threaded application. ^The SQLITE_MUTEX_PTHREADS and 6163 ** a single-threaded application. The SQLITE_MUTEX_PTHREADS and
5881 ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix 6164 ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
5882 ** and Windows. 6165 ** and Windows.
5883 ** 6166 **
5884 ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor 6167 ** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5885 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex 6168 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
5886 ** implementation is included with the library. In this case the 6169 ** implementation is included with the library. In this case the
5887 ** application must supply a custom mutex implementation using the 6170 ** application must supply a custom mutex implementation using the
5888 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function 6171 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
5889 ** before calling sqlite3_initialize() or any other public sqlite3_ 6172 ** before calling sqlite3_initialize() or any other public sqlite3_
5890 ** function that calls sqlite3_initialize().)^ 6173 ** function that calls sqlite3_initialize().
5891 ** 6174 **
5892 ** ^The sqlite3_mutex_alloc() routine allocates a new 6175 ** ^The sqlite3_mutex_alloc() routine allocates a new
5893 ** mutex and returns a pointer to it. ^If it returns NULL 6176 ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
5894 ** that means that a mutex could not be allocated. ^SQLite 6177 ** routine returns NULL if it is unable to allocate the requested
5895 ** will unwind its stack and return an error. ^(The argument 6178 ** mutex. The argument to sqlite3_mutex_alloc() must one of these
5896 ** to sqlite3_mutex_alloc() is one of these integer constants: 6179 ** integer constants:
5897 ** 6180 **
5898 ** <ul> 6181 ** <ul>
5899 ** <li> SQLITE_MUTEX_FAST 6182 ** <li> SQLITE_MUTEX_FAST
5900 ** <li> SQLITE_MUTEX_RECURSIVE 6183 ** <li> SQLITE_MUTEX_RECURSIVE
5901 ** <li> SQLITE_MUTEX_STATIC_MASTER 6184 ** <li> SQLITE_MUTEX_STATIC_MASTER
5902 ** <li> SQLITE_MUTEX_STATIC_MEM 6185 ** <li> SQLITE_MUTEX_STATIC_MEM
5903 ** <li> SQLITE_MUTEX_STATIC_OPEN 6186 ** <li> SQLITE_MUTEX_STATIC_OPEN
5904 ** <li> SQLITE_MUTEX_STATIC_PRNG 6187 ** <li> SQLITE_MUTEX_STATIC_PRNG
5905 ** <li> SQLITE_MUTEX_STATIC_LRU 6188 ** <li> SQLITE_MUTEX_STATIC_LRU
5906 ** <li> SQLITE_MUTEX_STATIC_PMEM 6189 ** <li> SQLITE_MUTEX_STATIC_PMEM
5907 ** <li> SQLITE_MUTEX_STATIC_APP1 6190 ** <li> SQLITE_MUTEX_STATIC_APP1
5908 ** <li> SQLITE_MUTEX_STATIC_APP2 6191 ** <li> SQLITE_MUTEX_STATIC_APP2
5909 ** </ul>)^ 6192 ** <li> SQLITE_MUTEX_STATIC_APP3
6193 ** <li> SQLITE_MUTEX_STATIC_VFS1
6194 ** <li> SQLITE_MUTEX_STATIC_VFS2
6195 ** <li> SQLITE_MUTEX_STATIC_VFS3
6196 ** </ul>
5910 ** 6197 **
5911 ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) 6198 ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
5912 ** cause sqlite3_mutex_alloc() to create 6199 ** cause sqlite3_mutex_alloc() to create
5913 ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE 6200 ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
5914 ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. 6201 ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
5915 ** The mutex implementation does not need to make a distinction 6202 ** The mutex implementation does not need to make a distinction
5916 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does 6203 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
5917 ** not want to. ^SQLite will only request a recursive mutex in 6204 ** not want to. SQLite will only request a recursive mutex in
5918 ** cases where it really needs one. ^If a faster non-recursive mutex 6205 ** cases where it really needs one. If a faster non-recursive mutex
5919 ** implementation is available on the host platform, the mutex subsystem 6206 ** implementation is available on the host platform, the mutex subsystem
5920 ** might return such a mutex in response to SQLITE_MUTEX_FAST. 6207 ** might return such a mutex in response to SQLITE_MUTEX_FAST.
5921 ** 6208 **
5922 ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other 6209 ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
5923 ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return 6210 ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
5924 ** a pointer to a static preexisting mutex. ^Six static mutexes are 6211 ** a pointer to a static preexisting mutex. ^Nine static mutexes are
5925 ** used by the current version of SQLite. Future versions of SQLite 6212 ** used by the current version of SQLite. Future versions of SQLite
5926 ** may add additional static mutexes. Static mutexes are for internal 6213 ** may add additional static mutexes. Static mutexes are for internal
5927 ** use by SQLite only. Applications that use SQLite mutexes should 6214 ** use by SQLite only. Applications that use SQLite mutexes should
5928 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or 6215 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
5929 ** SQLITE_MUTEX_RECURSIVE. 6216 ** SQLITE_MUTEX_RECURSIVE.
5930 ** 6217 **
5931 ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST 6218 ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
5932 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() 6219 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
5933 ** returns a different mutex on every call. ^But for the static 6220 ** returns a different mutex on every call. ^For the static
5934 ** mutex types, the same mutex is returned on every call that has 6221 ** mutex types, the same mutex is returned on every call that has
5935 ** the same type number. 6222 ** the same type number.
5936 ** 6223 **
5937 ** ^The sqlite3_mutex_free() routine deallocates a previously 6224 ** ^The sqlite3_mutex_free() routine deallocates a previously
5938 ** allocated dynamic mutex. ^SQLite is careful to deallocate every 6225 ** allocated dynamic mutex. Attempting to deallocate a static
5939 ** dynamic mutex that it allocates. The dynamic mutexes must not be in 6226 ** mutex results in undefined behavior.
5940 ** use when they are deallocated. Attempting to deallocate a static
5941 ** mutex results in undefined behavior. ^SQLite never deallocates
5942 ** a static mutex.
5943 ** 6227 **
5944 ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt 6228 ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
5945 ** to enter a mutex. ^If another thread is already within the mutex, 6229 ** to enter a mutex. ^If another thread is already within the mutex,
5946 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return 6230 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
5947 ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] 6231 ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
5948 ** upon successful entry. ^(Mutexes created using 6232 ** upon successful entry. ^(Mutexes created using
5949 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. 6233 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
5950 ** In such cases the, 6234 ** In such cases, the
5951 ** mutex must be exited an equal number of times before another thread 6235 ** mutex must be exited an equal number of times before another thread
5952 ** can enter.)^ ^(If the same thread tries to enter any other 6236 ** can enter.)^ If the same thread tries to enter any mutex other
5953 ** kind of mutex more than once, the behavior is undefined. 6237 ** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.
5954 ** SQLite will never exhibit
5955 ** such behavior in its own use of mutexes.)^
5956 ** 6238 **
5957 ** ^(Some systems (for example, Windows 95) do not support the operation 6239 ** ^(Some systems (for example, Windows 95) do not support the operation
5958 ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() 6240 ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
5959 ** will always return SQLITE_BUSY. The SQLite core only ever uses 6241 ** will always return SQLITE_BUSY. The SQLite core only ever uses
5960 ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ 6242 ** sqlite3_mutex_try() as an optimization so this is acceptable
6243 ** behavior.)^
5961 ** 6244 **
5962 ** ^The sqlite3_mutex_leave() routine exits a mutex that was 6245 ** ^The sqlite3_mutex_leave() routine exits a mutex that was
5963 ** previously entered by the same thread. ^(The behavior 6246 ** previously entered by the same thread. The behavior
5964 ** is undefined if the mutex is not currently entered by the 6247 ** is undefined if the mutex is not currently entered by the
5965 ** calling thread or is not currently allocated. SQLite will 6248 ** calling thread or is not currently allocated.
5966 ** never do either.)^
5967 ** 6249 **
5968 ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or 6250 ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
5969 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines 6251 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
5970 ** behave as no-ops. 6252 ** behave as no-ops.
5971 ** 6253 **
5972 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. 6254 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
5973 */ 6255 */
5974 sqlite3_mutex *sqlite3_mutex_alloc(int); 6256 sqlite3_mutex *sqlite3_mutex_alloc(int);
5975 void sqlite3_mutex_free(sqlite3_mutex*); 6257 void sqlite3_mutex_free(sqlite3_mutex*);
5976 void sqlite3_mutex_enter(sqlite3_mutex*); 6258 void sqlite3_mutex_enter(sqlite3_mutex*);
5977 int sqlite3_mutex_try(sqlite3_mutex*); 6259 int sqlite3_mutex_try(sqlite3_mutex*);
5978 void sqlite3_mutex_leave(sqlite3_mutex*); 6260 void sqlite3_mutex_leave(sqlite3_mutex*);
5979 6261
5980 /* 6262 /*
5981 ** CAPI3REF: Mutex Methods Object 6263 ** CAPI3REF: Mutex Methods Object
5982 ** 6264 **
5983 ** An instance of this structure defines the low-level routines 6265 ** An instance of this structure defines the low-level routines
5984 ** used to allocate and use mutexes. 6266 ** used to allocate and use mutexes.
5985 ** 6267 **
5986 ** Usually, the default mutex implementations provided by SQLite are 6268 ** Usually, the default mutex implementations provided by SQLite are
5987 ** sufficient, however the user has the option of substituting a custom 6269 ** sufficient, however the application has the option of substituting a custom
5988 ** implementation for specialized deployments or systems for which SQLite 6270 ** implementation for specialized deployments or systems for which SQLite
5989 ** does not provide a suitable implementation. In this case, the user 6271 ** does not provide a suitable implementation. In this case, the application
5990 ** creates and populates an instance of this structure to pass 6272 ** creates and populates an instance of this structure to pass
5991 ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. 6273 ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
5992 ** Additionally, an instance of this structure can be used as an 6274 ** Additionally, an instance of this structure can be used as an
5993 ** output variable when querying the system for the current mutex 6275 ** output variable when querying the system for the current mutex
5994 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. 6276 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
5995 ** 6277 **
5996 ** ^The xMutexInit method defined by this structure is invoked as 6278 ** ^The xMutexInit method defined by this structure is invoked as
5997 ** part of system initialization by the sqlite3_initialize() function. 6279 ** part of system initialization by the sqlite3_initialize() function.
5998 ** ^The xMutexInit routine is called by SQLite exactly once for each 6280 ** ^The xMutexInit routine is called by SQLite exactly once for each
5999 ** effective call to [sqlite3_initialize()]. 6281 ** effective call to [sqlite3_initialize()].
(...skipping 20 matching lines...) Expand all
6020 ** </ul>)^ 6302 ** </ul>)^
6021 ** 6303 **
6022 ** The only difference is that the public sqlite3_XXX functions enumerated 6304 ** The only difference is that the public sqlite3_XXX functions enumerated
6023 ** above silently ignore any invocations that pass a NULL pointer instead 6305 ** above silently ignore any invocations that pass a NULL pointer instead
6024 ** of a valid mutex handle. The implementations of the methods defined 6306 ** of a valid mutex handle. The implementations of the methods defined
6025 ** by this structure are not required to handle this case, the results 6307 ** by this structure are not required to handle this case, the results
6026 ** of passing a NULL pointer instead of a valid mutex handle are undefined 6308 ** of passing a NULL pointer instead of a valid mutex handle are undefined
6027 ** (i.e. it is acceptable to provide an implementation that segfaults if 6309 ** (i.e. it is acceptable to provide an implementation that segfaults if
6028 ** it is passed a NULL pointer). 6310 ** it is passed a NULL pointer).
6029 ** 6311 **
6030 ** The xMutexInit() method must be threadsafe. ^It must be harmless to 6312 ** The xMutexInit() method must be threadsafe. It must be harmless to
6031 ** invoke xMutexInit() multiple times within the same process and without 6313 ** invoke xMutexInit() multiple times within the same process and without
6032 ** intervening calls to xMutexEnd(). Second and subsequent calls to 6314 ** intervening calls to xMutexEnd(). Second and subsequent calls to
6033 ** xMutexInit() must be no-ops. 6315 ** xMutexInit() must be no-ops.
6034 ** 6316 **
6035 ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] 6317 ** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
6036 ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory 6318 ** and its associates). Similarly, xMutexAlloc() must not use SQLite memory
6037 ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite 6319 ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
6038 ** memory allocation for a fast or recursive mutex. 6320 ** memory allocation for a fast or recursive mutex.
6039 ** 6321 **
6040 ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is 6322 ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
6041 ** called, but only if the prior call to xMutexInit returned SQLITE_OK. 6323 ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
6042 ** If xMutexInit fails in any way, it is expected to clean up after itself 6324 ** If xMutexInit fails in any way, it is expected to clean up after itself
6043 ** prior to returning. 6325 ** prior to returning.
6044 */ 6326 */
6045 typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; 6327 typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
6046 struct sqlite3_mutex_methods { 6328 struct sqlite3_mutex_methods {
6047 int (*xMutexInit)(void); 6329 int (*xMutexInit)(void);
6048 int (*xMutexEnd)(void); 6330 int (*xMutexEnd)(void);
6049 sqlite3_mutex *(*xMutexAlloc)(int); 6331 sqlite3_mutex *(*xMutexAlloc)(int);
6050 void (*xMutexFree)(sqlite3_mutex *); 6332 void (*xMutexFree)(sqlite3_mutex *);
6051 void (*xMutexEnter)(sqlite3_mutex *); 6333 void (*xMutexEnter)(sqlite3_mutex *);
6052 int (*xMutexTry)(sqlite3_mutex *); 6334 int (*xMutexTry)(sqlite3_mutex *);
6053 void (*xMutexLeave)(sqlite3_mutex *); 6335 void (*xMutexLeave)(sqlite3_mutex *);
6054 int (*xMutexHeld)(sqlite3_mutex *); 6336 int (*xMutexHeld)(sqlite3_mutex *);
6055 int (*xMutexNotheld)(sqlite3_mutex *); 6337 int (*xMutexNotheld)(sqlite3_mutex *);
6056 }; 6338 };
6057 6339
6058 /* 6340 /*
6059 ** CAPI3REF: Mutex Verification Routines 6341 ** CAPI3REF: Mutex Verification Routines
6060 ** 6342 **
6061 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines 6343 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
6062 ** are intended for use inside assert() statements. ^The SQLite core 6344 ** are intended for use inside assert() statements. The SQLite core
6063 ** never uses these routines except inside an assert() and applications 6345 ** never uses these routines except inside an assert() and applications
6064 ** are advised to follow the lead of the core. ^The SQLite core only 6346 ** are advised to follow the lead of the core. The SQLite core only
6065 ** provides implementations for these routines when it is compiled 6347 ** provides implementations for these routines when it is compiled
6066 ** with the SQLITE_DEBUG flag. ^External mutex implementations 6348 ** with the SQLITE_DEBUG flag. External mutex implementations
6067 ** are only required to provide these routines if SQLITE_DEBUG is 6349 ** are only required to provide these routines if SQLITE_DEBUG is
6068 ** defined and if NDEBUG is not defined. 6350 ** defined and if NDEBUG is not defined.
6069 ** 6351 **
6070 ** ^These routines should return true if the mutex in their argument 6352 ** These routines should return true if the mutex in their argument
6071 ** is held or not held, respectively, by the calling thread. 6353 ** is held or not held, respectively, by the calling thread.
6072 ** 6354 **
6073 ** ^The implementation is not required to provide versions of these 6355 ** The implementation is not required to provide versions of these
6074 ** routines that actually work. If the implementation does not provide working 6356 ** routines that actually work. If the implementation does not provide working
6075 ** versions of these routines, it should at least provide stubs that always 6357 ** versions of these routines, it should at least provide stubs that always
6076 ** return true so that one does not get spurious assertion failures. 6358 ** return true so that one does not get spurious assertion failures.
6077 ** 6359 **
6078 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then 6360 ** If the argument to sqlite3_mutex_held() is a NULL pointer then
6079 ** the routine should return 1. This seems counter-intuitive since 6361 ** the routine should return 1. This seems counter-intuitive since
6080 ** clearly the mutex cannot be held if it does not exist. But 6362 ** clearly the mutex cannot be held if it does not exist. But
6081 ** the reason the mutex does not exist is because the build is not 6363 ** the reason the mutex does not exist is because the build is not
6082 ** using mutexes. And we do not want the assert() containing the 6364 ** using mutexes. And we do not want the assert() containing the
6083 ** call to sqlite3_mutex_held() to fail, so a non-zero return is 6365 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6084 ** the appropriate thing to do. ^The sqlite3_mutex_notheld() 6366 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6085 ** interface should also return 1 when given a NULL pointer. 6367 ** interface should also return 1 when given a NULL pointer.
6086 */ 6368 */
6087 #ifndef NDEBUG 6369 #ifndef NDEBUG
6088 int sqlite3_mutex_held(sqlite3_mutex*); 6370 int sqlite3_mutex_held(sqlite3_mutex*);
6089 int sqlite3_mutex_notheld(sqlite3_mutex*); 6371 int sqlite3_mutex_notheld(sqlite3_mutex*);
6090 #endif 6372 #endif
6091 6373
6092 /* 6374 /*
6093 ** CAPI3REF: Mutex Types 6375 ** CAPI3REF: Mutex Types
6094 ** 6376 **
(...skipping 10 matching lines...) Expand all
6105 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ 6387 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */
6106 #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ 6388 #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */
6107 #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ 6389 #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */
6108 #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ 6390 #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
6109 #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ 6391 #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
6110 #define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ 6392 #define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */
6111 #define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ 6393 #define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */
6112 #define SQLITE_MUTEX_STATIC_APP1 8 /* For use by application */ 6394 #define SQLITE_MUTEX_STATIC_APP1 8 /* For use by application */
6113 #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */ 6395 #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
6114 #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */ 6396 #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
6397 #define SQLITE_MUTEX_STATIC_VFS1 11 /* For use by built-in VFS */
6398 #define SQLITE_MUTEX_STATIC_VFS2 12 /* For use by extension VFS */
6399 #define SQLITE_MUTEX_STATIC_VFS3 13 /* For use by application VFS */
6115 6400
6116 /* 6401 /*
6117 ** CAPI3REF: Retrieve the mutex for a database connection 6402 ** CAPI3REF: Retrieve the mutex for a database connection
6403 ** METHOD: sqlite3
6118 ** 6404 **
6119 ** ^This interface returns a pointer the [sqlite3_mutex] object that 6405 ** ^This interface returns a pointer the [sqlite3_mutex] object that
6120 ** serializes access to the [database connection] given in the argument 6406 ** serializes access to the [database connection] given in the argument
6121 ** when the [threading mode] is Serialized. 6407 ** when the [threading mode] is Serialized.
6122 ** ^If the [threading mode] is Single-thread or Multi-thread then this 6408 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6123 ** routine returns a NULL pointer. 6409 ** routine returns a NULL pointer.
6124 */ 6410 */
6125 sqlite3_mutex *sqlite3_db_mutex(sqlite3*); 6411 sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6126 6412
6127 /* 6413 /*
6128 ** CAPI3REF: Low-Level Control Of Database Files 6414 ** CAPI3REF: Low-Level Control Of Database Files
6415 ** METHOD: sqlite3
6129 ** 6416 **
6130 ** ^The [sqlite3_file_control()] interface makes a direct call to the 6417 ** ^The [sqlite3_file_control()] interface makes a direct call to the
6131 ** xFileControl method for the [sqlite3_io_methods] object associated 6418 ** xFileControl method for the [sqlite3_io_methods] object associated
6132 ** with a particular database identified by the second argument. ^The 6419 ** with a particular database identified by the second argument. ^The
6133 ** name of the database is "main" for the main database or "temp" for the 6420 ** name of the database is "main" for the main database or "temp" for the
6134 ** TEMP database, or the name that appears after the AS keyword for 6421 ** TEMP database, or the name that appears after the AS keyword for
6135 ** databases that are added using the [ATTACH] SQL command. 6422 ** databases that are added using the [ATTACH] SQL command.
6136 ** ^A NULL pointer can be used in place of "main" to refer to the 6423 ** ^A NULL pointer can be used in place of "main" to refer to the
6137 ** main database file. 6424 ** main database file.
6138 ** ^The third and fourth parameters to this routine 6425 ** ^The third and fourth parameters to this routine
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
6202 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 6489 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
6203 #define SQLITE_TESTCTRL_ISKEYWORD 16 6490 #define SQLITE_TESTCTRL_ISKEYWORD 16
6204 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 6491 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17
6205 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 6492 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
6206 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */ 6493 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
6207 #define SQLITE_TESTCTRL_NEVER_CORRUPT 20 6494 #define SQLITE_TESTCTRL_NEVER_CORRUPT 20
6208 #define SQLITE_TESTCTRL_VDBE_COVERAGE 21 6495 #define SQLITE_TESTCTRL_VDBE_COVERAGE 21
6209 #define SQLITE_TESTCTRL_BYTEORDER 22 6496 #define SQLITE_TESTCTRL_BYTEORDER 22
6210 #define SQLITE_TESTCTRL_ISINIT 23 6497 #define SQLITE_TESTCTRL_ISINIT 23
6211 #define SQLITE_TESTCTRL_SORTER_MMAP 24 6498 #define SQLITE_TESTCTRL_SORTER_MMAP 24
6212 #define SQLITE_TESTCTRL_LAST 24 6499 #define SQLITE_TESTCTRL_IMPOSTER 25
6500 #define SQLITE_TESTCTRL_LAST 25
6213 6501
6214 /* 6502 /*
6215 ** CAPI3REF: SQLite Runtime Status 6503 ** CAPI3REF: SQLite Runtime Status
6216 ** 6504 **
6217 ** ^This interface is used to retrieve runtime status information 6505 ** ^These interfaces are used to retrieve runtime status information
6218 ** about the performance of SQLite, and optionally to reset various 6506 ** about the performance of SQLite, and optionally to reset various
6219 ** highwater marks. ^The first argument is an integer code for 6507 ** highwater marks. ^The first argument is an integer code for
6220 ** the specific parameter to measure. ^(Recognized integer codes 6508 ** the specific parameter to measure. ^(Recognized integer codes
6221 ** are of the form [status parameters | SQLITE_STATUS_...].)^ 6509 ** are of the form [status parameters | SQLITE_STATUS_...].)^
6222 ** ^The current value of the parameter is returned into *pCurrent. 6510 ** ^The current value of the parameter is returned into *pCurrent.
6223 ** ^The highest recorded value is returned in *pHighwater. ^If the 6511 ** ^The highest recorded value is returned in *pHighwater. ^If the
6224 ** resetFlag is true, then the highest record value is reset after 6512 ** resetFlag is true, then the highest record value is reset after
6225 ** *pHighwater is written. ^(Some parameters do not record the highest 6513 ** *pHighwater is written. ^(Some parameters do not record the highest
6226 ** value. For those parameters 6514 ** value. For those parameters
6227 ** nothing is written into *pHighwater and the resetFlag is ignored.)^ 6515 ** nothing is written into *pHighwater and the resetFlag is ignored.)^
6228 ** ^(Other parameters record only the highwater mark and not the current 6516 ** ^(Other parameters record only the highwater mark and not the current
6229 ** value. For these latter parameters nothing is written into *pCurrent.)^ 6517 ** value. For these latter parameters nothing is written into *pCurrent.)^
6230 ** 6518 **
6231 ** ^The sqlite3_status() routine returns SQLITE_OK on success and a 6519 ** ^The sqlite3_status() and sqlite3_status64() routines return
6232 ** non-zero [error code] on failure. 6520 ** SQLITE_OK on success and a non-zero [error code] on failure.
6233 ** 6521 **
6234 ** This routine is threadsafe but is not atomic. This routine can be 6522 ** If either the current value or the highwater mark is too large to
6235 ** called while other threads are running the same or different SQLite 6523 ** be represented by a 32-bit integer, then the values returned by
6236 ** interfaces. However the values returned in *pCurrent and 6524 ** sqlite3_status() are undefined.
6237 ** *pHighwater reflect the status of SQLite at different points in time
6238 ** and it is possible that another thread might change the parameter
6239 ** in between the times when *pCurrent and *pHighwater are written.
6240 ** 6525 **
6241 ** See also: [sqlite3_db_status()] 6526 ** See also: [sqlite3_db_status()]
6242 */ 6527 */
6243 int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); 6528 int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6529 int sqlite3_status64(
6530 int op,
6531 sqlite3_int64 *pCurrent,
6532 sqlite3_int64 *pHighwater,
6533 int resetFlag
6534 );
6244 6535
6245 6536
6246 /* 6537 /*
6247 ** CAPI3REF: Status Parameters 6538 ** CAPI3REF: Status Parameters
6248 ** KEYWORDS: {status parameters} 6539 ** KEYWORDS: {status parameters}
6249 ** 6540 **
6250 ** These integer constants designate various run-time status parameters 6541 ** These integer constants designate various run-time status parameters
6251 ** that can be returned by [sqlite3_status()]. 6542 ** that can be returned by [sqlite3_status()].
6252 ** 6543 **
6253 ** <dl> 6544 ** <dl>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6312 ** slots were available. 6603 ** slots were available.
6313 ** </dd>)^ 6604 ** </dd>)^
6314 ** 6605 **
6315 ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt> 6606 ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
6316 ** <dd>This parameter records the largest memory allocation request 6607 ** <dd>This parameter records the largest memory allocation request
6317 ** handed to [scratch memory allocator]. Only the value returned in the 6608 ** handed to [scratch memory allocator]. Only the value returned in the
6318 ** *pHighwater parameter to [sqlite3_status()] is of interest. 6609 ** *pHighwater parameter to [sqlite3_status()] is of interest.
6319 ** The value written into the *pCurrent parameter is undefined.</dd>)^ 6610 ** The value written into the *pCurrent parameter is undefined.</dd>)^
6320 ** 6611 **
6321 ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt> 6612 ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
6322 ** <dd>This parameter records the deepest parser stack. It is only 6613 ** <dd>The *pHighwater parameter records the deepest parser stack.
6614 ** The *pCurrent value is undefined. The *pHighwater value is only
6323 ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^ 6615 ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
6324 ** </dl> 6616 ** </dl>
6325 ** 6617 **
6326 ** New status parameters may be added from time to time. 6618 ** New status parameters may be added from time to time.
6327 */ 6619 */
6328 #define SQLITE_STATUS_MEMORY_USED 0 6620 #define SQLITE_STATUS_MEMORY_USED 0
6329 #define SQLITE_STATUS_PAGECACHE_USED 1 6621 #define SQLITE_STATUS_PAGECACHE_USED 1
6330 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 6622 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2
6331 #define SQLITE_STATUS_SCRATCH_USED 3 6623 #define SQLITE_STATUS_SCRATCH_USED 3
6332 #define SQLITE_STATUS_SCRATCH_OVERFLOW 4 6624 #define SQLITE_STATUS_SCRATCH_OVERFLOW 4
6333 #define SQLITE_STATUS_MALLOC_SIZE 5 6625 #define SQLITE_STATUS_MALLOC_SIZE 5
6334 #define SQLITE_STATUS_PARSER_STACK 6 6626 #define SQLITE_STATUS_PARSER_STACK 6
6335 #define SQLITE_STATUS_PAGECACHE_SIZE 7 6627 #define SQLITE_STATUS_PAGECACHE_SIZE 7
6336 #define SQLITE_STATUS_SCRATCH_SIZE 8 6628 #define SQLITE_STATUS_SCRATCH_SIZE 8
6337 #define SQLITE_STATUS_MALLOC_COUNT 9 6629 #define SQLITE_STATUS_MALLOC_COUNT 9
6338 6630
6339 /* 6631 /*
6340 ** CAPI3REF: Database Connection Status 6632 ** CAPI3REF: Database Connection Status
6633 ** METHOD: sqlite3
6341 ** 6634 **
6342 ** ^This interface is used to retrieve runtime status information 6635 ** ^This interface is used to retrieve runtime status information
6343 ** about a single [database connection]. ^The first argument is the 6636 ** about a single [database connection]. ^The first argument is the
6344 ** database connection object to be interrogated. ^The second argument 6637 ** database connection object to be interrogated. ^The second argument
6345 ** is an integer constant, taken from the set of 6638 ** is an integer constant, taken from the set of
6346 ** [SQLITE_DBSTATUS options], that 6639 ** [SQLITE_DBSTATUS options], that
6347 ** determines the parameter to interrogate. The set of 6640 ** determines the parameter to interrogate. The set of
6348 ** [SQLITE_DBSTATUS options] is likely 6641 ** [SQLITE_DBSTATUS options] is likely
6349 ** to grow in future releases of SQLite. 6642 ** to grow in future releases of SQLite.
6350 ** 6643 **
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
6459 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 6752 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6460 #define SQLITE_DBSTATUS_CACHE_HIT 7 6753 #define SQLITE_DBSTATUS_CACHE_HIT 7
6461 #define SQLITE_DBSTATUS_CACHE_MISS 8 6754 #define SQLITE_DBSTATUS_CACHE_MISS 8
6462 #define SQLITE_DBSTATUS_CACHE_WRITE 9 6755 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6463 #define SQLITE_DBSTATUS_DEFERRED_FKS 10 6756 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
6464 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */ 6757 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6465 6758
6466 6759
6467 /* 6760 /*
6468 ** CAPI3REF: Prepared Statement Status 6761 ** CAPI3REF: Prepared Statement Status
6762 ** METHOD: sqlite3_stmt
6469 ** 6763 **
6470 ** ^(Each prepared statement maintains various 6764 ** ^(Each prepared statement maintains various
6471 ** [SQLITE_STMTSTATUS counters] that measure the number 6765 ** [SQLITE_STMTSTATUS counters] that measure the number
6472 ** of times it has performed specific operations.)^ These counters can 6766 ** of times it has performed specific operations.)^ These counters can
6473 ** be used to monitor the performance characteristics of the prepared 6767 ** be used to monitor the performance characteristics of the prepared
6474 ** statements. For example, if the number of table steps greatly exceeds 6768 ** statements. For example, if the number of table steps greatly exceeds
6475 ** the number of table searches or result rows, that would tend to indicate 6769 ** the number of table searches or result rows, that would tend to indicate
6476 ** that the prepared statement is using a full table scan rather than 6770 ** that the prepared statement is using a full table scan rather than
6477 ** an index. 6771 ** an index.
6478 ** 6772 **
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
6807 ** ^The database name is "main" for the main database, "temp" for the 7101 ** ^The database name is "main" for the main database, "temp" for the
6808 ** temporary database, or the name specified after the AS keyword in 7102 ** temporary database, or the name specified after the AS keyword in
6809 ** an [ATTACH] statement for an attached database. 7103 ** an [ATTACH] statement for an attached database.
6810 ** ^The S and M arguments passed to 7104 ** ^The S and M arguments passed to
6811 ** sqlite3_backup_init(D,N,S,M) identify the [database connection] 7105 ** sqlite3_backup_init(D,N,S,M) identify the [database connection]
6812 ** and database name of the source database, respectively. 7106 ** and database name of the source database, respectively.
6813 ** ^The source and destination [database connections] (parameters S and D) 7107 ** ^The source and destination [database connections] (parameters S and D)
6814 ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with 7108 ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
6815 ** an error. 7109 ** an error.
6816 ** 7110 **
7111 ** ^A call to sqlite3_backup_init() will fail, returning SQLITE_ERROR, if
7112 ** there is already a read or read-write transaction open on the
7113 ** destination database.
7114 **
6817 ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is 7115 ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
6818 ** returned and an error code and error message are stored in the 7116 ** returned and an error code and error message are stored in the
6819 ** destination [database connection] D. 7117 ** destination [database connection] D.
6820 ** ^The error code and message for the failed call to sqlite3_backup_init() 7118 ** ^The error code and message for the failed call to sqlite3_backup_init()
6821 ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or 7119 ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
6822 ** [sqlite3_errmsg16()] functions. 7120 ** [sqlite3_errmsg16()] functions.
6823 ** ^A successful call to sqlite3_backup_init() returns a pointer to an 7121 ** ^A successful call to sqlite3_backup_init() returns a pointer to an
6824 ** [sqlite3_backup] object. 7122 ** [sqlite3_backup] object.
6825 ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and 7123 ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
6826 ** sqlite3_backup_finish() functions to perform the specified backup 7124 ** sqlite3_backup_finish() functions to perform the specified backup
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
6899 ** sqlite3_backup_step() errors occurred, regardless or whether or not 7197 ** sqlite3_backup_step() errors occurred, regardless or whether or not
6900 ** sqlite3_backup_step() completed. 7198 ** sqlite3_backup_step() completed.
6901 ** ^If an out-of-memory condition or IO error occurred during any prior 7199 ** ^If an out-of-memory condition or IO error occurred during any prior
6902 ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then 7200 ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
6903 ** sqlite3_backup_finish() returns the corresponding [error code]. 7201 ** sqlite3_backup_finish() returns the corresponding [error code].
6904 ** 7202 **
6905 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() 7203 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
6906 ** is not a permanent error and does not affect the return value of 7204 ** is not a permanent error and does not affect the return value of
6907 ** sqlite3_backup_finish(). 7205 ** sqlite3_backup_finish().
6908 ** 7206 **
6909 ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] 7207 ** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
6910 ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b> 7208 ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
6911 ** 7209 **
6912 ** ^Each call to sqlite3_backup_step() sets two values inside 7210 ** ^The sqlite3_backup_remaining() routine returns the number of pages still
6913 ** the [sqlite3_backup] object: the number of pages still to be backed 7211 ** to be backed up at the conclusion of the most recent sqlite3_backup_step().
6914 ** up and the total number of pages in the source database file. 7212 ** ^The sqlite3_backup_pagecount() routine returns the total number of pages
6915 ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces 7213 ** in the source database at the conclusion of the most recent
6916 ** retrieve these two values, respectively. 7214 ** sqlite3_backup_step().
6917 ** 7215 ** ^(The values returned by these functions are only updated by
6918 ** ^The values returned by these functions are only updated by 7216 ** sqlite3_backup_step(). If the source database is modified in a way that
6919 ** sqlite3_backup_step(). ^If the source database is modified during a backup 7217 ** changes the size of the source database or the number of pages remaining,
6920 ** operation, then the values are not updated to account for any extra 7218 ** those changes are not reflected in the output of sqlite3_backup_pagecount()
6921 ** pages that need to be updated or the size of the source database file 7219 ** and sqlite3_backup_remaining() until after the next
6922 ** changing. 7220 ** sqlite3_backup_step().)^
6923 ** 7221 **
6924 ** <b>Concurrent Usage of Database Handles</b> 7222 ** <b>Concurrent Usage of Database Handles</b>
6925 ** 7223 **
6926 ** ^The source [database connection] may be used by the application for other 7224 ** ^The source [database connection] may be used by the application for other
6927 ** purposes while a backup operation is underway or being initialized. 7225 ** purposes while a backup operation is underway or being initialized.
6928 ** ^If SQLite is compiled and configured to support threadsafe database 7226 ** ^If SQLite is compiled and configured to support threadsafe database
6929 ** connections, then the source database connection may be used concurrently 7227 ** connections, then the source database connection may be used concurrently
6930 ** from within other threads. 7228 ** from within other threads.
6931 ** 7229 **
6932 ** However, the application must guarantee that the destination 7230 ** However, the application must guarantee that the destination
(...skipping 25 matching lines...) Expand all
6958 sqlite3 *pSource, /* Source database handle */ 7256 sqlite3 *pSource, /* Source database handle */
6959 const char *zSourceName /* Source database name */ 7257 const char *zSourceName /* Source database name */
6960 ); 7258 );
6961 int sqlite3_backup_step(sqlite3_backup *p, int nPage); 7259 int sqlite3_backup_step(sqlite3_backup *p, int nPage);
6962 int sqlite3_backup_finish(sqlite3_backup *p); 7260 int sqlite3_backup_finish(sqlite3_backup *p);
6963 int sqlite3_backup_remaining(sqlite3_backup *p); 7261 int sqlite3_backup_remaining(sqlite3_backup *p);
6964 int sqlite3_backup_pagecount(sqlite3_backup *p); 7262 int sqlite3_backup_pagecount(sqlite3_backup *p);
6965 7263
6966 /* 7264 /*
6967 ** CAPI3REF: Unlock Notification 7265 ** CAPI3REF: Unlock Notification
7266 ** METHOD: sqlite3
6968 ** 7267 **
6969 ** ^When running in shared-cache mode, a database operation may fail with 7268 ** ^When running in shared-cache mode, a database operation may fail with
6970 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or 7269 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
6971 ** individual tables within the shared-cache cannot be obtained. See 7270 ** individual tables within the shared-cache cannot be obtained. See
6972 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. 7271 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
6973 ** ^This API may be used to register a callback that SQLite will invoke 7272 ** ^This API may be used to register a callback that SQLite will invoke
6974 ** when the connection currently holding the required lock relinquishes it. 7273 ** when the connection currently holding the required lock relinquishes it.
6975 ** ^This API is only available if the library was compiled with the 7274 ** ^This API is only available if the library was compiled with the
6976 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. 7275 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
6977 ** 7276 **
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
7091 ** and extensions to compare the contents of two buffers containing UTF-8 7390 ** and extensions to compare the contents of two buffers containing UTF-8
7092 ** strings in a case-independent fashion, using the same definition of "case 7391 ** strings in a case-independent fashion, using the same definition of "case
7093 ** independence" that SQLite uses internally when comparing identifiers. 7392 ** independence" that SQLite uses internally when comparing identifiers.
7094 */ 7393 */
7095 int sqlite3_stricmp(const char *, const char *); 7394 int sqlite3_stricmp(const char *, const char *);
7096 int sqlite3_strnicmp(const char *, const char *, int); 7395 int sqlite3_strnicmp(const char *, const char *, int);
7097 7396
7098 /* 7397 /*
7099 ** CAPI3REF: String Globbing 7398 ** CAPI3REF: String Globbing
7100 * 7399 *
7101 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches 7400 ** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if
7102 ** the glob pattern P, and it returns non-zero if string X does not match 7401 ** string X matches the [GLOB] pattern P.
7103 ** the glob pattern P. ^The definition of glob pattern matching used in 7402 ** ^The definition of [GLOB] pattern matching used in
7104 ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the 7403 ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the
7105 ** SQL dialect used by SQLite. ^The sqlite3_strglob(P,X) function is case 7404 ** SQL dialect understood by SQLite. ^The [sqlite3_strglob(P,X)] function
7106 ** sensitive. 7405 ** is case sensitive.
7107 ** 7406 **
7108 ** Note that this routine returns zero on a match and non-zero if the strings 7407 ** Note that this routine returns zero on a match and non-zero if the strings
7109 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. 7408 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7409 **
7410 ** See also: [sqlite3_strlike()].
7110 */ 7411 */
7111 int sqlite3_strglob(const char *zGlob, const char *zStr); 7412 int sqlite3_strglob(const char *zGlob, const char *zStr);
7112 7413
7414 /* Begin recover virtual table patch for Chromium */
7415 /* Our patches don't conform to SQLite's amalgamation processing. Hack it. */
7416 #ifndef CHROMIUM_SQLITE_API
7417 #define CHROMIUM_SQLITE_API SQLITE_API
7418 #endif
7419 /*
7420 ** Call to initialize the recover virtual-table modules (see recover.c).
7421 **
7422 ** This could be loaded by default in main.c, but that would make the
7423 ** virtual table available to Web SQL. Breaking it out allows only
7424 ** selected users to enable it (currently sql/recovery.cc).
7425 */
7426 CHROMIUM_SQLITE_API
7427 int recoverVtableInit(sqlite3 *db);
7428 /* End recover virtual table patch for Chromium */
7429
7430 /* Begin WebDatabase patch for Chromium */
7431 /* Expose some SQLite internals for the WebDatabase vfs.
7432 ** DO NOT EXTEND THE USE OF THIS.
7433 */
7434 #ifndef CHROMIUM_SQLITE_API
7435 #define CHROMIUM_SQLITE_API SQLITE_API
7436 #endif
7437 #if defined(CHROMIUM_SQLITE_INTERNALS)
7438 #ifdef _WIN32
7439 CHROMIUM_SQLITE_API
7440 void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE han dle);
7441 #else /* _WIN32 */
7442 CHROMIUM_SQLITE_API
7443 int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* pVfs,
7444 int fd,
7445 sqlite3_file* pFile,
7446 const char* zPath,
7447 int noLock,
7448 int flags);
7449 #endif /* _WIN32 */
7450 #endif /* CHROMIUM_SQLITE_INTERNALS */
7451 /* End WebDatabase patch for Chromium */
7452
7453 /*
7454 ** CAPI3REF: String LIKE Matching
7455 *
7456 ** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if
7457 ** string X matches the [LIKE] pattern P with escape character E.
7458 ** ^The definition of [LIKE] pattern matching used in
7459 ** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E"
7460 ** operator in the SQL dialect understood by SQLite. ^For "X LIKE P" without
7461 ** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.
7462 ** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case
7463 ** insensitive - equivalent upper and lower case ASCII characters match
7464 ** one another.
7465 **
7466 ** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though
7467 ** only ASCII characters are case folded.
7468 **
7469 ** Note that this routine returns zero on a match and non-zero if the strings
7470 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7471 **
7472 ** See also: [sqlite3_strglob()].
7473 */
7474 int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
7475
7113 /* 7476 /*
7114 ** CAPI3REF: Error Logging Interface 7477 ** CAPI3REF: Error Logging Interface
7115 ** 7478 **
7116 ** ^The [sqlite3_log()] interface writes a message into the [error log] 7479 ** ^The [sqlite3_log()] interface writes a message into the [error log]
7117 ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. 7480 ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].
7118 ** ^If logging is enabled, the zFormat string and subsequent arguments are 7481 ** ^If logging is enabled, the zFormat string and subsequent arguments are
7119 ** used with [sqlite3_snprintf()] to generate the final output string. 7482 ** used with [sqlite3_snprintf()] to generate the final output string.
7120 ** 7483 **
7121 ** The sqlite3_log() interface is intended for use by extensions such as 7484 ** The sqlite3_log() interface is intended for use by extensions such as
7122 ** virtual tables, collating functions, and SQL functions. While there is 7485 ** virtual tables, collating functions, and SQL functions. While there is
7123 ** nothing to prevent an application from calling sqlite3_log(), doing so 7486 ** nothing to prevent an application from calling sqlite3_log(), doing so
7124 ** is considered bad form. 7487 ** is considered bad form.
7125 ** 7488 **
7126 ** The zFormat string must not be NULL. 7489 ** The zFormat string must not be NULL.
7127 ** 7490 **
7128 ** To avoid deadlocks and other threading problems, the sqlite3_log() routine 7491 ** To avoid deadlocks and other threading problems, the sqlite3_log() routine
7129 ** will not use dynamically allocated memory. The log message is stored in 7492 ** will not use dynamically allocated memory. The log message is stored in
7130 ** a fixed-length buffer on the stack. If the log message is longer than 7493 ** a fixed-length buffer on the stack. If the log message is longer than
7131 ** a few hundred characters, it will be truncated to the length of the 7494 ** a few hundred characters, it will be truncated to the length of the
7132 ** buffer. 7495 ** buffer.
7133 */ 7496 */
7134 void sqlite3_log(int iErrCode, const char *zFormat, ...); 7497 void sqlite3_log(int iErrCode, const char *zFormat, ...);
7135 7498
7136 /* 7499 /*
7137 ** CAPI3REF: Write-Ahead Log Commit Hook 7500 ** CAPI3REF: Write-Ahead Log Commit Hook
7501 ** METHOD: sqlite3
7138 ** 7502 **
7139 ** ^The [sqlite3_wal_hook()] function is used to register a callback that 7503 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
7140 ** will be invoked each time a database connection commits data to a 7504 ** is invoked each time data is committed to a database in wal mode.
7141 ** [write-ahead log] (i.e. whenever a transaction is committed in
7142 ** [journal_mode | journal_mode=WAL mode]).
7143 ** 7505 **
7144 ** ^The callback is invoked by SQLite after the commit has taken place and 7506 ** ^(The callback is invoked by SQLite after the commit has taken place and
7145 ** the associated write-lock on the database released, so the implementation 7507 ** the associated write-lock on the database released)^, so the implementation
7146 ** may read, write or [checkpoint] the database as required. 7508 ** may read, write or [checkpoint] the database as required.
7147 ** 7509 **
7148 ** ^The first parameter passed to the callback function when it is invoked 7510 ** ^The first parameter passed to the callback function when it is invoked
7149 ** is a copy of the third parameter passed to sqlite3_wal_hook() when 7511 ** is a copy of the third parameter passed to sqlite3_wal_hook() when
7150 ** registering the callback. ^The second is a copy of the database handle. 7512 ** registering the callback. ^The second is a copy of the database handle.
7151 ** ^The third parameter is the name of the database that was written to - 7513 ** ^The third parameter is the name of the database that was written to -
7152 ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter 7514 ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
7153 ** is the number of pages currently in the write-ahead log file, 7515 ** is the number of pages currently in the write-ahead log file,
7154 ** including those that were just committed. 7516 ** including those that were just committed.
7155 ** 7517 **
(...skipping 13 matching lines...) Expand all
7169 ** those overwrite any prior [sqlite3_wal_hook()] settings. 7531 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7170 */ 7532 */
7171 void *sqlite3_wal_hook( 7533 void *sqlite3_wal_hook(
7172 sqlite3*, 7534 sqlite3*,
7173 int(*)(void *,sqlite3*,const char*,int), 7535 int(*)(void *,sqlite3*,const char*,int),
7174 void* 7536 void*
7175 ); 7537 );
7176 7538
7177 /* 7539 /*
7178 ** CAPI3REF: Configure an auto-checkpoint 7540 ** CAPI3REF: Configure an auto-checkpoint
7541 ** METHOD: sqlite3
7179 ** 7542 **
7180 ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around 7543 ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
7181 ** [sqlite3_wal_hook()] that causes any database on [database connection] D 7544 ** [sqlite3_wal_hook()] that causes any database on [database connection] D
7182 ** to automatically [checkpoint] 7545 ** to automatically [checkpoint]
7183 ** after committing a transaction if there are N or 7546 ** after committing a transaction if there are N or
7184 ** more frames in the [write-ahead log] file. ^Passing zero or 7547 ** more frames in the [write-ahead log] file. ^Passing zero or
7185 ** a negative value as the nFrame parameter disables automatic 7548 ** a negative value as the nFrame parameter disables automatic
7186 ** checkpoints entirely. 7549 ** checkpoints entirely.
7187 ** 7550 **
7188 ** ^The callback registered by this function replaces any existing callback 7551 ** ^The callback registered by this function replaces any existing callback
(...skipping 10 matching lines...) Expand all
7199 ** ^Every new [database connection] defaults to having the auto-checkpoint 7562 ** ^Every new [database connection] defaults to having the auto-checkpoint
7200 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] 7563 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7201 ** pages. The use of this interface 7564 ** pages. The use of this interface
7202 ** is only necessary if the default setting is found to be suboptimal 7565 ** is only necessary if the default setting is found to be suboptimal
7203 ** for a particular application. 7566 ** for a particular application.
7204 */ 7567 */
7205 int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); 7568 int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7206 7569
7207 /* 7570 /*
7208 ** CAPI3REF: Checkpoint a database 7571 ** CAPI3REF: Checkpoint a database
7572 ** METHOD: sqlite3
7209 ** 7573 **
7210 ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X 7574 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
7211 ** on [database connection] D to be [checkpointed]. ^If X is NULL or an 7575 ** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
7212 ** empty string, then a checkpoint is run on all databases of
7213 ** connection D. ^If the database connection D is not in
7214 ** [WAL | write-ahead log mode] then this interface is a harmless no-op.
7215 ** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
7216 ** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
7217 ** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
7218 ** or RESET checkpoint.
7219 ** 7576 **
7220 ** ^The [wal_checkpoint pragma] can be used to invoke this interface 7577 ** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
7221 ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the 7578 ** [write-ahead log] for database X on [database connection] D to be
7222 ** [wal_autocheckpoint pragma] can be used to cause this interface to be 7579 ** transferred into the database file and for the write-ahead log to
7223 ** run whenever the WAL reaches a certain size threshold. 7580 ** be reset. See the [checkpointing] documentation for addition
7581 ** information.
7224 ** 7582 **
7225 ** See also: [sqlite3_wal_checkpoint_v2()] 7583 ** This interface used to be the only way to cause a checkpoint to
7584 ** occur. But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
7585 ** interface was added. This interface is retained for backwards
7586 ** compatibility and as a convenience for applications that need to manually
7587 ** start a callback but which do not need the full power (and corresponding
7588 ** complication) of [sqlite3_wal_checkpoint_v2()].
7226 */ 7589 */
7227 int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); 7590 int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7228 7591
7229 /* 7592 /*
7230 ** CAPI3REF: Checkpoint a database 7593 ** CAPI3REF: Checkpoint a database
7594 ** METHOD: sqlite3
7231 ** 7595 **
7232 ** Run a checkpoint operation on WAL database zDb attached to database 7596 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
7233 ** handle db. The specific operation is determined by the value of the 7597 ** operation on database X of [database connection] D in mode M. Status
7234 ** eMode parameter: 7598 ** information is written back into integers pointed to by L and C.)^
7599 ** ^(The M parameter must be a valid [checkpoint mode]:)^
7235 ** 7600 **
7236 ** <dl> 7601 ** <dl>
7237 ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd> 7602 ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
7238 ** Checkpoint as many frames as possible without waiting for any database 7603 ** ^Checkpoint as many frames as possible without waiting for any database
7239 ** readers or writers to finish. Sync the db file if all frames in the log 7604 ** readers or writers to finish, then sync the database file if all frames
7240 ** are checkpointed. This mode is the same as calling 7605 ** in the log were checkpointed. ^The [busy-handler callback]
7241 ** sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback] 7606 ** is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.
7242 ** is never invoked. 7607 ** ^On the other hand, passive mode might leave the checkpoint unfinished
7608 ** if there are concurrent readers or writers.
7243 ** 7609 **
7244 ** <dt>SQLITE_CHECKPOINT_FULL<dd> 7610 ** <dt>SQLITE_CHECKPOINT_FULL<dd>
7245 ** This mode blocks (it invokes the 7611 ** ^This mode blocks (it invokes the
7246 ** [sqlite3_busy_handler|busy-handler callback]) until there is no 7612 ** [sqlite3_busy_handler|busy-handler callback]) until there is no
7247 ** database writer and all readers are reading from the most recent database 7613 ** database writer and all readers are reading from the most recent database
7248 ** snapshot. It then checkpoints all frames in the log file and syncs the 7614 ** snapshot. ^It then checkpoints all frames in the log file and syncs the
7249 ** database file. This call blocks database writers while it is running, 7615 ** database file. ^This mode blocks new database writers while it is pending,
7250 ** but not database readers. 7616 ** but new database readers are allowed to continue unimpeded.
7251 ** 7617 **
7252 ** <dt>SQLITE_CHECKPOINT_RESTART<dd> 7618 ** <dt>SQLITE_CHECKPOINT_RESTART<dd>
7253 ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after 7619 ** ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
7254 ** checkpointing the log file it blocks (calls the 7620 ** that after checkpointing the log file it blocks (calls the
7255 ** [sqlite3_busy_handler|busy-handler callback]) 7621 ** [busy-handler callback])
7256 ** until all readers are reading from the database file only. This ensures 7622 ** until all readers are reading from the database file only. ^This ensures
7257 ** that the next client to write to the database file restarts the log file 7623 ** that the next writer will restart the log file from the beginning.
7258 ** from the beginning. This call blocks database writers while it is running, 7624 ** ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
7259 ** but not database readers. 7625 ** database writer attempts while it is pending, but does not impede readers.
7626 **
7627 ** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
7628 ** ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
7629 ** addition that it also truncates the log file to zero bytes just prior
7630 ** to a successful return.
7260 ** </dl> 7631 ** </dl>
7261 ** 7632 **
7262 ** If pnLog is not NULL, then *pnLog is set to the total number of frames in 7633 ** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
7263 ** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to 7634 ** the log file or to -1 if the checkpoint could not run because
7264 ** the total number of checkpointed frames (including any that were already 7635 ** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
7265 ** checkpointed when this function is called). *pnLog and *pnCkpt may be 7636 ** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
7266 ** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK. 7637 ** log file (including any that were already checkpointed before the function
7267 ** If no values are available because of an error, they are both set to -1 7638 ** was called) or to -1 if the checkpoint could not run due to an error or
7268 ** before returning to communicate this to the caller. 7639 ** because the database is not in WAL mode. ^Note that upon successful
7640 ** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
7641 ** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
7269 ** 7642 **
7270 ** All calls obtain an exclusive "checkpoint" lock on the database file. If 7643 ** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
7271 ** any other process is running a checkpoint operation at the same time, the 7644 ** any other process is running a checkpoint operation at the same time, the
7272 ** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a 7645 ** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a
7273 ** busy-handler configured, it will not be invoked in this case. 7646 ** busy-handler configured, it will not be invoked in this case.
7274 ** 7647 **
7275 ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive 7648 ** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the
7276 ** "writer" lock on the database file. If the writer lock cannot be obtained 7649 ** exclusive "writer" lock on the database file. ^If the writer lock cannot be
7277 ** immediately, and a busy-handler is configured, it is invoked and the writer 7650 ** obtained immediately, and a busy-handler is configured, it is invoked and
7278 ** lock retried until either the busy-handler returns 0 or the lock is 7651 ** the writer lock retried until either the busy-handler returns 0 or the lock
7279 ** successfully obtained. The busy-handler is also invoked while waiting for 7652 ** is successfully obtained. ^The busy-handler is also invoked while waiting for
7280 ** database readers as described above. If the busy-handler returns 0 before 7653 ** database readers as described above. ^If the busy-handler returns 0 before
7281 ** the writer lock is obtained or while waiting for database readers, the 7654 ** the writer lock is obtained or while waiting for database readers, the
7282 ** checkpoint operation proceeds from that point in the same way as 7655 ** checkpoint operation proceeds from that point in the same way as
7283 ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible 7656 ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
7284 ** without blocking any further. SQLITE_BUSY is returned in this case. 7657 ** without blocking any further. ^SQLITE_BUSY is returned in this case.
7285 ** 7658 **
7286 ** If parameter zDb is NULL or points to a zero length string, then the 7659 ** ^If parameter zDb is NULL or points to a zero length string, then the
7287 ** specified operation is attempted on all WAL databases. In this case the 7660 ** specified operation is attempted on all WAL databases [attached] to
7288 ** values written to output parameters *pnLog and *pnCkpt are undefined. If 7661 ** [database connection] db. In this case the
7662 ** values written to output parameters *pnLog and *pnCkpt are undefined. ^If
7289 ** an SQLITE_BUSY error is encountered when processing one or more of the 7663 ** an SQLITE_BUSY error is encountered when processing one or more of the
7290 ** attached WAL databases, the operation is still attempted on any remaining 7664 ** attached WAL databases, the operation is still attempted on any remaining
7291 ** attached databases and SQLITE_BUSY is returned to the caller. If any other 7665 ** attached databases and SQLITE_BUSY is returned at the end. ^If any other
7292 ** error occurs while processing an attached database, processing is abandoned 7666 ** error occurs while processing an attached database, processing is abandoned
7293 ** and the error code returned to the caller immediately. If no error 7667 ** and the error code is returned to the caller immediately. ^If no error
7294 ** (SQLITE_BUSY or otherwise) is encountered while processing the attached 7668 ** (SQLITE_BUSY or otherwise) is encountered while processing the attached
7295 ** databases, SQLITE_OK is returned. 7669 ** databases, SQLITE_OK is returned.
7296 ** 7670 **
7297 ** If database zDb is the name of an attached database that is not in WAL 7671 ** ^If database zDb is the name of an attached database that is not in WAL
7298 ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If 7672 ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
7299 ** zDb is not NULL (or a zero length string) and is not the name of any 7673 ** zDb is not NULL (or a zero length string) and is not the name of any
7300 ** attached database, SQLITE_ERROR is returned to the caller. 7674 ** attached database, SQLITE_ERROR is returned to the caller.
7675 **
7676 ** ^Unless it returns SQLITE_MISUSE,
7677 ** the sqlite3_wal_checkpoint_v2() interface
7678 ** sets the error information that is queried by
7679 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7680 **
7681 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7682 ** from SQL.
7301 */ 7683 */
7302 int sqlite3_wal_checkpoint_v2( 7684 int sqlite3_wal_checkpoint_v2(
7303 sqlite3 *db, /* Database handle */ 7685 sqlite3 *db, /* Database handle */
7304 const char *zDb, /* Name of attached database (or NULL) */ 7686 const char *zDb, /* Name of attached database (or NULL) */
7305 int eMode, /* SQLITE_CHECKPOINT_* value */ 7687 int eMode, /* SQLITE_CHECKPOINT_* value */
7306 int *pnLog, /* OUT: Size of WAL log in frames */ 7688 int *pnLog, /* OUT: Size of WAL log in frames */
7307 int *pnCkpt /* OUT: Total number of frames checkpointed */ 7689 int *pnCkpt /* OUT: Total number of frames checkpointed */
7308 ); 7690 );
7309 7691
7310 /* 7692 /*
7311 ** CAPI3REF: Checkpoint operation parameters 7693 ** CAPI3REF: Checkpoint Mode Values
7694 ** KEYWORDS: {checkpoint mode}
7312 ** 7695 **
7313 ** These constants can be used as the 3rd parameter to 7696 ** These constants define all valid values for the "checkpoint mode" passed
7314 ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()] 7697 ** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
7315 ** documentation for additional information about the meaning and use of 7698 ** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
7316 ** each of these values. 7699 ** meaning of each of these checkpoint modes.
7317 */ 7700 */
7318 #define SQLITE_CHECKPOINT_PASSIVE 0 7701 #define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
7319 #define SQLITE_CHECKPOINT_FULL 1 7702 #define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
7320 #define SQLITE_CHECKPOINT_RESTART 2 7703 #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
7704 #define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
7321 7705
7322 /* 7706 /*
7323 ** CAPI3REF: Virtual Table Interface Configuration 7707 ** CAPI3REF: Virtual Table Interface Configuration
7324 ** 7708 **
7325 ** This function may be called by either the [xConnect] or [xCreate] method 7709 ** This function may be called by either the [xConnect] or [xCreate] method
7326 ** of a [virtual table] implementation to configure 7710 ** of a [virtual table] implementation to configure
7327 ** various facets of the virtual table interface. 7711 ** various facets of the virtual table interface.
7328 ** 7712 **
7329 ** If this interface is invoked outside the context of an xConnect or 7713 ** If this interface is invoked outside the context of an xConnect or
7330 ** xCreate virtual table method then the behavior is undefined. 7714 ** xCreate virtual table method then the behavior is undefined.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7399 ** Note that the [SQLITE_IGNORE] constant is also used as a potential 7783 ** Note that the [SQLITE_IGNORE] constant is also used as a potential
7400 ** return value from the [sqlite3_set_authorizer()] callback and that 7784 ** return value from the [sqlite3_set_authorizer()] callback and that
7401 ** [SQLITE_ABORT] is also a [result code]. 7785 ** [SQLITE_ABORT] is also a [result code].
7402 */ 7786 */
7403 #define SQLITE_ROLLBACK 1 7787 #define SQLITE_ROLLBACK 1
7404 /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ 7788 /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */
7405 #define SQLITE_FAIL 3 7789 #define SQLITE_FAIL 3
7406 /* #define SQLITE_ABORT 4 // Also an error code */ 7790 /* #define SQLITE_ABORT 4 // Also an error code */
7407 #define SQLITE_REPLACE 5 7791 #define SQLITE_REPLACE 5
7408 7792
7409 7793 /*
7410 7794 ** CAPI3REF: Prepared Statement Scan Status Opcodes
7411 /* Begin recover virtual table patch for Chromium */ 7795 ** KEYWORDS: {scanstatus options}
7412 /* Our patches don't conform to SQLite's amalgamation processing. Hack it. */ 7796 **
7413 #ifndef CHROMIUM_SQLITE_API 7797 ** The following constants can be used for the T parameter to the
7414 #define CHROMIUM_SQLITE_API SQLITE_API 7798 ** [sqlite3_stmt_scanstatus(S,X,T,V)] interface. Each constant designates a
7415 #endif 7799 ** different metric for sqlite3_stmt_scanstatus() to return.
7416 /* 7800 **
7417 ** Call to initialize the recover virtual-table modules (see recover.c). 7801 ** When the value returned to V is a string, space to hold that string is
7418 ** 7802 ** managed by the prepared statement S and will be automatically freed when
7419 ** This could be loaded by default in main.c, but that would make the 7803 ** S is finalized.
7420 ** virtual table available to Web SQL. Breaking it out allows only 7804 **
7421 ** selected users to enable it (currently sql/recovery.cc). 7805 ** <dl>
7422 */ 7806 ** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
7423 CHROMIUM_SQLITE_API 7807 ** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
7424 int recoverVtableInit(sqlite3 *db); 7808 ** set to the total number of times that the X-th loop has run.</dd>
7425 /* End recover virtual table patch for Chromium */ 7809 **
7426 7810 ** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
7427 /* Begin WebDatabase patch for Chromium */ 7811 ** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
7428 /* Expose some SQLite internals for the WebDatabase vfs. 7812 ** to the total number of rows examined by all iterations of the X-th loop.</dd>
7429 ** DO NOT EXTEND THE USE OF THIS. 7813 **
7430 */ 7814 ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
7431 #ifndef CHROMIUM_SQLITE_API 7815 ** <dd>^The "double" variable pointed to by the T parameter will be set to the
7432 #define CHROMIUM_SQLITE_API SQLITE_API 7816 ** query planner's estimate for the average number of rows output from each
7433 #endif 7817 ** iteration of the X-th loop. If the query planner's estimates was accurate,
7434 #if defined(CHROMIUM_SQLITE_INTERNALS) 7818 ** then this value will approximate the quotient NVISIT/NLOOP and the
7435 #ifdef _WIN32 7819 ** product of this value for all prior loops with the same SELECTID will
7436 CHROMIUM_SQLITE_API 7820 ** be the NLOOP value for the current loop.
7437 void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE han dle); 7821 **
7438 #else /* _WIN32 */ 7822 ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
7439 CHROMIUM_SQLITE_API 7823 ** <dd>^The "const char *" variable pointed to by the T parameter will be set
7440 int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* pVfs, 7824 ** to a zero-terminated UTF-8 string containing the name of the index or table
7441 int fd, 7825 ** used for the X-th loop.
7442 sqlite3_file* pFile, 7826 **
7443 const char* zPath, 7827 ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
7444 int noLock, 7828 ** <dd>^The "const char *" variable pointed to by the T parameter will be set
7445 int flags); 7829 ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
7446 #endif /* _WIN32 */ 7830 ** description for the X-th loop.
7447 #endif /* CHROMIUM_SQLITE_INTERNALS */ 7831 **
7448 /* End WebDatabase patch for Chromium */ 7832 ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
7833 ** <dd>^The "int" variable pointed to by the T parameter will be set to the
7834 ** "select-id" for the X-th loop. The select-id identifies which query or
7835 ** subquery the loop is part of. The main query has a select-id of zero.
7836 ** The select-id is the same value as is output in the first column
7837 ** of an [EXPLAIN QUERY PLAN] query.
7838 ** </dl>
7839 */
7840 #define SQLITE_SCANSTAT_NLOOP 0
7841 #define SQLITE_SCANSTAT_NVISIT 1
7842 #define SQLITE_SCANSTAT_EST 2
7843 #define SQLITE_SCANSTAT_NAME 3
7844 #define SQLITE_SCANSTAT_EXPLAIN 4
7845 #define SQLITE_SCANSTAT_SELECTID 5
7846
7847 /*
7848 ** CAPI3REF: Prepared Statement Scan Status
7849 ** METHOD: sqlite3_stmt
7850 **
7851 ** This interface returns information about the predicted and measured
7852 ** performance for pStmt. Advanced applications can use this
7853 ** interface to compare the predicted and the measured performance and
7854 ** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
7855 **
7856 ** Since this interface is expected to be rarely used, it is only
7857 ** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]
7858 ** compile-time option.
7859 **
7860 ** The "iScanStatusOp" parameter determines which status information to return.
7861 ** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
7862 ** of this interface is undefined.
7863 ** ^The requested measurement is written into a variable pointed to by
7864 ** the "pOut" parameter.
7865 ** Parameter "idx" identifies the specific loop to retrieve statistics for.
7866 ** Loops are numbered starting from zero. ^If idx is out of range - less than
7867 ** zero or greater than or equal to the total number of loops used to implement
7868 ** the statement - a non-zero value is returned and the variable that pOut
7869 ** points to is unchanged.
7870 **
7871 ** ^Statistics might not be available for all loops in all statements. ^In cases
7872 ** where there exist loops with no available statistics, this function behaves
7873 ** as if the loop did not exist - it returns non-zero and leave the variable
7874 ** that pOut points to unchanged.
7875 **
7876 ** See also: [sqlite3_stmt_scanstatus_reset()]
7877 */
7878 int sqlite3_stmt_scanstatus(
7879 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7880 int idx, /* Index of loop to report on */
7881 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7882 void *pOut /* Result written here */
7883 );
7884
7885 /*
7886 ** CAPI3REF: Zero Scan-Status Counters
7887 ** METHOD: sqlite3_stmt
7888 **
7889 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7890 **
7891 ** This API is only available if the library is built with pre-processor
7892 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7893 */
7894 void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7895
7896 /*
7897 ** CAPI3REF: Flush caches to disk mid-transaction
7898 **
7899 ** ^If a write-transaction is open on [database connection] D when the
7900 ** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
7901 ** pages in the pager-cache that are not currently in use are written out
7902 ** to disk. A dirty page may be in use if a database cursor created by an
7903 ** active SQL statement is reading from it, or if it is page 1 of a database
7904 ** file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)]
7905 ** interface flushes caches for all schemas - "main", "temp", and
7906 ** any [attached] databases.
7907 **
7908 ** ^If this function needs to obtain extra database locks before dirty pages
7909 ** can be flushed to disk, it does so. ^If those locks cannot be obtained
7910 ** immediately and there is a busy-handler callback configured, it is invoked
7911 ** in the usual manner. ^If the required lock still cannot be obtained, then
7912 ** the database is skipped and an attempt made to flush any dirty pages
7913 ** belonging to the next (if any) database. ^If any databases are skipped
7914 ** because locks cannot be obtained, but no other error occurs, this
7915 ** function returns SQLITE_BUSY.
7916 **
7917 ** ^If any other error occurs while flushing dirty pages to disk (for
7918 ** example an IO error or out-of-memory condition), then processing is
7919 ** abandoned and an SQLite [error code] is returned to the caller immediately.
7920 **
7921 ** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.
7922 **
7923 ** ^This function does not set the database handle error code or message
7924 ** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.
7925 */
7926 int sqlite3_db_cacheflush(sqlite3*);
7927
7928 /*
7929 ** CAPI3REF: Database Snapshot
7930 ** KEYWORDS: {snapshot}
7931 ** EXPERIMENTAL
7932 **
7933 ** An instance of the snapshot object records the state of a [WAL mode]
7934 ** database for some specific point in history.
7935 **
7936 ** In [WAL mode], multiple [database connections] that are open on the
7937 ** same database file can each be reading a different historical version
7938 ** of the database file. When a [database connection] begins a read
7939 ** transaction, that connection sees an unchanging copy of the database
7940 ** as it existed for the point in time when the transaction first started.
7941 ** Subsequent changes to the database from other connections are not seen
7942 ** by the reader until a new read transaction is started.
7943 **
7944 ** The sqlite3_snapshot object records state information about an historical
7945 ** version of the database file so that it is possible to later open a new read
7946 ** transaction that sees that historical version of the database rather than
7947 ** the most recent version.
7948 **
7949 ** The constructor for this object is [sqlite3_snapshot_get()]. The
7950 ** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
7951 ** to an historical snapshot (if possible). The destructor for
7952 ** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
7953 */
7954 typedef struct sqlite3_snapshot sqlite3_snapshot;
7955
7956 /*
7957 ** CAPI3REF: Record A Database Snapshot
7958 ** EXPERIMENTAL
7959 **
7960 ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
7961 ** new [sqlite3_snapshot] object that records the current state of
7962 ** schema S in database connection D. ^On success, the
7963 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
7964 ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
7965 ** ^If schema S of [database connection] D is not a [WAL mode] database
7966 ** that is in a read transaction, then [sqlite3_snapshot_get(D,S,P)]
7967 ** leaves the *P value unchanged and returns an appropriate [error code].
7968 **
7969 ** The [sqlite3_snapshot] object returned from a successful call to
7970 ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
7971 ** to avoid a memory leak.
7972 **
7973 ** The [sqlite3_snapshot_get()] interface is only available when the
7974 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
7975 */
7976 SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
7977 sqlite3 *db,
7978 const char *zSchema,
7979 sqlite3_snapshot **ppSnapshot
7980 );
7981
7982 /*
7983 ** CAPI3REF: Start a read transaction on an historical snapshot
7984 ** EXPERIMENTAL
7985 **
7986 ** ^The [sqlite3_snapshot_open(D,S,P)] interface attempts to move the
7987 ** read transaction that is currently open on schema S of
7988 ** [database connection] D so that it refers to historical [snapshot] P.
7989 ** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
7990 ** or an appropriate [error code] if it fails.
7991 **
7992 ** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
7993 ** the first operation, apart from other sqlite3_snapshot_open() calls,
7994 ** following the [BEGIN] that starts a new read transaction.
7995 ** ^A [snapshot] will fail to open if it has been overwritten by a
7996 ** [checkpoint].
7997 **
7998 ** The [sqlite3_snapshot_open()] interface is only available when the
7999 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
8000 */
8001 SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
8002 sqlite3 *db,
8003 const char *zSchema,
8004 sqlite3_snapshot *pSnapshot
8005 );
8006
8007 /*
8008 ** CAPI3REF: Destroy a snapshot
8009 ** EXPERIMENTAL
8010 **
8011 ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
8012 ** The application must eventually free every [sqlite3_snapshot] object
8013 ** using this routine to avoid a memory leak.
8014 **
8015 ** The [sqlite3_snapshot_free()] interface is only available when the
8016 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
8017 */
8018 SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
7449 8019
7450 /* 8020 /*
7451 ** Undo the hack that converts floating point types to integer for 8021 ** Undo the hack that converts floating point types to integer for
7452 ** builds on processors without floating point support. 8022 ** builds on processors without floating point support.
7453 */ 8023 */
7454 #ifdef SQLITE_OMIT_FLOATING_POINT 8024 #ifdef SQLITE_OMIT_FLOATING_POINT
7455 # undef double 8025 # undef double
7456 #endif 8026 #endif
7457 8027
7458 #ifdef __cplusplus 8028 #ifdef __cplusplus
7459 } /* End of the 'extern "C"' block */ 8029 } /* End of the 'extern "C"' block */
7460 #endif 8030 #endif
7461 #endif /* _SQLITE3_H_ */ 8031 #endif /* _SQLITE3_H_ */
OLDNEW
« no previous file with comments | « third_party/sqlite/src/src/shell.c ('k') | third_party/sqlite/src/src/sqlite3ext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698