| @@ -1,2377 +1,2378 @@ | | | @@ -1,2377 +1,2378 @@ |
1 | $NetBSD: patch-ab,v 1.3 2009/10/11 16:06:21 tnn Exp $ | | 1 | $NetBSD: patch-ab,v 1.4 2009/10/28 16:46:51 tnn Exp $ |
2 | | | 2 | |
3 | --- sqlite3.h.orig 2009-10-11 18:02:11.000000000 +0200 | | 3 | --- sqlite3.h.orig 2009-10-28 17:39:08.000000000 +0100 |
4 | +++ sqlite3.h | | 4 | +++ sqlite3.h |
5 | @@ -0,0 +1,5759 @@ | | 5 | @@ -0,0 +1,5763 @@ |
6 | +/* | | 6 | +/* |
7 | +** 2001 September 15 | | 7 | +** 2001 September 15 |
8 | +** | | 8 | +** |
9 | +** The author disclaims copyright to this source code. In place of | | 9 | +** The author disclaims copyright to this source code. In place of |
10 | +** a legal notice, here is a blessing: | | 10 | +** a legal notice, here is a blessing: |
11 | +** | | 11 | +** |
12 | +** May you do good and not evil. | | 12 | +** May you do good and not evil. |
13 | +** May you find forgiveness for yourself and forgive others. | | 13 | +** May you find forgiveness for yourself and forgive others. |
14 | +** May you share freely, never taking more than you give. | | 14 | +** May you share freely, never taking more than you give. |
15 | +** | | 15 | +** |
16 | +************************************************************************* | | 16 | +************************************************************************* |
17 | +** This header file defines the interface that the SQLite library | | 17 | +** This header file defines the interface that the SQLite library |
18 | +** presents to client programs. If a C-function, structure, datatype, | | 18 | +** presents to client programs. If a C-function, structure, datatype, |
19 | +** or constant definition does not appear in this file, then it is | | 19 | +** or constant definition does not appear in this file, then it is |
20 | +** not a published API of SQLite, is subject to change without | | 20 | +** not a published API of SQLite, is subject to change without |
21 | +** notice, and should not be referenced by programs that use SQLite. | | 21 | +** notice, and should not be referenced by programs that use SQLite. |
22 | +** | | 22 | +** |
23 | +** Some of the definitions that are in this file are marked as | | 23 | +** Some of the definitions that are in this file are marked as |
24 | +** "experimental". Experimental interfaces are normally new | | 24 | +** "experimental". Experimental interfaces are normally new |
25 | +** features recently added to SQLite. We do not anticipate changes | | 25 | +** features recently added to SQLite. We do not anticipate changes |
26 | +** to experimental interfaces but reserve the right to make minor changes | | 26 | +** to experimental interfaces but reserve the right to make minor changes |
27 | +** if experience from use "in the wild" suggest such changes are prudent. | | 27 | +** if experience from use "in the wild" suggest such changes are prudent. |
28 | +** | | 28 | +** |
29 | +** The official C-language API documentation for SQLite is derived | | 29 | +** The official C-language API documentation for SQLite is derived |
30 | +** from comments in this file. This file is the authoritative source | | 30 | +** from comments in this file. This file is the authoritative source |
31 | +** on how SQLite interfaces are suppose to operate. | | 31 | +** on how SQLite interfaces are suppose to operate. |
32 | +** | | 32 | +** |
33 | +** The name of this file under configuration management is "sqlite.h.in". | | 33 | +** The name of this file under configuration management is "sqlite.h.in". |
34 | +** The makefile makes some minor changes to this file (such as inserting | | 34 | +** The makefile makes some minor changes to this file (such as inserting |
35 | +** the version number) and changes its name to "sqlite3.h" as | | 35 | +** the version number) and changes its name to "sqlite3.h" as |
36 | +** part of the build process. | | 36 | +** part of the build process. |
37 | +*/ | | 37 | +*/ |
38 | +#ifndef _SQLITE3_H_ | | 38 | +#ifndef _SQLITE3_H_ |
39 | +#define _SQLITE3_H_ | | 39 | +#define _SQLITE3_H_ |
40 | +#include <stdarg.h> /* Needed for the definition of va_list */ | | 40 | +#include <stdarg.h> /* Needed for the definition of va_list */ |
41 | + | | 41 | + |
42 | +/* | | 42 | +/* |
43 | +** Make sure we can call this stuff from C++. | | 43 | +** Make sure we can call this stuff from C++. |
44 | +*/ | | 44 | +*/ |
45 | +#ifdef __cplusplus | | 45 | +#ifdef __cplusplus |
46 | +extern "C" { | | 46 | +extern "C" { |
47 | +#endif | | 47 | +#endif |
48 | + | | 48 | + |
49 | + | | 49 | + |
50 | +/* | | 50 | +/* |
51 | +** Add the ability to override 'extern' | | 51 | +** Add the ability to override 'extern' |
52 | +*/ | | 52 | +*/ |
53 | +#ifndef SQLITE_EXTERN | | 53 | +#ifndef SQLITE_EXTERN |
54 | +# define SQLITE_EXTERN extern | | 54 | +# define SQLITE_EXTERN extern |
55 | +#endif | | 55 | +#endif |
56 | + | | 56 | + |
57 | +#ifndef SQLITE_API | | 57 | +#ifndef SQLITE_API |
58 | +# define SQLITE_API | | 58 | +# define SQLITE_API |
59 | +#endif | | 59 | +#endif |
60 | + | | 60 | + |
61 | + | | 61 | + |
62 | +/* | | 62 | +/* |
63 | +** These no-op macros are used in front of interfaces to mark those | | 63 | +** These no-op macros are used in front of interfaces to mark those |
64 | +** interfaces as either deprecated or experimental. New applications | | 64 | +** interfaces as either deprecated or experimental. New applications |
65 | +** should not use deprecated interfaces - they are support for backwards | | 65 | +** should not use deprecated interfaces - they are support for backwards |
66 | +** compatibility only. Application writers should be aware that | | 66 | +** compatibility only. Application writers should be aware that |
67 | +** experimental interfaces are subject to change in point releases. | | 67 | +** experimental interfaces are subject to change in point releases. |
68 | +** | | 68 | +** |
69 | +** These macros used to resolve to various kinds of compiler magic that | | 69 | +** These macros used to resolve to various kinds of compiler magic that |
70 | +** would generate warning messages when they were used. But that | | 70 | +** would generate warning messages when they were used. But that |
71 | +** compiler magic ended up generating such a flurry of bug reports | | 71 | +** compiler magic ended up generating such a flurry of bug reports |
72 | +** that we have taken it all out and gone back to using simple | | 72 | +** that we have taken it all out and gone back to using simple |
73 | +** noop macros. | | 73 | +** noop macros. |
74 | +*/ | | 74 | +*/ |
75 | +#define SQLITE_DEPRECATED | | 75 | +#define SQLITE_DEPRECATED |
76 | +#define SQLITE_EXPERIMENTAL | | 76 | +#define SQLITE_EXPERIMENTAL |
77 | + | | 77 | + |
78 | +/* | | 78 | +/* |
79 | +** Ensure these symbols were not defined by some previous header file. | | 79 | +** Ensure these symbols were not defined by some previous header file. |
80 | +*/ | | 80 | +*/ |
81 | +#ifdef SQLITE_VERSION | | 81 | +#ifdef SQLITE_VERSION |
82 | +# undef SQLITE_VERSION | | 82 | +# undef SQLITE_VERSION |
83 | +#endif | | 83 | +#endif |
84 | +#ifdef SQLITE_VERSION_NUMBER | | 84 | +#ifdef SQLITE_VERSION_NUMBER |
85 | +# undef SQLITE_VERSION_NUMBER | | 85 | +# undef SQLITE_VERSION_NUMBER |
86 | +#endif | | 86 | +#endif |
87 | + | | 87 | + |
88 | +/* | | 88 | +/* |
89 | +** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100> | | 89 | +** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100> |
90 | +** | | 90 | +** |
91 | +** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in | | 91 | +** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in |
92 | +** the sqlite3.h file specify the version of SQLite with which | | 92 | +** the sqlite3.h file specify the version of SQLite with which |
93 | +** that header file is associated. | | 93 | +** that header file is associated. |
94 | +** | | 94 | +** |
95 | +** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z". | | 95 | +** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z". |
96 | +** The W value is major version number and is always 3 in SQLite3. | | 96 | +** The W value is major version number and is always 3 in SQLite3. |
97 | +** The W value only changes when backwards compatibility is | | 97 | +** The W value only changes when backwards compatibility is |
98 | +** broken and we intend to never break backwards compatibility. | | 98 | +** broken and we intend to never break backwards compatibility. |
99 | +** The X value is the minor version number and only changes when | | 99 | +** The X value is the minor version number and only changes when |
100 | +** there are major feature enhancements that are forwards compatible | | 100 | +** there are major feature enhancements that are forwards compatible |
101 | +** but not backwards compatible. | | 101 | +** but not backwards compatible. |
102 | +** The Y value is the release number and is incremented with | | 102 | +** The Y value is the release number and is incremented with |
103 | +** each release but resets back to 0 whenever X is incremented. | | 103 | +** each release but resets back to 0 whenever X is incremented. |
104 | +** The Z value only appears on branch releases. | | 104 | +** The Z value only appears on branch releases. |
105 | +** | | 105 | +** |
106 | +** The SQLITE_VERSION_NUMBER is an integer that is computed as | | 106 | +** The SQLITE_VERSION_NUMBER is an integer that is computed as |
107 | +** follows: | | 107 | +** follows: |
108 | +** | | 108 | +** |
109 | +** <blockquote><pre> | | 109 | +** <blockquote><pre> |
110 | +** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y | | 110 | +** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y |
111 | +** </pre></blockquote> | | 111 | +** </pre></blockquote> |
112 | +** | | 112 | +** |
113 | +** Since version 3.6.18, SQLite source code has been stored in the | | 113 | +** Since version 3.6.18, SQLite source code has been stored in the |
114 | +** <a href="http://www.fossil-scm.org/">fossil configuration management | | 114 | +** <a href="http://www.fossil-scm.org/">fossil configuration management |
115 | +** system</a>. The SQLITE_SOURCE_ID | | 115 | +** system</a>. The SQLITE_SOURCE_ID |
116 | +** macro is a string which identifies a particular check-in of SQLite | | 116 | +** macro is a string which identifies a particular check-in of SQLite |
117 | +** within its configuration management system. The string contains the | | 117 | +** within its configuration management system. The string contains the |
118 | +** date and time of the check-in (UTC) and an SHA1 hash of the entire | | 118 | +** date and time of the check-in (UTC) and an SHA1 hash of the entire |
119 | +** source tree. | | 119 | +** source tree. |
120 | +** | | 120 | +** |
121 | +** See also: [sqlite3_libversion()], | | 121 | +** See also: [sqlite3_libversion()], |
122 | +** [sqlite3_libversion_number()], [sqlite3_sourceid()], | | 122 | +** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
123 | +** [sqlite_version()] and [sqlite_source_id()]. | | 123 | +** [sqlite_version()] and [sqlite_source_id()]. |
124 | +** | | 124 | +** |
125 | +** Requirements: [H10011] [H10014] | | 125 | +** Requirements: [H10011] [H10014] |
126 | +*/ | | 126 | +*/ |
127 | +#define SQLITE_VERSION "3.6.18" | | 127 | +#define SQLITE_VERSION "3.6.19" |
128 | +#define SQLITE_VERSION_NUMBER 3006018 | | 128 | +#define SQLITE_VERSION_NUMBER 3006019 |
129 | +#define SQLITE_SOURCE_ID "2009-09-11 14:05:07 b084828a771ec40be85f07c590ca99de4f6c24ee" | | 129 | +#define SQLITE_SOURCE_ID "2009-10-14 11:33:55 c1d499afc50d54b376945b4efb65c56c787a073d" |
130 | + | | 130 | + |
131 | +/* | | 131 | +/* |
132 | +** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> | | 132 | +** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> |
133 | +** KEYWORDS: sqlite3_version | | 133 | +** KEYWORDS: sqlite3_version |
134 | +** | | 134 | +** |
135 | +** These interfaces provide the same information as the [SQLITE_VERSION], | | 135 | +** These interfaces provide the same information as the [SQLITE_VERSION], |
136 | +** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header, | | 136 | +** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header, |
137 | +** but are associated with the library instead of the header file. Cautious | | 137 | +** but are associated with the library instead of the header file. Cautious |
138 | +** programmers might include assert() statements in their application to | | 138 | +** programmers might include assert() statements in their application to |
139 | +** verify that values returned by these interfaces match the macros in | | 139 | +** verify that values returned by these interfaces match the macros in |
140 | +** the header, and thus insure that the application is | | 140 | +** the header, and thus insure that the application is |
141 | +** compiled with matching library and header files. | | 141 | +** compiled with matching library and header files. |
142 | +** | | 142 | +** |
143 | +** <blockquote><pre> | | 143 | +** <blockquote><pre> |
144 | +** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER ); | | 144 | +** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER ); |
145 | +** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 ); | | 145 | +** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 ); |
146 | +** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 ); | | 146 | +** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 ); |
147 | +** </pre></blockquote> | | 147 | +** </pre></blockquote> |
148 | +** | | 148 | +** |
149 | +** The sqlite3_libversion() function returns the same information as is | | 149 | +** The sqlite3_libversion() function returns the same information as is |
150 | +** in the sqlite3_version[] string constant. The function is provided | | 150 | +** in the sqlite3_version[] string constant. The function is provided |
151 | +** for use in DLLs since DLL users usually do not have direct access to string | | 151 | +** for use in DLLs since DLL users usually do not have direct access to string |
152 | +** constants within the DLL. Similarly, the sqlite3_sourceid() function | | 152 | +** constants within the DLL. Similarly, the sqlite3_sourceid() function |
153 | +** returns the same information as is in the [SQLITE_SOURCE_ID] #define of | | 153 | +** returns the same information as is in the [SQLITE_SOURCE_ID] #define of |
154 | +** the header file. | | 154 | +** the header file. |
155 | +** | | 155 | +** |
156 | +** See also: [sqlite_version()] and [sqlite_source_id()]. | | 156 | +** See also: [sqlite_version()] and [sqlite_source_id()]. |
157 | +** | | 157 | +** |
158 | +** Requirements: [H10021] [H10022] [H10023] | | 158 | +** Requirements: [H10021] [H10022] [H10023] |
159 | +*/ | | 159 | +*/ |
160 | +SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; | | 160 | +SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; |
161 | +SQLITE_API const char *sqlite3_libversion(void); | | 161 | +SQLITE_API const char *sqlite3_libversion(void); |
162 | +SQLITE_API const char *sqlite3_sourceid(void); | | 162 | +SQLITE_API const char *sqlite3_sourceid(void); |
163 | +SQLITE_API int sqlite3_libversion_number(void); | | 163 | +SQLITE_API int sqlite3_libversion_number(void); |
164 | + | | 164 | + |
165 | +/* | | 165 | +/* |
166 | +** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100> | | 166 | +** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100> |
167 | +** | | 167 | +** |
168 | +** SQLite can be compiled with or without mutexes. When | | 168 | +** SQLite can be compiled with or without mutexes. When |
169 | +** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes | | 169 | +** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
170 | +** are enabled and SQLite is threadsafe. When the | | 170 | +** are enabled and SQLite is threadsafe. When the |
171 | +** [SQLITE_THREADSAFE] macro is 0, | | 171 | +** [SQLITE_THREADSAFE] macro is 0, |
172 | +** the mutexes are omitted. Without the mutexes, it is not safe | | 172 | +** the mutexes are omitted. Without the mutexes, it is not safe |
173 | +** to use SQLite concurrently from more than one thread. | | 173 | +** to use SQLite concurrently from more than one thread. |
174 | +** | | 174 | +** |
175 | +** Enabling mutexes incurs a measurable performance penalty. | | 175 | +** Enabling mutexes incurs a measurable performance penalty. |
176 | +** So if speed is of utmost importance, it makes sense to disable | | 176 | +** So if speed is of utmost importance, it makes sense to disable |
177 | +** the mutexes. But for maximum safety, mutexes should be enabled. | | 177 | +** the mutexes. But for maximum safety, mutexes should be enabled. |
178 | +** The default behavior is for mutexes to be enabled. | | 178 | +** The default behavior is for mutexes to be enabled. |
179 | +** | | 179 | +** |
180 | +** This interface can be used by an application to make sure that the | | 180 | +** This interface can be used by an application to make sure that the |
181 | +** version of SQLite that it is linking against was compiled with | | 181 | +** version of SQLite that it is linking against was compiled with |
182 | +** the desired setting of the [SQLITE_THREADSAFE] macro. | | 182 | +** the desired setting of the [SQLITE_THREADSAFE] macro. |
183 | +** | | 183 | +** |
184 | +** This interface only reports on the compile-time mutex setting | | 184 | +** This interface only reports on the compile-time mutex setting |
185 | +** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with | | 185 | +** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with |
186 | +** SQLITE_THREADSAFE=1 then mutexes are enabled by default but | | 186 | +** SQLITE_THREADSAFE=1 then mutexes are enabled by default but |
187 | +** can be fully or partially disabled using a call to [sqlite3_config()] | | 187 | +** can be fully or partially disabled using a call to [sqlite3_config()] |
188 | +** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], | | 188 | +** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], |
189 | +** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows | | 189 | +** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows |
190 | +** only the default compile-time setting, not any run-time changes | | 190 | +** only the default compile-time setting, not any run-time changes |
191 | +** to that setting. | | 191 | +** to that setting. |
192 | +** | | 192 | +** |
193 | +** See the [threading mode] documentation for additional information. | | 193 | +** See the [threading mode] documentation for additional information. |
194 | +** | | 194 | +** |
195 | +** Requirements: [H10101] [H10102] | | 195 | +** Requirements: [H10101] [H10102] |
196 | +*/ | | 196 | +*/ |
197 | +SQLITE_API int sqlite3_threadsafe(void); | | 197 | +SQLITE_API int sqlite3_threadsafe(void); |
198 | + | | 198 | + |
199 | +/* | | 199 | +/* |
200 | +** CAPI3REF: Database Connection Handle {H12000} <S40200> | | 200 | +** CAPI3REF: Database Connection Handle {H12000} <S40200> |
201 | +** KEYWORDS: {database connection} {database connections} | | 201 | +** KEYWORDS: {database connection} {database connections} |
202 | +** | | 202 | +** |
203 | +** Each open SQLite database is represented by a pointer to an instance of | | 203 | +** Each open SQLite database is represented by a pointer to an instance of |
204 | +** the opaque structure named "sqlite3". It is useful to think of an sqlite3 | | 204 | +** the opaque structure named "sqlite3". It is useful to think of an sqlite3 |
205 | +** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and | | 205 | +** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and |
206 | +** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] | | 206 | +** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] |
207 | +** is its destructor. There are many other interfaces (such as | | 207 | +** is its destructor. There are many other interfaces (such as |
208 | +** [sqlite3_prepare_v2()], [sqlite3_create_function()], and | | 208 | +** [sqlite3_prepare_v2()], [sqlite3_create_function()], and |
209 | +** [sqlite3_busy_timeout()] to name but three) that are methods on an | | 209 | +** [sqlite3_busy_timeout()] to name but three) that are methods on an |
210 | +** sqlite3 object. | | 210 | +** sqlite3 object. |
211 | +*/ | | 211 | +*/ |
212 | +typedef struct sqlite3 sqlite3; | | 212 | +typedef struct sqlite3 sqlite3; |
213 | + | | 213 | + |
214 | +/* | | 214 | +/* |
215 | +** CAPI3REF: 64-Bit Integer Types {H10200} <S10110> | | 215 | +** CAPI3REF: 64-Bit Integer Types {H10200} <S10110> |
216 | +** KEYWORDS: sqlite_int64 sqlite_uint64 | | 216 | +** KEYWORDS: sqlite_int64 sqlite_uint64 |
217 | +** | | 217 | +** |
218 | +** Because there is no cross-platform way to specify 64-bit integer types | | 218 | +** Because there is no cross-platform way to specify 64-bit integer types |
219 | +** SQLite includes typedefs for 64-bit signed and unsigned integers. | | 219 | +** SQLite includes typedefs for 64-bit signed and unsigned integers. |
220 | +** | | 220 | +** |
221 | +** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. | | 221 | +** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. |
222 | +** The sqlite_int64 and sqlite_uint64 types are supported for backwards | | 222 | +** The sqlite_int64 and sqlite_uint64 types are supported for backwards |
223 | +** compatibility only. | | 223 | +** compatibility only. |
224 | +** | | 224 | +** |
225 | +** Requirements: [H10201] [H10202] | | 225 | +** Requirements: [H10201] [H10202] |
226 | +*/ | | 226 | +*/ |
227 | +#ifdef SQLITE_INT64_TYPE | | 227 | +#ifdef SQLITE_INT64_TYPE |
228 | + typedef SQLITE_INT64_TYPE sqlite_int64; | | 228 | + typedef SQLITE_INT64_TYPE sqlite_int64; |
229 | + typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; | | 229 | + typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; |
230 | +#elif defined(_MSC_VER) || defined(__BORLANDC__) | | 230 | +#elif defined(_MSC_VER) || defined(__BORLANDC__) |
231 | + typedef __int64 sqlite_int64; | | 231 | + typedef __int64 sqlite_int64; |
232 | + typedef unsigned __int64 sqlite_uint64; | | 232 | + typedef unsigned __int64 sqlite_uint64; |
233 | +#else | | 233 | +#else |
234 | + typedef long long int sqlite_int64; | | 234 | + typedef long long int sqlite_int64; |
235 | + typedef unsigned long long int sqlite_uint64; | | 235 | + typedef unsigned long long int sqlite_uint64; |
236 | +#endif | | 236 | +#endif |
237 | +typedef sqlite_int64 sqlite3_int64; | | 237 | +typedef sqlite_int64 sqlite3_int64; |
238 | +typedef sqlite_uint64 sqlite3_uint64; | | 238 | +typedef sqlite_uint64 sqlite3_uint64; |
239 | + | | 239 | + |
240 | +/* | | 240 | +/* |
241 | +** If compiling for a processor that lacks floating point support, | | 241 | +** If compiling for a processor that lacks floating point support, |
242 | +** substitute integer for floating-point. | | 242 | +** substitute integer for floating-point. |
243 | +*/ | | 243 | +*/ |
244 | +#ifdef SQLITE_OMIT_FLOATING_POINT | | 244 | +#ifdef SQLITE_OMIT_FLOATING_POINT |
245 | +# define double sqlite3_int64 | | 245 | +# define double sqlite3_int64 |
246 | +#endif | | 246 | +#endif |
247 | + | | 247 | + |
248 | +/* | | 248 | +/* |
249 | +** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200> | | 249 | +** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200> |
250 | +** | | 250 | +** |
251 | +** This routine is the destructor for the [sqlite3] object. | | 251 | +** This routine is the destructor for the [sqlite3] object. |
252 | +** | | 252 | +** |
253 | +** Applications should [sqlite3_finalize | finalize] all [prepared statements] | | 253 | +** Applications should [sqlite3_finalize | finalize] all [prepared statements] |
254 | +** and [sqlite3_blob_close | close] all [BLOB handles] associated with | | 254 | +** and [sqlite3_blob_close | close] all [BLOB handles] associated with |
255 | +** the [sqlite3] object prior to attempting to close the object. | | 255 | +** the [sqlite3] object prior to attempting to close the object. |
256 | +** The [sqlite3_next_stmt()] interface can be used to locate all | | 256 | +** The [sqlite3_next_stmt()] interface can be used to locate all |
257 | +** [prepared statements] associated with a [database connection] if desired. | | 257 | +** [prepared statements] associated with a [database connection] if desired. |
258 | +** Typical code might look like this: | | 258 | +** Typical code might look like this: |
259 | +** | | 259 | +** |
260 | +** <blockquote><pre> | | 260 | +** <blockquote><pre> |
261 | +** sqlite3_stmt *pStmt; | | 261 | +** sqlite3_stmt *pStmt; |
262 | +** while( (pStmt = sqlite3_next_stmt(db, 0))!=0 ){ | | 262 | +** while( (pStmt = sqlite3_next_stmt(db, 0))!=0 ){ |
263 | +** sqlite3_finalize(pStmt); | | 263 | +** sqlite3_finalize(pStmt); |
264 | +** } | | 264 | +** } |
265 | +** </pre></blockquote> | | 265 | +** </pre></blockquote> |
266 | +** | | 266 | +** |
267 | +** If [sqlite3_close()] is invoked while a transaction is open, | | 267 | +** If [sqlite3_close()] is invoked while a transaction is open, |
268 | +** the transaction is automatically rolled back. | | 268 | +** the transaction is automatically rolled back. |
269 | +** | | 269 | +** |
270 | +** The C parameter to [sqlite3_close(C)] must be either a NULL | | 270 | +** The C parameter to [sqlite3_close(C)] must be either a NULL |
271 | +** pointer or an [sqlite3] object pointer obtained | | 271 | +** pointer or an [sqlite3] object pointer obtained |
272 | +** from [sqlite3_open()], [sqlite3_open16()], or | | 272 | +** from [sqlite3_open()], [sqlite3_open16()], or |
273 | +** [sqlite3_open_v2()], and not previously closed. | | 273 | +** [sqlite3_open_v2()], and not previously closed. |
274 | +** | | 274 | +** |
275 | +** Requirements: | | 275 | +** Requirements: |
276 | +** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019] | | 276 | +** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019] |
277 | +*/ | | 277 | +*/ |
278 | +SQLITE_API int sqlite3_close(sqlite3 *); | | 278 | +SQLITE_API int sqlite3_close(sqlite3 *); |
279 | + | | 279 | + |
280 | +/* | | 280 | +/* |
281 | +** The type for a callback function. | | 281 | +** The type for a callback function. |
282 | +** This is legacy and deprecated. It is included for historical | | 282 | +** This is legacy and deprecated. It is included for historical |
283 | +** compatibility and is not documented. | | 283 | +** compatibility and is not documented. |
284 | +*/ | | 284 | +*/ |
285 | +typedef int (*sqlite3_callback)(void*,int,char**, char**); | | 285 | +typedef int (*sqlite3_callback)(void*,int,char**, char**); |
286 | + | | 286 | + |
287 | +/* | | 287 | +/* |
288 | +** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000> | | 288 | +** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000> |
289 | +** | | 289 | +** |
290 | +** The sqlite3_exec() interface is a convenient way of running one or more | | 290 | +** The sqlite3_exec() interface is a convenient way of running one or more |
291 | +** SQL statements without having to write a lot of C code. The UTF-8 encoded | | 291 | +** SQL statements without having to write a lot of C code. The UTF-8 encoded |
292 | +** SQL statements are passed in as the second parameter to sqlite3_exec(). | | 292 | +** SQL statements are passed in as the second parameter to sqlite3_exec(). |
293 | +** The statements are evaluated one by one until either an error or | | 293 | +** The statements are evaluated one by one until either an error or |
294 | +** an interrupt is encountered, or until they are all done. The 3rd parameter | | 294 | +** an interrupt is encountered, or until they are all done. The 3rd parameter |
295 | +** is an optional callback that is invoked once for each row of any query | | 295 | +** is an optional callback that is invoked once for each row of any query |
296 | +** results produced by the SQL statements. The 5th parameter tells where | | 296 | +** results produced by the SQL statements. The 5th parameter tells where |
297 | +** to write any error messages. | | 297 | +** to write any error messages. |
298 | +** | | 298 | +** |
299 | +** The error message passed back through the 5th parameter is held | | 299 | +** The error message passed back through the 5th parameter is held |
300 | +** in memory obtained from [sqlite3_malloc()]. To avoid a memory leak, | | 300 | +** in memory obtained from [sqlite3_malloc()]. To avoid a memory leak, |
301 | +** the calling application should call [sqlite3_free()] on any error | | 301 | +** the calling application should call [sqlite3_free()] on any error |
302 | +** message returned through the 5th parameter when it has finished using | | 302 | +** message returned through the 5th parameter when it has finished using |
303 | +** the error message. | | 303 | +** the error message. |
304 | +** | | 304 | +** |
305 | +** If the SQL statement in the 2nd parameter is NULL or an empty string | | 305 | +** If the SQL statement in the 2nd parameter is NULL or an empty string |
306 | +** or a string containing only whitespace and comments, then no SQL | | 306 | +** or a string containing only whitespace and comments, then no SQL |
307 | +** statements are evaluated and the database is not changed. | | 307 | +** statements are evaluated and the database is not changed. |
308 | +** | | 308 | +** |
309 | +** The sqlite3_exec() interface is implemented in terms of | | 309 | +** The sqlite3_exec() interface is implemented in terms of |
310 | +** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. | | 310 | +** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. |
311 | +** The sqlite3_exec() routine does nothing to the database that cannot be done | | 311 | +** The sqlite3_exec() routine does nothing to the database that cannot be done |
312 | +** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. | | 312 | +** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. |
313 | +** | | 313 | +** |
314 | +** The first parameter to [sqlite3_exec()] must be an valid and open | | 314 | +** The first parameter to [sqlite3_exec()] must be an valid and open |
315 | +** [database connection]. | | 315 | +** [database connection]. |
316 | +** | | 316 | +** |
317 | +** The database connection must not be closed while | | 317 | +** The database connection must not be closed while |
318 | +** [sqlite3_exec()] is running. | | 318 | +** [sqlite3_exec()] is running. |
319 | +** | | 319 | +** |
320 | +** The calling function should use [sqlite3_free()] to free | | 320 | +** The calling function should use [sqlite3_free()] to free |
321 | +** the memory that *errmsg is left pointing at once the error | | 321 | +** the memory that *errmsg is left pointing at once the error |
322 | +** message is no longer needed. | | 322 | +** message is no longer needed. |
323 | +** | | 323 | +** |
324 | +** The SQL statement text in the 2nd parameter to [sqlite3_exec()] | | 324 | +** The SQL statement text in the 2nd parameter to [sqlite3_exec()] |
325 | +** must remain unchanged while [sqlite3_exec()] is running. | | 325 | +** must remain unchanged while [sqlite3_exec()] is running. |
326 | +** | | 326 | +** |
327 | +** Requirements: | | 327 | +** Requirements: |
328 | +** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116] | | 328 | +** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116] |
329 | +** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138] | | 329 | +** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138] |
330 | +*/ | | 330 | +*/ |
331 | +SQLITE_API int sqlite3_exec( | | 331 | +SQLITE_API int sqlite3_exec( |
332 | + sqlite3*, /* An open database */ | | 332 | + sqlite3*, /* An open database */ |
333 | + const char *sql, /* SQL to be evaluated */ | | 333 | + const char *sql, /* SQL to be evaluated */ |
334 | + int (*callback)(void*,int,char**,char**), /* Callback function */ | | 334 | + int (*callback)(void*,int,char**,char**), /* Callback function */ |
335 | + void *, /* 1st argument to callback */ | | 335 | + void *, /* 1st argument to callback */ |
336 | + char **errmsg /* Error msg written here */ | | 336 | + char **errmsg /* Error msg written here */ |
337 | +); | | 337 | +); |
338 | + | | 338 | + |
339 | +/* | | 339 | +/* |
340 | +** CAPI3REF: Result Codes {H10210} <S10700> | | 340 | +** CAPI3REF: Result Codes {H10210} <S10700> |
341 | +** KEYWORDS: SQLITE_OK {error code} {error codes} | | 341 | +** KEYWORDS: SQLITE_OK {error code} {error codes} |
342 | +** KEYWORDS: {result code} {result codes} | | 342 | +** KEYWORDS: {result code} {result codes} |
343 | +** | | 343 | +** |
344 | +** Many SQLite functions return an integer result code from the set shown | | 344 | +** Many SQLite functions return an integer result code from the set shown |
345 | +** here in order to indicates success or failure. | | 345 | +** here in order to indicates success or failure. |
346 | +** | | 346 | +** |
347 | +** New error codes may be added in future versions of SQLite. | | 347 | +** New error codes may be added in future versions of SQLite. |
348 | +** | | 348 | +** |
349 | +** See also: [SQLITE_IOERR_READ | extended result codes] | | 349 | +** See also: [SQLITE_IOERR_READ | extended result codes] |
350 | +*/ | | 350 | +*/ |
351 | +#define SQLITE_OK 0 /* Successful result */ | | 351 | +#define SQLITE_OK 0 /* Successful result */ |
352 | +/* beginning-of-error-codes */ | | 352 | +/* beginning-of-error-codes */ |
353 | +#define SQLITE_ERROR 1 /* SQL error or missing database */ | | 353 | +#define SQLITE_ERROR 1 /* SQL error or missing database */ |
354 | +#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ | | 354 | +#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ |
355 | +#define SQLITE_PERM 3 /* Access permission denied */ | | 355 | +#define SQLITE_PERM 3 /* Access permission denied */ |
356 | +#define SQLITE_ABORT 4 /* Callback routine requested an abort */ | | 356 | +#define SQLITE_ABORT 4 /* Callback routine requested an abort */ |
357 | +#define SQLITE_BUSY 5 /* The database file is locked */ | | 357 | +#define SQLITE_BUSY 5 /* The database file is locked */ |
358 | +#define SQLITE_LOCKED 6 /* A table in the database is locked */ | | 358 | +#define SQLITE_LOCKED 6 /* A table in the database is locked */ |
359 | +#define SQLITE_NOMEM 7 /* A malloc() failed */ | | 359 | +#define SQLITE_NOMEM 7 /* A malloc() failed */ |
360 | +#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ | | 360 | +#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ |
361 | +#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ | | 361 | +#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ |
362 | +#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ | | 362 | +#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ |
363 | +#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ | | 363 | +#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ |
364 | +#define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */ | | 364 | +#define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */ |
365 | +#define SQLITE_FULL 13 /* Insertion failed because database is full */ | | 365 | +#define SQLITE_FULL 13 /* Insertion failed because database is full */ |
366 | +#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ | | 366 | +#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ |
367 | +#define SQLITE_PROTOCOL 15 /* NOT USED. Database lock protocol error */ | | 367 | +#define SQLITE_PROTOCOL 15 /* NOT USED. Database lock protocol error */ |
368 | +#define SQLITE_EMPTY 16 /* Database is empty */ | | 368 | +#define SQLITE_EMPTY 16 /* Database is empty */ |
369 | +#define SQLITE_SCHEMA 17 /* The database schema changed */ | | 369 | +#define SQLITE_SCHEMA 17 /* The database schema changed */ |
370 | +#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ | | 370 | +#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ |
371 | +#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ | | 371 | +#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ |
372 | +#define SQLITE_MISMATCH 20 /* Data type mismatch */ | | 372 | +#define SQLITE_MISMATCH 20 /* Data type mismatch */ |
373 | +#define SQLITE_MISUSE 21 /* Library used incorrectly */ | | 373 | +#define SQLITE_MISUSE 21 /* Library used incorrectly */ |
374 | +#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ | | 374 | +#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ |
375 | +#define SQLITE_AUTH 23 /* Authorization denied */ | | 375 | +#define SQLITE_AUTH 23 /* Authorization denied */ |
376 | +#define SQLITE_FORMAT 24 /* Auxiliary database format error */ | | 376 | +#define SQLITE_FORMAT 24 /* Auxiliary database format error */ |
377 | +#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ | | 377 | +#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ |
378 | +#define SQLITE_NOTADB 26 /* File opened that is not a database file */ | | 378 | +#define SQLITE_NOTADB 26 /* File opened that is not a database file */ |
379 | +#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ | | 379 | +#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ |
380 | +#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ | | 380 | +#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ |
381 | +/* end-of-error-codes */ | | 381 | +/* end-of-error-codes */ |
382 | + | | 382 | + |
383 | +/* | | 383 | +/* |
384 | +** CAPI3REF: Extended Result Codes {H10220} <S10700> | | 384 | +** CAPI3REF: Extended Result Codes {H10220} <S10700> |
385 | +** KEYWORDS: {extended error code} {extended error codes} | | 385 | +** KEYWORDS: {extended error code} {extended error codes} |
386 | +** KEYWORDS: {extended result code} {extended result codes} | | 386 | +** KEYWORDS: {extended result code} {extended result codes} |
387 | +** | | 387 | +** |
388 | +** In its default configuration, SQLite API routines return one of 26 integer | | 388 | +** In its default configuration, SQLite API routines return one of 26 integer |
389 | +** [SQLITE_OK | result codes]. However, experience has shown that many of | | 389 | +** [SQLITE_OK | result codes]. However, experience has shown that many of |
390 | +** these result codes are too coarse-grained. They do not provide as | | 390 | +** these result codes are too coarse-grained. They do not provide as |
391 | +** much information about problems as programmers might like. In an effort to | | 391 | +** much information about problems as programmers might like. In an effort to |
392 | +** address this, newer versions of SQLite (version 3.3.8 and later) include | | 392 | +** address this, newer versions of SQLite (version 3.3.8 and later) include |
393 | +** support for additional result codes that provide more detailed information | | 393 | +** support for additional result codes that provide more detailed information |
394 | +** about errors. The extended result codes are enabled or disabled | | 394 | +** about errors. The extended result codes are enabled or disabled |
395 | +** on a per database connection basis using the | | 395 | +** on a per database connection basis using the |
396 | +** [sqlite3_extended_result_codes()] API. | | 396 | +** [sqlite3_extended_result_codes()] API. |
397 | +** | | 397 | +** |
398 | +** Some of the available extended result codes are listed here. | | 398 | +** Some of the available extended result codes are listed here. |
399 | +** One may expect the number of extended result codes will be expand | | 399 | +** One may expect the number of extended result codes will be expand |
400 | +** over time. Software that uses extended result codes should expect | | 400 | +** over time. Software that uses extended result codes should expect |
401 | +** to see new result codes in future releases of SQLite. | | 401 | +** to see new result codes in future releases of SQLite. |
402 | +** | | 402 | +** |
403 | +** The SQLITE_OK result code will never be extended. It will always | | 403 | +** The SQLITE_OK result code will never be extended. It will always |
404 | +** be exactly zero. | | 404 | +** be exactly zero. |
405 | +*/ | | 405 | +*/ |
406 | +#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) | | 406 | +#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) |
407 | +#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) | | 407 | +#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) |
408 | +#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) | | 408 | +#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) |
409 | +#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) | | 409 | +#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) |
410 | +#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) | | 410 | +#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) |
411 | +#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) | | 411 | +#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) |
412 | +#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) | | 412 | +#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) |
413 | +#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) | | 413 | +#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) |
414 | +#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) | | 414 | +#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) |
415 | +#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) | | 415 | +#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) |
416 | +#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) | | 416 | +#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) |
417 | +#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) | | 417 | +#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) |
418 | +#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) | | 418 | +#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) |
419 | +#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) | | 419 | +#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) |
420 | +#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) | | 420 | +#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) |
421 | +#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) | | 421 | +#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) |
422 | +#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) | | 422 | +#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) |
423 | +#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) ) | | 423 | +#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) ) |
424 | + | | 424 | + |
425 | +/* | | 425 | +/* |
426 | +** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> | | 426 | +** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> |
427 | +** | | 427 | +** |
428 | +** These bit values are intended for use in the | | 428 | +** These bit values are intended for use in the |
429 | +** 3rd parameter to the [sqlite3_open_v2()] interface and | | 429 | +** 3rd parameter to the [sqlite3_open_v2()] interface and |
430 | +** in the 4th parameter to the xOpen method of the | | 430 | +** in the 4th parameter to the xOpen method of the |
431 | +** [sqlite3_vfs] object. | | 431 | +** [sqlite3_vfs] object. |
432 | +*/ | | 432 | +*/ |
433 | +#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ | | 433 | +#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ |
434 | +#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ | | 434 | +#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ |
435 | +#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ | | 435 | +#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ |
436 | +#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ | | 436 | +#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ |
437 | +#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ | | 437 | +#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ |
438 | +#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ | | 438 | +#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ |
439 | +#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ | | 439 | +#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ |
440 | +#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ | | 440 | +#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ |
441 | +#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ | | 441 | +#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ |
442 | +#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ | | 442 | +#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ |
443 | +#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ | | 443 | +#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ |
444 | +#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ | | 444 | +#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ |
445 | +#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ | | 445 | +#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ |
446 | +#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ | | 446 | +#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
447 | +#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ | | 447 | +#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
448 | +#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ | | 448 | +#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
449 | + | | 449 | + |
450 | +/* | | 450 | +/* |
451 | +** CAPI3REF: Device Characteristics {H10240} <H11120> | | 451 | +** CAPI3REF: Device Characteristics {H10240} <H11120> |
452 | +** | | 452 | +** |
453 | +** The xDeviceCapabilities method of the [sqlite3_io_methods] | | 453 | +** The xDeviceCapabilities method of the [sqlite3_io_methods] |
454 | +** object returns an integer which is a vector of the these | | 454 | +** object returns an integer which is a vector of the these |
455 | +** bit values expressing I/O characteristics of the mass storage | | 455 | +** bit values expressing I/O characteristics of the mass storage |
456 | +** device that holds the file that the [sqlite3_io_methods] | | 456 | +** device that holds the file that the [sqlite3_io_methods] |
457 | +** refers to. | | 457 | +** refers to. |
458 | +** | | 458 | +** |
459 | +** The SQLITE_IOCAP_ATOMIC property means that all writes of | | 459 | +** The SQLITE_IOCAP_ATOMIC property means that all writes of |
460 | +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values | | 460 | +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values |
461 | +** mean that writes of blocks that are nnn bytes in size and | | 461 | +** mean that writes of blocks that are nnn bytes in size and |
462 | +** are aligned to an address which is an integer multiple of | | 462 | +** are aligned to an address which is an integer multiple of |
463 | +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means | | 463 | +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means |
464 | +** that when data is appended to a file, the data is appended | | 464 | +** that when data is appended to a file, the data is appended |
465 | +** first then the size of the file is extended, never the other | | 465 | +** first then the size of the file is extended, never the other |
466 | +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that | | 466 | +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
467 | +** information is written to disk in the same order as calls | | 467 | +** information is written to disk in the same order as calls |
468 | +** to xWrite(). | | 468 | +** to xWrite(). |
469 | +*/ | | 469 | +*/ |
470 | +#define SQLITE_IOCAP_ATOMIC 0x00000001 | | 470 | +#define SQLITE_IOCAP_ATOMIC 0x00000001 |
471 | +#define SQLITE_IOCAP_ATOMIC512 0x00000002 | | 471 | +#define SQLITE_IOCAP_ATOMIC512 0x00000002 |
472 | +#define SQLITE_IOCAP_ATOMIC1K 0x00000004 | | 472 | +#define SQLITE_IOCAP_ATOMIC1K 0x00000004 |
473 | +#define SQLITE_IOCAP_ATOMIC2K 0x00000008 | | 473 | +#define SQLITE_IOCAP_ATOMIC2K 0x00000008 |
474 | +#define SQLITE_IOCAP_ATOMIC4K 0x00000010 | | 474 | +#define SQLITE_IOCAP_ATOMIC4K 0x00000010 |
475 | +#define SQLITE_IOCAP_ATOMIC8K 0x00000020 | | 475 | +#define SQLITE_IOCAP_ATOMIC8K 0x00000020 |
476 | +#define SQLITE_IOCAP_ATOMIC16K 0x00000040 | | 476 | +#define SQLITE_IOCAP_ATOMIC16K 0x00000040 |
477 | +#define SQLITE_IOCAP_ATOMIC32K 0x00000080 | | 477 | +#define SQLITE_IOCAP_ATOMIC32K 0x00000080 |
478 | +#define SQLITE_IOCAP_ATOMIC64K 0x00000100 | | 478 | +#define SQLITE_IOCAP_ATOMIC64K 0x00000100 |
479 | +#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 | | 479 | +#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 |
480 | +#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 | | 480 | +#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 |
481 | + | | 481 | + |
482 | +/* | | 482 | +/* |
483 | +** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310> | | 483 | +** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310> |
484 | +** | | 484 | +** |
485 | +** SQLite uses one of these integer values as the second | | 485 | +** SQLite uses one of these integer values as the second |
486 | +** argument to calls it makes to the xLock() and xUnlock() methods | | 486 | +** argument to calls it makes to the xLock() and xUnlock() methods |
487 | +** of an [sqlite3_io_methods] object. | | 487 | +** of an [sqlite3_io_methods] object. |
488 | +*/ | | 488 | +*/ |
489 | +#define SQLITE_LOCK_NONE 0 | | 489 | +#define SQLITE_LOCK_NONE 0 |
490 | +#define SQLITE_LOCK_SHARED 1 | | 490 | +#define SQLITE_LOCK_SHARED 1 |
491 | +#define SQLITE_LOCK_RESERVED 2 | | 491 | +#define SQLITE_LOCK_RESERVED 2 |
492 | +#define SQLITE_LOCK_PENDING 3 | | 492 | +#define SQLITE_LOCK_PENDING 3 |
493 | +#define SQLITE_LOCK_EXCLUSIVE 4 | | 493 | +#define SQLITE_LOCK_EXCLUSIVE 4 |
494 | + | | 494 | + |
495 | +/* | | 495 | +/* |
496 | +** CAPI3REF: Synchronization Type Flags {H10260} <H11120> | | 496 | +** CAPI3REF: Synchronization Type Flags {H10260} <H11120> |
497 | +** | | 497 | +** |
498 | +** When SQLite invokes the xSync() method of an | | 498 | +** When SQLite invokes the xSync() method of an |
499 | +** [sqlite3_io_methods] object it uses a combination of | | 499 | +** [sqlite3_io_methods] object it uses a combination of |
500 | +** these integer values as the second argument. | | 500 | +** these integer values as the second argument. |
501 | +** | | 501 | +** |
502 | +** When the SQLITE_SYNC_DATAONLY flag is used, it means that the | | 502 | +** When the SQLITE_SYNC_DATAONLY flag is used, it means that the |
503 | +** sync operation only needs to flush data to mass storage. Inode | | 503 | +** sync operation only needs to flush data to mass storage. Inode |
504 | +** information need not be flushed. If the lower four bits of the flag | | 504 | +** information need not be flushed. If the lower four bits of the flag |
505 | +** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. | | 505 | +** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. |
506 | +** If the lower four bits equal SQLITE_SYNC_FULL, that means | | 506 | +** If the lower four bits equal SQLITE_SYNC_FULL, that means |
507 | +** to use Mac OS X style fullsync instead of fsync(). | | 507 | +** to use Mac OS X style fullsync instead of fsync(). |
508 | +*/ | | 508 | +*/ |
509 | +#define SQLITE_SYNC_NORMAL 0x00002 | | 509 | +#define SQLITE_SYNC_NORMAL 0x00002 |
510 | +#define SQLITE_SYNC_FULL 0x00003 | | 510 | +#define SQLITE_SYNC_FULL 0x00003 |
511 | +#define SQLITE_SYNC_DATAONLY 0x00010 | | 511 | +#define SQLITE_SYNC_DATAONLY 0x00010 |
512 | + | | 512 | + |
513 | +/* | | 513 | +/* |
514 | +** CAPI3REF: OS Interface Open File Handle {H11110} <S20110> | | 514 | +** CAPI3REF: OS Interface Open File Handle {H11110} <S20110> |
515 | +** | | 515 | +** |
516 | +** An [sqlite3_file] object represents an open file in the | | 516 | +** An [sqlite3_file] object represents an open file in the |
517 | +** [sqlite3_vfs | OS interface layer]. Individual OS interface | | 517 | +** [sqlite3_vfs | OS interface layer]. Individual OS interface |
518 | +** implementations will | | 518 | +** implementations will |
519 | +** want to subclass this object by appending additional fields | | 519 | +** want to subclass this object by appending additional fields |
520 | +** for their own use. The pMethods entry is a pointer to an | | 520 | +** for their own use. The pMethods entry is a pointer to an |
521 | +** [sqlite3_io_methods] object that defines methods for performing | | 521 | +** [sqlite3_io_methods] object that defines methods for performing |
522 | +** I/O operations on the open file. | | 522 | +** I/O operations on the open file. |
523 | +*/ | | 523 | +*/ |
524 | +typedef struct sqlite3_file sqlite3_file; | | 524 | +typedef struct sqlite3_file sqlite3_file; |
525 | +struct sqlite3_file { | | 525 | +struct sqlite3_file { |
526 | + const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ | | 526 | + const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ |
527 | +}; | | 527 | +}; |
528 | + | | 528 | + |
529 | +/* | | 529 | +/* |
530 | +** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110> | | 530 | +** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110> |
531 | +** | | 531 | +** |
532 | +** Every file opened by the [sqlite3_vfs] xOpen method populates an | | 532 | +** Every file opened by the [sqlite3_vfs] xOpen method populates an |
533 | +** [sqlite3_file] object (or, more commonly, a subclass of the | | 533 | +** [sqlite3_file] object (or, more commonly, a subclass of the |
534 | +** [sqlite3_file] object) with a pointer to an instance of this object. | | 534 | +** [sqlite3_file] object) with a pointer to an instance of this object. |
535 | +** This object defines the methods used to perform various operations | | 535 | +** This object defines the methods used to perform various operations |
536 | +** against the open file represented by the [sqlite3_file] object. | | 536 | +** against the open file represented by the [sqlite3_file] object. |
537 | +** | | 537 | +** |
538 | +** If the xOpen method sets the sqlite3_file.pMethods element | | 538 | +** If the xOpen method sets the sqlite3_file.pMethods element |
539 | +** to a non-NULL pointer, then the sqlite3_io_methods.xClose method | | 539 | +** to a non-NULL pointer, then the sqlite3_io_methods.xClose method |
540 | +** may be invoked even if the xOpen reported that it failed. The | | 540 | +** may be invoked even if the xOpen reported that it failed. The |
541 | +** only way to prevent a call to xClose following a failed xOpen | | 541 | +** only way to prevent a call to xClose following a failed xOpen |
542 | +** is for the xOpen to set the sqlite3_file.pMethods element to NULL. | | 542 | +** is for the xOpen to set the sqlite3_file.pMethods element to NULL. |
543 | +** | | 543 | +** |
544 | +** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or | | 544 | +** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or |
545 | +** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). | | 545 | +** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). |
546 | +** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] | | 546 | +** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] |
547 | +** flag may be ORed in to indicate that only the data of the file | | 547 | +** flag may be ORed in to indicate that only the data of the file |
548 | +** and not its inode needs to be synced. | | 548 | +** and not its inode needs to be synced. |
549 | +** | | 549 | +** |
550 | +** The integer values to xLock() and xUnlock() are one of | | 550 | +** The integer values to xLock() and xUnlock() are one of |
551 | +** <ul> | | 551 | +** <ul> |
552 | +** <li> [SQLITE_LOCK_NONE], | | 552 | +** <li> [SQLITE_LOCK_NONE], |
553 | +** <li> [SQLITE_LOCK_SHARED], | | 553 | +** <li> [SQLITE_LOCK_SHARED], |
554 | +** <li> [SQLITE_LOCK_RESERVED], | | 554 | +** <li> [SQLITE_LOCK_RESERVED], |
555 | +** <li> [SQLITE_LOCK_PENDING], or | | 555 | +** <li> [SQLITE_LOCK_PENDING], or |
556 | +** <li> [SQLITE_LOCK_EXCLUSIVE]. | | 556 | +** <li> [SQLITE_LOCK_EXCLUSIVE]. |
557 | +** </ul> | | 557 | +** </ul> |
558 | +** xLock() increases the lock. xUnlock() decreases the lock. | | 558 | +** xLock() increases the lock. xUnlock() decreases the lock. |
559 | +** The xCheckReservedLock() method checks whether any database connection, | | 559 | +** The xCheckReservedLock() method checks whether any database connection, |
560 | +** either in this process or in some other process, is holding a RESERVED, | | 560 | +** either in this process or in some other process, is holding a RESERVED, |
561 | +** PENDING, or EXCLUSIVE lock on the file. It returns true | | 561 | +** PENDING, or EXCLUSIVE lock on the file. It returns true |
562 | +** if such a lock exists and false otherwise. | | 562 | +** if such a lock exists and false otherwise. |
563 | +** | | 563 | +** |
564 | +** The xFileControl() method is a generic interface that allows custom | | 564 | +** The xFileControl() method is a generic interface that allows custom |
565 | +** VFS implementations to directly control an open file using the | | 565 | +** VFS implementations to directly control an open file using the |
566 | +** [sqlite3_file_control()] interface. The second "op" argument is an | | 566 | +** [sqlite3_file_control()] interface. The second "op" argument is an |
567 | +** integer opcode. The third argument is a generic pointer intended to | | 567 | +** integer opcode. The third argument is a generic pointer intended to |
568 | +** point to a structure that may contain arguments or space in which to | | 568 | +** point to a structure that may contain arguments or space in which to |
569 | +** write return values. Potential uses for xFileControl() might be | | 569 | +** write return values. Potential uses for xFileControl() might be |
570 | +** functions to enable blocking locks with timeouts, to change the | | 570 | +** functions to enable blocking locks with timeouts, to change the |
571 | +** locking strategy (for example to use dot-file locks), to inquire | | 571 | +** locking strategy (for example to use dot-file locks), to inquire |
572 | +** about the status of a lock, or to break stale locks. The SQLite | | 572 | +** about the status of a lock, or to break stale locks. The SQLite |
573 | +** core reserves all opcodes less than 100 for its own use. | | 573 | +** core reserves all opcodes less than 100 for its own use. |
574 | +** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. | | 574 | +** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. |
575 | +** Applications that define a custom xFileControl method should use opcodes | | 575 | +** Applications that define a custom xFileControl method should use opcodes |
576 | +** greater than 100 to avoid conflicts. | | 576 | +** greater than 100 to avoid conflicts. |
577 | +** | | 577 | +** |
578 | +** The xSectorSize() method returns the sector size of the | | 578 | +** The xSectorSize() method returns the sector size of the |
579 | +** device that underlies the file. The sector size is the | | 579 | +** device that underlies the file. The sector size is the |
580 | +** minimum write that can be performed without disturbing | | 580 | +** minimum write that can be performed without disturbing |
581 | +** other bytes in the file. The xDeviceCharacteristics() | | 581 | +** other bytes in the file. The xDeviceCharacteristics() |
582 | +** method returns a bit vector describing behaviors of the | | 582 | +** method returns a bit vector describing behaviors of the |
583 | +** underlying device: | | 583 | +** underlying device: |
584 | +** | | 584 | +** |
585 | +** <ul> | | 585 | +** <ul> |
586 | +** <li> [SQLITE_IOCAP_ATOMIC] | | 586 | +** <li> [SQLITE_IOCAP_ATOMIC] |
587 | +** <li> [SQLITE_IOCAP_ATOMIC512] | | 587 | +** <li> [SQLITE_IOCAP_ATOMIC512] |
588 | +** <li> [SQLITE_IOCAP_ATOMIC1K] | | 588 | +** <li> [SQLITE_IOCAP_ATOMIC1K] |
589 | +** <li> [SQLITE_IOCAP_ATOMIC2K] | | 589 | +** <li> [SQLITE_IOCAP_ATOMIC2K] |
590 | +** <li> [SQLITE_IOCAP_ATOMIC4K] | | 590 | +** <li> [SQLITE_IOCAP_ATOMIC4K] |
591 | +** <li> [SQLITE_IOCAP_ATOMIC8K] | | 591 | +** <li> [SQLITE_IOCAP_ATOMIC8K] |
592 | +** <li> [SQLITE_IOCAP_ATOMIC16K] | | 592 | +** <li> [SQLITE_IOCAP_ATOMIC16K] |
593 | +** <li> [SQLITE_IOCAP_ATOMIC32K] | | 593 | +** <li> [SQLITE_IOCAP_ATOMIC32K] |
594 | +** <li> [SQLITE_IOCAP_ATOMIC64K] | | 594 | +** <li> [SQLITE_IOCAP_ATOMIC64K] |
595 | +** <li> [SQLITE_IOCAP_SAFE_APPEND] | | 595 | +** <li> [SQLITE_IOCAP_SAFE_APPEND] |
596 | +** <li> [SQLITE_IOCAP_SEQUENTIAL] | | 596 | +** <li> [SQLITE_IOCAP_SEQUENTIAL] |
597 | +** </ul> | | 597 | +** </ul> |
598 | +** | | 598 | +** |
599 | +** The SQLITE_IOCAP_ATOMIC property means that all writes of | | 599 | +** The SQLITE_IOCAP_ATOMIC property means that all writes of |
600 | +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values | | 600 | +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values |
601 | +** mean that writes of blocks that are nnn bytes in size and | | 601 | +** mean that writes of blocks that are nnn bytes in size and |
602 | +** are aligned to an address which is an integer multiple of | | 602 | +** are aligned to an address which is an integer multiple of |
603 | +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means | | 603 | +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means |
604 | +** that when data is appended to a file, the data is appended | | 604 | +** that when data is appended to a file, the data is appended |
605 | +** first then the size of the file is extended, never the other | | 605 | +** first then the size of the file is extended, never the other |
606 | +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that | | 606 | +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
607 | +** information is written to disk in the same order as calls | | 607 | +** information is written to disk in the same order as calls |
608 | +** to xWrite(). | | 608 | +** to xWrite(). |
609 | +** | | 609 | +** |
610 | +** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill | | 610 | +** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill |
611 | +** in the unread portions of the buffer with zeros. A VFS that | | 611 | +** in the unread portions of the buffer with zeros. A VFS that |
612 | +** fails to zero-fill short reads might seem to work. However, | | 612 | +** fails to zero-fill short reads might seem to work. However, |
613 | +** failure to zero-fill short reads will eventually lead to | | 613 | +** failure to zero-fill short reads will eventually lead to |
614 | +** database corruption. | | 614 | +** database corruption. |
615 | +*/ | | 615 | +*/ |
616 | +typedef struct sqlite3_io_methods sqlite3_io_methods; | | 616 | +typedef struct sqlite3_io_methods sqlite3_io_methods; |
617 | +struct sqlite3_io_methods { | | 617 | +struct sqlite3_io_methods { |
618 | + int iVersion; | | 618 | + int iVersion; |
619 | + int (*xClose)(sqlite3_file*); | | 619 | + int (*xClose)(sqlite3_file*); |
620 | + int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); | | 620 | + int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); |
621 | + int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); | | 621 | + int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); |
622 | + int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); | | 622 | + int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); |
623 | + int (*xSync)(sqlite3_file*, int flags); | | 623 | + int (*xSync)(sqlite3_file*, int flags); |
624 | + int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); | | 624 | + int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); |
625 | + int (*xLock)(sqlite3_file*, int); | | 625 | + int (*xLock)(sqlite3_file*, int); |
626 | + int (*xUnlock)(sqlite3_file*, int); | | 626 | + int (*xUnlock)(sqlite3_file*, int); |
627 | + int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); | | 627 | + int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); |
628 | + int (*xFileControl)(sqlite3_file*, int op, void *pArg); | | 628 | + int (*xFileControl)(sqlite3_file*, int op, void *pArg); |
629 | + int (*xSectorSize)(sqlite3_file*); | | 629 | + int (*xSectorSize)(sqlite3_file*); |
630 | + int (*xDeviceCharacteristics)(sqlite3_file*); | | 630 | + int (*xDeviceCharacteristics)(sqlite3_file*); |
631 | + /* Additional methods may be added in future releases */ | | 631 | + /* Additional methods may be added in future releases */ |
632 | +}; | | 632 | +}; |
633 | + | | 633 | + |
634 | +/* | | 634 | +/* |
635 | +** CAPI3REF: Standard File Control Opcodes {H11310} <S30800> | | 635 | +** CAPI3REF: Standard File Control Opcodes {H11310} <S30800> |
636 | +** | | 636 | +** |
637 | +** These integer constants are opcodes for the xFileControl method | | 637 | +** These integer constants are opcodes for the xFileControl method |
638 | +** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] | | 638 | +** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] |
639 | +** interface. | | 639 | +** interface. |
640 | +** | | 640 | +** |
641 | +** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This | | 641 | +** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This |
642 | +** opcode causes the xFileControl method to write the current state of | | 642 | +** opcode causes the xFileControl method to write the current state of |
643 | +** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], | | 643 | +** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], |
644 | +** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) | | 644 | +** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) |
645 | +** into an integer that the pArg argument points to. This capability | | 645 | +** into an integer that the pArg argument points to. This capability |
646 | +** is used during testing and only needs to be supported when SQLITE_TEST | | 646 | +** is used during testing and only needs to be supported when SQLITE_TEST |
647 | +** is defined. | | 647 | +** is defined. |
648 | +*/ | | 648 | +*/ |
649 | +#define SQLITE_FCNTL_LOCKSTATE 1 | | 649 | +#define SQLITE_FCNTL_LOCKSTATE 1 |
650 | +#define SQLITE_GET_LOCKPROXYFILE 2 | | 650 | +#define SQLITE_GET_LOCKPROXYFILE 2 |
651 | +#define SQLITE_SET_LOCKPROXYFILE 3 | | 651 | +#define SQLITE_SET_LOCKPROXYFILE 3 |
652 | +#define SQLITE_LAST_ERRNO 4 | | 652 | +#define SQLITE_LAST_ERRNO 4 |
653 | + | | 653 | + |
654 | +/* | | 654 | +/* |
655 | +** CAPI3REF: Mutex Handle {H17110} <S20130> | | 655 | +** CAPI3REF: Mutex Handle {H17110} <S20130> |
656 | +** | | 656 | +** |
657 | +** The mutex module within SQLite defines [sqlite3_mutex] to be an | | 657 | +** The mutex module within SQLite defines [sqlite3_mutex] to be an |
658 | +** abstract type for a mutex object. The SQLite core never looks | | 658 | +** abstract type for a mutex object. The SQLite core never looks |
659 | +** at the internal representation of an [sqlite3_mutex]. It only | | 659 | +** at the internal representation of an [sqlite3_mutex]. It only |
660 | +** deals with pointers to the [sqlite3_mutex] object. | | 660 | +** deals with pointers to the [sqlite3_mutex] object. |
661 | +** | | 661 | +** |
662 | +** Mutexes are created using [sqlite3_mutex_alloc()]. | | 662 | +** Mutexes are created using [sqlite3_mutex_alloc()]. |
663 | +*/ | | 663 | +*/ |
664 | +typedef struct sqlite3_mutex sqlite3_mutex; | | 664 | +typedef struct sqlite3_mutex sqlite3_mutex; |
665 | + | | 665 | + |
666 | +/* | | 666 | +/* |
667 | +** CAPI3REF: OS Interface Object {H11140} <S20100> | | 667 | +** CAPI3REF: OS Interface Object {H11140} <S20100> |
668 | +** | | 668 | +** |
669 | +** An instance of the sqlite3_vfs object defines the interface between | | 669 | +** An instance of the sqlite3_vfs object defines the interface between |
670 | +** the SQLite core and the underlying operating system. The "vfs" | | 670 | +** the SQLite core and the underlying operating system. The "vfs" |
671 | +** in the name of the object stands for "virtual file system". | | 671 | +** in the name of the object stands for "virtual file system". |
672 | +** | | 672 | +** |
673 | +** The value of the iVersion field is initially 1 but may be larger in | | 673 | +** The value of the iVersion field is initially 1 but may be larger in |
674 | +** future versions of SQLite. Additional fields may be appended to this | | 674 | +** future versions of SQLite. Additional fields may be appended to this |
675 | +** object when the iVersion value is increased. Note that the structure | | 675 | +** object when the iVersion value is increased. Note that the structure |
676 | +** of the sqlite3_vfs object changes in the transaction between | | 676 | +** of the sqlite3_vfs object changes in the transaction between |
677 | +** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not | | 677 | +** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not |
678 | +** modified. | | 678 | +** modified. |
679 | +** | | 679 | +** |
680 | +** The szOsFile field is the size of the subclassed [sqlite3_file] | | 680 | +** The szOsFile field is the size of the subclassed [sqlite3_file] |
681 | +** structure used by this VFS. mxPathname is the maximum length of | | 681 | +** structure used by this VFS. mxPathname is the maximum length of |
682 | +** a pathname in this VFS. | | 682 | +** a pathname in this VFS. |
683 | +** | | 683 | +** |
684 | +** Registered sqlite3_vfs objects are kept on a linked list formed by | | 684 | +** Registered sqlite3_vfs objects are kept on a linked list formed by |
685 | +** the pNext pointer. The [sqlite3_vfs_register()] | | 685 | +** the pNext pointer. The [sqlite3_vfs_register()] |
686 | +** and [sqlite3_vfs_unregister()] interfaces manage this list | | 686 | +** and [sqlite3_vfs_unregister()] interfaces manage this list |
687 | +** in a thread-safe way. The [sqlite3_vfs_find()] interface | | 687 | +** in a thread-safe way. The [sqlite3_vfs_find()] interface |
688 | +** searches the list. Neither the application code nor the VFS | | 688 | +** searches the list. Neither the application code nor the VFS |
689 | +** implementation should use the pNext pointer. | | 689 | +** implementation should use the pNext pointer. |
690 | +** | | 690 | +** |
691 | +** The pNext field is the only field in the sqlite3_vfs | | 691 | +** The pNext field is the only field in the sqlite3_vfs |
692 | +** structure that SQLite will ever modify. SQLite will only access | | 692 | +** structure that SQLite will ever modify. SQLite will only access |
693 | +** or modify this field while holding a particular static mutex. | | 693 | +** or modify this field while holding a particular static mutex. |
694 | +** The application should never modify anything within the sqlite3_vfs | | 694 | +** The application should never modify anything within the sqlite3_vfs |
695 | +** object once the object has been registered. | | 695 | +** object once the object has been registered. |
696 | +** | | 696 | +** |
697 | +** The zName field holds the name of the VFS module. The name must | | 697 | +** The zName field holds the name of the VFS module. The name must |
698 | +** be unique across all VFS modules. | | 698 | +** be unique across all VFS modules. |
699 | +** | | 699 | +** |
700 | +** SQLite will guarantee that the zFilename parameter to xOpen | | 700 | +** SQLite will guarantee that the zFilename parameter to xOpen |
701 | +** is either a NULL pointer or string obtained | | 701 | +** is either a NULL pointer or string obtained |
702 | +** from xFullPathname(). SQLite further guarantees that | | 702 | +** from xFullPathname(). SQLite further guarantees that |
703 | +** the string will be valid and unchanged until xClose() is | | 703 | +** the string will be valid and unchanged until xClose() is |
704 | +** called. Because of the previous sentence, | | 704 | +** called. Because of the previous sentence, |
705 | +** the [sqlite3_file] can safely store a pointer to the | | 705 | +** the [sqlite3_file] can safely store a pointer to the |
706 | +** filename if it needs to remember the filename for some reason. | | 706 | +** filename if it needs to remember the filename for some reason. |
707 | +** If the zFilename parameter is xOpen is a NULL pointer then xOpen | | 707 | +** If the zFilename parameter is xOpen is a NULL pointer then xOpen |
708 | +** must invent its own temporary name for the file. Whenever the | | 708 | +** must invent its own temporary name for the file. Whenever the |
709 | +** xFilename parameter is NULL it will also be the case that the | | 709 | +** xFilename parameter is NULL it will also be the case that the |
710 | +** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. | | 710 | +** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. |
711 | +** | | 711 | +** |
712 | +** The flags argument to xOpen() includes all bits set in | | 712 | +** The flags argument to xOpen() includes all bits set in |
713 | +** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] | | 713 | +** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] |
714 | +** or [sqlite3_open16()] is used, then flags includes at least | | 714 | +** or [sqlite3_open16()] is used, then flags includes at least |
715 | +** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. | | 715 | +** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. |
716 | +** If xOpen() opens a file read-only then it sets *pOutFlags to | | 716 | +** If xOpen() opens a file read-only then it sets *pOutFlags to |
717 | +** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. | | 717 | +** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. |
718 | +** | | 718 | +** |
719 | +** SQLite will also add one of the following flags to the xOpen() | | 719 | +** SQLite will also add one of the following flags to the xOpen() |
720 | +** call, depending on the object being opened: | | 720 | +** call, depending on the object being opened: |
721 | +** | | 721 | +** |
722 | +** <ul> | | 722 | +** <ul> |
723 | +** <li> [SQLITE_OPEN_MAIN_DB] | | 723 | +** <li> [SQLITE_OPEN_MAIN_DB] |
724 | +** <li> [SQLITE_OPEN_MAIN_JOURNAL] | | 724 | +** <li> [SQLITE_OPEN_MAIN_JOURNAL] |
725 | +** <li> [SQLITE_OPEN_TEMP_DB] | | 725 | +** <li> [SQLITE_OPEN_TEMP_DB] |
726 | +** <li> [SQLITE_OPEN_TEMP_JOURNAL] | | 726 | +** <li> [SQLITE_OPEN_TEMP_JOURNAL] |
727 | +** <li> [SQLITE_OPEN_TRANSIENT_DB] | | 727 | +** <li> [SQLITE_OPEN_TRANSIENT_DB] |
728 | +** <li> [SQLITE_OPEN_SUBJOURNAL] | | 728 | +** <li> [SQLITE_OPEN_SUBJOURNAL] |
729 | +** <li> [SQLITE_OPEN_MASTER_JOURNAL] | | 729 | +** <li> [SQLITE_OPEN_MASTER_JOURNAL] |
730 | +** </ul> | | 730 | +** </ul> |
731 | +** | | 731 | +** |
732 | +** The file I/O implementation can use the object type flags to | | 732 | +** The file I/O implementation can use the object type flags to |
733 | +** change the way it deals with files. For example, an application | | 733 | +** change the way it deals with files. For example, an application |
734 | +** that does not care about crash recovery or rollback might make | | 734 | +** that does not care about crash recovery or rollback might make |
735 | +** the open of a journal file a no-op. Writes to this journal would | | 735 | +** the open of a journal file a no-op. Writes to this journal would |
736 | +** also be no-ops, and any attempt to read the journal would return | | 736 | +** also be no-ops, and any attempt to read the journal would return |
737 | +** SQLITE_IOERR. Or the implementation might recognize that a database | | 737 | +** SQLITE_IOERR. Or the implementation might recognize that a database |
738 | +** file will be doing page-aligned sector reads and writes in a random | | 738 | +** file will be doing page-aligned sector reads and writes in a random |
739 | +** order and set up its I/O subsystem accordingly. | | 739 | +** order and set up its I/O subsystem accordingly. |
740 | +** | | 740 | +** |
741 | +** SQLite might also add one of the following flags to the xOpen method: | | 741 | +** SQLite might also add one of the following flags to the xOpen method: |
742 | +** | | 742 | +** |
743 | +** <ul> | | 743 | +** <ul> |
744 | +** <li> [SQLITE_OPEN_DELETEONCLOSE] | | 744 | +** <li> [SQLITE_OPEN_DELETEONCLOSE] |
745 | +** <li> [SQLITE_OPEN_EXCLUSIVE] | | 745 | +** <li> [SQLITE_OPEN_EXCLUSIVE] |
746 | +** </ul> | | 746 | +** </ul> |
747 | +** | | 747 | +** |
748 | +** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be | | 748 | +** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be |
749 | +** deleted when it is closed. The [SQLITE_OPEN_DELETEONCLOSE] | | 749 | +** deleted when it is closed. The [SQLITE_OPEN_DELETEONCLOSE] |
750 | +** will be set for TEMP databases, journals and for subjournals. | | 750 | +** will be set for TEMP databases, journals and for subjournals. |
751 | +** | | 751 | +** |
752 | +** The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction | | 752 | +** The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction |
753 | +** with the [SQLITE_OPEN_CREATE] flag, which are both directly | | 753 | +** with the [SQLITE_OPEN_CREATE] flag, which are both directly |
754 | +** analogous to the O_EXCL and O_CREAT flags of the POSIX open() | | 754 | +** analogous to the O_EXCL and O_CREAT flags of the POSIX open() |
755 | +** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the | | 755 | +** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the |
756 | +** SQLITE_OPEN_CREATE, is used to indicate that file should always | | 756 | +** SQLITE_OPEN_CREATE, is used to indicate that file should always |
757 | +** be created, and that it is an error if it already exists. | | 757 | +** be created, and that it is an error if it already exists. |
758 | +** It is <i>not</i> used to indicate the file should be opened | | 758 | +** It is <i>not</i> used to indicate the file should be opened |
759 | +** for exclusive access. | | 759 | +** for exclusive access. |
760 | +** | | 760 | +** |
761 | +** At least szOsFile bytes of memory are allocated by SQLite | | 761 | +** At least szOsFile bytes of memory are allocated by SQLite |
762 | +** to hold the [sqlite3_file] structure passed as the third | | 762 | +** to hold the [sqlite3_file] structure passed as the third |
763 | +** argument to xOpen. The xOpen method does not have to | | 763 | +** argument to xOpen. The xOpen method does not have to |
764 | +** allocate the structure; it should just fill it in. Note that | | 764 | +** allocate the structure; it should just fill it in. Note that |
765 | +** the xOpen method must set the sqlite3_file.pMethods to either | | 765 | +** the xOpen method must set the sqlite3_file.pMethods to either |
766 | +** a valid [sqlite3_io_methods] object or to NULL. xOpen must do | | 766 | +** a valid [sqlite3_io_methods] object or to NULL. xOpen must do |
767 | +** this even if the open fails. SQLite expects that the sqlite3_file.pMethods | | 767 | +** this even if the open fails. SQLite expects that the sqlite3_file.pMethods |
768 | +** element will be valid after xOpen returns regardless of the success | | 768 | +** element will be valid after xOpen returns regardless of the success |
769 | +** or failure of the xOpen call. | | 769 | +** or failure of the xOpen call. |
770 | +** | | 770 | +** |
771 | +** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] | | 771 | +** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] |
772 | +** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to | | 772 | +** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to |
773 | +** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] | | 773 | +** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] |
774 | +** to test whether a file is at least readable. The file can be a | | 774 | +** to test whether a file is at least readable. The file can be a |
775 | +** directory. | | 775 | +** directory. |
776 | +** | | 776 | +** |
777 | +** SQLite will always allocate at least mxPathname+1 bytes for the | | 777 | +** SQLite will always allocate at least mxPathname+1 bytes for the |
778 | +** output buffer xFullPathname. The exact size of the output buffer | | 778 | +** output buffer xFullPathname. The exact size of the output buffer |
779 | +** is also passed as a parameter to both methods. If the output buffer | | 779 | +** is also passed as a parameter to both methods. If the output buffer |
780 | +** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is | | 780 | +** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is |
781 | +** handled as a fatal error by SQLite, vfs implementations should endeavor | | 781 | +** handled as a fatal error by SQLite, vfs implementations should endeavor |
782 | +** to prevent this by setting mxPathname to a sufficiently large value. | | 782 | +** to prevent this by setting mxPathname to a sufficiently large value. |
783 | +** | | 783 | +** |
784 | +** The xRandomness(), xSleep(), and xCurrentTime() interfaces | | 784 | +** The xRandomness(), xSleep(), and xCurrentTime() interfaces |
785 | +** are not strictly a part of the filesystem, but they are | | 785 | +** are not strictly a part of the filesystem, but they are |
786 | +** included in the VFS structure for completeness. | | 786 | +** included in the VFS structure for completeness. |
787 | +** The xRandomness() function attempts to return nBytes bytes | | 787 | +** The xRandomness() function attempts to return nBytes bytes |
788 | +** of good-quality randomness into zOut. The return value is | | 788 | +** of good-quality randomness into zOut. The return value is |
789 | +** the actual number of bytes of randomness obtained. | | 789 | +** the actual number of bytes of randomness obtained. |
790 | +** The xSleep() method causes the calling thread to sleep for at | | 790 | +** The xSleep() method causes the calling thread to sleep for at |
791 | +** least the number of microseconds given. The xCurrentTime() | | 791 | +** least the number of microseconds given. The xCurrentTime() |
792 | +** method returns a Julian Day Number for the current date and time. | | 792 | +** method returns a Julian Day Number for the current date and time. |
793 | +** | | 793 | +** |
794 | +*/ | | 794 | +*/ |
795 | +typedef struct sqlite3_vfs sqlite3_vfs; | | 795 | +typedef struct sqlite3_vfs sqlite3_vfs; |
796 | +struct sqlite3_vfs { | | 796 | +struct sqlite3_vfs { |
797 | + int iVersion; /* Structure version number */ | | 797 | + int iVersion; /* Structure version number */ |
798 | + int szOsFile; /* Size of subclassed sqlite3_file */ | | 798 | + int szOsFile; /* Size of subclassed sqlite3_file */ |
799 | + int mxPathname; /* Maximum file pathname length */ | | 799 | + int mxPathname; /* Maximum file pathname length */ |
800 | + sqlite3_vfs *pNext; /* Next registered VFS */ | | 800 | + sqlite3_vfs *pNext; /* Next registered VFS */ |
801 | + const char *zName; /* Name of this virtual file system */ | | 801 | + const char *zName; /* Name of this virtual file system */ |
802 | + void *pAppData; /* Pointer to application-specific data */ | | 802 | + void *pAppData; /* Pointer to application-specific data */ |
803 | + int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, | | 803 | + int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, |
804 | + int flags, int *pOutFlags); | | 804 | + int flags, int *pOutFlags); |
805 | + int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); | | 805 | + int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); |
806 | + int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); | | 806 | + int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); |
807 | + int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); | | 807 | + int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); |
808 | + void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); | | 808 | + void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); |
809 | + void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); | | 809 | + void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); |
810 | + void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); | | 810 | + void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); |
811 | + void (*xDlClose)(sqlite3_vfs*, void*); | | 811 | + void (*xDlClose)(sqlite3_vfs*, void*); |
812 | + int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); | | 812 | + int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); |
813 | + int (*xSleep)(sqlite3_vfs*, int microseconds); | | 813 | + int (*xSleep)(sqlite3_vfs*, int microseconds); |
814 | + int (*xCurrentTime)(sqlite3_vfs*, double*); | | 814 | + int (*xCurrentTime)(sqlite3_vfs*, double*); |
815 | + int (*xGetLastError)(sqlite3_vfs*, int, char *); | | 815 | + int (*xGetLastError)(sqlite3_vfs*, int, char *); |
816 | + /* New fields may be appended in figure versions. The iVersion | | 816 | + /* New fields may be appended in figure versions. The iVersion |
817 | + ** value will increment whenever this happens. */ | | 817 | + ** value will increment whenever this happens. */ |
818 | +}; | | 818 | +}; |
819 | + | | 819 | + |
820 | +/* | | 820 | +/* |
821 | +** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140> | | 821 | +** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140> |
822 | +** | | 822 | +** |
823 | +** These integer constants can be used as the third parameter to | | 823 | +** These integer constants can be used as the third parameter to |
824 | +** the xAccess method of an [sqlite3_vfs] object. {END} They determine | | 824 | +** the xAccess method of an [sqlite3_vfs] object. {END} They determine |
825 | +** what kind of permissions the xAccess method is looking for. | | 825 | +** what kind of permissions the xAccess method is looking for. |
826 | +** With SQLITE_ACCESS_EXISTS, the xAccess method | | 826 | +** With SQLITE_ACCESS_EXISTS, the xAccess method |
827 | +** simply checks whether the file exists. | | 827 | +** simply checks whether the file exists. |
828 | +** With SQLITE_ACCESS_READWRITE, the xAccess method | | 828 | +** With SQLITE_ACCESS_READWRITE, the xAccess method |
829 | +** checks whether the file is both readable and writable. | | 829 | +** checks whether the file is both readable and writable. |
830 | +** With SQLITE_ACCESS_READ, the xAccess method | | 830 | +** With SQLITE_ACCESS_READ, the xAccess method |
831 | +** checks whether the file is readable. | | 831 | +** checks whether the file is readable. |
832 | +*/ | | 832 | +*/ |
833 | +#define SQLITE_ACCESS_EXISTS 0 | | 833 | +#define SQLITE_ACCESS_EXISTS 0 |
834 | +#define SQLITE_ACCESS_READWRITE 1 | | 834 | +#define SQLITE_ACCESS_READWRITE 1 |
835 | +#define SQLITE_ACCESS_READ 2 | | 835 | +#define SQLITE_ACCESS_READ 2 |
836 | + | | 836 | + |
837 | +/* | | 837 | +/* |
838 | +** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100> | | 838 | +** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100> |
839 | +** | | 839 | +** |
840 | +** The sqlite3_initialize() routine initializes the | | 840 | +** The sqlite3_initialize() routine initializes the |
841 | +** SQLite library. The sqlite3_shutdown() routine | | 841 | +** SQLite library. The sqlite3_shutdown() routine |
842 | +** deallocates any resources that were allocated by sqlite3_initialize(). | | 842 | +** deallocates any resources that were allocated by sqlite3_initialize(). |
843 | +** | | 843 | +** |
844 | +** A call to sqlite3_initialize() is an "effective" call if it is | | 844 | +** A call to sqlite3_initialize() is an "effective" call if it is |
845 | +** the first time sqlite3_initialize() is invoked during the lifetime of | | 845 | +** the first time sqlite3_initialize() is invoked during the lifetime of |
846 | +** the process, or if it is the first time sqlite3_initialize() is invoked | | 846 | +** the process, or if it is the first time sqlite3_initialize() is invoked |
847 | +** following a call to sqlite3_shutdown(). Only an effective call | | 847 | +** following a call to sqlite3_shutdown(). Only an effective call |
848 | +** of sqlite3_initialize() does any initialization. All other calls | | 848 | +** of sqlite3_initialize() does any initialization. All other calls |
849 | +** are harmless no-ops. | | 849 | +** are harmless no-ops. |
850 | +** | | 850 | +** |
851 | +** A call to sqlite3_shutdown() is an "effective" call if it is the first | | 851 | +** A call to sqlite3_shutdown() is an "effective" call if it is the first |
852 | +** call to sqlite3_shutdown() since the last sqlite3_initialize(). Only | | 852 | +** call to sqlite3_shutdown() since the last sqlite3_initialize(). Only |
853 | +** an effective call to sqlite3_shutdown() does any deinitialization. | | 853 | +** an effective call to sqlite3_shutdown() does any deinitialization. |
854 | +** All other calls to sqlite3_shutdown() are harmless no-ops. | | 854 | +** All other calls to sqlite3_shutdown() are harmless no-ops. |
855 | +** | | 855 | +** |
856 | +** Among other things, sqlite3_initialize() shall invoke | | 856 | +** Among other things, sqlite3_initialize() shall invoke |
857 | +** sqlite3_os_init(). Similarly, sqlite3_shutdown() | | 857 | +** sqlite3_os_init(). Similarly, sqlite3_shutdown() |
858 | +** shall invoke sqlite3_os_end(). | | 858 | +** shall invoke sqlite3_os_end(). |
859 | +** | | 859 | +** |
860 | +** The sqlite3_initialize() routine returns [SQLITE_OK] on success. | | 860 | +** The sqlite3_initialize() routine returns [SQLITE_OK] on success. |
861 | +** If for some reason, sqlite3_initialize() is unable to initialize | | 861 | +** If for some reason, sqlite3_initialize() is unable to initialize |
862 | +** the library (perhaps it is unable to allocate a needed resource such | | 862 | +** the library (perhaps it is unable to allocate a needed resource such |
863 | +** as a mutex) it returns an [error code] other than [SQLITE_OK]. | | 863 | +** as a mutex) it returns an [error code] other than [SQLITE_OK]. |
864 | +** | | 864 | +** |
865 | +** The sqlite3_initialize() routine is called internally by many other | | 865 | +** The sqlite3_initialize() routine is called internally by many other |
866 | +** SQLite interfaces so that an application usually does not need to | | 866 | +** SQLite interfaces so that an application usually does not need to |
867 | +** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] | | 867 | +** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] |
868 | +** calls sqlite3_initialize() so the SQLite library will be automatically | | 868 | +** calls sqlite3_initialize() so the SQLite library will be automatically |
869 | +** initialized when [sqlite3_open()] is called if it has not be initialized | | 869 | +** initialized when [sqlite3_open()] is called if it has not be initialized |
870 | +** already. However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] | | 870 | +** already. However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] |
871 | +** compile-time option, then the automatic calls to sqlite3_initialize() | | 871 | +** compile-time option, then the automatic calls to sqlite3_initialize() |
872 | +** are omitted and the application must call sqlite3_initialize() directly | | 872 | +** are omitted and the application must call sqlite3_initialize() directly |
873 | +** prior to using any other SQLite interface. For maximum portability, | | 873 | +** prior to using any other SQLite interface. For maximum portability, |
874 | +** it is recommended that applications always invoke sqlite3_initialize() | | 874 | +** it is recommended that applications always invoke sqlite3_initialize() |
875 | +** directly prior to using any other SQLite interface. Future releases | | 875 | +** directly prior to using any other SQLite interface. Future releases |
876 | +** of SQLite may require this. In other words, the behavior exhibited | | 876 | +** of SQLite may require this. In other words, the behavior exhibited |
877 | +** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the | | 877 | +** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the |
878 | +** default behavior in some future release of SQLite. | | 878 | +** default behavior in some future release of SQLite. |
879 | +** | | 879 | +** |
880 | +** The sqlite3_os_init() routine does operating-system specific | | 880 | +** The sqlite3_os_init() routine does operating-system specific |
881 | +** initialization of the SQLite library. The sqlite3_os_end() | | 881 | +** initialization of the SQLite library. The sqlite3_os_end() |
882 | +** routine undoes the effect of sqlite3_os_init(). Typical tasks | | 882 | +** routine undoes the effect of sqlite3_os_init(). Typical tasks |
883 | +** performed by these routines include allocation or deallocation | | 883 | +** performed by these routines include allocation or deallocation |
884 | +** of static resources, initialization of global variables, | | 884 | +** of static resources, initialization of global variables, |
885 | +** setting up a default [sqlite3_vfs] module, or setting up | | 885 | +** setting up a default [sqlite3_vfs] module, or setting up |
886 | +** a default configuration using [sqlite3_config()]. | | 886 | +** a default configuration using [sqlite3_config()]. |
887 | +** | | 887 | +** |
888 | +** The application should never invoke either sqlite3_os_init() | | 888 | +** The application should never invoke either sqlite3_os_init() |
889 | +** or sqlite3_os_end() directly. The application should only invoke | | 889 | +** or sqlite3_os_end() directly. The application should only invoke |
890 | +** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() | | 890 | +** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() |
891 | +** interface is called automatically by sqlite3_initialize() and | | 891 | +** interface is called automatically by sqlite3_initialize() and |
892 | +** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate | | 892 | +** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate |
893 | +** implementations for sqlite3_os_init() and sqlite3_os_end() | | 893 | +** implementations for sqlite3_os_init() and sqlite3_os_end() |
894 | +** are built into SQLite when it is compiled for Unix, Windows, or OS/2. | | 894 | +** are built into SQLite when it is compiled for Unix, Windows, or OS/2. |
895 | +** When [custom builds | built for other platforms] | | 895 | +** When [custom builds | built for other platforms] |
896 | +** (using the [SQLITE_OS_OTHER=1] compile-time | | 896 | +** (using the [SQLITE_OS_OTHER=1] compile-time |
897 | +** option) the application must supply a suitable implementation for | | 897 | +** option) the application must supply a suitable implementation for |
898 | +** sqlite3_os_init() and sqlite3_os_end(). An application-supplied | | 898 | +** sqlite3_os_init() and sqlite3_os_end(). An application-supplied |
899 | +** implementation of sqlite3_os_init() or sqlite3_os_end() | | 899 | +** implementation of sqlite3_os_init() or sqlite3_os_end() |
900 | +** must return [SQLITE_OK] on success and some other [error code] upon | | 900 | +** must return [SQLITE_OK] on success and some other [error code] upon |
901 | +** failure. | | 901 | +** failure. |
902 | +*/ | | 902 | +*/ |
903 | +SQLITE_API int sqlite3_initialize(void); | | 903 | +SQLITE_API int sqlite3_initialize(void); |
904 | +SQLITE_API int sqlite3_shutdown(void); | | 904 | +SQLITE_API int sqlite3_shutdown(void); |
905 | +SQLITE_API int sqlite3_os_init(void); | | 905 | +SQLITE_API int sqlite3_os_init(void); |
906 | +SQLITE_API int sqlite3_os_end(void); | | 906 | +SQLITE_API int sqlite3_os_end(void); |
907 | + | | 907 | + |
908 | +/* | | 908 | +/* |
909 | +** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200> | | 909 | +** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200> |
910 | +** EXPERIMENTAL | | 910 | +** EXPERIMENTAL |
911 | +** | | 911 | +** |
912 | +** The sqlite3_config() interface is used to make global configuration | | 912 | +** The sqlite3_config() interface is used to make global configuration |
913 | +** changes to SQLite in order to tune SQLite to the specific needs of | | 913 | +** changes to SQLite in order to tune SQLite to the specific needs of |
914 | +** the application. The default configuration is recommended for most | | 914 | +** the application. The default configuration is recommended for most |
915 | +** applications and so this routine is usually not necessary. It is | | 915 | +** applications and so this routine is usually not necessary. It is |
916 | +** provided to support rare applications with unusual needs. | | 916 | +** provided to support rare applications with unusual needs. |
917 | +** | | 917 | +** |
918 | +** The sqlite3_config() interface is not threadsafe. The application | | 918 | +** The sqlite3_config() interface is not threadsafe. The application |
919 | +** must insure that no other SQLite interfaces are invoked by other | | 919 | +** must insure that no other SQLite interfaces are invoked by other |
920 | +** threads while sqlite3_config() is running. Furthermore, sqlite3_config() | | 920 | +** threads while sqlite3_config() is running. Furthermore, sqlite3_config() |
921 | +** may only be invoked prior to library initialization using | | 921 | +** may only be invoked prior to library initialization using |
922 | +** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. | | 922 | +** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. |
923 | +** Note, however, that sqlite3_config() can be called as part of the | | 923 | +** Note, however, that sqlite3_config() can be called as part of the |
924 | +** implementation of an application-defined [sqlite3_os_init()]. | | 924 | +** implementation of an application-defined [sqlite3_os_init()]. |
925 | +** | | 925 | +** |
926 | +** The first argument to sqlite3_config() is an integer | | 926 | +** The first argument to sqlite3_config() is an integer |
927 | +** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines | | 927 | +** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines |
928 | +** what property of SQLite is to be configured. Subsequent arguments | | 928 | +** what property of SQLite is to be configured. Subsequent arguments |
929 | +** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] | | 929 | +** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] |
930 | +** in the first argument. | | 930 | +** in the first argument. |
931 | +** | | 931 | +** |
932 | +** When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. | | 932 | +** When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. |
933 | +** If the option is unknown or SQLite is unable to set the option | | 933 | +** If the option is unknown or SQLite is unable to set the option |
934 | +** then this routine returns a non-zero [error code]. | | 934 | +** then this routine returns a non-zero [error code]. |
935 | +** | | 935 | +** |
936 | +** Requirements: | | 936 | +** Requirements: |
937 | +** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135] | | 937 | +** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135] |
938 | +** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159] | | 938 | +** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159] |
939 | +** [H14162] [H14165] [H14168] | | 939 | +** [H14162] [H14165] [H14168] |
940 | +*/ | | 940 | +*/ |
941 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...); | | 941 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...); |
942 | + | | 942 | + |
943 | +/* | | 943 | +/* |
944 | +** CAPI3REF: Configure database connections {H14200} <S20000> | | 944 | +** CAPI3REF: Configure database connections {H14200} <S20000> |
945 | +** EXPERIMENTAL | | 945 | +** EXPERIMENTAL |
946 | +** | | 946 | +** |
947 | +** The sqlite3_db_config() interface is used to make configuration | | 947 | +** The sqlite3_db_config() interface is used to make configuration |
948 | +** changes to a [database connection]. The interface is similar to | | 948 | +** changes to a [database connection]. The interface is similar to |
949 | +** [sqlite3_config()] except that the changes apply to a single | | 949 | +** [sqlite3_config()] except that the changes apply to a single |
950 | +** [database connection] (specified in the first argument). The | | 950 | +** [database connection] (specified in the first argument). The |
951 | +** sqlite3_db_config() interface can only be used immediately after | | 951 | +** sqlite3_db_config() interface can only be used immediately after |
952 | +** the database connection is created using [sqlite3_open()], | | 952 | +** the database connection is created using [sqlite3_open()], |
953 | +** [sqlite3_open16()], or [sqlite3_open_v2()]. | | 953 | +** [sqlite3_open16()], or [sqlite3_open_v2()]. |
954 | +** | | 954 | +** |
955 | +** The second argument to sqlite3_db_config(D,V,...) is the | | 955 | +** The second argument to sqlite3_db_config(D,V,...) is the |
956 | +** configuration verb - an integer code that indicates what | | 956 | +** configuration verb - an integer code that indicates what |
957 | +** aspect of the [database connection] is being configured. | | 957 | +** aspect of the [database connection] is being configured. |
958 | +** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. | | 958 | +** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. |
959 | +** New verbs are likely to be added in future releases of SQLite. | | 959 | +** New verbs are likely to be added in future releases of SQLite. |
960 | +** Additional arguments depend on the verb. | | 960 | +** Additional arguments depend on the verb. |
961 | +** | | 961 | +** |
962 | +** Requirements: | | 962 | +** Requirements: |
963 | +** [H14203] [H14206] [H14209] [H14212] [H14215] | | 963 | +** [H14203] [H14206] [H14209] [H14212] [H14215] |
964 | +*/ | | 964 | +*/ |
965 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...); | | 965 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...); |
966 | + | | 966 | + |
967 | +/* | | 967 | +/* |
968 | +** CAPI3REF: Memory Allocation Routines {H10155} <S20120> | | 968 | +** CAPI3REF: Memory Allocation Routines {H10155} <S20120> |
969 | +** EXPERIMENTAL | | 969 | +** EXPERIMENTAL |
970 | +** | | 970 | +** |
971 | +** An instance of this object defines the interface between SQLite | | 971 | +** An instance of this object defines the interface between SQLite |
972 | +** and low-level memory allocation routines. | | 972 | +** and low-level memory allocation routines. |
973 | +** | | 973 | +** |
974 | +** This object is used in only one place in the SQLite interface. | | 974 | +** This object is used in only one place in the SQLite interface. |
975 | +** A pointer to an instance of this object is the argument to | | 975 | +** A pointer to an instance of this object is the argument to |
976 | +** [sqlite3_config()] when the configuration option is | | 976 | +** [sqlite3_config()] when the configuration option is |
977 | +** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. | | 977 | +** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. |
978 | +** By creating an instance of this object | | 978 | +** By creating an instance of this object |
979 | +** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) | | 979 | +** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) |
980 | +** during configuration, an application can specify an alternative | | 980 | +** during configuration, an application can specify an alternative |
981 | +** memory allocation subsystem for SQLite to use for all of its | | 981 | +** memory allocation subsystem for SQLite to use for all of its |
982 | +** dynamic memory needs. | | 982 | +** dynamic memory needs. |
983 | +** | | 983 | +** |
984 | +** Note that SQLite comes with several [built-in memory allocators] | | 984 | +** Note that SQLite comes with several [built-in memory allocators] |
985 | +** that are perfectly adequate for the overwhelming majority of applications | | 985 | +** that are perfectly adequate for the overwhelming majority of applications |
986 | +** and that this object is only useful to a tiny minority of applications | | 986 | +** and that this object is only useful to a tiny minority of applications |
987 | +** with specialized memory allocation requirements. This object is | | 987 | +** with specialized memory allocation requirements. This object is |
988 | +** also used during testing of SQLite in order to specify an alternative | | 988 | +** also used during testing of SQLite in order to specify an alternative |
989 | +** memory allocator that simulates memory out-of-memory conditions in | | 989 | +** memory allocator that simulates memory out-of-memory conditions in |
990 | +** order to verify that SQLite recovers gracefully from such | | 990 | +** order to verify that SQLite recovers gracefully from such |
991 | +** conditions. | | 991 | +** conditions. |
992 | +** | | 992 | +** |
993 | +** The xMalloc and xFree methods must work like the | | 993 | +** The xMalloc and xFree methods must work like the |
994 | +** malloc() and free() functions from the standard C library. | | 994 | +** malloc() and free() functions from the standard C library. |
995 | +** The xRealloc method must work like realloc() from the standard C library | | 995 | +** The xRealloc method must work like realloc() from the standard C library |
996 | +** with the exception that if the second argument to xRealloc is zero, | | 996 | +** with the exception that if the second argument to xRealloc is zero, |
997 | +** xRealloc must be a no-op - it must not perform any allocation or | | 997 | +** xRealloc must be a no-op - it must not perform any allocation or |
998 | +** deallocation. SQLite guaranteeds that the second argument to | | 998 | +** deallocation. SQLite guaranteeds that the second argument to |
999 | +** xRealloc is always a value returned by a prior call to xRoundup. | | 999 | +** xRealloc is always a value returned by a prior call to xRoundup. |
1000 | +** And so in cases where xRoundup always returns a positive number, | | 1000 | +** And so in cases where xRoundup always returns a positive number, |
1001 | +** xRealloc can perform exactly as the standard library realloc() and | | 1001 | +** xRealloc can perform exactly as the standard library realloc() and |
1002 | +** still be in compliance with this specification. | | 1002 | +** still be in compliance with this specification. |
1003 | +** | | 1003 | +** |
1004 | +** xSize should return the allocated size of a memory allocation | | 1004 | +** xSize should return the allocated size of a memory allocation |
1005 | +** previously obtained from xMalloc or xRealloc. The allocated size | | 1005 | +** previously obtained from xMalloc or xRealloc. The allocated size |
1006 | +** is always at least as big as the requested size but may be larger. | | 1006 | +** is always at least as big as the requested size but may be larger. |
1007 | +** | | 1007 | +** |
1008 | +** The xRoundup method returns what would be the allocated size of | | 1008 | +** The xRoundup method returns what would be the allocated size of |
1009 | +** a memory allocation given a particular requested size. Most memory | | 1009 | +** a memory allocation given a particular requested size. Most memory |
1010 | +** allocators round up memory allocations at least to the next multiple | | 1010 | +** allocators round up memory allocations at least to the next multiple |
1011 | +** of 8. Some allocators round up to a larger multiple or to a power of 2. | | 1011 | +** of 8. Some allocators round up to a larger multiple or to a power of 2. |
1012 | +** Every memory allocation request coming in through [sqlite3_malloc()] | | 1012 | +** Every memory allocation request coming in through [sqlite3_malloc()] |
1013 | +** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, | | 1013 | +** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, |
1014 | +** that causes the corresponding memory allocation to fail. | | 1014 | +** that causes the corresponding memory allocation to fail. |
1015 | +** | | 1015 | +** |
1016 | +** The xInit method initializes the memory allocator. (For example, | | 1016 | +** The xInit method initializes the memory allocator. (For example, |
1017 | +** it might allocate any require mutexes or initialize internal data | | 1017 | +** it might allocate any require mutexes or initialize internal data |
1018 | +** structures. The xShutdown method is invoked (indirectly) by | | 1018 | +** structures. The xShutdown method is invoked (indirectly) by |
1019 | +** [sqlite3_shutdown()] and should deallocate any resources acquired | | 1019 | +** [sqlite3_shutdown()] and should deallocate any resources acquired |
1020 | +** by xInit. The pAppData pointer is used as the only parameter to | | 1020 | +** by xInit. The pAppData pointer is used as the only parameter to |
1021 | +** xInit and xShutdown. | | 1021 | +** xInit and xShutdown. |
1022 | +** | | 1022 | +** |
1023 | +** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes | | 1023 | +** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes |
1024 | +** the xInit method, so the xInit method need not be threadsafe. The | | 1024 | +** the xInit method, so the xInit method need not be threadsafe. The |
1025 | +** xShutdown method is only called from [sqlite3_shutdown()] so it does | | 1025 | +** xShutdown method is only called from [sqlite3_shutdown()] so it does |
1026 | +** not need to be threadsafe either. For all other methods, SQLite | | 1026 | +** not need to be threadsafe either. For all other methods, SQLite |
1027 | +** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the | | 1027 | +** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the |
1028 | +** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which | | 1028 | +** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which |
1029 | +** it is by default) and so the methods are automatically serialized. | | 1029 | +** it is by default) and so the methods are automatically serialized. |
1030 | +** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other | | 1030 | +** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other |
1031 | +** methods must be threadsafe or else make their own arrangements for | | 1031 | +** methods must be threadsafe or else make their own arrangements for |
1032 | +** serialization. | | 1032 | +** serialization. |
1033 | +** | | 1033 | +** |
1034 | +** SQLite will never invoke xInit() more than once without an intervening | | 1034 | +** SQLite will never invoke xInit() more than once without an intervening |
1035 | +** call to xShutdown(). | | 1035 | +** call to xShutdown(). |
1036 | +*/ | | 1036 | +*/ |
1037 | +typedef struct sqlite3_mem_methods sqlite3_mem_methods; | | 1037 | +typedef struct sqlite3_mem_methods sqlite3_mem_methods; |
1038 | +struct sqlite3_mem_methods { | | 1038 | +struct sqlite3_mem_methods { |
1039 | + void *(*xMalloc)(int); /* Memory allocation function */ | | 1039 | + void *(*xMalloc)(int); /* Memory allocation function */ |
1040 | + void (*xFree)(void*); /* Free a prior allocation */ | | 1040 | + void (*xFree)(void*); /* Free a prior allocation */ |
1041 | + void *(*xRealloc)(void*,int); /* Resize an allocation */ | | 1041 | + void *(*xRealloc)(void*,int); /* Resize an allocation */ |
1042 | + int (*xSize)(void*); /* Return the size of an allocation */ | | 1042 | + int (*xSize)(void*); /* Return the size of an allocation */ |
1043 | + int (*xRoundup)(int); /* Round up request size to allocation size */ | | 1043 | + int (*xRoundup)(int); /* Round up request size to allocation size */ |
1044 | + int (*xInit)(void*); /* Initialize the memory allocator */ | | 1044 | + int (*xInit)(void*); /* Initialize the memory allocator */ |
1045 | + void (*xShutdown)(void*); /* Deinitialize the memory allocator */ | | 1045 | + void (*xShutdown)(void*); /* Deinitialize the memory allocator */ |
1046 | + void *pAppData; /* Argument to xInit() and xShutdown() */ | | 1046 | + void *pAppData; /* Argument to xInit() and xShutdown() */ |
1047 | +}; | | 1047 | +}; |
1048 | + | | 1048 | + |
1049 | +/* | | 1049 | +/* |
1050 | +** CAPI3REF: Configuration Options {H10160} <S20000> | | 1050 | +** CAPI3REF: Configuration Options {H10160} <S20000> |
1051 | +** EXPERIMENTAL | | 1051 | +** EXPERIMENTAL |
1052 | +** | | 1052 | +** |
1053 | +** These constants are the available integer configuration options that | | 1053 | +** These constants are the available integer configuration options that |
1054 | +** can be passed as the first argument to the [sqlite3_config()] interface. | | 1054 | +** can be passed as the first argument to the [sqlite3_config()] interface. |
1055 | +** | | 1055 | +** |
1056 | +** New configuration options may be added in future releases of SQLite. | | 1056 | +** New configuration options may be added in future releases of SQLite. |
1057 | +** Existing configuration options might be discontinued. Applications | | 1057 | +** Existing configuration options might be discontinued. Applications |
1058 | +** should check the return code from [sqlite3_config()] to make sure that | | 1058 | +** should check the return code from [sqlite3_config()] to make sure that |
1059 | +** the call worked. The [sqlite3_config()] interface will return a | | 1059 | +** the call worked. The [sqlite3_config()] interface will return a |
1060 | +** non-zero [error code] if a discontinued or unsupported configuration option | | 1060 | +** non-zero [error code] if a discontinued or unsupported configuration option |
1061 | +** is invoked. | | 1061 | +** is invoked. |
1062 | +** | | 1062 | +** |
1063 | +** <dl> | | 1063 | +** <dl> |
1064 | +** <dt>SQLITE_CONFIG_SINGLETHREAD</dt> | | 1064 | +** <dt>SQLITE_CONFIG_SINGLETHREAD</dt> |
1065 | +** <dd>There are no arguments to this option. This option disables | | 1065 | +** <dd>There are no arguments to this option. This option disables |
1066 | +** all mutexing and puts SQLite into a mode where it can only be used | | 1066 | +** all mutexing and puts SQLite into a mode where it can only be used |
1067 | +** by a single thread.</dd> | | 1067 | +** by a single thread.</dd> |
1068 | +** | | 1068 | +** |
1069 | +** <dt>SQLITE_CONFIG_MULTITHREAD</dt> | | 1069 | +** <dt>SQLITE_CONFIG_MULTITHREAD</dt> |
1070 | +** <dd>There are no arguments to this option. This option disables | | 1070 | +** <dd>There are no arguments to this option. This option disables |
1071 | +** mutexing on [database connection] and [prepared statement] objects. | | 1071 | +** mutexing on [database connection] and [prepared statement] objects. |
1072 | +** The application is responsible for serializing access to | | 1072 | +** The application is responsible for serializing access to |
1073 | +** [database connections] and [prepared statements]. But other mutexes | | 1073 | +** [database connections] and [prepared statements]. But other mutexes |
1074 | +** are enabled so that SQLite will be safe to use in a multi-threaded | | 1074 | +** are enabled so that SQLite will be safe to use in a multi-threaded |
1075 | +** environment as long as no two threads attempt to use the same | | 1075 | +** environment as long as no two threads attempt to use the same |
1076 | +** [database connection] at the same time. See the [threading mode] | | 1076 | +** [database connection] at the same time. See the [threading mode] |
1077 | +** documentation for additional information.</dd> | | 1077 | +** documentation for additional information.</dd> |
1078 | +** | | 1078 | +** |
1079 | +** <dt>SQLITE_CONFIG_SERIALIZED</dt> | | 1079 | +** <dt>SQLITE_CONFIG_SERIALIZED</dt> |
1080 | +** <dd>There are no arguments to this option. This option enables | | 1080 | +** <dd>There are no arguments to this option. This option enables |
1081 | +** all mutexes including the recursive | | 1081 | +** all mutexes including the recursive |
1082 | +** mutexes on [database connection] and [prepared statement] objects. | | 1082 | +** mutexes on [database connection] and [prepared statement] objects. |
1083 | +** In this mode (which is the default when SQLite is compiled with | | 1083 | +** In this mode (which is the default when SQLite is compiled with |
1084 | +** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access | | 1084 | +** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access |
1085 | +** to [database connections] and [prepared statements] so that the | | 1085 | +** to [database connections] and [prepared statements] so that the |
1086 | +** application is free to use the same [database connection] or the | | 1086 | +** application is free to use the same [database connection] or the |
1087 | +** same [prepared statement] in different threads at the same time. | | 1087 | +** same [prepared statement] in different threads at the same time. |
1088 | +** See the [threading mode] documentation for additional information.</dd> | | 1088 | +** See the [threading mode] documentation for additional information.</dd> |
1089 | +** | | 1089 | +** |
1090 | +** <dt>SQLITE_CONFIG_MALLOC</dt> | | 1090 | +** <dt>SQLITE_CONFIG_MALLOC</dt> |
1091 | +** <dd>This option takes a single argument which is a pointer to an | | 1091 | +** <dd>This option takes a single argument which is a pointer to an |
1092 | +** instance of the [sqlite3_mem_methods] structure. The argument specifies | | 1092 | +** instance of the [sqlite3_mem_methods] structure. The argument specifies |
1093 | +** alternative low-level memory allocation routines to be used in place of | | 1093 | +** alternative low-level memory allocation routines to be used in place of |
1094 | +** the memory allocation routines built into SQLite.</dd> | | 1094 | +** the memory allocation routines built into SQLite.</dd> |
1095 | +** | | 1095 | +** |
1096 | +** <dt>SQLITE_CONFIG_GETMALLOC</dt> | | 1096 | +** <dt>SQLITE_CONFIG_GETMALLOC</dt> |
1097 | +** <dd>This option takes a single argument which is a pointer to an | | 1097 | +** <dd>This option takes a single argument which is a pointer to an |
1098 | +** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] | | 1098 | +** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] |
1099 | +** structure is filled with the currently defined memory allocation routines. | | 1099 | +** structure is filled with the currently defined memory allocation routines. |
1100 | +** This option can be used to overload the default memory allocation | | 1100 | +** This option can be used to overload the default memory allocation |
1101 | +** routines with a wrapper that simulations memory allocation failure or | | 1101 | +** routines with a wrapper that simulations memory allocation failure or |
1102 | +** tracks memory usage, for example.</dd> | | 1102 | +** tracks memory usage, for example.</dd> |
1103 | +** | | 1103 | +** |
1104 | +** <dt>SQLITE_CONFIG_MEMSTATUS</dt> | | 1104 | +** <dt>SQLITE_CONFIG_MEMSTATUS</dt> |
1105 | +** <dd>This option takes single argument of type int, interpreted as a | | 1105 | +** <dd>This option takes single argument of type int, interpreted as a |
1106 | +** boolean, which enables or disables the collection of memory allocation | | 1106 | +** boolean, which enables or disables the collection of memory allocation |
1107 | +** statistics. When disabled, the following SQLite interfaces become | | 1107 | +** statistics. When disabled, the following SQLite interfaces become |
1108 | +** non-operational: | | 1108 | +** non-operational: |
1109 | +** <ul> | | 1109 | +** <ul> |
1110 | +** <li> [sqlite3_memory_used()] | | 1110 | +** <li> [sqlite3_memory_used()] |
1111 | +** <li> [sqlite3_memory_highwater()] | | 1111 | +** <li> [sqlite3_memory_highwater()] |
1112 | +** <li> [sqlite3_soft_heap_limit()] | | 1112 | +** <li> [sqlite3_soft_heap_limit()] |
1113 | +** <li> [sqlite3_status()] | | 1113 | +** <li> [sqlite3_status()] |
1114 | +** </ul> | | 1114 | +** </ul> |
1115 | +** </dd> | | 1115 | +** </dd> |
1116 | +** | | 1116 | +** |
1117 | +** <dt>SQLITE_CONFIG_SCRATCH</dt> | | 1117 | +** <dt>SQLITE_CONFIG_SCRATCH</dt> |
1118 | +** <dd>This option specifies a static memory buffer that SQLite can use for | | 1118 | +** <dd>This option specifies a static memory buffer that SQLite can use for |
1119 | +** scratch memory. There are three arguments: A pointer an 8-byte | | 1119 | +** scratch memory. There are three arguments: A pointer an 8-byte |
1120 | +** aligned memory buffer from which the scrach allocations will be | | 1120 | +** aligned memory buffer from which the scrach allocations will be |
1121 | +** drawn, the size of each scratch allocation (sz), | | 1121 | +** drawn, the size of each scratch allocation (sz), |
1122 | +** and the maximum number of scratch allocations (N). The sz | | 1122 | +** and the maximum number of scratch allocations (N). The sz |
1123 | +** argument must be a multiple of 16. The sz parameter should be a few bytes | | 1123 | +** argument must be a multiple of 16. The sz parameter should be a few bytes |
1124 | +** larger than the actual scratch space required due to internal overhead. | | 1124 | +** larger than the actual scratch space required due to internal overhead. |
1125 | +** The first argument should pointer to an 8-byte aligned buffer | | 1125 | +** The first argument should pointer to an 8-byte aligned buffer |
1126 | +** of at least sz*N bytes of memory. | | 1126 | +** of at least sz*N bytes of memory. |
1127 | +** SQLite will use no more than one scratch buffer at once per thread, so | | 1127 | +** SQLite will use no more than one scratch buffer at once per thread, so |
1128 | +** N should be set to the expected maximum number of threads. The sz | | 1128 | +** N should be set to the expected maximum number of threads. The sz |
1129 | +** parameter should be 6 times the size of the largest database page size. | | 1129 | +** parameter should be 6 times the size of the largest database page size. |
1130 | +** Scratch buffers are used as part of the btree balance operation. If | | 1130 | +** Scratch buffers are used as part of the btree balance operation. If |
1131 | +** The btree balancer needs additional memory beyond what is provided by | | 1131 | +** The btree balancer needs additional memory beyond what is provided by |
1132 | +** scratch buffers or if no scratch buffer space is specified, then SQLite | | 1132 | +** scratch buffers or if no scratch buffer space is specified, then SQLite |
1133 | +** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd> | | 1133 | +** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd> |
1134 | +** | | 1134 | +** |
1135 | +** <dt>SQLITE_CONFIG_PAGECACHE</dt> | | 1135 | +** <dt>SQLITE_CONFIG_PAGECACHE</dt> |
1136 | +** <dd>This option specifies a static memory buffer that SQLite can use for | | 1136 | +** <dd>This option specifies a static memory buffer that SQLite can use for |
1137 | +** the database page cache with the default page cache implemenation. | | 1137 | +** the database page cache with the default page cache implemenation. |
1138 | +** This configuration should not be used if an application-define page | | 1138 | +** This configuration should not be used if an application-define page |
1139 | +** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. | | 1139 | +** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
1140 | +** There are three arguments to this option: A pointer to 8-byte aligned | | 1140 | +** There are three arguments to this option: A pointer to 8-byte aligned |
1141 | +** memory, the size of each page buffer (sz), and the number of pages (N). | | 1141 | +** memory, the size of each page buffer (sz), and the number of pages (N). |
1142 | +** The sz argument should be the size of the largest database page | | 1142 | +** The sz argument should be the size of the largest database page |
1143 | +** (a power of two between 512 and 32768) plus a little extra for each | | 1143 | +** (a power of two between 512 and 32768) plus a little extra for each |
1144 | +** page header. The page header size is 20 to 40 bytes depending on | | 1144 | +** page header. The page header size is 20 to 40 bytes depending on |
1145 | +** the host architecture. It is harmless, apart from the wasted memory, | | 1145 | +** the host architecture. It is harmless, apart from the wasted memory, |
1146 | +** to make sz a little too large. The first | | 1146 | +** to make sz a little too large. The first |
1147 | +** argument should point to an allocation of at least sz*N bytes of memory. | | 1147 | +** argument should point to an allocation of at least sz*N bytes of memory. |
1148 | +** SQLite will use the memory provided by the first argument to satisfy its | | 1148 | +** SQLite will use the memory provided by the first argument to satisfy its |
1149 | +** memory needs for the first N pages that it adds to cache. If additional | | 1149 | +** memory needs for the first N pages that it adds to cache. If additional |
1150 | +** page cache memory is needed beyond what is provided by this option, then | | 1150 | +** page cache memory is needed beyond what is provided by this option, then |
1151 | +** SQLite goes to [sqlite3_malloc()] for the additional storage space. | | 1151 | +** SQLite goes to [sqlite3_malloc()] for the additional storage space. |
1152 | +** The implementation might use one or more of the N buffers to hold | | 1152 | +** The implementation might use one or more of the N buffers to hold |
1153 | +** memory accounting information. The pointer in the first argument must | | 1153 | +** memory accounting information. The pointer in the first argument must |
1154 | +** be aligned to an 8-byte boundary or subsequent behavior of SQLite | | 1154 | +** be aligned to an 8-byte boundary or subsequent behavior of SQLite |
1155 | +** will be undefined.</dd> | | 1155 | +** will be undefined.</dd> |
1156 | +** | | 1156 | +** |
1157 | +** <dt>SQLITE_CONFIG_HEAP</dt> | | 1157 | +** <dt>SQLITE_CONFIG_HEAP</dt> |
1158 | +** <dd>This option specifies a static memory buffer that SQLite will use | | 1158 | +** <dd>This option specifies a static memory buffer that SQLite will use |
1159 | +** for all of its dynamic memory allocation needs beyond those provided | | 1159 | +** for all of its dynamic memory allocation needs beyond those provided |
1160 | +** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. | | 1160 | +** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. |
1161 | +** There are three arguments: An 8-byte aligned pointer to the memory, | | 1161 | +** There are three arguments: An 8-byte aligned pointer to the memory, |
1162 | +** the number of bytes in the memory buffer, and the minimum allocation size. | | 1162 | +** the number of bytes in the memory buffer, and the minimum allocation size. |
1163 | +** If the first pointer (the memory pointer) is NULL, then SQLite reverts | | 1163 | +** If the first pointer (the memory pointer) is NULL, then SQLite reverts |
1164 | +** to using its default memory allocator (the system malloc() implementation), | | 1164 | +** to using its default memory allocator (the system malloc() implementation), |
1165 | +** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. If the | | 1165 | +** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. If the |
1166 | +** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or | | 1166 | +** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or |
1167 | +** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory | | 1167 | +** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory |
1168 | +** allocator is engaged to handle all of SQLites memory allocation needs. | | 1168 | +** allocator is engaged to handle all of SQLites memory allocation needs. |
1169 | +** The first pointer (the memory pointer) must be aligned to an 8-byte | | 1169 | +** The first pointer (the memory pointer) must be aligned to an 8-byte |
1170 | +** boundary or subsequent behavior of SQLite will be undefined.</dd> | | 1170 | +** boundary or subsequent behavior of SQLite will be undefined.</dd> |
1171 | +** | | 1171 | +** |
1172 | +** <dt>SQLITE_CONFIG_MUTEX</dt> | | 1172 | +** <dt>SQLITE_CONFIG_MUTEX</dt> |
1173 | +** <dd>This option takes a single argument which is a pointer to an | | 1173 | +** <dd>This option takes a single argument which is a pointer to an |
1174 | +** instance of the [sqlite3_mutex_methods] structure. The argument specifies | | 1174 | +** instance of the [sqlite3_mutex_methods] structure. The argument specifies |
1175 | +** alternative low-level mutex routines to be used in place | | 1175 | +** alternative low-level mutex routines to be used in place |
1176 | +** the mutex routines built into SQLite.</dd> | | 1176 | +** the mutex routines built into SQLite.</dd> |
1177 | +** | | 1177 | +** |
1178 | +** <dt>SQLITE_CONFIG_GETMUTEX</dt> | | 1178 | +** <dt>SQLITE_CONFIG_GETMUTEX</dt> |
1179 | +** <dd>This option takes a single argument which is a pointer to an | | 1179 | +** <dd>This option takes a single argument which is a pointer to an |
1180 | +** instance of the [sqlite3_mutex_methods] structure. The | | 1180 | +** instance of the [sqlite3_mutex_methods] structure. The |
1181 | +** [sqlite3_mutex_methods] | | 1181 | +** [sqlite3_mutex_methods] |
1182 | +** structure is filled with the currently defined mutex routines. | | 1182 | +** structure is filled with the currently defined mutex routines. |
1183 | +** This option can be used to overload the default mutex allocation | | 1183 | +** This option can be used to overload the default mutex allocation |
1184 | +** routines with a wrapper used to track mutex usage for performance | | 1184 | +** routines with a wrapper used to track mutex usage for performance |
1185 | +** profiling or testing, for example.</dd> | | 1185 | +** profiling or testing, for example.</dd> |
1186 | +** | | 1186 | +** |
1187 | +** <dt>SQLITE_CONFIG_LOOKASIDE</dt> | | 1187 | +** <dt>SQLITE_CONFIG_LOOKASIDE</dt> |
1188 | +** <dd>This option takes two arguments that determine the default | | 1188 | +** <dd>This option takes two arguments that determine the default |
1189 | +** memory allocation lookaside optimization. The first argument is the | | 1189 | +** memory allocation lookaside optimization. The first argument is the |
1190 | +** size of each lookaside buffer slot and the second is the number of | | 1190 | +** size of each lookaside buffer slot and the second is the number of |
1191 | +** slots allocated to each database connection. This option sets the | | 1191 | +** slots allocated to each database connection. This option sets the |
1192 | +** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] | | 1192 | +** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] |
1193 | +** verb to [sqlite3_db_config()] can be used to change the lookaside | | 1193 | +** verb to [sqlite3_db_config()] can be used to change the lookaside |
1194 | +** configuration on individual connections.</dd> | | 1194 | +** configuration on individual connections.</dd> |
1195 | +** | | 1195 | +** |
1196 | +** <dt>SQLITE_CONFIG_PCACHE</dt> | | 1196 | +** <dt>SQLITE_CONFIG_PCACHE</dt> |
1197 | +** <dd>This option takes a single argument which is a pointer to | | 1197 | +** <dd>This option takes a single argument which is a pointer to |
1198 | +** an [sqlite3_pcache_methods] object. This object specifies the interface | | 1198 | +** an [sqlite3_pcache_methods] object. This object specifies the interface |
1199 | +** to a custom page cache implementation. SQLite makes a copy of the | | 1199 | +** to a custom page cache implementation. SQLite makes a copy of the |
1200 | +** object and uses it for page cache memory allocations.</dd> | | 1200 | +** object and uses it for page cache memory allocations.</dd> |
1201 | +** | | 1201 | +** |
1202 | +** <dt>SQLITE_CONFIG_GETPCACHE</dt> | | 1202 | +** <dt>SQLITE_CONFIG_GETPCACHE</dt> |
1203 | +** <dd>This option takes a single argument which is a pointer to an | | 1203 | +** <dd>This option takes a single argument which is a pointer to an |
1204 | +** [sqlite3_pcache_methods] object. SQLite copies of the current | | 1204 | +** [sqlite3_pcache_methods] object. SQLite copies of the current |
1205 | +** page cache implementation into that object.</dd> | | 1205 | +** page cache implementation into that object.</dd> |
1206 | +** | | 1206 | +** |
1207 | +** </dl> | | 1207 | +** </dl> |
1208 | +*/ | | 1208 | +*/ |
1209 | +#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ | | 1209 | +#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ |
1210 | +#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ | | 1210 | +#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ |
1211 | +#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ | | 1211 | +#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ |
1212 | +#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ | | 1212 | +#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ |
1213 | +#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ | | 1213 | +#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ |
1214 | +#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ | | 1214 | +#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ |
1215 | +#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ | | 1215 | +#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ |
1216 | +#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ | | 1216 | +#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ |
1217 | +#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ | | 1217 | +#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ |
1218 | +#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ | | 1218 | +#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ |
1219 | +#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ | | 1219 | +#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ |
1220 | +/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ | | 1220 | +/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ |
1221 | +#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ | | 1221 | +#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ |
1222 | +#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ | | 1222 | +#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ |
1223 | +#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ | | 1223 | +#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ |
1224 | + | | 1224 | + |
1225 | +/* | | 1225 | +/* |
1226 | +** CAPI3REF: Configuration Options {H10170} <S20000> | | 1226 | +** CAPI3REF: Configuration Options {H10170} <S20000> |
1227 | +** EXPERIMENTAL | | 1227 | +** EXPERIMENTAL |
1228 | +** | | 1228 | +** |
1229 | +** These constants are the available integer configuration options that | | 1229 | +** These constants are the available integer configuration options that |
1230 | +** can be passed as the second argument to the [sqlite3_db_config()] interface. | | 1230 | +** can be passed as the second argument to the [sqlite3_db_config()] interface. |
1231 | +** | | 1231 | +** |
1232 | +** New configuration options may be added in future releases of SQLite. | | 1232 | +** New configuration options may be added in future releases of SQLite. |
1233 | +** Existing configuration options might be discontinued. Applications | | 1233 | +** Existing configuration options might be discontinued. Applications |
1234 | +** should check the return code from [sqlite3_db_config()] to make sure that | | 1234 | +** should check the return code from [sqlite3_db_config()] to make sure that |
1235 | +** the call worked. The [sqlite3_db_config()] interface will return a | | 1235 | +** the call worked. The [sqlite3_db_config()] interface will return a |
1236 | +** non-zero [error code] if a discontinued or unsupported configuration option | | 1236 | +** non-zero [error code] if a discontinued or unsupported configuration option |
1237 | +** is invoked. | | 1237 | +** is invoked. |
1238 | +** | | 1238 | +** |
1239 | +** <dl> | | 1239 | +** <dl> |
1240 | +** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt> | | 1240 | +** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt> |
1241 | +** <dd>This option takes three additional arguments that determine the | | 1241 | +** <dd>This option takes three additional arguments that determine the |
1242 | +** [lookaside memory allocator] configuration for the [database connection]. | | 1242 | +** [lookaside memory allocator] configuration for the [database connection]. |
1243 | +** The first argument (the third parameter to [sqlite3_db_config()] is a | | 1243 | +** The first argument (the third parameter to [sqlite3_db_config()] is a |
1244 | +** pointer to an memory buffer to use for lookaside memory. | | 1244 | +** pointer to an memory buffer to use for lookaside memory. |
1245 | +** The first argument may be NULL in which case SQLite will allocate the | | 1245 | +** The first argument may be NULL in which case SQLite will allocate the |
1246 | +** lookaside buffer itself using [sqlite3_malloc()]. The second argument is the | | 1246 | +** lookaside buffer itself using [sqlite3_malloc()]. The second argument is the |
1247 | +** size of each lookaside buffer slot and the third argument is the number of | | 1247 | +** size of each lookaside buffer slot and the third argument is the number of |
1248 | +** slots. The size of the buffer in the first argument must be greater than | | 1248 | +** slots. The size of the buffer in the first argument must be greater than |
1249 | +** or equal to the product of the second and third arguments. The buffer | | 1249 | +** or equal to the product of the second and third arguments. The buffer |
1250 | +** must be aligned to an 8-byte boundary. If the second argument is not | | 1250 | +** must be aligned to an 8-byte boundary. If the second argument is not |
1251 | +** a multiple of 8, it is internally rounded down to the next smaller | | 1251 | +** a multiple of 8, it is internally rounded down to the next smaller |
1252 | +** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd> | | 1252 | +** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd> |
1253 | +** | | 1253 | +** |
1254 | +** </dl> | | 1254 | +** </dl> |
1255 | +*/ | | 1255 | +*/ |
1256 | +#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ | | 1256 | +#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ |
1257 | + | | 1257 | + |
1258 | + | | 1258 | + |
1259 | +/* | | 1259 | +/* |
1260 | +** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700> | | 1260 | +** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700> |
1261 | +** | | 1261 | +** |
1262 | +** The sqlite3_extended_result_codes() routine enables or disables the | | 1262 | +** The sqlite3_extended_result_codes() routine enables or disables the |
1263 | +** [extended result codes] feature of SQLite. The extended result | | 1263 | +** [extended result codes] feature of SQLite. The extended result |
1264 | +** codes are disabled by default for historical compatibility considerations. | | 1264 | +** codes are disabled by default for historical compatibility considerations. |
1265 | +** | | 1265 | +** |
1266 | +** Requirements: | | 1266 | +** Requirements: |
1267 | +** [H12201] [H12202] | | 1267 | +** [H12201] [H12202] |
1268 | +*/ | | 1268 | +*/ |
1269 | +SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); | | 1269 | +SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); |
1270 | + | | 1270 | + |
1271 | +/* | | 1271 | +/* |
1272 | +** CAPI3REF: Last Insert Rowid {H12220} <S10700> | | 1272 | +** CAPI3REF: Last Insert Rowid {H12220} <S10700> |
1273 | +** | | 1273 | +** |
1274 | +** Each entry in an SQLite table has a unique 64-bit signed | | 1274 | +** Each entry in an SQLite table has a unique 64-bit signed |
1275 | +** integer key called the [ROWID | "rowid"]. The rowid is always available | | 1275 | +** integer key called the [ROWID | "rowid"]. The rowid is always available |
1276 | +** as an undeclared column named ROWID, OID, or _ROWID_ as long as those | | 1276 | +** as an undeclared column named ROWID, OID, or _ROWID_ as long as those |
1277 | +** names are not also used by explicitly declared columns. If | | 1277 | +** names are not also used by explicitly declared columns. If |
1278 | +** the table has a column of type [INTEGER PRIMARY KEY] then that column | | 1278 | +** the table has a column of type [INTEGER PRIMARY KEY] then that column |
1279 | +** is another alias for the rowid. | | 1279 | +** is another alias for the rowid. |
1280 | +** | | 1280 | +** |
1281 | +** This routine returns the [rowid] of the most recent | | 1281 | +** This routine returns the [rowid] of the most recent |
1282 | +** successful [INSERT] into the database from the [database connection] | | 1282 | +** successful [INSERT] into the database from the [database connection] |
1283 | +** in the first argument. If no successful [INSERT]s | | 1283 | +** in the first argument. If no successful [INSERT]s |
1284 | +** have ever occurred on that database connection, zero is returned. | | 1284 | +** have ever occurred on that database connection, zero is returned. |
1285 | +** | | 1285 | +** |
1286 | +** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted | | 1286 | +** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted |
1287 | +** row is returned by this routine as long as the trigger is running. | | 1287 | +** row is returned by this routine as long as the trigger is running. |
1288 | +** But once the trigger terminates, the value returned by this routine | | 1288 | +** But once the trigger terminates, the value returned by this routine |
1289 | +** reverts to the last value inserted before the trigger fired. | | 1289 | +** reverts to the last value inserted before the trigger fired. |
1290 | +** | | 1290 | +** |
1291 | +** An [INSERT] that fails due to a constraint violation is not a | | 1291 | +** An [INSERT] that fails due to a constraint violation is not a |
1292 | +** successful [INSERT] and does not change the value returned by this | | 1292 | +** successful [INSERT] and does not change the value returned by this |
1293 | +** routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, | | 1293 | +** routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, |
1294 | +** and INSERT OR ABORT make no changes to the return value of this | | 1294 | +** and INSERT OR ABORT make no changes to the return value of this |
1295 | +** routine when their insertion fails. When INSERT OR REPLACE | | 1295 | +** routine when their insertion fails. When INSERT OR REPLACE |
1296 | +** encounters a constraint violation, it does not fail. The | | 1296 | +** encounters a constraint violation, it does not fail. The |
1297 | +** INSERT continues to completion after deleting rows that caused | | 1297 | +** INSERT continues to completion after deleting rows that caused |
1298 | +** the constraint problem so INSERT OR REPLACE will always change | | 1298 | +** the constraint problem so INSERT OR REPLACE will always change |
1299 | +** the return value of this interface. | | 1299 | +** the return value of this interface. |
1300 | +** | | 1300 | +** |
1301 | +** For the purposes of this routine, an [INSERT] is considered to | | 1301 | +** For the purposes of this routine, an [INSERT] is considered to |
1302 | +** be successful even if it is subsequently rolled back. | | 1302 | +** be successful even if it is subsequently rolled back. |
1303 | +** | | 1303 | +** |
1304 | +** Requirements: | | 1304 | +** Requirements: |
1305 | +** [H12221] [H12223] | | 1305 | +** [H12221] [H12223] |
1306 | +** | | 1306 | +** |
1307 | +** If a separate thread performs a new [INSERT] on the same | | 1307 | +** If a separate thread performs a new [INSERT] on the same |
1308 | +** database connection while the [sqlite3_last_insert_rowid()] | | 1308 | +** database connection while the [sqlite3_last_insert_rowid()] |
1309 | +** function is running and thus changes the last insert [rowid], | | 1309 | +** function is running and thus changes the last insert [rowid], |
1310 | +** then the value returned by [sqlite3_last_insert_rowid()] is | | 1310 | +** then the value returned by [sqlite3_last_insert_rowid()] is |
1311 | +** unpredictable and might not equal either the old or the new | | 1311 | +** unpredictable and might not equal either the old or the new |
1312 | +** last insert [rowid]. | | 1312 | +** last insert [rowid]. |
1313 | +*/ | | 1313 | +*/ |
1314 | +SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); | | 1314 | +SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); |
1315 | + | | 1315 | + |
1316 | +/* | | 1316 | +/* |
1317 | +** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600> | | 1317 | +** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600> |
1318 | +** | | 1318 | +** |
1319 | +** This function returns the number of database rows that were changed | | 1319 | +** This function returns the number of database rows that were changed |
1320 | +** or inserted or deleted by the most recently completed SQL statement | | 1320 | +** or inserted or deleted by the most recently completed SQL statement |
1321 | +** on the [database connection] specified by the first parameter. | | 1321 | +** on the [database connection] specified by the first parameter. |
1322 | +** Only changes that are directly specified by the [INSERT], [UPDATE], | | 1322 | +** Only changes that are directly specified by the [INSERT], [UPDATE], |
1323 | +** or [DELETE] statement are counted. Auxiliary changes caused by | | 1323 | +** or [DELETE] statement are counted. Auxiliary changes caused by |
1324 | +** triggers are not counted. Use the [sqlite3_total_changes()] function | | 1324 | +** triggers or [foreign key actions] are not counted. Use the |
1325 | +** to find the total number of changes including changes caused by triggers. | | 1325 | +** [sqlite3_total_changes()] function to find the total number of changes |
| | | 1326 | +** including changes caused by triggers and foreign key actions. |
1326 | +** | | 1327 | +** |
1327 | +** Changes to a view that are simulated by an [INSTEAD OF trigger] | | 1328 | +** Changes to a view that are simulated by an [INSTEAD OF trigger] |
1328 | +** are not counted. Only real table changes are counted. | | 1329 | +** are not counted. Only real table changes are counted. |
1329 | +** | | 1330 | +** |
1330 | +** A "row change" is a change to a single row of a single table | | 1331 | +** A "row change" is a change to a single row of a single table |
1331 | +** caused by an INSERT, DELETE, or UPDATE statement. Rows that | | 1332 | +** caused by an INSERT, DELETE, or UPDATE statement. Rows that |
1332 | +** are changed as side effects of [REPLACE] constraint resolution, | | 1333 | +** are changed as side effects of [REPLACE] constraint resolution, |
1333 | +** rollback, ABORT processing, [DROP TABLE], or by any other | | 1334 | +** rollback, ABORT processing, [DROP TABLE], or by any other |
1334 | +** mechanisms do not count as direct row changes. | | 1335 | +** mechanisms do not count as direct row changes. |
1335 | +** | | 1336 | +** |
1336 | +** A "trigger context" is a scope of execution that begins and | | 1337 | +** A "trigger context" is a scope of execution that begins and |
1337 | +** ends with the script of a [CREATE TRIGGER | trigger]. | | 1338 | +** ends with the script of a [CREATE TRIGGER | trigger]. |
1338 | +** Most SQL statements are | | 1339 | +** Most SQL statements are |
1339 | +** evaluated outside of any trigger. This is the "top level" | | 1340 | +** evaluated outside of any trigger. This is the "top level" |
1340 | +** trigger context. If a trigger fires from the top level, a | | 1341 | +** trigger context. If a trigger fires from the top level, a |
1341 | +** new trigger context is entered for the duration of that one | | 1342 | +** new trigger context is entered for the duration of that one |
1342 | +** trigger. Subtriggers create subcontexts for their duration. | | 1343 | +** trigger. Subtriggers create subcontexts for their duration. |
1343 | +** | | 1344 | +** |
1344 | +** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does | | 1345 | +** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does |
1345 | +** not create a new trigger context. | | 1346 | +** not create a new trigger context. |
1346 | +** | | 1347 | +** |
1347 | +** This function returns the number of direct row changes in the | | 1348 | +** This function returns the number of direct row changes in the |
1348 | +** most recent INSERT, UPDATE, or DELETE statement within the same | | 1349 | +** most recent INSERT, UPDATE, or DELETE statement within the same |
1349 | +** trigger context. | | 1350 | +** trigger context. |
1350 | +** | | 1351 | +** |
1351 | +** Thus, when called from the top level, this function returns the | | 1352 | +** Thus, when called from the top level, this function returns the |
1352 | +** number of changes in the most recent INSERT, UPDATE, or DELETE | | 1353 | +** number of changes in the most recent INSERT, UPDATE, or DELETE |
1353 | +** that also occurred at the top level. Within the body of a trigger, | | 1354 | +** that also occurred at the top level. Within the body of a trigger, |
1354 | +** the sqlite3_changes() interface can be called to find the number of | | 1355 | +** the sqlite3_changes() interface can be called to find the number of |
1355 | +** changes in the most recently completed INSERT, UPDATE, or DELETE | | 1356 | +** changes in the most recently completed INSERT, UPDATE, or DELETE |
1356 | +** statement within the body of the same trigger. | | 1357 | +** statement within the body of the same trigger. |
1357 | +** However, the number returned does not include changes | | 1358 | +** However, the number returned does not include changes |
1358 | +** caused by subtriggers since those have their own context. | | 1359 | +** caused by subtriggers since those have their own context. |
1359 | +** | | 1360 | +** |
1360 | +** See also the [sqlite3_total_changes()] interface and the | | 1361 | +** See also the [sqlite3_total_changes()] interface and the |
1361 | +** [count_changes pragma]. | | 1362 | +** [count_changes pragma]. |
1362 | +** | | 1363 | +** |
1363 | +** Requirements: | | 1364 | +** Requirements: |
1364 | +** [H12241] [H12243] | | 1365 | +** [H12241] [H12243] |
1365 | +** | | 1366 | +** |
1366 | +** If a separate thread makes changes on the same database connection | | 1367 | +** If a separate thread makes changes on the same database connection |
1367 | +** while [sqlite3_changes()] is running then the value returned | | 1368 | +** while [sqlite3_changes()] is running then the value returned |
1368 | +** is unpredictable and not meaningful. | | 1369 | +** is unpredictable and not meaningful. |
1369 | +*/ | | 1370 | +*/ |
1370 | +SQLITE_API int sqlite3_changes(sqlite3*); | | 1371 | +SQLITE_API int sqlite3_changes(sqlite3*); |
1371 | + | | 1372 | + |
1372 | +/* | | 1373 | +/* |
1373 | +** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600> | | 1374 | +** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600> |
1374 | +** | | 1375 | +** |
1375 | +** This function returns the number of row changes caused by [INSERT], | | 1376 | +** This function returns the number of row changes caused by [INSERT], |
1376 | +** [UPDATE] or [DELETE] statements since the [database connection] was opened. | | 1377 | +** [UPDATE] or [DELETE] statements since the [database connection] was opened. |
1377 | +** The count includes all changes from all | | 1378 | +** The count includes all changes from all [CREATE TRIGGER | trigger] |
1378 | +** [CREATE TRIGGER | trigger] contexts. However, | | 1379 | +** contexts and changes made by [foreign key actions]. However, |
1379 | +** the count does not include changes used to implement [REPLACE] constraints, | | 1380 | +** the count does not include changes used to implement [REPLACE] constraints, |
1380 | +** do rollbacks or ABORT processing, or [DROP TABLE] processing. The | | 1381 | +** do rollbacks or ABORT processing, or [DROP TABLE] processing. The |
1381 | +** count does not include rows of views that fire an [INSTEAD OF trigger], | | 1382 | +** count does not include rows of views that fire an [INSTEAD OF trigger], |
1382 | +** though if the INSTEAD OF trigger makes changes of its own, those changes | | 1383 | +** though if the INSTEAD OF trigger makes changes of its own, those changes |
1383 | +** are counted. | | 1384 | +** are counted. |
1384 | +** The changes are counted as soon as the statement that makes them is | | 1385 | +** The changes are counted as soon as the statement that makes them is |
1385 | +** completed (when the statement handle is passed to [sqlite3_reset()] or | | 1386 | +** completed (when the statement handle is passed to [sqlite3_reset()] or |
1386 | +** [sqlite3_finalize()]). | | 1387 | +** [sqlite3_finalize()]). |
1387 | +** | | 1388 | +** |
1388 | +** See also the [sqlite3_changes()] interface and the | | 1389 | +** See also the [sqlite3_changes()] interface and the |
1389 | +** [count_changes pragma]. | | 1390 | +** [count_changes pragma]. |
1390 | +** | | 1391 | +** |
1391 | +** Requirements: | | 1392 | +** Requirements: |
1392 | +** [H12261] [H12263] | | 1393 | +** [H12261] [H12263] |
1393 | +** | | 1394 | +** |
1394 | +** If a separate thread makes changes on the same database connection | | 1395 | +** If a separate thread makes changes on the same database connection |
1395 | +** while [sqlite3_total_changes()] is running then the value | | 1396 | +** while [sqlite3_total_changes()] is running then the value |
1396 | +** returned is unpredictable and not meaningful. | | 1397 | +** returned is unpredictable and not meaningful. |
1397 | +*/ | | 1398 | +*/ |
1398 | +SQLITE_API int sqlite3_total_changes(sqlite3*); | | 1399 | +SQLITE_API int sqlite3_total_changes(sqlite3*); |
1399 | + | | 1400 | + |
1400 | +/* | | 1401 | +/* |
1401 | +** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500> | | 1402 | +** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500> |
1402 | +** | | 1403 | +** |
1403 | +** This function causes any pending database operation to abort and | | 1404 | +** This function causes any pending database operation to abort and |
1404 | +** return at its earliest opportunity. This routine is typically | | 1405 | +** return at its earliest opportunity. This routine is typically |
1405 | +** called in response to a user action such as pressing "Cancel" | | 1406 | +** called in response to a user action such as pressing "Cancel" |
1406 | +** or Ctrl-C where the user wants a long query operation to halt | | 1407 | +** or Ctrl-C where the user wants a long query operation to halt |
1407 | +** immediately. | | 1408 | +** immediately. |
1408 | +** | | 1409 | +** |
1409 | +** It is safe to call this routine from a thread different from the | | 1410 | +** It is safe to call this routine from a thread different from the |
1410 | +** thread that is currently running the database operation. But it | | 1411 | +** thread that is currently running the database operation. But it |
1411 | +** is not safe to call this routine with a [database connection] that | | 1412 | +** is not safe to call this routine with a [database connection] that |
1412 | +** is closed or might close before sqlite3_interrupt() returns. | | 1413 | +** is closed or might close before sqlite3_interrupt() returns. |
1413 | +** | | 1414 | +** |
1414 | +** If an SQL operation is very nearly finished at the time when | | 1415 | +** If an SQL operation is very nearly finished at the time when |
1415 | +** sqlite3_interrupt() is called, then it might not have an opportunity | | 1416 | +** sqlite3_interrupt() is called, then it might not have an opportunity |
1416 | +** to be interrupted and might continue to completion. | | 1417 | +** to be interrupted and might continue to completion. |
1417 | +** | | 1418 | +** |
1418 | +** An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. | | 1419 | +** An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. |
1419 | +** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE | | 1420 | +** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE |
1420 | +** that is inside an explicit transaction, then the entire transaction | | 1421 | +** that is inside an explicit transaction, then the entire transaction |
1421 | +** will be rolled back automatically. | | 1422 | +** will be rolled back automatically. |
1422 | +** | | 1423 | +** |
1423 | +** The sqlite3_interrupt(D) call is in effect until all currently running | | 1424 | +** The sqlite3_interrupt(D) call is in effect until all currently running |
1424 | +** SQL statements on [database connection] D complete. Any new SQL statements | | 1425 | +** SQL statements on [database connection] D complete. Any new SQL statements |
1425 | +** that are started after the sqlite3_interrupt() call and before the | | 1426 | +** that are started after the sqlite3_interrupt() call and before the |
1426 | +** running statements reaches zero are interrupted as if they had been | | 1427 | +** running statements reaches zero are interrupted as if they had been |
1427 | +** running prior to the sqlite3_interrupt() call. New SQL statements | | 1428 | +** running prior to the sqlite3_interrupt() call. New SQL statements |
1428 | +** that are started after the running statement count reaches zero are | | 1429 | +** that are started after the running statement count reaches zero are |
1429 | +** not effected by the sqlite3_interrupt(). | | 1430 | +** not effected by the sqlite3_interrupt(). |
1430 | +** A call to sqlite3_interrupt(D) that occurs when there are no running | | 1431 | +** A call to sqlite3_interrupt(D) that occurs when there are no running |
1431 | +** SQL statements is a no-op and has no effect on SQL statements | | 1432 | +** SQL statements is a no-op and has no effect on SQL statements |
1432 | +** that are started after the sqlite3_interrupt() call returns. | | 1433 | +** that are started after the sqlite3_interrupt() call returns. |
1433 | +** | | 1434 | +** |
1434 | +** Requirements: | | 1435 | +** Requirements: |
1435 | +** [H12271] [H12272] | | 1436 | +** [H12271] [H12272] |
1436 | +** | | 1437 | +** |
1437 | +** If the database connection closes while [sqlite3_interrupt()] | | 1438 | +** If the database connection closes while [sqlite3_interrupt()] |
1438 | +** is running then bad things will likely happen. | | 1439 | +** is running then bad things will likely happen. |
1439 | +*/ | | 1440 | +*/ |
1440 | +SQLITE_API void sqlite3_interrupt(sqlite3*); | | 1441 | +SQLITE_API void sqlite3_interrupt(sqlite3*); |
1441 | + | | 1442 | + |
1442 | +/* | | 1443 | +/* |
1443 | +** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200> | | 1444 | +** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200> |
1444 | +** | | 1445 | +** |
1445 | +** These routines are useful during command-line input to determine if the | | 1446 | +** These routines are useful during command-line input to determine if the |
1446 | +** currently entered text seems to form a complete SQL statement or | | 1447 | +** currently entered text seems to form a complete SQL statement or |
1447 | +** if additional input is needed before sending the text into | | 1448 | +** if additional input is needed before sending the text into |
1448 | +** SQLite for parsing. These routines return 1 if the input string | | 1449 | +** SQLite for parsing. These routines return 1 if the input string |
1449 | +** appears to be a complete SQL statement. A statement is judged to be | | 1450 | +** appears to be a complete SQL statement. A statement is judged to be |
1450 | +** complete if it ends with a semicolon token and is not a prefix of a | | 1451 | +** complete if it ends with a semicolon token and is not a prefix of a |
1451 | +** well-formed CREATE TRIGGER statement. Semicolons that are embedded within | | 1452 | +** well-formed CREATE TRIGGER statement. Semicolons that are embedded within |
1452 | +** string literals or quoted identifier names or comments are not | | 1453 | +** string literals or quoted identifier names or comments are not |
1453 | +** independent tokens (they are part of the token in which they are | | 1454 | +** independent tokens (they are part of the token in which they are |
1454 | +** embedded) and thus do not count as a statement terminator. Whitespace | | 1455 | +** embedded) and thus do not count as a statement terminator. Whitespace |
1455 | +** and comments that follow the final semicolon are ignored. | | 1456 | +** and comments that follow the final semicolon are ignored. |
1456 | +** | | 1457 | +** |
1457 | +** These routines return 0 if the statement is incomplete. If a | | 1458 | +** These routines return 0 if the statement is incomplete. If a |
1458 | +** memory allocation fails, then SQLITE_NOMEM is returned. | | 1459 | +** memory allocation fails, then SQLITE_NOMEM is returned. |
1459 | +** | | 1460 | +** |
1460 | +** These routines do not parse the SQL statements thus | | 1461 | +** These routines do not parse the SQL statements thus |
1461 | +** will not detect syntactically incorrect SQL. | | 1462 | +** will not detect syntactically incorrect SQL. |
1462 | +** | | 1463 | +** |
1463 | +** If SQLite has not been initialized using [sqlite3_initialize()] prior | | 1464 | +** If SQLite has not been initialized using [sqlite3_initialize()] prior |
1464 | +** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked | | 1465 | +** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked |
1465 | +** automatically by sqlite3_complete16(). If that initialization fails, | | 1466 | +** automatically by sqlite3_complete16(). If that initialization fails, |
1466 | +** then the return value from sqlite3_complete16() will be non-zero | | 1467 | +** then the return value from sqlite3_complete16() will be non-zero |
1467 | +** regardless of whether or not the input SQL is complete. | | 1468 | +** regardless of whether or not the input SQL is complete. |
1468 | +** | | 1469 | +** |
1469 | +** Requirements: [H10511] [H10512] | | 1470 | +** Requirements: [H10511] [H10512] |
1470 | +** | | 1471 | +** |
1471 | +** The input to [sqlite3_complete()] must be a zero-terminated | | 1472 | +** The input to [sqlite3_complete()] must be a zero-terminated |
1472 | +** UTF-8 string. | | 1473 | +** UTF-8 string. |
1473 | +** | | 1474 | +** |
1474 | +** The input to [sqlite3_complete16()] must be a zero-terminated | | 1475 | +** The input to [sqlite3_complete16()] must be a zero-terminated |
1475 | +** UTF-16 string in native byte order. | | 1476 | +** UTF-16 string in native byte order. |
1476 | +*/ | | 1477 | +*/ |
1477 | +SQLITE_API int sqlite3_complete(const char *sql); | | 1478 | +SQLITE_API int sqlite3_complete(const char *sql); |
1478 | +SQLITE_API int sqlite3_complete16(const void *sql); | | 1479 | +SQLITE_API int sqlite3_complete16(const void *sql); |
1479 | + | | 1480 | + |
1480 | +/* | | 1481 | +/* |
1481 | +** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400> | | 1482 | +** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400> |
1482 | +** | | 1483 | +** |
1483 | +** This routine sets a callback function that might be invoked whenever | | 1484 | +** This routine sets a callback function that might be invoked whenever |
1484 | +** an attempt is made to open a database table that another thread | | 1485 | +** an attempt is made to open a database table that another thread |
1485 | +** or process has locked. | | 1486 | +** or process has locked. |
1486 | +** | | 1487 | +** |
1487 | +** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] | | 1488 | +** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] |
1488 | +** is returned immediately upon encountering the lock. If the busy callback | | 1489 | +** is returned immediately upon encountering the lock. If the busy callback |
1489 | +** is not NULL, then the callback will be invoked with two arguments. | | 1490 | +** is not NULL, then the callback will be invoked with two arguments. |
1490 | +** | | 1491 | +** |
1491 | +** The first argument to the handler is a copy of the void* pointer which | | 1492 | +** The first argument to the handler is a copy of the void* pointer which |
1492 | +** is the third argument to sqlite3_busy_handler(). The second argument to | | 1493 | +** is the third argument to sqlite3_busy_handler(). The second argument to |
1493 | +** the handler callback is the number of times that the busy handler has | | 1494 | +** the handler callback is the number of times that the busy handler has |
1494 | +** been invoked for this locking event. If the | | 1495 | +** been invoked for this locking event. If the |
1495 | +** busy callback returns 0, then no additional attempts are made to | | 1496 | +** busy callback returns 0, then no additional attempts are made to |
1496 | +** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. | | 1497 | +** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. |
1497 | +** If the callback returns non-zero, then another attempt | | 1498 | +** If the callback returns non-zero, then another attempt |
1498 | +** is made to open the database for reading and the cycle repeats. | | 1499 | +** is made to open the database for reading and the cycle repeats. |
1499 | +** | | 1500 | +** |
1500 | +** The presence of a busy handler does not guarantee that it will be invoked | | 1501 | +** The presence of a busy handler does not guarantee that it will be invoked |
1501 | +** when there is lock contention. If SQLite determines that invoking the busy | | 1502 | +** when there is lock contention. If SQLite determines that invoking the busy |
1502 | +** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] | | 1503 | +** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] |
1503 | +** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. | | 1504 | +** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. |
1504 | +** Consider a scenario where one process is holding a read lock that | | 1505 | +** Consider a scenario where one process is holding a read lock that |
1505 | +** it is trying to promote to a reserved lock and | | 1506 | +** it is trying to promote to a reserved lock and |
1506 | +** a second process is holding a reserved lock that it is trying | | 1507 | +** a second process is holding a reserved lock that it is trying |
1507 | +** to promote to an exclusive lock. The first process cannot proceed | | 1508 | +** to promote to an exclusive lock. The first process cannot proceed |
1508 | +** because it is blocked by the second and the second process cannot | | 1509 | +** because it is blocked by the second and the second process cannot |
1509 | +** proceed because it is blocked by the first. If both processes | | 1510 | +** proceed because it is blocked by the first. If both processes |
1510 | +** invoke the busy handlers, neither will make any progress. Therefore, | | 1511 | +** invoke the busy handlers, neither will make any progress. Therefore, |
1511 | +** SQLite returns [SQLITE_BUSY] for the first process, hoping that this | | 1512 | +** SQLite returns [SQLITE_BUSY] for the first process, hoping that this |
1512 | +** will induce the first process to release its read lock and allow | | 1513 | +** will induce the first process to release its read lock and allow |
1513 | +** the second process to proceed. | | 1514 | +** the second process to proceed. |
1514 | +** | | 1515 | +** |
1515 | +** The default busy callback is NULL. | | 1516 | +** The default busy callback is NULL. |
1516 | +** | | 1517 | +** |
1517 | +** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] | | 1518 | +** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] |
1518 | +** when SQLite is in the middle of a large transaction where all the | | 1519 | +** when SQLite is in the middle of a large transaction where all the |
1519 | +** changes will not fit into the in-memory cache. SQLite will | | 1520 | +** changes will not fit into the in-memory cache. SQLite will |
1520 | +** already hold a RESERVED lock on the database file, but it needs | | 1521 | +** already hold a RESERVED lock on the database file, but it needs |
1521 | +** to promote this lock to EXCLUSIVE so that it can spill cache | | 1522 | +** to promote this lock to EXCLUSIVE so that it can spill cache |
1522 | +** pages into the database file without harm to concurrent | | 1523 | +** pages into the database file without harm to concurrent |
1523 | +** readers. If it is unable to promote the lock, then the in-memory | | 1524 | +** readers. If it is unable to promote the lock, then the in-memory |
1524 | +** cache will be left in an inconsistent state and so the error | | 1525 | +** cache will be left in an inconsistent state and so the error |
1525 | +** code is promoted from the relatively benign [SQLITE_BUSY] to | | 1526 | +** code is promoted from the relatively benign [SQLITE_BUSY] to |
1526 | +** the more severe [SQLITE_IOERR_BLOCKED]. This error code promotion | | 1527 | +** the more severe [SQLITE_IOERR_BLOCKED]. This error code promotion |
1527 | +** forces an automatic rollback of the changes. See the | | 1528 | +** forces an automatic rollback of the changes. See the |
1528 | +** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError"> | | 1529 | +** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError"> |
1529 | +** CorruptionFollowingBusyError</a> wiki page for a discussion of why | | 1530 | +** CorruptionFollowingBusyError</a> wiki page for a discussion of why |
1530 | +** this is important. | | 1531 | +** this is important. |
1531 | +** | | 1532 | +** |
1532 | +** There can only be a single busy handler defined for each | | 1533 | +** There can only be a single busy handler defined for each |
1533 | +** [database connection]. Setting a new busy handler clears any | | 1534 | +** [database connection]. Setting a new busy handler clears any |
1534 | +** previously set handler. Note that calling [sqlite3_busy_timeout()] | | 1535 | +** previously set handler. Note that calling [sqlite3_busy_timeout()] |
1535 | +** will also set or clear the busy handler. | | 1536 | +** will also set or clear the busy handler. |
1536 | +** | | 1537 | +** |
1537 | +** The busy callback should not take any actions which modify the | | 1538 | +** The busy callback should not take any actions which modify the |
1538 | +** database connection that invoked the busy handler. Any such actions | | 1539 | +** database connection that invoked the busy handler. Any such actions |
1539 | +** result in undefined behavior. | | 1540 | +** result in undefined behavior. |
1540 | +** | | 1541 | +** |
1541 | +** Requirements: | | 1542 | +** Requirements: |
1542 | +** [H12311] [H12312] [H12314] [H12316] [H12318] | | 1543 | +** [H12311] [H12312] [H12314] [H12316] [H12318] |
1543 | +** | | 1544 | +** |
1544 | +** A busy handler must not close the database connection | | 1545 | +** A busy handler must not close the database connection |
1545 | +** or [prepared statement] that invoked the busy handler. | | 1546 | +** or [prepared statement] that invoked the busy handler. |
1546 | +*/ | | 1547 | +*/ |
1547 | +SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); | | 1548 | +SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); |
1548 | + | | 1549 | + |
1549 | +/* | | 1550 | +/* |
1550 | +** CAPI3REF: Set A Busy Timeout {H12340} <S40410> | | 1551 | +** CAPI3REF: Set A Busy Timeout {H12340} <S40410> |
1551 | +** | | 1552 | +** |
1552 | +** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps | | 1553 | +** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps |
1553 | +** for a specified amount of time when a table is locked. The handler | | 1554 | +** for a specified amount of time when a table is locked. The handler |
1554 | +** will sleep multiple times until at least "ms" milliseconds of sleeping | | 1555 | +** will sleep multiple times until at least "ms" milliseconds of sleeping |
1555 | +** have accumulated. {H12343} After "ms" milliseconds of sleeping, | | 1556 | +** have accumulated. {H12343} After "ms" milliseconds of sleeping, |
1556 | +** the handler returns 0 which causes [sqlite3_step()] to return | | 1557 | +** the handler returns 0 which causes [sqlite3_step()] to return |
1557 | +** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. | | 1558 | +** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. |
1558 | +** | | 1559 | +** |
1559 | +** Calling this routine with an argument less than or equal to zero | | 1560 | +** Calling this routine with an argument less than or equal to zero |
1560 | +** turns off all busy handlers. | | 1561 | +** turns off all busy handlers. |
1561 | +** | | 1562 | +** |
1562 | +** There can only be a single busy handler for a particular | | 1563 | +** There can only be a single busy handler for a particular |
1563 | +** [database connection] any any given moment. If another busy handler | | 1564 | +** [database connection] any any given moment. If another busy handler |
1564 | +** was defined (using [sqlite3_busy_handler()]) prior to calling | | 1565 | +** was defined (using [sqlite3_busy_handler()]) prior to calling |
1565 | +** this routine, that other busy handler is cleared. | | 1566 | +** this routine, that other busy handler is cleared. |
1566 | +** | | 1567 | +** |
1567 | +** Requirements: | | 1568 | +** Requirements: |
1568 | +** [H12341] [H12343] [H12344] | | 1569 | +** [H12341] [H12343] [H12344] |
1569 | +*/ | | 1570 | +*/ |
1570 | +SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); | | 1571 | +SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); |
1571 | + | | 1572 | + |
1572 | +/* | | 1573 | +/* |
1573 | +** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000> | | 1574 | +** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000> |
1574 | +** | | 1575 | +** |
1575 | +** Definition: A <b>result table</b> is memory data structure created by the | | 1576 | +** Definition: A <b>result table</b> is memory data structure created by the |
1576 | +** [sqlite3_get_table()] interface. A result table records the | | 1577 | +** [sqlite3_get_table()] interface. A result table records the |
1577 | +** complete query results from one or more queries. | | 1578 | +** complete query results from one or more queries. |
1578 | +** | | 1579 | +** |
1579 | +** The table conceptually has a number of rows and columns. But | | 1580 | +** The table conceptually has a number of rows and columns. But |
1580 | +** these numbers are not part of the result table itself. These | | 1581 | +** these numbers are not part of the result table itself. These |
1581 | +** numbers are obtained separately. Let N be the number of rows | | 1582 | +** numbers are obtained separately. Let N be the number of rows |
1582 | +** and M be the number of columns. | | 1583 | +** and M be the number of columns. |
1583 | +** | | 1584 | +** |
1584 | +** A result table is an array of pointers to zero-terminated UTF-8 strings. | | 1585 | +** A result table is an array of pointers to zero-terminated UTF-8 strings. |
1585 | +** There are (N+1)*M elements in the array. The first M pointers point | | 1586 | +** There are (N+1)*M elements in the array. The first M pointers point |
1586 | +** to zero-terminated strings that contain the names of the columns. | | 1587 | +** to zero-terminated strings that contain the names of the columns. |
1587 | +** The remaining entries all point to query results. NULL values result | | 1588 | +** The remaining entries all point to query results. NULL values result |
1588 | +** in NULL pointers. All other values are in their UTF-8 zero-terminated | | 1589 | +** in NULL pointers. All other values are in their UTF-8 zero-terminated |
1589 | +** string representation as returned by [sqlite3_column_text()]. | | 1590 | +** string representation as returned by [sqlite3_column_text()]. |
1590 | +** | | 1591 | +** |
1591 | +** A result table might consist of one or more memory allocations. | | 1592 | +** A result table might consist of one or more memory allocations. |
1592 | +** It is not safe to pass a result table directly to [sqlite3_free()]. | | 1593 | +** It is not safe to pass a result table directly to [sqlite3_free()]. |
1593 | +** A result table should be deallocated using [sqlite3_free_table()]. | | 1594 | +** A result table should be deallocated using [sqlite3_free_table()]. |
1594 | +** | | 1595 | +** |
1595 | +** As an example of the result table format, suppose a query result | | 1596 | +** As an example of the result table format, suppose a query result |
1596 | +** is as follows: | | 1597 | +** is as follows: |
1597 | +** | | 1598 | +** |
1598 | +** <blockquote><pre> | | 1599 | +** <blockquote><pre> |
1599 | +** Name | Age | | 1600 | +** Name | Age |
1600 | +** ----------------------- | | 1601 | +** ----------------------- |
1601 | +** Alice | 43 | | 1602 | +** Alice | 43 |
1602 | +** Bob | 28 | | 1603 | +** Bob | 28 |
1603 | +** Cindy | 21 | | 1604 | +** Cindy | 21 |
1604 | +** </pre></blockquote> | | 1605 | +** </pre></blockquote> |
1605 | +** | | 1606 | +** |
1606 | +** There are two column (M==2) and three rows (N==3). Thus the | | 1607 | +** There are two column (M==2) and three rows (N==3). Thus the |
1607 | +** result table has 8 entries. Suppose the result table is stored | | 1608 | +** result table has 8 entries. Suppose the result table is stored |
1608 | +** in an array names azResult. Then azResult holds this content: | | 1609 | +** in an array names azResult. Then azResult holds this content: |
1609 | +** | | 1610 | +** |
1610 | +** <blockquote><pre> | | 1611 | +** <blockquote><pre> |
1611 | +** azResult[0] = "Name"; | | 1612 | +** azResult[0] = "Name"; |
1612 | +** azResult[1] = "Age"; | | 1613 | +** azResult[1] = "Age"; |
1613 | +** azResult[2] = "Alice"; | | 1614 | +** azResult[2] = "Alice"; |
1614 | +** azResult[3] = "43"; | | 1615 | +** azResult[3] = "43"; |
1615 | +** azResult[4] = "Bob"; | | 1616 | +** azResult[4] = "Bob"; |
1616 | +** azResult[5] = "28"; | | 1617 | +** azResult[5] = "28"; |
1617 | +** azResult[6] = "Cindy"; | | 1618 | +** azResult[6] = "Cindy"; |
1618 | +** azResult[7] = "21"; | | 1619 | +** azResult[7] = "21"; |
1619 | +** </pre></blockquote> | | 1620 | +** </pre></blockquote> |
1620 | +** | | 1621 | +** |
1621 | +** The sqlite3_get_table() function evaluates one or more | | 1622 | +** The sqlite3_get_table() function evaluates one or more |
1622 | +** semicolon-separated SQL statements in the zero-terminated UTF-8 | | 1623 | +** semicolon-separated SQL statements in the zero-terminated UTF-8 |
1623 | +** string of its 2nd parameter. It returns a result table to the | | 1624 | +** string of its 2nd parameter. It returns a result table to the |
1624 | +** pointer given in its 3rd parameter. | | 1625 | +** pointer given in its 3rd parameter. |
1625 | +** | | 1626 | +** |
1626 | +** After the calling function has finished using the result, it should | | 1627 | +** After the calling function has finished using the result, it should |
1627 | +** pass the pointer to the result table to sqlite3_free_table() in order to | | 1628 | +** pass the pointer to the result table to sqlite3_free_table() in order to |
1628 | +** release the memory that was malloced. Because of the way the | | 1629 | +** release the memory that was malloced. Because of the way the |
1629 | +** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling | | 1630 | +** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling |
1630 | +** function must not try to call [sqlite3_free()] directly. Only | | 1631 | +** function must not try to call [sqlite3_free()] directly. Only |
1631 | +** [sqlite3_free_table()] is able to release the memory properly and safely. | | 1632 | +** [sqlite3_free_table()] is able to release the memory properly and safely. |
1632 | +** | | 1633 | +** |
1633 | +** The sqlite3_get_table() interface is implemented as a wrapper around | | 1634 | +** The sqlite3_get_table() interface is implemented as a wrapper around |
1634 | +** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access | | 1635 | +** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access |
1635 | +** to any internal data structures of SQLite. It uses only the public | | 1636 | +** to any internal data structures of SQLite. It uses only the public |
1636 | +** interface defined here. As a consequence, errors that occur in the | | 1637 | +** interface defined here. As a consequence, errors that occur in the |
1637 | +** wrapper layer outside of the internal [sqlite3_exec()] call are not | | 1638 | +** wrapper layer outside of the internal [sqlite3_exec()] call are not |
1638 | +** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()]. | | 1639 | +** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()]. |
1639 | +** | | 1640 | +** |
1640 | +** Requirements: | | 1641 | +** Requirements: |
1641 | +** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382] | | 1642 | +** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382] |
1642 | +*/ | | 1643 | +*/ |
1643 | +SQLITE_API int sqlite3_get_table( | | 1644 | +SQLITE_API int sqlite3_get_table( |
1644 | + sqlite3 *db, /* An open database */ | | 1645 | + sqlite3 *db, /* An open database */ |
1645 | + const char *zSql, /* SQL to be evaluated */ | | 1646 | + const char *zSql, /* SQL to be evaluated */ |
1646 | + char ***pazResult, /* Results of the query */ | | 1647 | + char ***pazResult, /* Results of the query */ |
1647 | + int *pnRow, /* Number of result rows written here */ | | 1648 | + int *pnRow, /* Number of result rows written here */ |
1648 | + int *pnColumn, /* Number of result columns written here */ | | 1649 | + int *pnColumn, /* Number of result columns written here */ |
1649 | + char **pzErrmsg /* Error msg written here */ | | 1650 | + char **pzErrmsg /* Error msg written here */ |
1650 | +); | | 1651 | +); |
1651 | +SQLITE_API void sqlite3_free_table(char **result); | | 1652 | +SQLITE_API void sqlite3_free_table(char **result); |
1652 | + | | 1653 | + |
1653 | +/* | | 1654 | +/* |
1654 | +** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000> | | 1655 | +** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000> |
1655 | +** | | 1656 | +** |
1656 | +** These routines are work-alikes of the "printf()" family of functions | | 1657 | +** These routines are work-alikes of the "printf()" family of functions |
1657 | +** from the standard C library. | | 1658 | +** from the standard C library. |
1658 | +** | | 1659 | +** |
1659 | +** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their | | 1660 | +** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their |
1660 | +** results into memory obtained from [sqlite3_malloc()]. | | 1661 | +** results into memory obtained from [sqlite3_malloc()]. |
1661 | +** The strings returned by these two routines should be | | 1662 | +** The strings returned by these two routines should be |
1662 | +** released by [sqlite3_free()]. Both routines return a | | 1663 | +** released by [sqlite3_free()]. Both routines return a |
1663 | +** NULL pointer if [sqlite3_malloc()] is unable to allocate enough | | 1664 | +** NULL pointer if [sqlite3_malloc()] is unable to allocate enough |
1664 | +** memory to hold the resulting string. | | 1665 | +** memory to hold the resulting string. |
1665 | +** | | 1666 | +** |
1666 | +** In sqlite3_snprintf() routine is similar to "snprintf()" from | | 1667 | +** In sqlite3_snprintf() routine is similar to "snprintf()" from |
1667 | +** the standard C library. The result is written into the | | 1668 | +** the standard C library. The result is written into the |
1668 | +** buffer supplied as the second parameter whose size is given by | | 1669 | +** buffer supplied as the second parameter whose size is given by |
1669 | +** the first parameter. Note that the order of the | | 1670 | +** the first parameter. Note that the order of the |
1670 | +** first two parameters is reversed from snprintf(). This is an | | 1671 | +** first two parameters is reversed from snprintf(). This is an |
1671 | +** historical accident that cannot be fixed without breaking | | 1672 | +** historical accident that cannot be fixed without breaking |
1672 | +** backwards compatibility. Note also that sqlite3_snprintf() | | 1673 | +** backwards compatibility. Note also that sqlite3_snprintf() |
1673 | +** returns a pointer to its buffer instead of the number of | | 1674 | +** returns a pointer to its buffer instead of the number of |
1674 | +** characters actually written into the buffer. We admit that | | 1675 | +** characters actually written into the buffer. We admit that |
1675 | +** the number of characters written would be a more useful return | | 1676 | +** the number of characters written would be a more useful return |
1676 | +** value but we cannot change the implementation of sqlite3_snprintf() | | 1677 | +** value but we cannot change the implementation of sqlite3_snprintf() |
1677 | +** now without breaking compatibility. | | 1678 | +** now without breaking compatibility. |
1678 | +** | | 1679 | +** |
1679 | +** As long as the buffer size is greater than zero, sqlite3_snprintf() | | 1680 | +** As long as the buffer size is greater than zero, sqlite3_snprintf() |
1680 | +** guarantees that the buffer is always zero-terminated. The first | | 1681 | +** guarantees that the buffer is always zero-terminated. The first |
1681 | +** parameter "n" is the total size of the buffer, including space for | | 1682 | +** parameter "n" is the total size of the buffer, including space for |
1682 | +** the zero terminator. So the longest string that can be completely | | 1683 | +** the zero terminator. So the longest string that can be completely |
1683 | +** written will be n-1 characters. | | 1684 | +** written will be n-1 characters. |
1684 | +** | | 1685 | +** |
1685 | +** These routines all implement some additional formatting | | 1686 | +** These routines all implement some additional formatting |
1686 | +** options that are useful for constructing SQL statements. | | 1687 | +** options that are useful for constructing SQL statements. |
1687 | +** All of the usual printf() formatting options apply. In addition, there | | 1688 | +** All of the usual printf() formatting options apply. In addition, there |
1688 | +** is are "%q", "%Q", and "%z" options. | | 1689 | +** is are "%q", "%Q", and "%z" options. |
1689 | +** | | 1690 | +** |
1690 | +** The %q option works like %s in that it substitutes a null-terminated | | 1691 | +** The %q option works like %s in that it substitutes a null-terminated |
1691 | +** string from the argument list. But %q also doubles every '\'' character. | | 1692 | +** string from the argument list. But %q also doubles every '\'' character. |
1692 | +** %q is designed for use inside a string literal. By doubling each '\'' | | 1693 | +** %q is designed for use inside a string literal. By doubling each '\'' |
1693 | +** character it escapes that character and allows it to be inserted into | | 1694 | +** character it escapes that character and allows it to be inserted into |
1694 | +** the string. | | 1695 | +** the string. |
1695 | +** | | 1696 | +** |
1696 | +** For example, assume the string variable zText contains text as follows: | | 1697 | +** For example, assume the string variable zText contains text as follows: |
1697 | +** | | 1698 | +** |
1698 | +** <blockquote><pre> | | 1699 | +** <blockquote><pre> |
1699 | +** char *zText = "It's a happy day!"; | | 1700 | +** char *zText = "It's a happy day!"; |
1700 | +** </pre></blockquote> | | 1701 | +** </pre></blockquote> |
1701 | +** | | 1702 | +** |
1702 | +** One can use this text in an SQL statement as follows: | | 1703 | +** One can use this text in an SQL statement as follows: |
1703 | +** | | 1704 | +** |
1704 | +** <blockquote><pre> | | 1705 | +** <blockquote><pre> |
1705 | +** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText); | | 1706 | +** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText); |
1706 | +** sqlite3_exec(db, zSQL, 0, 0, 0); | | 1707 | +** sqlite3_exec(db, zSQL, 0, 0, 0); |
1707 | +** sqlite3_free(zSQL); | | 1708 | +** sqlite3_free(zSQL); |
1708 | +** </pre></blockquote> | | 1709 | +** </pre></blockquote> |
1709 | +** | | 1710 | +** |
1710 | +** Because the %q format string is used, the '\'' character in zText | | 1711 | +** Because the %q format string is used, the '\'' character in zText |
1711 | +** is escaped and the SQL generated is as follows: | | 1712 | +** is escaped and the SQL generated is as follows: |
1712 | +** | | 1713 | +** |
1713 | +** <blockquote><pre> | | 1714 | +** <blockquote><pre> |
1714 | +** INSERT INTO table1 VALUES('It''s a happy day!') | | 1715 | +** INSERT INTO table1 VALUES('It''s a happy day!') |
1715 | +** </pre></blockquote> | | 1716 | +** </pre></blockquote> |
1716 | +** | | 1717 | +** |
1717 | +** This is correct. Had we used %s instead of %q, the generated SQL | | 1718 | +** This is correct. Had we used %s instead of %q, the generated SQL |
1718 | +** would have looked like this: | | 1719 | +** would have looked like this: |
1719 | +** | | 1720 | +** |
1720 | +** <blockquote><pre> | | 1721 | +** <blockquote><pre> |
1721 | +** INSERT INTO table1 VALUES('It's a happy day!'); | | 1722 | +** INSERT INTO table1 VALUES('It's a happy day!'); |
1722 | +** </pre></blockquote> | | 1723 | +** </pre></blockquote> |
1723 | +** | | 1724 | +** |
1724 | +** This second example is an SQL syntax error. As a general rule you should | | 1725 | +** This second example is an SQL syntax error. As a general rule you should |
1725 | +** always use %q instead of %s when inserting text into a string literal. | | 1726 | +** always use %q instead of %s when inserting text into a string literal. |
1726 | +** | | 1727 | +** |
1727 | +** The %Q option works like %q except it also adds single quotes around | | 1728 | +** The %Q option works like %q except it also adds single quotes around |
1728 | +** the outside of the total string. Additionally, if the parameter in the | | 1729 | +** the outside of the total string. Additionally, if the parameter in the |
1729 | +** argument list is a NULL pointer, %Q substitutes the text "NULL" (without | | 1730 | +** argument list is a NULL pointer, %Q substitutes the text "NULL" (without |
1730 | +** single quotes) in place of the %Q option. So, for example, one could say: | | 1731 | +** single quotes) in place of the %Q option. So, for example, one could say: |
1731 | +** | | 1732 | +** |
1732 | +** <blockquote><pre> | | 1733 | +** <blockquote><pre> |
1733 | +** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText); | | 1734 | +** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText); |
1734 | +** sqlite3_exec(db, zSQL, 0, 0, 0); | | 1735 | +** sqlite3_exec(db, zSQL, 0, 0, 0); |
1735 | +** sqlite3_free(zSQL); | | 1736 | +** sqlite3_free(zSQL); |
1736 | +** </pre></blockquote> | | 1737 | +** </pre></blockquote> |
1737 | +** | | 1738 | +** |
1738 | +** The code above will render a correct SQL statement in the zSQL | | 1739 | +** The code above will render a correct SQL statement in the zSQL |
1739 | +** variable even if the zText variable is a NULL pointer. | | 1740 | +** variable even if the zText variable is a NULL pointer. |
1740 | +** | | 1741 | +** |
1741 | +** The "%z" formatting option works exactly like "%s" with the | | 1742 | +** The "%z" formatting option works exactly like "%s" with the |
1742 | +** addition that after the string has been read and copied into | | 1743 | +** addition that after the string has been read and copied into |
1743 | +** the result, [sqlite3_free()] is called on the input string. {END} | | 1744 | +** the result, [sqlite3_free()] is called on the input string. {END} |
1744 | +** | | 1745 | +** |
1745 | +** Requirements: | | 1746 | +** Requirements: |
1746 | +** [H17403] [H17406] [H17407] | | 1747 | +** [H17403] [H17406] [H17407] |
1747 | +*/ | | 1748 | +*/ |
1748 | +SQLITE_API char *sqlite3_mprintf(const char*,...); | | 1749 | +SQLITE_API char *sqlite3_mprintf(const char*,...); |
1749 | +SQLITE_API char *sqlite3_vmprintf(const char*, va_list); | | 1750 | +SQLITE_API char *sqlite3_vmprintf(const char*, va_list); |
1750 | +SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); | | 1751 | +SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); |
1751 | + | | 1752 | + |
1752 | +/* | | 1753 | +/* |
1753 | +** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000> | | 1754 | +** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000> |
1754 | +** | | 1755 | +** |
1755 | +** The SQLite core uses these three routines for all of its own | | 1756 | +** The SQLite core uses these three routines for all of its own |
1756 | +** internal memory allocation needs. "Core" in the previous sentence | | 1757 | +** internal memory allocation needs. "Core" in the previous sentence |
1757 | +** does not include operating-system specific VFS implementation. The | | 1758 | +** does not include operating-system specific VFS implementation. The |
1758 | +** Windows VFS uses native malloc() and free() for some operations. | | 1759 | +** Windows VFS uses native malloc() and free() for some operations. |
1759 | +** | | 1760 | +** |
1760 | +** The sqlite3_malloc() routine returns a pointer to a block | | 1761 | +** The sqlite3_malloc() routine returns a pointer to a block |
1761 | +** of memory at least N bytes in length, where N is the parameter. | | 1762 | +** of memory at least N bytes in length, where N is the parameter. |
1762 | +** If sqlite3_malloc() is unable to obtain sufficient free | | 1763 | +** If sqlite3_malloc() is unable to obtain sufficient free |
1763 | +** memory, it returns a NULL pointer. If the parameter N to | | 1764 | +** memory, it returns a NULL pointer. If the parameter N to |
1764 | +** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns | | 1765 | +** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns |
1765 | +** a NULL pointer. | | 1766 | +** a NULL pointer. |
1766 | +** | | 1767 | +** |
1767 | +** Calling sqlite3_free() with a pointer previously returned | | 1768 | +** Calling sqlite3_free() with a pointer previously returned |
1768 | +** by sqlite3_malloc() or sqlite3_realloc() releases that memory so | | 1769 | +** by sqlite3_malloc() or sqlite3_realloc() releases that memory so |
1769 | +** that it might be reused. The sqlite3_free() routine is | | 1770 | +** that it might be reused. The sqlite3_free() routine is |
1770 | +** a no-op if is called with a NULL pointer. Passing a NULL pointer | | 1771 | +** a no-op if is called with a NULL pointer. Passing a NULL pointer |
1771 | +** to sqlite3_free() is harmless. After being freed, memory | | 1772 | +** to sqlite3_free() is harmless. After being freed, memory |
1772 | +** should neither be read nor written. Even reading previously freed | | 1773 | +** should neither be read nor written. Even reading previously freed |
1773 | +** memory might result in a segmentation fault or other severe error. | | 1774 | +** memory might result in a segmentation fault or other severe error. |
1774 | +** Memory corruption, a segmentation fault, or other severe error | | 1775 | +** Memory corruption, a segmentation fault, or other severe error |
1775 | +** might result if sqlite3_free() is called with a non-NULL pointer that | | 1776 | +** might result if sqlite3_free() is called with a non-NULL pointer that |
1776 | +** was not obtained from sqlite3_malloc() or sqlite3_realloc(). | | 1777 | +** was not obtained from sqlite3_malloc() or sqlite3_realloc(). |
1777 | +** | | 1778 | +** |
1778 | +** The sqlite3_realloc() interface attempts to resize a | | 1779 | +** The sqlite3_realloc() interface attempts to resize a |
1779 | +** prior memory allocation to be at least N bytes, where N is the | | 1780 | +** prior memory allocation to be at least N bytes, where N is the |
1780 | +** second parameter. The memory allocation to be resized is the first | | 1781 | +** second parameter. The memory allocation to be resized is the first |
1781 | +** parameter. If the first parameter to sqlite3_realloc() | | 1782 | +** parameter. If the first parameter to sqlite3_realloc() |
1782 | +** is a NULL pointer then its behavior is identical to calling | | 1783 | +** is a NULL pointer then its behavior is identical to calling |
1783 | +** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). | | 1784 | +** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). |
1784 | +** If the second parameter to sqlite3_realloc() is zero or | | 1785 | +** If the second parameter to sqlite3_realloc() is zero or |
1785 | +** negative then the behavior is exactly the same as calling | | 1786 | +** negative then the behavior is exactly the same as calling |
1786 | +** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). | | 1787 | +** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). |
1787 | +** sqlite3_realloc() returns a pointer to a memory allocation | | 1788 | +** sqlite3_realloc() returns a pointer to a memory allocation |
1788 | +** of at least N bytes in size or NULL if sufficient memory is unavailable. | | 1789 | +** of at least N bytes in size or NULL if sufficient memory is unavailable. |
1789 | +** If M is the size of the prior allocation, then min(N,M) bytes | | 1790 | +** If M is the size of the prior allocation, then min(N,M) bytes |
1790 | +** of the prior allocation are copied into the beginning of buffer returned | | 1791 | +** of the prior allocation are copied into the beginning of buffer returned |
1791 | +** by sqlite3_realloc() and the prior allocation is freed. | | 1792 | +** by sqlite3_realloc() and the prior allocation is freed. |
1792 | +** If sqlite3_realloc() returns NULL, then the prior allocation | | 1793 | +** If sqlite3_realloc() returns NULL, then the prior allocation |
1793 | +** is not freed. | | 1794 | +** is not freed. |
1794 | +** | | 1795 | +** |
1795 | +** The memory returned by sqlite3_malloc() and sqlite3_realloc() | | 1796 | +** The memory returned by sqlite3_malloc() and sqlite3_realloc() |
1796 | +** is always aligned to at least an 8 byte boundary. {END} | | 1797 | +** is always aligned to at least an 8 byte boundary. {END} |
1797 | +** | | 1798 | +** |
1798 | +** The default implementation of the memory allocation subsystem uses | | 1799 | +** The default implementation of the memory allocation subsystem uses |
1799 | +** the malloc(), realloc() and free() provided by the standard C library. | | 1800 | +** the malloc(), realloc() and free() provided by the standard C library. |
1800 | +** {H17382} However, if SQLite is compiled with the | | 1801 | +** {H17382} However, if SQLite is compiled with the |
1801 | +** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i> | | 1802 | +** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i> |
1802 | +** is an integer), then SQLite create a static array of at least | | 1803 | +** is an integer), then SQLite create a static array of at least |
1803 | +** <i>NNN</i> bytes in size and uses that array for all of its dynamic | | 1804 | +** <i>NNN</i> bytes in size and uses that array for all of its dynamic |
1804 | +** memory allocation needs. {END} Additional memory allocator options | | 1805 | +** memory allocation needs. {END} Additional memory allocator options |
1805 | +** may be added in future releases. | | 1806 | +** may be added in future releases. |
1806 | +** | | 1807 | +** |
1807 | +** In SQLite version 3.5.0 and 3.5.1, it was possible to define | | 1808 | +** In SQLite version 3.5.0 and 3.5.1, it was possible to define |
1808 | +** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in | | 1809 | +** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in |
1809 | +** implementation of these routines to be omitted. That capability | | 1810 | +** implementation of these routines to be omitted. That capability |
1810 | +** is no longer provided. Only built-in memory allocators can be used. | | 1811 | +** is no longer provided. Only built-in memory allocators can be used. |
1811 | +** | | 1812 | +** |
1812 | +** The Windows OS interface layer calls | | 1813 | +** The Windows OS interface layer calls |
1813 | +** the system malloc() and free() directly when converting | | 1814 | +** the system malloc() and free() directly when converting |
1814 | +** filenames between the UTF-8 encoding used by SQLite | | 1815 | +** filenames between the UTF-8 encoding used by SQLite |
1815 | +** and whatever filename encoding is used by the particular Windows | | 1816 | +** and whatever filename encoding is used by the particular Windows |
1816 | +** installation. Memory allocation errors are detected, but | | 1817 | +** installation. Memory allocation errors are detected, but |
1817 | +** they are reported back as [SQLITE_CANTOPEN] or | | 1818 | +** they are reported back as [SQLITE_CANTOPEN] or |
1818 | +** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. | | 1819 | +** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. |
1819 | +** | | 1820 | +** |
1820 | +** Requirements: | | 1821 | +** Requirements: |
1821 | +** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318] | | 1822 | +** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318] |
1822 | +** [H17321] [H17322] [H17323] | | 1823 | +** [H17321] [H17322] [H17323] |
1823 | +** | | 1824 | +** |
1824 | +** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] | | 1825 | +** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] |
1825 | +** must be either NULL or else pointers obtained from a prior | | 1826 | +** must be either NULL or else pointers obtained from a prior |
1826 | +** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have | | 1827 | +** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have |
1827 | +** not yet been released. | | 1828 | +** not yet been released. |
1828 | +** | | 1829 | +** |
1829 | +** The application must not read or write any part of | | 1830 | +** The application must not read or write any part of |
1830 | +** a block of memory after it has been released using | | 1831 | +** a block of memory after it has been released using |
1831 | +** [sqlite3_free()] or [sqlite3_realloc()]. | | 1832 | +** [sqlite3_free()] or [sqlite3_realloc()]. |
1832 | +*/ | | 1833 | +*/ |
1833 | +SQLITE_API void *sqlite3_malloc(int); | | 1834 | +SQLITE_API void *sqlite3_malloc(int); |
1834 | +SQLITE_API void *sqlite3_realloc(void*, int); | | 1835 | +SQLITE_API void *sqlite3_realloc(void*, int); |
1835 | +SQLITE_API void sqlite3_free(void*); | | 1836 | +SQLITE_API void sqlite3_free(void*); |
1836 | + | | 1837 | + |
1837 | +/* | | 1838 | +/* |
1838 | +** CAPI3REF: Memory Allocator Statistics {H17370} <S30210> | | 1839 | +** CAPI3REF: Memory Allocator Statistics {H17370} <S30210> |
1839 | +** | | 1840 | +** |
1840 | +** SQLite provides these two interfaces for reporting on the status | | 1841 | +** SQLite provides these two interfaces for reporting on the status |
1841 | +** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] | | 1842 | +** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] |
1842 | +** routines, which form the built-in memory allocation subsystem. | | 1843 | +** routines, which form the built-in memory allocation subsystem. |
1843 | +** | | 1844 | +** |
1844 | +** Requirements: | | 1845 | +** Requirements: |
1845 | +** [H17371] [H17373] [H17374] [H17375] | | 1846 | +** [H17371] [H17373] [H17374] [H17375] |
1846 | +*/ | | 1847 | +*/ |
1847 | +SQLITE_API sqlite3_int64 sqlite3_memory_used(void); | | 1848 | +SQLITE_API sqlite3_int64 sqlite3_memory_used(void); |
1848 | +SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); | | 1849 | +SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); |
1849 | + | | 1850 | + |
1850 | +/* | | 1851 | +/* |
1851 | +** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000> | | 1852 | +** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000> |
1852 | +** | | 1853 | +** |
1853 | +** SQLite contains a high-quality pseudo-random number generator (PRNG) used to | | 1854 | +** SQLite contains a high-quality pseudo-random number generator (PRNG) used to |
1854 | +** select random [ROWID | ROWIDs] when inserting new records into a table that | | 1855 | +** select random [ROWID | ROWIDs] when inserting new records into a table that |
1855 | +** already uses the largest possible [ROWID]. The PRNG is also used for | | 1856 | +** already uses the largest possible [ROWID]. The PRNG is also used for |
1856 | +** the build-in random() and randomblob() SQL functions. This interface allows | | 1857 | +** the build-in random() and randomblob() SQL functions. This interface allows |
1857 | +** applications to access the same PRNG for other purposes. | | 1858 | +** applications to access the same PRNG for other purposes. |
1858 | +** | | 1859 | +** |
1859 | +** A call to this routine stores N bytes of randomness into buffer P. | | 1860 | +** A call to this routine stores N bytes of randomness into buffer P. |
1860 | +** | | 1861 | +** |
1861 | +** The first time this routine is invoked (either internally or by | | 1862 | +** The first time this routine is invoked (either internally or by |
1862 | +** the application) the PRNG is seeded using randomness obtained | | 1863 | +** the application) the PRNG is seeded using randomness obtained |
1863 | +** from the xRandomness method of the default [sqlite3_vfs] object. | | 1864 | +** from the xRandomness method of the default [sqlite3_vfs] object. |
1864 | +** On all subsequent invocations, the pseudo-randomness is generated | | 1865 | +** On all subsequent invocations, the pseudo-randomness is generated |
1865 | +** internally and without recourse to the [sqlite3_vfs] xRandomness | | 1866 | +** internally and without recourse to the [sqlite3_vfs] xRandomness |
1866 | +** method. | | 1867 | +** method. |
1867 | +** | | 1868 | +** |
1868 | +** Requirements: | | 1869 | +** Requirements: |
1869 | +** [H17392] | | 1870 | +** [H17392] |
1870 | +*/ | | 1871 | +*/ |
1871 | +SQLITE_API void sqlite3_randomness(int N, void *P); | | 1872 | +SQLITE_API void sqlite3_randomness(int N, void *P); |
1872 | + | | 1873 | + |
1873 | +/* | | 1874 | +/* |
1874 | +** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100> | | 1875 | +** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100> |
1875 | +** | | 1876 | +** |
1876 | +** This routine registers a authorizer callback with a particular | | 1877 | +** This routine registers a authorizer callback with a particular |
1877 | +** [database connection], supplied in the first argument. | | 1878 | +** [database connection], supplied in the first argument. |
1878 | +** The authorizer callback is invoked as SQL statements are being compiled | | 1879 | +** The authorizer callback is invoked as SQL statements are being compiled |
1879 | +** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], | | 1880 | +** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], |
1880 | +** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various | | 1881 | +** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various |
1881 | +** points during the compilation process, as logic is being created | | 1882 | +** points during the compilation process, as logic is being created |
1882 | +** to perform various actions, the authorizer callback is invoked to | | 1883 | +** to perform various actions, the authorizer callback is invoked to |
1883 | +** see if those actions are allowed. The authorizer callback should | | 1884 | +** see if those actions are allowed. The authorizer callback should |
1884 | +** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the | | 1885 | +** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the |
1885 | +** specific action but allow the SQL statement to continue to be | | 1886 | +** specific action but allow the SQL statement to continue to be |
1886 | +** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be | | 1887 | +** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be |
1887 | +** rejected with an error. If the authorizer callback returns | | 1888 | +** rejected with an error. If the authorizer callback returns |
1888 | +** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] | | 1889 | +** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] |
1889 | +** then the [sqlite3_prepare_v2()] or equivalent call that triggered | | 1890 | +** then the [sqlite3_prepare_v2()] or equivalent call that triggered |
1890 | +** the authorizer will fail with an error message. | | 1891 | +** the authorizer will fail with an error message. |
1891 | +** | | 1892 | +** |
1892 | +** When the callback returns [SQLITE_OK], that means the operation | | 1893 | +** When the callback returns [SQLITE_OK], that means the operation |
1893 | +** requested is ok. When the callback returns [SQLITE_DENY], the | | 1894 | +** requested is ok. When the callback returns [SQLITE_DENY], the |
1894 | +** [sqlite3_prepare_v2()] or equivalent call that triggered the | | 1895 | +** [sqlite3_prepare_v2()] or equivalent call that triggered the |
1895 | +** authorizer will fail with an error message explaining that | | 1896 | +** authorizer will fail with an error message explaining that |
1896 | +** access is denied. | | 1897 | +** access is denied. |
1897 | +** | | 1898 | +** |
1898 | +** The first parameter to the authorizer callback is a copy of the third | | 1899 | +** The first parameter to the authorizer callback is a copy of the third |
1899 | +** parameter to the sqlite3_set_authorizer() interface. The second parameter | | 1900 | +** parameter to the sqlite3_set_authorizer() interface. The second parameter |
1900 | +** to the callback is an integer [SQLITE_COPY | action code] that specifies | | 1901 | +** to the callback is an integer [SQLITE_COPY | action code] that specifies |
1901 | +** the particular action to be authorized. The third through sixth parameters | | 1902 | +** the particular action to be authorized. The third through sixth parameters |
1902 | +** to the callback are zero-terminated strings that contain additional | | 1903 | +** to the callback are zero-terminated strings that contain additional |
1903 | +** details about the action to be authorized. | | 1904 | +** details about the action to be authorized. |
1904 | +** | | 1905 | +** |
1905 | +** If the action code is [SQLITE_READ] | | 1906 | +** If the action code is [SQLITE_READ] |
1906 | +** and the callback returns [SQLITE_IGNORE] then the | | 1907 | +** and the callback returns [SQLITE_IGNORE] then the |
1907 | +** [prepared statement] statement is constructed to substitute | | 1908 | +** [prepared statement] statement is constructed to substitute |
1908 | +** a NULL value in place of the table column that would have | | 1909 | +** a NULL value in place of the table column that would have |
1909 | +** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] | | 1910 | +** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] |
1910 | +** return can be used to deny an untrusted user access to individual | | 1911 | +** return can be used to deny an untrusted user access to individual |
1911 | +** columns of a table. | | 1912 | +** columns of a table. |
1912 | +** If the action code is [SQLITE_DELETE] and the callback returns | | 1913 | +** If the action code is [SQLITE_DELETE] and the callback returns |
1913 | +** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the | | 1914 | +** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the |
1914 | +** [truncate optimization] is disabled and all rows are deleted individually. | | 1915 | +** [truncate optimization] is disabled and all rows are deleted individually. |
1915 | +** | | 1916 | +** |
1916 | +** An authorizer is used when [sqlite3_prepare | preparing] | | 1917 | +** An authorizer is used when [sqlite3_prepare | preparing] |
1917 | +** SQL statements from an untrusted source, to ensure that the SQL statements | | 1918 | +** SQL statements from an untrusted source, to ensure that the SQL statements |
1918 | +** do not try to access data they are not allowed to see, or that they do not | | 1919 | +** do not try to access data they are not allowed to see, or that they do not |
1919 | +** try to execute malicious statements that damage the database. For | | 1920 | +** try to execute malicious statements that damage the database. For |
1920 | +** example, an application may allow a user to enter arbitrary | | 1921 | +** example, an application may allow a user to enter arbitrary |
1921 | +** SQL queries for evaluation by a database. But the application does | | 1922 | +** SQL queries for evaluation by a database. But the application does |
1922 | +** not want the user to be able to make arbitrary changes to the | | 1923 | +** not want the user to be able to make arbitrary changes to the |
1923 | +** database. An authorizer could then be put in place while the | | 1924 | +** database. An authorizer could then be put in place while the |
1924 | +** user-entered SQL is being [sqlite3_prepare | prepared] that | | 1925 | +** user-entered SQL is being [sqlite3_prepare | prepared] that |
1925 | +** disallows everything except [SELECT] statements. | | 1926 | +** disallows everything except [SELECT] statements. |
1926 | +** | | 1927 | +** |
1927 | +** Applications that need to process SQL from untrusted sources | | 1928 | +** Applications that need to process SQL from untrusted sources |
1928 | +** might also consider lowering resource limits using [sqlite3_limit()] | | 1929 | +** might also consider lowering resource limits using [sqlite3_limit()] |
1929 | +** and limiting database size using the [max_page_count] [PRAGMA] | | 1930 | +** and limiting database size using the [max_page_count] [PRAGMA] |
1930 | +** in addition to using an authorizer. | | 1931 | +** in addition to using an authorizer. |
1931 | +** | | 1932 | +** |
1932 | +** Only a single authorizer can be in place on a database connection | | 1933 | +** Only a single authorizer can be in place on a database connection |
1933 | +** at a time. Each call to sqlite3_set_authorizer overrides the | | 1934 | +** at a time. Each call to sqlite3_set_authorizer overrides the |
1934 | +** previous call. Disable the authorizer by installing a NULL callback. | | 1935 | +** previous call. Disable the authorizer by installing a NULL callback. |
1935 | +** The authorizer is disabled by default. | | 1936 | +** The authorizer is disabled by default. |
1936 | +** | | 1937 | +** |
1937 | +** The authorizer callback must not do anything that will modify | | 1938 | +** The authorizer callback must not do anything that will modify |
1938 | +** the database connection that invoked the authorizer callback. | | 1939 | +** the database connection that invoked the authorizer callback. |
1939 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their | | 1940 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
1940 | +** database connections for the meaning of "modify" in this paragraph. | | 1941 | +** database connections for the meaning of "modify" in this paragraph. |
1941 | +** | | 1942 | +** |
1942 | +** When [sqlite3_prepare_v2()] is used to prepare a statement, the | | 1943 | +** When [sqlite3_prepare_v2()] is used to prepare a statement, the |
1943 | +** statement might be re-prepared during [sqlite3_step()] due to a | | 1944 | +** statement might be re-prepared during [sqlite3_step()] due to a |
1944 | +** schema change. Hence, the application should ensure that the | | 1945 | +** schema change. Hence, the application should ensure that the |
1945 | +** correct authorizer callback remains in place during the [sqlite3_step()]. | | 1946 | +** correct authorizer callback remains in place during the [sqlite3_step()]. |
1946 | +** | | 1947 | +** |
1947 | +** Note that the authorizer callback is invoked only during | | 1948 | +** Note that the authorizer callback is invoked only during |
1948 | +** [sqlite3_prepare()] or its variants. Authorization is not | | 1949 | +** [sqlite3_prepare()] or its variants. Authorization is not |
1949 | +** performed during statement evaluation in [sqlite3_step()], unless | | 1950 | +** performed during statement evaluation in [sqlite3_step()], unless |
1950 | +** as stated in the previous paragraph, sqlite3_step() invokes | | 1951 | +** as stated in the previous paragraph, sqlite3_step() invokes |
1951 | +** sqlite3_prepare_v2() to reprepare a statement after a schema change. | | 1952 | +** sqlite3_prepare_v2() to reprepare a statement after a schema change. |
1952 | +** | | 1953 | +** |
1953 | +** Requirements: | | 1954 | +** Requirements: |
1954 | +** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510] | | 1955 | +** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510] |
1955 | +** [H12511] [H12512] [H12520] [H12521] [H12522] | | 1956 | +** [H12511] [H12512] [H12520] [H12521] [H12522] |
1956 | +*/ | | 1957 | +*/ |
1957 | +SQLITE_API int sqlite3_set_authorizer( | | 1958 | +SQLITE_API int sqlite3_set_authorizer( |
1958 | + sqlite3*, | | 1959 | + sqlite3*, |
1959 | + int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), | | 1960 | + int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), |
1960 | + void *pUserData | | 1961 | + void *pUserData |
1961 | +); | | 1962 | +); |
1962 | + | | 1963 | + |
1963 | +/* | | 1964 | +/* |
1964 | +** CAPI3REF: Authorizer Return Codes {H12590} <H12500> | | 1965 | +** CAPI3REF: Authorizer Return Codes {H12590} <H12500> |
1965 | +** | | 1966 | +** |
1966 | +** The [sqlite3_set_authorizer | authorizer callback function] must | | 1967 | +** The [sqlite3_set_authorizer | authorizer callback function] must |
1967 | +** return either [SQLITE_OK] or one of these two constants in order | | 1968 | +** return either [SQLITE_OK] or one of these two constants in order |
1968 | +** to signal SQLite whether or not the action is permitted. See the | | 1969 | +** to signal SQLite whether or not the action is permitted. See the |
1969 | +** [sqlite3_set_authorizer | authorizer documentation] for additional | | 1970 | +** [sqlite3_set_authorizer | authorizer documentation] for additional |
1970 | +** information. | | 1971 | +** information. |
1971 | +*/ | | 1972 | +*/ |
1972 | +#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ | | 1973 | +#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ |
1973 | +#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ | | 1974 | +#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ |
1974 | + | | 1975 | + |
1975 | +/* | | 1976 | +/* |
1976 | +** CAPI3REF: Authorizer Action Codes {H12550} <H12500> | | 1977 | +** CAPI3REF: Authorizer Action Codes {H12550} <H12500> |
1977 | +** | | 1978 | +** |
1978 | +** The [sqlite3_set_authorizer()] interface registers a callback function | | 1979 | +** The [sqlite3_set_authorizer()] interface registers a callback function |
1979 | +** that is invoked to authorize certain SQL statement actions. The | | 1980 | +** that is invoked to authorize certain SQL statement actions. The |
1980 | +** second parameter to the callback is an integer code that specifies | | 1981 | +** second parameter to the callback is an integer code that specifies |
1981 | +** what action is being authorized. These are the integer action codes that | | 1982 | +** what action is being authorized. These are the integer action codes that |
1982 | +** the authorizer callback may be passed. | | 1983 | +** the authorizer callback may be passed. |
1983 | +** | | 1984 | +** |
1984 | +** These action code values signify what kind of operation is to be | | 1985 | +** These action code values signify what kind of operation is to be |
1985 | +** authorized. The 3rd and 4th parameters to the authorization | | 1986 | +** authorized. The 3rd and 4th parameters to the authorization |
1986 | +** callback function will be parameters or NULL depending on which of these | | 1987 | +** callback function will be parameters or NULL depending on which of these |
1987 | +** codes is used as the second parameter. The 5th parameter to the | | 1988 | +** codes is used as the second parameter. The 5th parameter to the |
1988 | +** authorizer callback is the name of the database ("main", "temp", | | 1989 | +** authorizer callback is the name of the database ("main", "temp", |
1989 | +** etc.) if applicable. The 6th parameter to the authorizer callback | | 1990 | +** etc.) if applicable. The 6th parameter to the authorizer callback |
1990 | +** is the name of the inner-most trigger or view that is responsible for | | 1991 | +** is the name of the inner-most trigger or view that is responsible for |
1991 | +** the access attempt or NULL if this access attempt is directly from | | 1992 | +** the access attempt or NULL if this access attempt is directly from |
1992 | +** top-level SQL code. | | 1993 | +** top-level SQL code. |
1993 | +** | | 1994 | +** |
1994 | +** Requirements: | | 1995 | +** Requirements: |
1995 | +** [H12551] [H12552] [H12553] [H12554] | | 1996 | +** [H12551] [H12552] [H12553] [H12554] |
1996 | +*/ | | 1997 | +*/ |
1997 | +/******************************************* 3rd ************ 4th ***********/ | | 1998 | +/******************************************* 3rd ************ 4th ***********/ |
1998 | +#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ | | 1999 | +#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ |
1999 | +#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ | | 2000 | +#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ |
2000 | +#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ | | 2001 | +#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ |
2001 | +#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ | | 2002 | +#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ |
2002 | +#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ | | 2003 | +#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ |
2003 | +#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ | | 2004 | +#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ |
2004 | +#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ | | 2005 | +#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ |
2005 | +#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ | | 2006 | +#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ |
2006 | +#define SQLITE_DELETE 9 /* Table Name NULL */ | | 2007 | +#define SQLITE_DELETE 9 /* Table Name NULL */ |
2007 | +#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ | | 2008 | +#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ |
2008 | +#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ | | 2009 | +#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ |
2009 | +#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ | | 2010 | +#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ |
2010 | +#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ | | 2011 | +#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ |
2011 | +#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ | | 2012 | +#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ |
2012 | +#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ | | 2013 | +#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ |
2013 | +#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ | | 2014 | +#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ |
2014 | +#define SQLITE_DROP_VIEW 17 /* View Name NULL */ | | 2015 | +#define SQLITE_DROP_VIEW 17 /* View Name NULL */ |
2015 | +#define SQLITE_INSERT 18 /* Table Name NULL */ | | 2016 | +#define SQLITE_INSERT 18 /* Table Name NULL */ |
2016 | +#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ | | 2017 | +#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ |
2017 | +#define SQLITE_READ 20 /* Table Name Column Name */ | | 2018 | +#define SQLITE_READ 20 /* Table Name Column Name */ |
2018 | +#define SQLITE_SELECT 21 /* NULL NULL */ | | 2019 | +#define SQLITE_SELECT 21 /* NULL NULL */ |
2019 | +#define SQLITE_TRANSACTION 22 /* Operation NULL */ | | 2020 | +#define SQLITE_TRANSACTION 22 /* Operation NULL */ |
2020 | +#define SQLITE_UPDATE 23 /* Table Name Column Name */ | | 2021 | +#define SQLITE_UPDATE 23 /* Table Name Column Name */ |
2021 | +#define SQLITE_ATTACH 24 /* Filename NULL */ | | 2022 | +#define SQLITE_ATTACH 24 /* Filename NULL */ |
2022 | +#define SQLITE_DETACH 25 /* Database Name NULL */ | | 2023 | +#define SQLITE_DETACH 25 /* Database Name NULL */ |
2023 | +#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ | | 2024 | +#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ |
2024 | +#define SQLITE_REINDEX 27 /* Index Name NULL */ | | 2025 | +#define SQLITE_REINDEX 27 /* Index Name NULL */ |
2025 | +#define SQLITE_ANALYZE 28 /* Table Name NULL */ | | 2026 | +#define SQLITE_ANALYZE 28 /* Table Name NULL */ |
2026 | +#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ | | 2027 | +#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ |
2027 | +#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ | | 2028 | +#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ |
2028 | +#define SQLITE_FUNCTION 31 /* NULL Function Name */ | | 2029 | +#define SQLITE_FUNCTION 31 /* NULL Function Name */ |
2029 | +#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ | | 2030 | +#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ |
2030 | +#define SQLITE_COPY 0 /* No longer used */ | | 2031 | +#define SQLITE_COPY 0 /* No longer used */ |
2031 | + | | 2032 | + |
2032 | +/* | | 2033 | +/* |
2033 | +** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400> | | 2034 | +** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400> |
2034 | +** EXPERIMENTAL | | 2035 | +** EXPERIMENTAL |
2035 | +** | | 2036 | +** |
2036 | +** These routines register callback functions that can be used for | | 2037 | +** These routines register callback functions that can be used for |
2037 | +** tracing and profiling the execution of SQL statements. | | 2038 | +** tracing and profiling the execution of SQL statements. |
2038 | +** | | 2039 | +** |
2039 | +** The callback function registered by sqlite3_trace() is invoked at | | 2040 | +** The callback function registered by sqlite3_trace() is invoked at |
2040 | +** various times when an SQL statement is being run by [sqlite3_step()]. | | 2041 | +** various times when an SQL statement is being run by [sqlite3_step()]. |
2041 | +** The callback returns a UTF-8 rendering of the SQL statement text | | 2042 | +** The callback returns a UTF-8 rendering of the SQL statement text |
2042 | +** as the statement first begins executing. Additional callbacks occur | | 2043 | +** as the statement first begins executing. Additional callbacks occur |
2043 | +** as each triggered subprogram is entered. The callbacks for triggers | | 2044 | +** as each triggered subprogram is entered. The callbacks for triggers |
2044 | +** contain a UTF-8 SQL comment that identifies the trigger. | | 2045 | +** contain a UTF-8 SQL comment that identifies the trigger. |
2045 | +** | | 2046 | +** |
2046 | +** The callback function registered by sqlite3_profile() is invoked | | 2047 | +** The callback function registered by sqlite3_profile() is invoked |
2047 | +** as each SQL statement finishes. The profile callback contains | | 2048 | +** as each SQL statement finishes. The profile callback contains |
2048 | +** the original statement text and an estimate of wall-clock time | | 2049 | +** the original statement text and an estimate of wall-clock time |
2049 | +** of how long that statement took to run. | | 2050 | +** of how long that statement took to run. |
2050 | +** | | 2051 | +** |
2051 | +** Requirements: | | 2052 | +** Requirements: |
2052 | +** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289] | | 2053 | +** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289] |
2053 | +** [H12290] | | 2054 | +** [H12290] |
2054 | +*/ | | 2055 | +*/ |
2055 | +SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); | | 2056 | +SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
2056 | +SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, | | 2057 | +SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, |
2057 | + void(*xProfile)(void*,const char*,sqlite3_uint64), void*); | | 2058 | + void(*xProfile)(void*,const char*,sqlite3_uint64), void*); |
2058 | + | | 2059 | + |
2059 | +/* | | 2060 | +/* |
2060 | +** CAPI3REF: Query Progress Callbacks {H12910} <S60400> | | 2061 | +** CAPI3REF: Query Progress Callbacks {H12910} <S60400> |
2061 | +** | | 2062 | +** |
2062 | +** This routine configures a callback function - the | | 2063 | +** This routine configures a callback function - the |
2063 | +** progress callback - that is invoked periodically during long | | 2064 | +** progress callback - that is invoked periodically during long |
2064 | +** running calls to [sqlite3_exec()], [sqlite3_step()] and | | 2065 | +** running calls to [sqlite3_exec()], [sqlite3_step()] and |
2065 | +** [sqlite3_get_table()]. An example use for this | | 2066 | +** [sqlite3_get_table()]. An example use for this |
2066 | +** interface is to keep a GUI updated during a large query. | | 2067 | +** interface is to keep a GUI updated during a large query. |
2067 | +** | | 2068 | +** |
2068 | +** If the progress callback returns non-zero, the operation is | | 2069 | +** If the progress callback returns non-zero, the operation is |
2069 | +** interrupted. This feature can be used to implement a | | 2070 | +** interrupted. This feature can be used to implement a |
2070 | +** "Cancel" button on a GUI progress dialog box. | | 2071 | +** "Cancel" button on a GUI progress dialog box. |
2071 | +** | | 2072 | +** |
2072 | +** The progress handler must not do anything that will modify | | 2073 | +** The progress handler must not do anything that will modify |
2073 | +** the database connection that invoked the progress handler. | | 2074 | +** the database connection that invoked the progress handler. |
2074 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their | | 2075 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
2075 | +** database connections for the meaning of "modify" in this paragraph. | | 2076 | +** database connections for the meaning of "modify" in this paragraph. |
2076 | +** | | 2077 | +** |
2077 | +** Requirements: | | 2078 | +** Requirements: |
2078 | +** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918] | | 2079 | +** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918] |
2079 | +** | | 2080 | +** |
2080 | +*/ | | 2081 | +*/ |
2081 | +SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); | | 2082 | +SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
2082 | + | | 2083 | + |
2083 | +/* | | 2084 | +/* |
2084 | +** CAPI3REF: Opening A New Database Connection {H12700} <S40200> | | 2085 | +** CAPI3REF: Opening A New Database Connection {H12700} <S40200> |
2085 | +** | | 2086 | +** |
2086 | +** These routines open an SQLite database file whose name is given by the | | 2087 | +** These routines open an SQLite database file whose name is given by the |
2087 | +** filename argument. The filename argument is interpreted as UTF-8 for | | 2088 | +** filename argument. The filename argument is interpreted as UTF-8 for |
2088 | +** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte | | 2089 | +** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte |
2089 | +** order for sqlite3_open16(). A [database connection] handle is usually | | 2090 | +** order for sqlite3_open16(). A [database connection] handle is usually |
2090 | +** returned in *ppDb, even if an error occurs. The only exception is that | | 2091 | +** returned in *ppDb, even if an error occurs. The only exception is that |
2091 | +** if SQLite is unable to allocate memory to hold the [sqlite3] object, | | 2092 | +** if SQLite is unable to allocate memory to hold the [sqlite3] object, |
2092 | +** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] | | 2093 | +** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] |
2093 | +** object. If the database is opened (and/or created) successfully, then | | 2094 | +** object. If the database is opened (and/or created) successfully, then |
2094 | +** [SQLITE_OK] is returned. Otherwise an [error code] is returned. The | | 2095 | +** [SQLITE_OK] is returned. Otherwise an [error code] is returned. The |
2095 | +** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain | | 2096 | +** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain |
2096 | +** an English language description of the error. | | 2097 | +** an English language description of the error. |
2097 | +** | | 2098 | +** |
2098 | +** The default encoding for the database will be UTF-8 if | | 2099 | +** The default encoding for the database will be UTF-8 if |
2099 | +** sqlite3_open() or sqlite3_open_v2() is called and | | 2100 | +** sqlite3_open() or sqlite3_open_v2() is called and |
2100 | +** UTF-16 in the native byte order if sqlite3_open16() is used. | | 2101 | +** UTF-16 in the native byte order if sqlite3_open16() is used. |
2101 | +** | | 2102 | +** |
2102 | +** Whether or not an error occurs when it is opened, resources | | 2103 | +** Whether or not an error occurs when it is opened, resources |
2103 | +** associated with the [database connection] handle should be released by | | 2104 | +** associated with the [database connection] handle should be released by |
2104 | +** passing it to [sqlite3_close()] when it is no longer required. | | 2105 | +** passing it to [sqlite3_close()] when it is no longer required. |
2105 | +** | | 2106 | +** |
2106 | +** The sqlite3_open_v2() interface works like sqlite3_open() | | 2107 | +** The sqlite3_open_v2() interface works like sqlite3_open() |
2107 | +** except that it accepts two additional parameters for additional control | | 2108 | +** except that it accepts two additional parameters for additional control |
2108 | +** over the new database connection. The flags parameter can take one of | | 2109 | +** over the new database connection. The flags parameter can take one of |
2109 | +** the following three values, optionally combined with the | | 2110 | +** the following three values, optionally combined with the |
2110 | +** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], | | 2111 | +** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], |
2111 | +** and/or [SQLITE_OPEN_PRIVATECACHE] flags: | | 2112 | +** and/or [SQLITE_OPEN_PRIVATECACHE] flags: |
2112 | +** | | 2113 | +** |
2113 | +** <dl> | | 2114 | +** <dl> |
2114 | +** <dt>[SQLITE_OPEN_READONLY]</dt> | | 2115 | +** <dt>[SQLITE_OPEN_READONLY]</dt> |
2115 | +** <dd>The database is opened in read-only mode. If the database does not | | 2116 | +** <dd>The database is opened in read-only mode. If the database does not |
2116 | +** already exist, an error is returned.</dd> | | 2117 | +** already exist, an error is returned.</dd> |
2117 | +** | | 2118 | +** |
2118 | +** <dt>[SQLITE_OPEN_READWRITE]</dt> | | 2119 | +** <dt>[SQLITE_OPEN_READWRITE]</dt> |
2119 | +** <dd>The database is opened for reading and writing if possible, or reading | | 2120 | +** <dd>The database is opened for reading and writing if possible, or reading |
2120 | +** only if the file is write protected by the operating system. In either | | 2121 | +** only if the file is write protected by the operating system. In either |
2121 | +** case the database must already exist, otherwise an error is returned.</dd> | | 2122 | +** case the database must already exist, otherwise an error is returned.</dd> |
2122 | +** | | 2123 | +** |
2123 | +** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> | | 2124 | +** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> |
2124 | +** <dd>The database is opened for reading and writing, and is creates it if | | 2125 | +** <dd>The database is opened for reading and writing, and is creates it if |
2125 | +** it does not already exist. This is the behavior that is always used for | | 2126 | +** it does not already exist. This is the behavior that is always used for |
2126 | +** sqlite3_open() and sqlite3_open16().</dd> | | 2127 | +** sqlite3_open() and sqlite3_open16().</dd> |
2127 | +** </dl> | | 2128 | +** </dl> |
2128 | +** | | 2129 | +** |
2129 | +** If the 3rd parameter to sqlite3_open_v2() is not one of the | | 2130 | +** If the 3rd parameter to sqlite3_open_v2() is not one of the |
2130 | +** combinations shown above or one of the combinations shown above combined | | 2131 | +** combinations shown above or one of the combinations shown above combined |
2131 | +** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], | | 2132 | +** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], |
2132 | +** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags, | | 2133 | +** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags, |
2133 | +** then the behavior is undefined. | | 2134 | +** then the behavior is undefined. |
2134 | +** | | 2135 | +** |
2135 | +** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection | | 2136 | +** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection |
2136 | +** opens in the multi-thread [threading mode] as long as the single-thread | | 2137 | +** opens in the multi-thread [threading mode] as long as the single-thread |
2137 | +** mode has not been set at compile-time or start-time. If the | | 2138 | +** mode has not been set at compile-time or start-time. If the |
2138 | +** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens | | 2139 | +** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens |
2139 | +** in the serialized [threading mode] unless single-thread was | | 2140 | +** in the serialized [threading mode] unless single-thread was |
2140 | +** previously selected at compile-time or start-time. | | 2141 | +** previously selected at compile-time or start-time. |
2141 | +** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be | | 2142 | +** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be |
2142 | +** eligible to use [shared cache mode], regardless of whether or not shared | | 2143 | +** eligible to use [shared cache mode], regardless of whether or not shared |
2143 | +** cache is enabled using [sqlite3_enable_shared_cache()]. The | | 2144 | +** cache is enabled using [sqlite3_enable_shared_cache()]. The |
2144 | +** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not | | 2145 | +** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not |
2145 | +** participate in [shared cache mode] even if it is enabled. | | 2146 | +** participate in [shared cache mode] even if it is enabled. |
2146 | +** | | 2147 | +** |
2147 | +** If the filename is ":memory:", then a private, temporary in-memory database | | 2148 | +** If the filename is ":memory:", then a private, temporary in-memory database |
2148 | +** is created for the connection. This in-memory database will vanish when | | 2149 | +** is created for the connection. This in-memory database will vanish when |
2149 | +** the database connection is closed. Future versions of SQLite might | | 2150 | +** the database connection is closed. Future versions of SQLite might |
2150 | +** make use of additional special filenames that begin with the ":" character. | | 2151 | +** make use of additional special filenames that begin with the ":" character. |
2151 | +** It is recommended that when a database filename actually does begin with | | 2152 | +** It is recommended that when a database filename actually does begin with |
2152 | +** a ":" character you should prefix the filename with a pathname such as | | 2153 | +** a ":" character you should prefix the filename with a pathname such as |
2153 | +** "./" to avoid ambiguity. | | 2154 | +** "./" to avoid ambiguity. |
2154 | +** | | 2155 | +** |
2155 | +** If the filename is an empty string, then a private, temporary | | 2156 | +** If the filename is an empty string, then a private, temporary |
2156 | +** on-disk database will be created. This private database will be | | 2157 | +** on-disk database will be created. This private database will be |
2157 | +** automatically deleted as soon as the database connection is closed. | | 2158 | +** automatically deleted as soon as the database connection is closed. |
2158 | +** | | 2159 | +** |
2159 | +** The fourth parameter to sqlite3_open_v2() is the name of the | | 2160 | +** The fourth parameter to sqlite3_open_v2() is the name of the |
2160 | +** [sqlite3_vfs] object that defines the operating system interface that | | 2161 | +** [sqlite3_vfs] object that defines the operating system interface that |
2161 | +** the new database connection should use. If the fourth parameter is | | 2162 | +** the new database connection should use. If the fourth parameter is |
2162 | +** a NULL pointer then the default [sqlite3_vfs] object is used. | | 2163 | +** a NULL pointer then the default [sqlite3_vfs] object is used. |
2163 | +** | | 2164 | +** |
2164 | +** <b>Note to Windows users:</b> The encoding used for the filename argument | | 2165 | +** <b>Note to Windows users:</b> The encoding used for the filename argument |
2165 | +** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever | | 2166 | +** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever |
2166 | +** codepage is currently defined. Filenames containing international | | 2167 | +** codepage is currently defined. Filenames containing international |
2167 | +** characters must be converted to UTF-8 prior to passing them into | | 2168 | +** characters must be converted to UTF-8 prior to passing them into |
2168 | +** sqlite3_open() or sqlite3_open_v2(). | | 2169 | +** sqlite3_open() or sqlite3_open_v2(). |
2169 | +** | | 2170 | +** |
2170 | +** Requirements: | | 2171 | +** Requirements: |
2171 | +** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711] | | 2172 | +** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711] |
2172 | +** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723] | | 2173 | +** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723] |
2173 | +*/ | | 2174 | +*/ |
2174 | +SQLITE_API int sqlite3_open( | | 2175 | +SQLITE_API int sqlite3_open( |
2175 | + const char *filename, /* Database filename (UTF-8) */ | | 2176 | + const char *filename, /* Database filename (UTF-8) */ |
2176 | + sqlite3 **ppDb /* OUT: SQLite db handle */ | | 2177 | + sqlite3 **ppDb /* OUT: SQLite db handle */ |
2177 | +); | | 2178 | +); |
2178 | +SQLITE_API int sqlite3_open16( | | 2179 | +SQLITE_API int sqlite3_open16( |
2179 | + const void *filename, /* Database filename (UTF-16) */ | | 2180 | + const void *filename, /* Database filename (UTF-16) */ |
2180 | + sqlite3 **ppDb /* OUT: SQLite db handle */ | | 2181 | + sqlite3 **ppDb /* OUT: SQLite db handle */ |
2181 | +); | | 2182 | +); |
2182 | +SQLITE_API int sqlite3_open_v2( | | 2183 | +SQLITE_API int sqlite3_open_v2( |
2183 | + const char *filename, /* Database filename (UTF-8) */ | | 2184 | + const char *filename, /* Database filename (UTF-8) */ |
2184 | + sqlite3 **ppDb, /* OUT: SQLite db handle */ | | 2185 | + sqlite3 **ppDb, /* OUT: SQLite db handle */ |
2185 | + int flags, /* Flags */ | | 2186 | + int flags, /* Flags */ |
2186 | + const char *zVfs /* Name of VFS module to use */ | | 2187 | + const char *zVfs /* Name of VFS module to use */ |
2187 | +); | | 2188 | +); |
2188 | + | | 2189 | + |
2189 | +/* | | 2190 | +/* |
2190 | +** CAPI3REF: Error Codes And Messages {H12800} <S60200> | | 2191 | +** CAPI3REF: Error Codes And Messages {H12800} <S60200> |
2191 | +** | | 2192 | +** |
2192 | +** The sqlite3_errcode() interface returns the numeric [result code] or | | 2193 | +** The sqlite3_errcode() interface returns the numeric [result code] or |
2193 | +** [extended result code] for the most recent failed sqlite3_* API call | | 2194 | +** [extended result code] for the most recent failed sqlite3_* API call |
2194 | +** associated with a [database connection]. If a prior API call failed | | 2195 | +** associated with a [database connection]. If a prior API call failed |
2195 | +** but the most recent API call succeeded, the return value from | | 2196 | +** but the most recent API call succeeded, the return value from |
2196 | +** sqlite3_errcode() is undefined. The sqlite3_extended_errcode() | | 2197 | +** sqlite3_errcode() is undefined. The sqlite3_extended_errcode() |
2197 | +** interface is the same except that it always returns the | | 2198 | +** interface is the same except that it always returns the |
2198 | +** [extended result code] even when extended result codes are | | 2199 | +** [extended result code] even when extended result codes are |
2199 | +** disabled. | | 2200 | +** disabled. |
2200 | +** | | 2201 | +** |
2201 | +** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language | | 2202 | +** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language |
2202 | +** text that describes the error, as either UTF-8 or UTF-16 respectively. | | 2203 | +** text that describes the error, as either UTF-8 or UTF-16 respectively. |
2203 | +** Memory to hold the error message string is managed internally. | | 2204 | +** Memory to hold the error message string is managed internally. |
2204 | +** The application does not need to worry about freeing the result. | | 2205 | +** The application does not need to worry about freeing the result. |
2205 | +** However, the error string might be overwritten or deallocated by | | 2206 | +** However, the error string might be overwritten or deallocated by |
2206 | +** subsequent calls to other SQLite interface functions. | | 2207 | +** subsequent calls to other SQLite interface functions. |
2207 | +** | | 2208 | +** |
2208 | +** When the serialized [threading mode] is in use, it might be the | | 2209 | +** When the serialized [threading mode] is in use, it might be the |
2209 | +** case that a second error occurs on a separate thread in between | | 2210 | +** case that a second error occurs on a separate thread in between |
2210 | +** the time of the first error and the call to these interfaces. | | 2211 | +** the time of the first error and the call to these interfaces. |
2211 | +** When that happens, the second error will be reported since these | | 2212 | +** When that happens, the second error will be reported since these |
2212 | +** interfaces always report the most recent result. To avoid | | 2213 | +** interfaces always report the most recent result. To avoid |
2213 | +** this, each thread can obtain exclusive use of the [database connection] D | | 2214 | +** this, each thread can obtain exclusive use of the [database connection] D |
2214 | +** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning | | 2215 | +** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning |
2215 | +** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after | | 2216 | +** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after |
2216 | +** all calls to the interfaces listed here are completed. | | 2217 | +** all calls to the interfaces listed here are completed. |
2217 | +** | | 2218 | +** |
2218 | +** If an interface fails with SQLITE_MISUSE, that means the interface | | 2219 | +** If an interface fails with SQLITE_MISUSE, that means the interface |
2219 | +** was invoked incorrectly by the application. In that case, the | | 2220 | +** was invoked incorrectly by the application. In that case, the |
2220 | +** error code and message may or may not be set. | | 2221 | +** error code and message may or may not be set. |
2221 | +** | | 2222 | +** |
2222 | +** Requirements: | | 2223 | +** Requirements: |
2223 | +** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809] | | 2224 | +** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809] |
2224 | +*/ | | 2225 | +*/ |
2225 | +SQLITE_API int sqlite3_errcode(sqlite3 *db); | | 2226 | +SQLITE_API int sqlite3_errcode(sqlite3 *db); |
2226 | +SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); | | 2227 | +SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); |
2227 | +SQLITE_API const char *sqlite3_errmsg(sqlite3*); | | 2228 | +SQLITE_API const char *sqlite3_errmsg(sqlite3*); |
2228 | +SQLITE_API const void *sqlite3_errmsg16(sqlite3*); | | 2229 | +SQLITE_API const void *sqlite3_errmsg16(sqlite3*); |
2229 | + | | 2230 | + |
2230 | +/* | | 2231 | +/* |
2231 | +** CAPI3REF: SQL Statement Object {H13000} <H13010> | | 2232 | +** CAPI3REF: SQL Statement Object {H13000} <H13010> |
2232 | +** KEYWORDS: {prepared statement} {prepared statements} | | 2233 | +** KEYWORDS: {prepared statement} {prepared statements} |
2233 | +** | | 2234 | +** |
2234 | +** An instance of this object represents a single SQL statement. | | 2235 | +** An instance of this object represents a single SQL statement. |
2235 | +** This object is variously known as a "prepared statement" or a | | 2236 | +** This object is variously known as a "prepared statement" or a |
2236 | +** "compiled SQL statement" or simply as a "statement". | | 2237 | +** "compiled SQL statement" or simply as a "statement". |
2237 | +** | | 2238 | +** |
2238 | +** The life of a statement object goes something like this: | | 2239 | +** The life of a statement object goes something like this: |
2239 | +** | | 2240 | +** |
2240 | +** <ol> | | 2241 | +** <ol> |
2241 | +** <li> Create the object using [sqlite3_prepare_v2()] or a related | | 2242 | +** <li> Create the object using [sqlite3_prepare_v2()] or a related |
2242 | +** function. | | 2243 | +** function. |
2243 | +** <li> Bind values to [host parameters] using the sqlite3_bind_*() | | 2244 | +** <li> Bind values to [host parameters] using the sqlite3_bind_*() |
2244 | +** interfaces. | | 2245 | +** interfaces. |
2245 | +** <li> Run the SQL by calling [sqlite3_step()] one or more times. | | 2246 | +** <li> Run the SQL by calling [sqlite3_step()] one or more times. |
2246 | +** <li> Reset the statement using [sqlite3_reset()] then go back | | 2247 | +** <li> Reset the statement using [sqlite3_reset()] then go back |
2247 | +** to step 2. Do this zero or more times. | | 2248 | +** to step 2. Do this zero or more times. |
2248 | +** <li> Destroy the object using [sqlite3_finalize()]. | | 2249 | +** <li> Destroy the object using [sqlite3_finalize()]. |
2249 | +** </ol> | | 2250 | +** </ol> |
2250 | +** | | 2251 | +** |
2251 | +** Refer to documentation on individual methods above for additional | | 2252 | +** Refer to documentation on individual methods above for additional |
2252 | +** information. | | 2253 | +** information. |
2253 | +*/ | | 2254 | +*/ |
2254 | +typedef struct sqlite3_stmt sqlite3_stmt; | | 2255 | +typedef struct sqlite3_stmt sqlite3_stmt; |
2255 | + | | 2256 | + |
2256 | +/* | | 2257 | +/* |
2257 | +** CAPI3REF: Run-time Limits {H12760} <S20600> | | 2258 | +** CAPI3REF: Run-time Limits {H12760} <S20600> |
2258 | +** | | 2259 | +** |
2259 | +** This interface allows the size of various constructs to be limited | | 2260 | +** This interface allows the size of various constructs to be limited |
2260 | +** on a connection by connection basis. The first parameter is the | | 2261 | +** on a connection by connection basis. The first parameter is the |
2261 | +** [database connection] whose limit is to be set or queried. The | | 2262 | +** [database connection] whose limit is to be set or queried. The |
2262 | +** second parameter is one of the [limit categories] that define a | | 2263 | +** second parameter is one of the [limit categories] that define a |
2263 | +** class of constructs to be size limited. The third parameter is the | | 2264 | +** class of constructs to be size limited. The third parameter is the |
2264 | +** new limit for that construct. The function returns the old limit. | | 2265 | +** new limit for that construct. The function returns the old limit. |
2265 | +** | | 2266 | +** |
2266 | +** If the new limit is a negative number, the limit is unchanged. | | 2267 | +** If the new limit is a negative number, the limit is unchanged. |
2267 | +** For the limit category of SQLITE_LIMIT_XYZ there is a | | 2268 | +** For the limit category of SQLITE_LIMIT_XYZ there is a |
2268 | +** [limits | hard upper bound] | | 2269 | +** [limits | hard upper bound] |
2269 | +** set by a compile-time C preprocessor macro named | | 2270 | +** set by a compile-time C preprocessor macro named |
2270 | +** [limits | SQLITE_MAX_XYZ]. | | 2271 | +** [limits | SQLITE_MAX_XYZ]. |
2271 | +** (The "_LIMIT_" in the name is changed to "_MAX_".) | | 2272 | +** (The "_LIMIT_" in the name is changed to "_MAX_".) |
2272 | +** Attempts to increase a limit above its hard upper bound are | | 2273 | +** Attempts to increase a limit above its hard upper bound are |
2273 | +** silently truncated to the hard upper limit. | | 2274 | +** silently truncated to the hard upper limit. |
2274 | +** | | 2275 | +** |
2275 | +** Run time limits are intended for use in applications that manage | | 2276 | +** Run time limits are intended for use in applications that manage |
2276 | +** both their own internal database and also databases that are controlled | | 2277 | +** both their own internal database and also databases that are controlled |
2277 | +** by untrusted external sources. An example application might be a | | 2278 | +** by untrusted external sources. An example application might be a |
2278 | +** web browser that has its own databases for storing history and | | 2279 | +** web browser that has its own databases for storing history and |
2279 | +** separate databases controlled by JavaScript applications downloaded | | 2280 | +** separate databases controlled by JavaScript applications downloaded |
2280 | +** off the Internet. The internal databases can be given the | | 2281 | +** off the Internet. The internal databases can be given the |
2281 | +** large, default limits. Databases managed by external sources can | | 2282 | +** large, default limits. Databases managed by external sources can |
2282 | +** be given much smaller limits designed to prevent a denial of service | | 2283 | +** be given much smaller limits designed to prevent a denial of service |
2283 | +** attack. Developers might also want to use the [sqlite3_set_authorizer()] | | 2284 | +** attack. Developers might also want to use the [sqlite3_set_authorizer()] |
2284 | +** interface to further control untrusted SQL. The size of the database | | 2285 | +** interface to further control untrusted SQL. The size of the database |
2285 | +** created by an untrusted script can be contained using the | | 2286 | +** created by an untrusted script can be contained using the |
2286 | +** [max_page_count] [PRAGMA]. | | 2287 | +** [max_page_count] [PRAGMA]. |
2287 | +** | | 2288 | +** |
2288 | +** New run-time limit categories may be added in future releases. | | 2289 | +** New run-time limit categories may be added in future releases. |
2289 | +** | | 2290 | +** |
2290 | +** Requirements: | | 2291 | +** Requirements: |
2291 | +** [H12762] [H12766] [H12769] | | 2292 | +** [H12762] [H12766] [H12769] |
2292 | +*/ | | 2293 | +*/ |
2293 | +SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); | | 2294 | +SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
2294 | + | | 2295 | + |
2295 | +/* | | 2296 | +/* |
2296 | +** CAPI3REF: Run-Time Limit Categories {H12790} <H12760> | | 2297 | +** CAPI3REF: Run-Time Limit Categories {H12790} <H12760> |
2297 | +** KEYWORDS: {limit category} {limit categories} | | 2298 | +** KEYWORDS: {limit category} {limit categories} |
2298 | +** | | 2299 | +** |
2299 | +** These constants define various performance limits | | 2300 | +** These constants define various performance limits |
2300 | +** that can be lowered at run-time using [sqlite3_limit()]. | | 2301 | +** that can be lowered at run-time using [sqlite3_limit()]. |
2301 | +** The synopsis of the meanings of the various limits is shown below. | | 2302 | +** The synopsis of the meanings of the various limits is shown below. |
2302 | +** Additional information is available at [limits | Limits in SQLite]. | | 2303 | +** Additional information is available at [limits | Limits in SQLite]. |
2303 | +** | | 2304 | +** |
2304 | +** <dl> | | 2305 | +** <dl> |
2305 | +** <dt>SQLITE_LIMIT_LENGTH</dt> | | 2306 | +** <dt>SQLITE_LIMIT_LENGTH</dt> |
2306 | +** <dd>The maximum size of any string or BLOB or table row.<dd> | | 2307 | +** <dd>The maximum size of any string or BLOB or table row.<dd> |
2307 | +** | | 2308 | +** |
2308 | +** <dt>SQLITE_LIMIT_SQL_LENGTH</dt> | | 2309 | +** <dt>SQLITE_LIMIT_SQL_LENGTH</dt> |
2309 | +** <dd>The maximum length of an SQL statement.</dd> | | 2310 | +** <dd>The maximum length of an SQL statement.</dd> |
2310 | +** | | 2311 | +** |
2311 | +** <dt>SQLITE_LIMIT_COLUMN</dt> | | 2312 | +** <dt>SQLITE_LIMIT_COLUMN</dt> |
2312 | +** <dd>The maximum number of columns in a table definition or in the | | 2313 | +** <dd>The maximum number of columns in a table definition or in the |
2313 | +** result set of a [SELECT] or the maximum number of columns in an index | | 2314 | +** result set of a [SELECT] or the maximum number of columns in an index |
2314 | +** or in an ORDER BY or GROUP BY clause.</dd> | | 2315 | +** or in an ORDER BY or GROUP BY clause.</dd> |
2315 | +** | | 2316 | +** |
2316 | +** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt> | | 2317 | +** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt> |
2317 | +** <dd>The maximum depth of the parse tree on any expression.</dd> | | 2318 | +** <dd>The maximum depth of the parse tree on any expression.</dd> |
2318 | +** | | 2319 | +** |
2319 | +** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt> | | 2320 | +** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt> |
2320 | +** <dd>The maximum number of terms in a compound SELECT statement.</dd> | | 2321 | +** <dd>The maximum number of terms in a compound SELECT statement.</dd> |
2321 | +** | | 2322 | +** |
2322 | +** <dt>SQLITE_LIMIT_VDBE_OP</dt> | | 2323 | +** <dt>SQLITE_LIMIT_VDBE_OP</dt> |
2323 | +** <dd>The maximum number of instructions in a virtual machine program | | 2324 | +** <dd>The maximum number of instructions in a virtual machine program |
2324 | +** used to implement an SQL statement.</dd> | | 2325 | +** used to implement an SQL statement.</dd> |
2325 | +** | | 2326 | +** |
2326 | +** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt> | | 2327 | +** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt> |
2327 | +** <dd>The maximum number of arguments on a function.</dd> | | 2328 | +** <dd>The maximum number of arguments on a function.</dd> |
2328 | +** | | 2329 | +** |
2329 | +** <dt>SQLITE_LIMIT_ATTACHED</dt> | | 2330 | +** <dt>SQLITE_LIMIT_ATTACHED</dt> |
2330 | +** <dd>The maximum number of [ATTACH | attached databases].</dd> | | 2331 | +** <dd>The maximum number of [ATTACH | attached databases].</dd> |
2331 | +** | | 2332 | +** |
2332 | +** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt> | | 2333 | +** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt> |
2333 | +** <dd>The maximum length of the pattern argument to the [LIKE] or | | 2334 | +** <dd>The maximum length of the pattern argument to the [LIKE] or |
2334 | +** [GLOB] operators.</dd> | | 2335 | +** [GLOB] operators.</dd> |
2335 | +** | | 2336 | +** |
2336 | +** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt> | | 2337 | +** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt> |
2337 | +** <dd>The maximum number of variables in an SQL statement that can | | 2338 | +** <dd>The maximum number of variables in an SQL statement that can |
2338 | +** be bound.</dd> | | 2339 | +** be bound.</dd> |
2339 | +** | | 2340 | +** |
2340 | +** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt> | | 2341 | +** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt> |
2341 | +** <dd>The maximum depth of recursion for triggers.</dd> | | 2342 | +** <dd>The maximum depth of recursion for triggers.</dd> |
2342 | +** </dl> | | 2343 | +** </dl> |
2343 | +*/ | | 2344 | +*/ |
2344 | +#define SQLITE_LIMIT_LENGTH 0 | | 2345 | +#define SQLITE_LIMIT_LENGTH 0 |
2345 | +#define SQLITE_LIMIT_SQL_LENGTH 1 | | 2346 | +#define SQLITE_LIMIT_SQL_LENGTH 1 |
2346 | +#define SQLITE_LIMIT_COLUMN 2 | | 2347 | +#define SQLITE_LIMIT_COLUMN 2 |
2347 | +#define SQLITE_LIMIT_EXPR_DEPTH 3 | | 2348 | +#define SQLITE_LIMIT_EXPR_DEPTH 3 |
2348 | +#define SQLITE_LIMIT_COMPOUND_SELECT 4 | | 2349 | +#define SQLITE_LIMIT_COMPOUND_SELECT 4 |
2349 | +#define SQLITE_LIMIT_VDBE_OP 5 | | 2350 | +#define SQLITE_LIMIT_VDBE_OP 5 |
2350 | +#define SQLITE_LIMIT_FUNCTION_ARG 6 | | 2351 | +#define SQLITE_LIMIT_FUNCTION_ARG 6 |
2351 | +#define SQLITE_LIMIT_ATTACHED 7 | | 2352 | +#define SQLITE_LIMIT_ATTACHED 7 |
2352 | +#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 | | 2353 | +#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 |
2353 | +#define SQLITE_LIMIT_VARIABLE_NUMBER 9 | | 2354 | +#define SQLITE_LIMIT_VARIABLE_NUMBER 9 |
2354 | +#define SQLITE_LIMIT_TRIGGER_DEPTH 10 | | 2355 | +#define SQLITE_LIMIT_TRIGGER_DEPTH 10 |
2355 | + | | 2356 | + |
2356 | +/* | | 2357 | +/* |
2357 | +** CAPI3REF: Compiling An SQL Statement {H13010} <S10000> | | 2358 | +** CAPI3REF: Compiling An SQL Statement {H13010} <S10000> |
2358 | +** KEYWORDS: {SQL statement compiler} | | 2359 | +** KEYWORDS: {SQL statement compiler} |
2359 | +** | | 2360 | +** |
2360 | +** To execute an SQL query, it must first be compiled into a byte-code | | 2361 | +** To execute an SQL query, it must first be compiled into a byte-code |
2361 | +** program using one of these routines. | | 2362 | +** program using one of these routines. |
2362 | +** | | 2363 | +** |
2363 | +** The first argument, "db", is a [database connection] obtained from a | | 2364 | +** The first argument, "db", is a [database connection] obtained from a |
2364 | +** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or | | 2365 | +** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or |
2365 | +** [sqlite3_open16()]. The database connection must not have been closed. | | 2366 | +** [sqlite3_open16()]. The database connection must not have been closed. |
2366 | +** | | 2367 | +** |
2367 | +** The second argument, "zSql", is the statement to be compiled, encoded | | 2368 | +** The second argument, "zSql", is the statement to be compiled, encoded |
2368 | +** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() | | 2369 | +** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
2369 | +** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() | | 2370 | +** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() |
2370 | +** use UTF-16. | | 2371 | +** use UTF-16. |
2371 | +** | | 2372 | +** |
2372 | +** If the nByte argument is less than zero, then zSql is read up to the | | 2373 | +** If the nByte argument is less than zero, then zSql is read up to the |
2373 | +** first zero terminator. If nByte is non-negative, then it is the maximum | | 2374 | +** first zero terminator. If nByte is non-negative, then it is the maximum |
2374 | +** number of bytes read from zSql. When nByte is non-negative, the | | 2375 | +** number of bytes read from zSql. When nByte is non-negative, the |
2375 | +** zSql string ends at either the first '\000' or '\u0000' character or | | 2376 | +** zSql string ends at either the first '\000' or '\u0000' character or |
2376 | +** the nByte-th byte, whichever comes first. If the caller knows | | 2377 | +** the nByte-th byte, whichever comes first. If the caller knows |
2377 | +** that the supplied string is nul-terminated, then there is a small | | 2378 | +** that the supplied string is nul-terminated, then there is a small |
| @@ -3520,1998 +3521,2001 @@ $NetBSD: patch-ab,v 1.3 2009/10/11 16:06 | | | @@ -3520,1998 +3521,2001 @@ $NetBSD: patch-ab,v 1.3 2009/10/11 16:06 |
3520 | +** sqlite3_result_error16() is non-negative then SQLite takes that many | | 3521 | +** sqlite3_result_error16() is non-negative then SQLite takes that many |
3521 | +** bytes (not characters) from the 2nd parameter as the error message. | | 3522 | +** bytes (not characters) from the 2nd parameter as the error message. |
3522 | +** The sqlite3_result_error() and sqlite3_result_error16() | | 3523 | +** The sqlite3_result_error() and sqlite3_result_error16() |
3523 | +** routines make a private copy of the error message text before | | 3524 | +** routines make a private copy of the error message text before |
3524 | +** they return. Hence, the calling function can deallocate or | | 3525 | +** they return. Hence, the calling function can deallocate or |
3525 | +** modify the text after they return without harm. | | 3526 | +** modify the text after they return without harm. |
3526 | +** The sqlite3_result_error_code() function changes the error code | | 3527 | +** The sqlite3_result_error_code() function changes the error code |
3527 | +** returned by SQLite as a result of an error in a function. By default, | | 3528 | +** returned by SQLite as a result of an error in a function. By default, |
3528 | +** the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error() | | 3529 | +** the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error() |
3529 | +** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. | | 3530 | +** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. |
3530 | +** | | 3531 | +** |
3531 | +** The sqlite3_result_toobig() interface causes SQLite to throw an error | | 3532 | +** The sqlite3_result_toobig() interface causes SQLite to throw an error |
3532 | +** indicating that a string or BLOB is to long to represent. | | 3533 | +** indicating that a string or BLOB is to long to represent. |
3533 | +** | | 3534 | +** |
3534 | +** The sqlite3_result_nomem() interface causes SQLite to throw an error | | 3535 | +** The sqlite3_result_nomem() interface causes SQLite to throw an error |
3535 | +** indicating that a memory allocation failed. | | 3536 | +** indicating that a memory allocation failed. |
3536 | +** | | 3537 | +** |
3537 | +** The sqlite3_result_int() interface sets the return value | | 3538 | +** The sqlite3_result_int() interface sets the return value |
3538 | +** of the application-defined function to be the 32-bit signed integer | | 3539 | +** of the application-defined function to be the 32-bit signed integer |
3539 | +** value given in the 2nd argument. | | 3540 | +** value given in the 2nd argument. |
3540 | +** The sqlite3_result_int64() interface sets the return value | | 3541 | +** The sqlite3_result_int64() interface sets the return value |
3541 | +** of the application-defined function to be the 64-bit signed integer | | 3542 | +** of the application-defined function to be the 64-bit signed integer |
3542 | +** value given in the 2nd argument. | | 3543 | +** value given in the 2nd argument. |
3543 | +** | | 3544 | +** |
3544 | +** The sqlite3_result_null() interface sets the return value | | 3545 | +** The sqlite3_result_null() interface sets the return value |
3545 | +** of the application-defined function to be NULL. | | 3546 | +** of the application-defined function to be NULL. |
3546 | +** | | 3547 | +** |
3547 | +** The sqlite3_result_text(), sqlite3_result_text16(), | | 3548 | +** The sqlite3_result_text(), sqlite3_result_text16(), |
3548 | +** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces | | 3549 | +** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces |
3549 | +** set the return value of the application-defined function to be | | 3550 | +** set the return value of the application-defined function to be |
3550 | +** a text string which is represented as UTF-8, UTF-16 native byte order, | | 3551 | +** a text string which is represented as UTF-8, UTF-16 native byte order, |
3551 | +** UTF-16 little endian, or UTF-16 big endian, respectively. | | 3552 | +** UTF-16 little endian, or UTF-16 big endian, respectively. |
3552 | +** SQLite takes the text result from the application from | | 3553 | +** SQLite takes the text result from the application from |
3553 | +** the 2nd parameter of the sqlite3_result_text* interfaces. | | 3554 | +** the 2nd parameter of the sqlite3_result_text* interfaces. |
3554 | +** If the 3rd parameter to the sqlite3_result_text* interfaces | | 3555 | +** If the 3rd parameter to the sqlite3_result_text* interfaces |
3555 | +** is negative, then SQLite takes result text from the 2nd parameter | | 3556 | +** is negative, then SQLite takes result text from the 2nd parameter |
3556 | +** through the first zero character. | | 3557 | +** through the first zero character. |
3557 | +** If the 3rd parameter to the sqlite3_result_text* interfaces | | 3558 | +** If the 3rd parameter to the sqlite3_result_text* interfaces |
3558 | +** is non-negative, then as many bytes (not characters) of the text | | 3559 | +** is non-negative, then as many bytes (not characters) of the text |
3559 | +** pointed to by the 2nd parameter are taken as the application-defined | | 3560 | +** pointed to by the 2nd parameter are taken as the application-defined |
3560 | +** function result. | | 3561 | +** function result. |
3561 | +** If the 4th parameter to the sqlite3_result_text* interfaces | | 3562 | +** If the 4th parameter to the sqlite3_result_text* interfaces |
3562 | +** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that | | 3563 | +** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that |
3563 | +** function as the destructor on the text or BLOB result when it has | | 3564 | +** function as the destructor on the text or BLOB result when it has |
3564 | +** finished using that result. | | 3565 | +** finished using that result. |
3565 | +** If the 4th parameter to the sqlite3_result_text* interfaces or to | | 3566 | +** If the 4th parameter to the sqlite3_result_text* interfaces or to |
3566 | +** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite | | 3567 | +** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite |
3567 | +** assumes that the text or BLOB result is in constant space and does not | | 3568 | +** assumes that the text or BLOB result is in constant space and does not |
3568 | +** copy the content of the parameter nor call a destructor on the content | | 3569 | +** copy the content of the parameter nor call a destructor on the content |
3569 | +** when it has finished using that result. | | 3570 | +** when it has finished using that result. |
3570 | +** If the 4th parameter to the sqlite3_result_text* interfaces | | 3571 | +** If the 4th parameter to the sqlite3_result_text* interfaces |
3571 | +** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT | | 3572 | +** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT |
3572 | +** then SQLite makes a copy of the result into space obtained from | | 3573 | +** then SQLite makes a copy of the result into space obtained from |
3573 | +** from [sqlite3_malloc()] before it returns. | | 3574 | +** from [sqlite3_malloc()] before it returns. |
3574 | +** | | 3575 | +** |
3575 | +** The sqlite3_result_value() interface sets the result of | | 3576 | +** The sqlite3_result_value() interface sets the result of |
3576 | +** the application-defined function to be a copy the | | 3577 | +** the application-defined function to be a copy the |
3577 | +** [unprotected sqlite3_value] object specified by the 2nd parameter. The | | 3578 | +** [unprotected sqlite3_value] object specified by the 2nd parameter. The |
3578 | +** sqlite3_result_value() interface makes a copy of the [sqlite3_value] | | 3579 | +** sqlite3_result_value() interface makes a copy of the [sqlite3_value] |
3579 | +** so that the [sqlite3_value] specified in the parameter may change or | | 3580 | +** so that the [sqlite3_value] specified in the parameter may change or |
3580 | +** be deallocated after sqlite3_result_value() returns without harm. | | 3581 | +** be deallocated after sqlite3_result_value() returns without harm. |
3581 | +** A [protected sqlite3_value] object may always be used where an | | 3582 | +** A [protected sqlite3_value] object may always be used where an |
3582 | +** [unprotected sqlite3_value] object is required, so either | | 3583 | +** [unprotected sqlite3_value] object is required, so either |
3583 | +** kind of [sqlite3_value] object can be used with this interface. | | 3584 | +** kind of [sqlite3_value] object can be used with this interface. |
3584 | +** | | 3585 | +** |
3585 | +** If these routines are called from within the different thread | | 3586 | +** If these routines are called from within the different thread |
3586 | +** than the one containing the application-defined function that received | | 3587 | +** than the one containing the application-defined function that received |
3587 | +** the [sqlite3_context] pointer, the results are undefined. | | 3588 | +** the [sqlite3_context] pointer, the results are undefined. |
3588 | +** | | 3589 | +** |
3589 | +** Requirements: | | 3590 | +** Requirements: |
3590 | +** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424] | | 3591 | +** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424] |
3591 | +** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448] | | 3592 | +** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448] |
3592 | +** [H16451] [H16454] [H16457] [H16460] [H16463] | | 3593 | +** [H16451] [H16454] [H16457] [H16460] [H16463] |
3593 | +*/ | | 3594 | +*/ |
3594 | +SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); | | 3595 | +SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); |
3595 | +SQLITE_API void sqlite3_result_double(sqlite3_context*, double); | | 3596 | +SQLITE_API void sqlite3_result_double(sqlite3_context*, double); |
3596 | +SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); | | 3597 | +SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); |
3597 | +SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); | | 3598 | +SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); |
3598 | +SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); | | 3599 | +SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); |
3599 | +SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); | | 3600 | +SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); |
3600 | +SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); | | 3601 | +SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); |
3601 | +SQLITE_API void sqlite3_result_int(sqlite3_context*, int); | | 3602 | +SQLITE_API void sqlite3_result_int(sqlite3_context*, int); |
3602 | +SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); | | 3603 | +SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); |
3603 | +SQLITE_API void sqlite3_result_null(sqlite3_context*); | | 3604 | +SQLITE_API void sqlite3_result_null(sqlite3_context*); |
3604 | +SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); | | 3605 | +SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); |
3605 | +SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); | | 3606 | +SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
3606 | +SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); | | 3607 | +SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
3607 | +SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); | | 3608 | +SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
3608 | +SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); | | 3609 | +SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
3609 | +SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); | | 3610 | +SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
3610 | + | | 3611 | + |
3611 | +/* | | 3612 | +/* |
3612 | +** CAPI3REF: Define New Collating Sequences {H16600} <S20300> | | 3613 | +** CAPI3REF: Define New Collating Sequences {H16600} <S20300> |
3613 | +** | | 3614 | +** |
3614 | +** These functions are used to add new collation sequences to the | | 3615 | +** These functions are used to add new collation sequences to the |
3615 | +** [database connection] specified as the first argument. | | 3616 | +** [database connection] specified as the first argument. |
3616 | +** | | 3617 | +** |
3617 | +** The name of the new collation sequence is specified as a UTF-8 string | | 3618 | +** The name of the new collation sequence is specified as a UTF-8 string |
3618 | +** for sqlite3_create_collation() and sqlite3_create_collation_v2() | | 3619 | +** for sqlite3_create_collation() and sqlite3_create_collation_v2() |
3619 | +** and a UTF-16 string for sqlite3_create_collation16(). In all cases | | 3620 | +** and a UTF-16 string for sqlite3_create_collation16(). In all cases |
3620 | +** the name is passed as the second function argument. | | 3621 | +** the name is passed as the second function argument. |
3621 | +** | | 3622 | +** |
3622 | +** The third argument may be one of the constants [SQLITE_UTF8], | | 3623 | +** The third argument may be one of the constants [SQLITE_UTF8], |
3623 | +** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied | | 3624 | +** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied |
3624 | +** routine expects to be passed pointers to strings encoded using UTF-8, | | 3625 | +** routine expects to be passed pointers to strings encoded using UTF-8, |
3625 | +** UTF-16 little-endian, or UTF-16 big-endian, respectively. The | | 3626 | +** UTF-16 little-endian, or UTF-16 big-endian, respectively. The |
3626 | +** third argument might also be [SQLITE_UTF16] to indicate that the routine | | 3627 | +** third argument might also be [SQLITE_UTF16] to indicate that the routine |
3627 | +** expects pointers to be UTF-16 strings in the native byte order, or the | | 3628 | +** expects pointers to be UTF-16 strings in the native byte order, or the |
3628 | +** argument can be [SQLITE_UTF16_ALIGNED] if the | | 3629 | +** argument can be [SQLITE_UTF16_ALIGNED] if the |
3629 | +** the routine expects pointers to 16-bit word aligned strings | | 3630 | +** the routine expects pointers to 16-bit word aligned strings |
3630 | +** of UTF-16 in the native byte order. | | 3631 | +** of UTF-16 in the native byte order. |
3631 | +** | | 3632 | +** |
3632 | +** A pointer to the user supplied routine must be passed as the fifth | | 3633 | +** A pointer to the user supplied routine must be passed as the fifth |
3633 | +** argument. If it is NULL, this is the same as deleting the collation | | 3634 | +** argument. If it is NULL, this is the same as deleting the collation |
3634 | +** sequence (so that SQLite cannot call it anymore). | | 3635 | +** sequence (so that SQLite cannot call it anymore). |
3635 | +** Each time the application supplied function is invoked, it is passed | | 3636 | +** Each time the application supplied function is invoked, it is passed |
3636 | +** as its first parameter a copy of the void* passed as the fourth argument | | 3637 | +** as its first parameter a copy of the void* passed as the fourth argument |
3637 | +** to sqlite3_create_collation() or sqlite3_create_collation16(). | | 3638 | +** to sqlite3_create_collation() or sqlite3_create_collation16(). |
3638 | +** | | 3639 | +** |
3639 | +** The remaining arguments to the application-supplied routine are two strings, | | 3640 | +** The remaining arguments to the application-supplied routine are two strings, |
3640 | +** each represented by a (length, data) pair and encoded in the encoding | | 3641 | +** each represented by a (length, data) pair and encoded in the encoding |
3641 | +** that was passed as the third argument when the collation sequence was | | 3642 | +** that was passed as the third argument when the collation sequence was |
3642 | +** registered. {END} The application defined collation routine should | | 3643 | +** registered. {END} The application defined collation routine should |
3643 | +** return negative, zero or positive if the first string is less than, | | 3644 | +** return negative, zero or positive if the first string is less than, |
3644 | +** equal to, or greater than the second string. i.e. (STRING1 - STRING2). | | 3645 | +** equal to, or greater than the second string. i.e. (STRING1 - STRING2). |
3645 | +** | | 3646 | +** |
3646 | +** The sqlite3_create_collation_v2() works like sqlite3_create_collation() | | 3647 | +** The sqlite3_create_collation_v2() works like sqlite3_create_collation() |
3647 | +** except that it takes an extra argument which is a destructor for | | 3648 | +** except that it takes an extra argument which is a destructor for |
3648 | +** the collation. The destructor is called when the collation is | | 3649 | +** the collation. The destructor is called when the collation is |
3649 | +** destroyed and is passed a copy of the fourth parameter void* pointer | | 3650 | +** destroyed and is passed a copy of the fourth parameter void* pointer |
3650 | +** of the sqlite3_create_collation_v2(). | | 3651 | +** of the sqlite3_create_collation_v2(). |
3651 | +** Collations are destroyed when they are overridden by later calls to the | | 3652 | +** Collations are destroyed when they are overridden by later calls to the |
3652 | +** collation creation functions or when the [database connection] is closed | | 3653 | +** collation creation functions or when the [database connection] is closed |
3653 | +** using [sqlite3_close()]. | | 3654 | +** using [sqlite3_close()]. |
3654 | +** | | 3655 | +** |
3655 | +** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. | | 3656 | +** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. |
3656 | +** | | 3657 | +** |
3657 | +** Requirements: | | 3658 | +** Requirements: |
3658 | +** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621] | | 3659 | +** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621] |
3659 | +** [H16624] [H16627] [H16630] | | 3660 | +** [H16624] [H16627] [H16630] |
3660 | +*/ | | 3661 | +*/ |
3661 | +SQLITE_API int sqlite3_create_collation( | | 3662 | +SQLITE_API int sqlite3_create_collation( |
3662 | + sqlite3*, | | 3663 | + sqlite3*, |
3663 | + const char *zName, | | 3664 | + const char *zName, |
3664 | + int eTextRep, | | 3665 | + int eTextRep, |
3665 | + void*, | | 3666 | + void*, |
3666 | + int(*xCompare)(void*,int,const void*,int,const void*) | | 3667 | + int(*xCompare)(void*,int,const void*,int,const void*) |
3667 | +); | | 3668 | +); |
3668 | +SQLITE_API int sqlite3_create_collation_v2( | | 3669 | +SQLITE_API int sqlite3_create_collation_v2( |
3669 | + sqlite3*, | | 3670 | + sqlite3*, |
3670 | + const char *zName, | | 3671 | + const char *zName, |
3671 | + int eTextRep, | | 3672 | + int eTextRep, |
3672 | + void*, | | 3673 | + void*, |
3673 | + int(*xCompare)(void*,int,const void*,int,const void*), | | 3674 | + int(*xCompare)(void*,int,const void*,int,const void*), |
3674 | + void(*xDestroy)(void*) | | 3675 | + void(*xDestroy)(void*) |
3675 | +); | | 3676 | +); |
3676 | +SQLITE_API int sqlite3_create_collation16( | | 3677 | +SQLITE_API int sqlite3_create_collation16( |
3677 | + sqlite3*, | | 3678 | + sqlite3*, |
3678 | + const void *zName, | | 3679 | + const void *zName, |
3679 | + int eTextRep, | | 3680 | + int eTextRep, |
3680 | + void*, | | 3681 | + void*, |
3681 | + int(*xCompare)(void*,int,const void*,int,const void*) | | 3682 | + int(*xCompare)(void*,int,const void*,int,const void*) |
3682 | +); | | 3683 | +); |
3683 | + | | 3684 | + |
3684 | +/* | | 3685 | +/* |
3685 | +** CAPI3REF: Collation Needed Callbacks {H16700} <S20300> | | 3686 | +** CAPI3REF: Collation Needed Callbacks {H16700} <S20300> |
3686 | +** | | 3687 | +** |
3687 | +** To avoid having to register all collation sequences before a database | | 3688 | +** To avoid having to register all collation sequences before a database |
3688 | +** can be used, a single callback function may be registered with the | | 3689 | +** can be used, a single callback function may be registered with the |
3689 | +** [database connection] to be called whenever an undefined collation | | 3690 | +** [database connection] to be called whenever an undefined collation |
3690 | +** sequence is required. | | 3691 | +** sequence is required. |
3691 | +** | | 3692 | +** |
3692 | +** If the function is registered using the sqlite3_collation_needed() API, | | 3693 | +** If the function is registered using the sqlite3_collation_needed() API, |
3693 | +** then it is passed the names of undefined collation sequences as strings | | 3694 | +** then it is passed the names of undefined collation sequences as strings |
3694 | +** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used, | | 3695 | +** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used, |
3695 | +** the names are passed as UTF-16 in machine native byte order. | | 3696 | +** the names are passed as UTF-16 in machine native byte order. |
3696 | +** A call to either function replaces any existing callback. | | 3697 | +** A call to either function replaces any existing callback. |
3697 | +** | | 3698 | +** |
3698 | +** When the callback is invoked, the first argument passed is a copy | | 3699 | +** When the callback is invoked, the first argument passed is a copy |
3699 | +** of the second argument to sqlite3_collation_needed() or | | 3700 | +** of the second argument to sqlite3_collation_needed() or |
3700 | +** sqlite3_collation_needed16(). The second argument is the database | | 3701 | +** sqlite3_collation_needed16(). The second argument is the database |
3701 | +** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], | | 3702 | +** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], |
3702 | +** or [SQLITE_UTF16LE], indicating the most desirable form of the collation | | 3703 | +** or [SQLITE_UTF16LE], indicating the most desirable form of the collation |
3703 | +** sequence function required. The fourth parameter is the name of the | | 3704 | +** sequence function required. The fourth parameter is the name of the |
3704 | +** required collation sequence. | | 3705 | +** required collation sequence. |
3705 | +** | | 3706 | +** |
3706 | +** The callback function should register the desired collation using | | 3707 | +** The callback function should register the desired collation using |
3707 | +** [sqlite3_create_collation()], [sqlite3_create_collation16()], or | | 3708 | +** [sqlite3_create_collation()], [sqlite3_create_collation16()], or |
3708 | +** [sqlite3_create_collation_v2()]. | | 3709 | +** [sqlite3_create_collation_v2()]. |
3709 | +** | | 3710 | +** |
3710 | +** Requirements: | | 3711 | +** Requirements: |
3711 | +** [H16702] [H16704] [H16706] | | 3712 | +** [H16702] [H16704] [H16706] |
3712 | +*/ | | 3713 | +*/ |
3713 | +SQLITE_API int sqlite3_collation_needed( | | 3714 | +SQLITE_API int sqlite3_collation_needed( |
3714 | + sqlite3*, | | 3715 | + sqlite3*, |
3715 | + void*, | | 3716 | + void*, |
3716 | + void(*)(void*,sqlite3*,int eTextRep,const char*) | | 3717 | + void(*)(void*,sqlite3*,int eTextRep,const char*) |
3717 | +); | | 3718 | +); |
3718 | +SQLITE_API int sqlite3_collation_needed16( | | 3719 | +SQLITE_API int sqlite3_collation_needed16( |
3719 | + sqlite3*, | | 3720 | + sqlite3*, |
3720 | + void*, | | 3721 | + void*, |
3721 | + void(*)(void*,sqlite3*,int eTextRep,const void*) | | 3722 | + void(*)(void*,sqlite3*,int eTextRep,const void*) |
3722 | +); | | 3723 | +); |
3723 | + | | 3724 | + |
3724 | +/* | | 3725 | +/* |
3725 | +** Specify the key for an encrypted database. This routine should be | | 3726 | +** Specify the key for an encrypted database. This routine should be |
3726 | +** called right after sqlite3_open(). | | 3727 | +** called right after sqlite3_open(). |
3727 | +** | | 3728 | +** |
3728 | +** The code to implement this API is not available in the public release | | 3729 | +** The code to implement this API is not available in the public release |
3729 | +** of SQLite. | | 3730 | +** of SQLite. |
3730 | +*/ | | 3731 | +*/ |
3731 | +SQLITE_API int sqlite3_key( | | 3732 | +SQLITE_API int sqlite3_key( |
3732 | + sqlite3 *db, /* Database to be rekeyed */ | | 3733 | + sqlite3 *db, /* Database to be rekeyed */ |
3733 | + const void *pKey, int nKey /* The key */ | | 3734 | + const void *pKey, int nKey /* The key */ |
3734 | +); | | 3735 | +); |
3735 | + | | 3736 | + |
3736 | +/* | | 3737 | +/* |
3737 | +** Change the key on an open database. If the current database is not | | 3738 | +** Change the key on an open database. If the current database is not |
3738 | +** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the | | 3739 | +** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the |
3739 | +** database is decrypted. | | 3740 | +** database is decrypted. |
3740 | +** | | 3741 | +** |
3741 | +** The code to implement this API is not available in the public release | | 3742 | +** The code to implement this API is not available in the public release |
3742 | +** of SQLite. | | 3743 | +** of SQLite. |
3743 | +*/ | | 3744 | +*/ |
3744 | +SQLITE_API int sqlite3_rekey( | | 3745 | +SQLITE_API int sqlite3_rekey( |
3745 | + sqlite3 *db, /* Database to be rekeyed */ | | 3746 | + sqlite3 *db, /* Database to be rekeyed */ |
3746 | + const void *pKey, int nKey /* The new key */ | | 3747 | + const void *pKey, int nKey /* The new key */ |
3747 | +); | | 3748 | +); |
3748 | + | | 3749 | + |
3749 | +/* | | 3750 | +/* |
3750 | +** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410> | | 3751 | +** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410> |
3751 | +** | | 3752 | +** |
3752 | +** The sqlite3_sleep() function causes the current thread to suspend execution | | 3753 | +** The sqlite3_sleep() function causes the current thread to suspend execution |
3753 | +** for at least a number of milliseconds specified in its parameter. | | 3754 | +** for at least a number of milliseconds specified in its parameter. |
3754 | +** | | 3755 | +** |
3755 | +** If the operating system does not support sleep requests with | | 3756 | +** If the operating system does not support sleep requests with |
3756 | +** millisecond time resolution, then the time will be rounded up to | | 3757 | +** millisecond time resolution, then the time will be rounded up to |
3757 | +** the nearest second. The number of milliseconds of sleep actually | | 3758 | +** the nearest second. The number of milliseconds of sleep actually |
3758 | +** requested from the operating system is returned. | | 3759 | +** requested from the operating system is returned. |
3759 | +** | | 3760 | +** |
3760 | +** SQLite implements this interface by calling the xSleep() | | 3761 | +** SQLite implements this interface by calling the xSleep() |
3761 | +** method of the default [sqlite3_vfs] object. | | 3762 | +** method of the default [sqlite3_vfs] object. |
3762 | +** | | 3763 | +** |
3763 | +** Requirements: [H10533] [H10536] | | 3764 | +** Requirements: [H10533] [H10536] |
3764 | +*/ | | 3765 | +*/ |
3765 | +SQLITE_API int sqlite3_sleep(int); | | 3766 | +SQLITE_API int sqlite3_sleep(int); |
3766 | + | | 3767 | + |
3767 | +/* | | 3768 | +/* |
3768 | +** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000> | | 3769 | +** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000> |
3769 | +** | | 3770 | +** |
3770 | +** If this global variable is made to point to a string which is | | 3771 | +** If this global variable is made to point to a string which is |
3771 | +** the name of a folder (a.k.a. directory), then all temporary files | | 3772 | +** the name of a folder (a.k.a. directory), then all temporary files |
3772 | +** created by SQLite will be placed in that directory. If this variable | | 3773 | +** created by SQLite will be placed in that directory. If this variable |
3773 | +** is a NULL pointer, then SQLite performs a search for an appropriate | | 3774 | +** is a NULL pointer, then SQLite performs a search for an appropriate |
3774 | +** temporary file directory. | | 3775 | +** temporary file directory. |
3775 | +** | | 3776 | +** |
3776 | +** It is not safe to read or modify this variable in more than one | | 3777 | +** It is not safe to read or modify this variable in more than one |
3777 | +** thread at a time. It is not safe to read or modify this variable | | 3778 | +** thread at a time. It is not safe to read or modify this variable |
3778 | +** if a [database connection] is being used at the same time in a separate | | 3779 | +** if a [database connection] is being used at the same time in a separate |
3779 | +** thread. | | 3780 | +** thread. |
3780 | +** It is intended that this variable be set once | | 3781 | +** It is intended that this variable be set once |
3781 | +** as part of process initialization and before any SQLite interface | | 3782 | +** as part of process initialization and before any SQLite interface |
3782 | +** routines have been called and that this variable remain unchanged | | 3783 | +** routines have been called and that this variable remain unchanged |
3783 | +** thereafter. | | 3784 | +** thereafter. |
3784 | +** | | 3785 | +** |
3785 | +** The [temp_store_directory pragma] may modify this variable and cause | | 3786 | +** The [temp_store_directory pragma] may modify this variable and cause |
3786 | +** it to point to memory obtained from [sqlite3_malloc]. Furthermore, | | 3787 | +** it to point to memory obtained from [sqlite3_malloc]. Furthermore, |
3787 | +** the [temp_store_directory pragma] always assumes that any string | | 3788 | +** the [temp_store_directory pragma] always assumes that any string |
3788 | +** that this variable points to is held in memory obtained from | | 3789 | +** that this variable points to is held in memory obtained from |
3789 | +** [sqlite3_malloc] and the pragma may attempt to free that memory | | 3790 | +** [sqlite3_malloc] and the pragma may attempt to free that memory |
3790 | +** using [sqlite3_free]. | | 3791 | +** using [sqlite3_free]. |
3791 | +** Hence, if this variable is modified directly, either it should be | | 3792 | +** Hence, if this variable is modified directly, either it should be |
3792 | +** made NULL or made to point to memory obtained from [sqlite3_malloc] | | 3793 | +** made NULL or made to point to memory obtained from [sqlite3_malloc] |
3793 | +** or else the use of the [temp_store_directory pragma] should be avoided. | | 3794 | +** or else the use of the [temp_store_directory pragma] should be avoided. |
3794 | +*/ | | 3795 | +*/ |
3795 | +SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; | | 3796 | +SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; |
3796 | + | | 3797 | + |
3797 | +/* | | 3798 | +/* |
3798 | +** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> | | 3799 | +** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> |
3799 | +** KEYWORDS: {autocommit mode} | | 3800 | +** KEYWORDS: {autocommit mode} |
3800 | +** | | 3801 | +** |
3801 | +** The sqlite3_get_autocommit() interface returns non-zero or | | 3802 | +** The sqlite3_get_autocommit() interface returns non-zero or |
3802 | +** zero if the given database connection is or is not in autocommit mode, | | 3803 | +** zero if the given database connection is or is not in autocommit mode, |
3803 | +** respectively. Autocommit mode is on by default. | | 3804 | +** respectively. Autocommit mode is on by default. |
3804 | +** Autocommit mode is disabled by a [BEGIN] statement. | | 3805 | +** Autocommit mode is disabled by a [BEGIN] statement. |
3805 | +** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. | | 3806 | +** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. |
3806 | +** | | 3807 | +** |
3807 | +** If certain kinds of errors occur on a statement within a multi-statement | | 3808 | +** If certain kinds of errors occur on a statement within a multi-statement |
3808 | +** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], | | 3809 | +** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], |
3809 | +** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the | | 3810 | +** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the |
3810 | +** transaction might be rolled back automatically. The only way to | | 3811 | +** transaction might be rolled back automatically. The only way to |
3811 | +** find out whether SQLite automatically rolled back the transaction after | | 3812 | +** find out whether SQLite automatically rolled back the transaction after |
3812 | +** an error is to use this function. | | 3813 | +** an error is to use this function. |
3813 | +** | | 3814 | +** |
3814 | +** If another thread changes the autocommit status of the database | | 3815 | +** If another thread changes the autocommit status of the database |
3815 | +** connection while this routine is running, then the return value | | 3816 | +** connection while this routine is running, then the return value |
3816 | +** is undefined. | | 3817 | +** is undefined. |
3817 | +** | | 3818 | +** |
3818 | +** Requirements: [H12931] [H12932] [H12933] [H12934] | | 3819 | +** Requirements: [H12931] [H12932] [H12933] [H12934] |
3819 | +*/ | | 3820 | +*/ |
3820 | +SQLITE_API int sqlite3_get_autocommit(sqlite3*); | | 3821 | +SQLITE_API int sqlite3_get_autocommit(sqlite3*); |
3821 | + | | 3822 | + |
3822 | +/* | | 3823 | +/* |
3823 | +** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600> | | 3824 | +** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600> |
3824 | +** | | 3825 | +** |
3825 | +** The sqlite3_db_handle interface returns the [database connection] handle | | 3826 | +** The sqlite3_db_handle interface returns the [database connection] handle |
3826 | +** to which a [prepared statement] belongs. The [database connection] | | 3827 | +** to which a [prepared statement] belongs. The [database connection] |
3827 | +** returned by sqlite3_db_handle is the same [database connection] that was the first argument | | 3828 | +** returned by sqlite3_db_handle is the same [database connection] that was the first argument |
3828 | +** to the [sqlite3_prepare_v2()] call (or its variants) that was used to | | 3829 | +** to the [sqlite3_prepare_v2()] call (or its variants) that was used to |
3829 | +** create the statement in the first place. | | 3830 | +** create the statement in the first place. |
3830 | +** | | 3831 | +** |
3831 | +** Requirements: [H13123] | | 3832 | +** Requirements: [H13123] |
3832 | +*/ | | 3833 | +*/ |
3833 | +SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); | | 3834 | +SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); |
3834 | + | | 3835 | + |
3835 | +/* | | 3836 | +/* |
3836 | +** CAPI3REF: Find the next prepared statement {H13140} <S60600> | | 3837 | +** CAPI3REF: Find the next prepared statement {H13140} <S60600> |
3837 | +** | | 3838 | +** |
3838 | +** This interface returns a pointer to the next [prepared statement] after | | 3839 | +** This interface returns a pointer to the next [prepared statement] after |
3839 | +** pStmt associated with the [database connection] pDb. If pStmt is NULL | | 3840 | +** pStmt associated with the [database connection] pDb. If pStmt is NULL |
3840 | +** then this interface returns a pointer to the first prepared statement | | 3841 | +** then this interface returns a pointer to the first prepared statement |
3841 | +** associated with the database connection pDb. If no prepared statement | | 3842 | +** associated with the database connection pDb. If no prepared statement |
3842 | +** satisfies the conditions of this routine, it returns NULL. | | 3843 | +** satisfies the conditions of this routine, it returns NULL. |
3843 | +** | | 3844 | +** |
3844 | +** The [database connection] pointer D in a call to | | 3845 | +** The [database connection] pointer D in a call to |
3845 | +** [sqlite3_next_stmt(D,S)] must refer to an open database | | 3846 | +** [sqlite3_next_stmt(D,S)] must refer to an open database |
3846 | +** connection and in particular must not be a NULL pointer. | | 3847 | +** connection and in particular must not be a NULL pointer. |
3847 | +** | | 3848 | +** |
3848 | +** Requirements: [H13143] [H13146] [H13149] [H13152] | | 3849 | +** Requirements: [H13143] [H13146] [H13149] [H13152] |
3849 | +*/ | | 3850 | +*/ |
3850 | +SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); | | 3851 | +SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); |
3851 | + | | 3852 | + |
3852 | +/* | | 3853 | +/* |
3853 | +** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400> | | 3854 | +** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400> |
3854 | +** | | 3855 | +** |
3855 | +** The sqlite3_commit_hook() interface registers a callback | | 3856 | +** The sqlite3_commit_hook() interface registers a callback |
3856 | +** function to be invoked whenever a transaction is [COMMIT | committed]. | | 3857 | +** function to be invoked whenever a transaction is [COMMIT | committed]. |
3857 | +** Any callback set by a previous call to sqlite3_commit_hook() | | 3858 | +** Any callback set by a previous call to sqlite3_commit_hook() |
3858 | +** for the same database connection is overridden. | | 3859 | +** for the same database connection is overridden. |
3859 | +** The sqlite3_rollback_hook() interface registers a callback | | 3860 | +** The sqlite3_rollback_hook() interface registers a callback |
3860 | +** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. | | 3861 | +** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. |
3861 | +** Any callback set by a previous call to sqlite3_commit_hook() | | 3862 | +** Any callback set by a previous call to sqlite3_commit_hook() |
3862 | +** for the same database connection is overridden. | | 3863 | +** for the same database connection is overridden. |
3863 | +** The pArg argument is passed through to the callback. | | 3864 | +** The pArg argument is passed through to the callback. |
3864 | +** If the callback on a commit hook function returns non-zero, | | 3865 | +** If the callback on a commit hook function returns non-zero, |
3865 | +** then the commit is converted into a rollback. | | 3866 | +** then the commit is converted into a rollback. |
3866 | +** | | 3867 | +** |
3867 | +** If another function was previously registered, its | | 3868 | +** If another function was previously registered, its |
3868 | +** pArg value is returned. Otherwise NULL is returned. | | 3869 | +** pArg value is returned. Otherwise NULL is returned. |
3869 | +** | | 3870 | +** |
3870 | +** The callback implementation must not do anything that will modify | | 3871 | +** The callback implementation must not do anything that will modify |
3871 | +** the database connection that invoked the callback. Any actions | | 3872 | +** the database connection that invoked the callback. Any actions |
3872 | +** to modify the database connection must be deferred until after the | | 3873 | +** to modify the database connection must be deferred until after the |
3873 | +** completion of the [sqlite3_step()] call that triggered the commit | | 3874 | +** completion of the [sqlite3_step()] call that triggered the commit |
3874 | +** or rollback hook in the first place. | | 3875 | +** or rollback hook in the first place. |
3875 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their | | 3876 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
3876 | +** database connections for the meaning of "modify" in this paragraph. | | 3877 | +** database connections for the meaning of "modify" in this paragraph. |
3877 | +** | | 3878 | +** |
3878 | +** Registering a NULL function disables the callback. | | 3879 | +** Registering a NULL function disables the callback. |
3879 | +** | | 3880 | +** |
3880 | +** When the commit hook callback routine returns zero, the [COMMIT] | | 3881 | +** When the commit hook callback routine returns zero, the [COMMIT] |
3881 | +** operation is allowed to continue normally. If the commit hook | | 3882 | +** operation is allowed to continue normally. If the commit hook |
3882 | +** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. | | 3883 | +** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. |
3883 | +** The rollback hook is invoked on a rollback that results from a commit | | 3884 | +** The rollback hook is invoked on a rollback that results from a commit |
3884 | +** hook returning non-zero, just as it would be with any other rollback. | | 3885 | +** hook returning non-zero, just as it would be with any other rollback. |
3885 | +** | | 3886 | +** |
3886 | +** For the purposes of this API, a transaction is said to have been | | 3887 | +** For the purposes of this API, a transaction is said to have been |
3887 | +** rolled back if an explicit "ROLLBACK" statement is executed, or | | 3888 | +** rolled back if an explicit "ROLLBACK" statement is executed, or |
3888 | +** an error or constraint causes an implicit rollback to occur. | | 3889 | +** an error or constraint causes an implicit rollback to occur. |
3889 | +** The rollback callback is not invoked if a transaction is | | 3890 | +** The rollback callback is not invoked if a transaction is |
3890 | +** automatically rolled back because the database connection is closed. | | 3891 | +** automatically rolled back because the database connection is closed. |
3891 | +** The rollback callback is not invoked if a transaction is | | 3892 | +** The rollback callback is not invoked if a transaction is |
3892 | +** rolled back because a commit callback returned non-zero. | | 3893 | +** rolled back because a commit callback returned non-zero. |
3893 | +** <todo> Check on this </todo> | | 3894 | +** <todo> Check on this </todo> |
3894 | +** | | 3895 | +** |
3895 | +** See also the [sqlite3_update_hook()] interface. | | 3896 | +** See also the [sqlite3_update_hook()] interface. |
3896 | +** | | 3897 | +** |
3897 | +** Requirements: | | 3898 | +** Requirements: |
3898 | +** [H12951] [H12952] [H12953] [H12954] [H12955] | | 3899 | +** [H12951] [H12952] [H12953] [H12954] [H12955] |
3899 | +** [H12961] [H12962] [H12963] [H12964] | | 3900 | +** [H12961] [H12962] [H12963] [H12964] |
3900 | +*/ | | 3901 | +*/ |
3901 | +SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); | | 3902 | +SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); |
3902 | +SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); | | 3903 | +SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
3903 | + | | 3904 | + |
3904 | +/* | | 3905 | +/* |
3905 | +** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400> | | 3906 | +** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400> |
3906 | +** | | 3907 | +** |
3907 | +** The sqlite3_update_hook() interface registers a callback function | | 3908 | +** The sqlite3_update_hook() interface registers a callback function |
3908 | +** with the [database connection] identified by the first argument | | 3909 | +** with the [database connection] identified by the first argument |
3909 | +** to be invoked whenever a row is updated, inserted or deleted. | | 3910 | +** to be invoked whenever a row is updated, inserted or deleted. |
3910 | +** Any callback set by a previous call to this function | | 3911 | +** Any callback set by a previous call to this function |
3911 | +** for the same database connection is overridden. | | 3912 | +** for the same database connection is overridden. |
3912 | +** | | 3913 | +** |
3913 | +** The second argument is a pointer to the function to invoke when a | | 3914 | +** The second argument is a pointer to the function to invoke when a |
3914 | +** row is updated, inserted or deleted. | | 3915 | +** row is updated, inserted or deleted. |
3915 | +** The first argument to the callback is a copy of the third argument | | 3916 | +** The first argument to the callback is a copy of the third argument |
3916 | +** to sqlite3_update_hook(). | | 3917 | +** to sqlite3_update_hook(). |
3917 | +** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], | | 3918 | +** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], |
3918 | +** or [SQLITE_UPDATE], depending on the operation that caused the callback | | 3919 | +** or [SQLITE_UPDATE], depending on the operation that caused the callback |
3919 | +** to be invoked. | | 3920 | +** to be invoked. |
3920 | +** The third and fourth arguments to the callback contain pointers to the | | 3921 | +** The third and fourth arguments to the callback contain pointers to the |
3921 | +** database and table name containing the affected row. | | 3922 | +** database and table name containing the affected row. |
3922 | +** The final callback parameter is the [rowid] of the row. | | 3923 | +** The final callback parameter is the [rowid] of the row. |
3923 | +** In the case of an update, this is the [rowid] after the update takes place. | | 3924 | +** In the case of an update, this is the [rowid] after the update takes place. |
3924 | +** | | 3925 | +** |
3925 | +** The update hook is not invoked when internal system tables are | | 3926 | +** The update hook is not invoked when internal system tables are |
3926 | +** modified (i.e. sqlite_master and sqlite_sequence). | | 3927 | +** modified (i.e. sqlite_master and sqlite_sequence). |
3927 | +** | | 3928 | +** |
3928 | +** In the current implementation, the update hook | | 3929 | +** In the current implementation, the update hook |
3929 | +** is not invoked when duplication rows are deleted because of an | | 3930 | +** is not invoked when duplication rows are deleted because of an |
3930 | +** [ON CONFLICT | ON CONFLICT REPLACE] clause. Nor is the update hook | | 3931 | +** [ON CONFLICT | ON CONFLICT REPLACE] clause. Nor is the update hook |
3931 | +** invoked when rows are deleted using the [truncate optimization]. | | 3932 | +** invoked when rows are deleted using the [truncate optimization]. |
3932 | +** The exceptions defined in this paragraph might change in a future | | 3933 | +** The exceptions defined in this paragraph might change in a future |
3933 | +** release of SQLite. | | 3934 | +** release of SQLite. |
3934 | +** | | 3935 | +** |
3935 | +** The update hook implementation must not do anything that will modify | | 3936 | +** The update hook implementation must not do anything that will modify |
3936 | +** the database connection that invoked the update hook. Any actions | | 3937 | +** the database connection that invoked the update hook. Any actions |
3937 | +** to modify the database connection must be deferred until after the | | 3938 | +** to modify the database connection must be deferred until after the |
3938 | +** completion of the [sqlite3_step()] call that triggered the update hook. | | 3939 | +** completion of the [sqlite3_step()] call that triggered the update hook. |
3939 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their | | 3940 | +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
3940 | +** database connections for the meaning of "modify" in this paragraph. | | 3941 | +** database connections for the meaning of "modify" in this paragraph. |
3941 | +** | | 3942 | +** |
3942 | +** If another function was previously registered, its pArg value | | 3943 | +** If another function was previously registered, its pArg value |
3943 | +** is returned. Otherwise NULL is returned. | | 3944 | +** is returned. Otherwise NULL is returned. |
3944 | +** | | 3945 | +** |
3945 | +** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] | | 3946 | +** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] |
3946 | +** interfaces. | | 3947 | +** interfaces. |
3947 | +** | | 3948 | +** |
3948 | +** Requirements: | | 3949 | +** Requirements: |
3949 | +** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986] | | 3950 | +** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986] |
3950 | +*/ | | 3951 | +*/ |
3951 | +SQLITE_API void *sqlite3_update_hook( | | 3952 | +SQLITE_API void *sqlite3_update_hook( |
3952 | + sqlite3*, | | 3953 | + sqlite3*, |
3953 | + void(*)(void *,int ,char const *,char const *,sqlite3_int64), | | 3954 | + void(*)(void *,int ,char const *,char const *,sqlite3_int64), |
3954 | + void* | | 3955 | + void* |
3955 | +); | | 3956 | +); |
3956 | + | | 3957 | + |
3957 | +/* | | 3958 | +/* |
3958 | +** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900> | | 3959 | +** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900> |
3959 | +** KEYWORDS: {shared cache} | | 3960 | +** KEYWORDS: {shared cache} |
3960 | +** | | 3961 | +** |
3961 | +** This routine enables or disables the sharing of the database cache | | 3962 | +** This routine enables or disables the sharing of the database cache |
3962 | +** and schema data structures between [database connection | connections] | | 3963 | +** and schema data structures between [database connection | connections] |
3963 | +** to the same database. Sharing is enabled if the argument is true | | 3964 | +** to the same database. Sharing is enabled if the argument is true |
3964 | +** and disabled if the argument is false. | | 3965 | +** and disabled if the argument is false. |
3965 | +** | | 3966 | +** |
3966 | +** Cache sharing is enabled and disabled for an entire process. | | 3967 | +** Cache sharing is enabled and disabled for an entire process. |
3967 | +** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, | | 3968 | +** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, |
3968 | +** sharing was enabled or disabled for each thread separately. | | 3969 | +** sharing was enabled or disabled for each thread separately. |
3969 | +** | | 3970 | +** |
3970 | +** The cache sharing mode set by this interface effects all subsequent | | 3971 | +** The cache sharing mode set by this interface effects all subsequent |
3971 | +** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. | | 3972 | +** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. |
3972 | +** Existing database connections continue use the sharing mode | | 3973 | +** Existing database connections continue use the sharing mode |
3973 | +** that was in effect at the time they were opened. | | 3974 | +** that was in effect at the time they were opened. |
3974 | +** | | 3975 | +** |
3975 | +** Virtual tables cannot be used with a shared cache. When shared | | 3976 | +** Virtual tables cannot be used with a shared cache. When shared |
3976 | +** cache is enabled, the [sqlite3_create_module()] API used to register | | 3977 | +** cache is enabled, the [sqlite3_create_module()] API used to register |
3977 | +** virtual tables will always return an error. | | 3978 | +** virtual tables will always return an error. |
3978 | +** | | 3979 | +** |
3979 | +** This routine returns [SQLITE_OK] if shared cache was enabled or disabled | | 3980 | +** This routine returns [SQLITE_OK] if shared cache was enabled or disabled |
3980 | +** successfully. An [error code] is returned otherwise. | | 3981 | +** successfully. An [error code] is returned otherwise. |
3981 | +** | | 3982 | +** |
3982 | +** Shared cache is disabled by default. But this might change in | | 3983 | +** Shared cache is disabled by default. But this might change in |
3983 | +** future releases of SQLite. Applications that care about shared | | 3984 | +** future releases of SQLite. Applications that care about shared |
3984 | +** cache setting should set it explicitly. | | 3985 | +** cache setting should set it explicitly. |
3985 | +** | | 3986 | +** |
3986 | +** See Also: [SQLite Shared-Cache Mode] | | 3987 | +** See Also: [SQLite Shared-Cache Mode] |
3987 | +** | | 3988 | +** |
3988 | +** Requirements: [H10331] [H10336] [H10337] [H10339] | | 3989 | +** Requirements: [H10331] [H10336] [H10337] [H10339] |
3989 | +*/ | | 3990 | +*/ |
3990 | +SQLITE_API int sqlite3_enable_shared_cache(int); | | 3991 | +SQLITE_API int sqlite3_enable_shared_cache(int); |
3991 | + | | 3992 | + |
3992 | +/* | | 3993 | +/* |
3993 | +** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220> | | 3994 | +** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220> |
3994 | +** | | 3995 | +** |
3995 | +** The sqlite3_release_memory() interface attempts to free N bytes | | 3996 | +** The sqlite3_release_memory() interface attempts to free N bytes |
3996 | +** of heap memory by deallocating non-essential memory allocations | | 3997 | +** of heap memory by deallocating non-essential memory allocations |
3997 | +** held by the database library. {END} Memory used to cache database | | 3998 | +** held by the database library. {END} Memory used to cache database |
3998 | +** pages to improve performance is an example of non-essential memory. | | 3999 | +** pages to improve performance is an example of non-essential memory. |
3999 | +** sqlite3_release_memory() returns the number of bytes actually freed, | | 4000 | +** sqlite3_release_memory() returns the number of bytes actually freed, |
4000 | +** which might be more or less than the amount requested. | | 4001 | +** which might be more or less than the amount requested. |
4001 | +** | | 4002 | +** |
4002 | +** Requirements: [H17341] [H17342] | | 4003 | +** Requirements: [H17341] [H17342] |
4003 | +*/ | | 4004 | +*/ |
4004 | +SQLITE_API int sqlite3_release_memory(int); | | 4005 | +SQLITE_API int sqlite3_release_memory(int); |
4005 | + | | 4006 | + |
4006 | +/* | | 4007 | +/* |
4007 | +** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220> | | 4008 | +** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220> |
4008 | +** | | 4009 | +** |
4009 | +** The sqlite3_soft_heap_limit() interface places a "soft" limit | | 4010 | +** The sqlite3_soft_heap_limit() interface places a "soft" limit |
4010 | +** on the amount of heap memory that may be allocated by SQLite. | | 4011 | +** on the amount of heap memory that may be allocated by SQLite. |
4011 | +** If an internal allocation is requested that would exceed the | | 4012 | +** If an internal allocation is requested that would exceed the |
4012 | +** soft heap limit, [sqlite3_release_memory()] is invoked one or | | 4013 | +** soft heap limit, [sqlite3_release_memory()] is invoked one or |
4013 | +** more times to free up some space before the allocation is performed. | | 4014 | +** more times to free up some space before the allocation is performed. |
4014 | +** | | 4015 | +** |
4015 | +** The limit is called "soft", because if [sqlite3_release_memory()] | | 4016 | +** The limit is called "soft", because if [sqlite3_release_memory()] |
4016 | +** cannot free sufficient memory to prevent the limit from being exceeded, | | 4017 | +** cannot free sufficient memory to prevent the limit from being exceeded, |
4017 | +** the memory is allocated anyway and the current operation proceeds. | | 4018 | +** the memory is allocated anyway and the current operation proceeds. |
4018 | +** | | 4019 | +** |
4019 | +** A negative or zero value for N means that there is no soft heap limit and | | 4020 | +** A negative or zero value for N means that there is no soft heap limit and |
4020 | +** [sqlite3_release_memory()] will only be called when memory is exhausted. | | 4021 | +** [sqlite3_release_memory()] will only be called when memory is exhausted. |
4021 | +** The default value for the soft heap limit is zero. | | 4022 | +** The default value for the soft heap limit is zero. |
4022 | +** | | 4023 | +** |
4023 | +** SQLite makes a best effort to honor the soft heap limit. | | 4024 | +** SQLite makes a best effort to honor the soft heap limit. |
4024 | +** But if the soft heap limit cannot be honored, execution will | | 4025 | +** But if the soft heap limit cannot be honored, execution will |
4025 | +** continue without error or notification. This is why the limit is | | 4026 | +** continue without error or notification. This is why the limit is |
4026 | +** called a "soft" limit. It is advisory only. | | 4027 | +** called a "soft" limit. It is advisory only. |
4027 | +** | | 4028 | +** |
4028 | +** Prior to SQLite version 3.5.0, this routine only constrained the memory | | 4029 | +** Prior to SQLite version 3.5.0, this routine only constrained the memory |
4029 | +** allocated by a single thread - the same thread in which this routine | | 4030 | +** allocated by a single thread - the same thread in which this routine |
4030 | +** runs. Beginning with SQLite version 3.5.0, the soft heap limit is | | 4031 | +** runs. Beginning with SQLite version 3.5.0, the soft heap limit is |
4031 | +** applied to all threads. The value specified for the soft heap limit | | 4032 | +** applied to all threads. The value specified for the soft heap limit |
4032 | +** is an upper bound on the total memory allocation for all threads. In | | 4033 | +** is an upper bound on the total memory allocation for all threads. In |
4033 | +** version 3.5.0 there is no mechanism for limiting the heap usage for | | 4034 | +** version 3.5.0 there is no mechanism for limiting the heap usage for |
4034 | +** individual threads. | | 4035 | +** individual threads. |
4035 | +** | | 4036 | +** |
4036 | +** Requirements: | | 4037 | +** Requirements: |
4037 | +** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358] | | 4038 | +** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358] |
4038 | +*/ | | 4039 | +*/ |
4039 | +SQLITE_API void sqlite3_soft_heap_limit(int); | | 4040 | +SQLITE_API void sqlite3_soft_heap_limit(int); |
4040 | + | | 4041 | + |
4041 | +/* | | 4042 | +/* |
4042 | +** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300> | | 4043 | +** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300> |
4043 | +** | | 4044 | +** |
4044 | +** This routine returns metadata about a specific column of a specific | | 4045 | +** This routine returns metadata about a specific column of a specific |
4045 | +** database table accessible using the [database connection] handle | | 4046 | +** database table accessible using the [database connection] handle |
4046 | +** passed as the first function argument. | | 4047 | +** passed as the first function argument. |
4047 | +** | | 4048 | +** |
4048 | +** The column is identified by the second, third and fourth parameters to | | 4049 | +** The column is identified by the second, third and fourth parameters to |
4049 | +** this function. The second parameter is either the name of the database | | 4050 | +** this function. The second parameter is either the name of the database |
4050 | +** (i.e. "main", "temp" or an attached database) containing the specified | | 4051 | +** (i.e. "main", "temp" or an attached database) containing the specified |
4051 | +** table or NULL. If it is NULL, then all attached databases are searched | | 4052 | +** table or NULL. If it is NULL, then all attached databases are searched |
4052 | +** for the table using the same algorithm used by the database engine to | | 4053 | +** for the table using the same algorithm used by the database engine to |
4053 | +** resolve unqualified table references. | | 4054 | +** resolve unqualified table references. |
4054 | +** | | 4055 | +** |
4055 | +** The third and fourth parameters to this function are the table and column | | 4056 | +** The third and fourth parameters to this function are the table and column |
4056 | +** name of the desired column, respectively. Neither of these parameters | | 4057 | +** name of the desired column, respectively. Neither of these parameters |
4057 | +** may be NULL. | | 4058 | +** may be NULL. |
4058 | +** | | 4059 | +** |
4059 | +** Metadata is returned by writing to the memory locations passed as the 5th | | 4060 | +** Metadata is returned by writing to the memory locations passed as the 5th |
4060 | +** and subsequent parameters to this function. Any of these arguments may be | | 4061 | +** and subsequent parameters to this function. Any of these arguments may be |
4061 | +** NULL, in which case the corresponding element of metadata is omitted. | | 4062 | +** NULL, in which case the corresponding element of metadata is omitted. |
4062 | +** | | 4063 | +** |
4063 | +** <blockquote> | | 4064 | +** <blockquote> |
4064 | +** <table border="1"> | | 4065 | +** <table border="1"> |
4065 | +** <tr><th> Parameter <th> Output<br>Type <th> Description | | 4066 | +** <tr><th> Parameter <th> Output<br>Type <th> Description |
4066 | +** | | 4067 | +** |
4067 | +** <tr><td> 5th <td> const char* <td> Data type | | 4068 | +** <tr><td> 5th <td> const char* <td> Data type |
4068 | +** <tr><td> 6th <td> const char* <td> Name of default collation sequence | | 4069 | +** <tr><td> 6th <td> const char* <td> Name of default collation sequence |
4069 | +** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint | | 4070 | +** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint |
4070 | +** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY | | 4071 | +** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY |
4071 | +** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT] | | 4072 | +** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT] |
4072 | +** </table> | | 4073 | +** </table> |
4073 | +** </blockquote> | | 4074 | +** </blockquote> |
4074 | +** | | 4075 | +** |
4075 | +** The memory pointed to by the character pointers returned for the | | 4076 | +** The memory pointed to by the character pointers returned for the |
4076 | +** declaration type and collation sequence is valid only until the next | | 4077 | +** declaration type and collation sequence is valid only until the next |
4077 | +** call to any SQLite API function. | | 4078 | +** call to any SQLite API function. |
4078 | +** | | 4079 | +** |
4079 | +** If the specified table is actually a view, an [error code] is returned. | | 4080 | +** If the specified table is actually a view, an [error code] is returned. |
4080 | +** | | 4081 | +** |
4081 | +** If the specified column is "rowid", "oid" or "_rowid_" and an | | 4082 | +** If the specified column is "rowid", "oid" or "_rowid_" and an |
4082 | +** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output | | 4083 | +** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output |
4083 | +** parameters are set for the explicitly declared column. If there is no | | 4084 | +** parameters are set for the explicitly declared column. If there is no |
4084 | +** explicitly declared [INTEGER PRIMARY KEY] column, then the output | | 4085 | +** explicitly declared [INTEGER PRIMARY KEY] column, then the output |
4085 | +** parameters are set as follows: | | 4086 | +** parameters are set as follows: |
4086 | +** | | 4087 | +** |
4087 | +** <pre> | | 4088 | +** <pre> |
4088 | +** data type: "INTEGER" | | 4089 | +** data type: "INTEGER" |
4089 | +** collation sequence: "BINARY" | | 4090 | +** collation sequence: "BINARY" |
4090 | +** not null: 0 | | 4091 | +** not null: 0 |
4091 | +** primary key: 1 | | 4092 | +** primary key: 1 |
4092 | +** auto increment: 0 | | 4093 | +** auto increment: 0 |
4093 | +** </pre> | | 4094 | +** </pre> |
4094 | +** | | 4095 | +** |
4095 | +** This function may load one or more schemas from database files. If an | | 4096 | +** This function may load one or more schemas from database files. If an |
4096 | +** error occurs during this process, or if the requested table or column | | 4097 | +** error occurs during this process, or if the requested table or column |
4097 | +** cannot be found, an [error code] is returned and an error message left | | 4098 | +** cannot be found, an [error code] is returned and an error message left |
4098 | +** in the [database connection] (to be retrieved using sqlite3_errmsg()). | | 4099 | +** in the [database connection] (to be retrieved using sqlite3_errmsg()). |
4099 | +** | | 4100 | +** |
4100 | +** This API is only available if the library was compiled with the | | 4101 | +** This API is only available if the library was compiled with the |
4101 | +** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. | | 4102 | +** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. |
4102 | +*/ | | 4103 | +*/ |
4103 | +SQLITE_API int sqlite3_table_column_metadata( | | 4104 | +SQLITE_API int sqlite3_table_column_metadata( |
4104 | + sqlite3 *db, /* Connection handle */ | | 4105 | + sqlite3 *db, /* Connection handle */ |
4105 | + const char *zDbName, /* Database name or NULL */ | | 4106 | + const char *zDbName, /* Database name or NULL */ |
4106 | + const char *zTableName, /* Table name */ | | 4107 | + const char *zTableName, /* Table name */ |
4107 | + const char *zColumnName, /* Column name */ | | 4108 | + const char *zColumnName, /* Column name */ |
4108 | + char const **pzDataType, /* OUTPUT: Declared data type */ | | 4109 | + char const **pzDataType, /* OUTPUT: Declared data type */ |
4109 | + char const **pzCollSeq, /* OUTPUT: Collation sequence name */ | | 4110 | + char const **pzCollSeq, /* OUTPUT: Collation sequence name */ |
4110 | + int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ | | 4111 | + int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ |
4111 | + int *pPrimaryKey, /* OUTPUT: True if column part of PK */ | | 4112 | + int *pPrimaryKey, /* OUTPUT: True if column part of PK */ |
4112 | + int *pAutoinc /* OUTPUT: True if column is auto-increment */ | | 4113 | + int *pAutoinc /* OUTPUT: True if column is auto-increment */ |
4113 | +); | | 4114 | +); |
4114 | + | | 4115 | + |
4115 | +/* | | 4116 | +/* |
4116 | +** CAPI3REF: Load An Extension {H12600} <S20500> | | 4117 | +** CAPI3REF: Load An Extension {H12600} <S20500> |
4117 | +** | | 4118 | +** |
4118 | +** This interface loads an SQLite extension library from the named file. | | 4119 | +** This interface loads an SQLite extension library from the named file. |
4119 | +** | | 4120 | +** |
4120 | +** {H12601} The sqlite3_load_extension() interface attempts to load an | | 4121 | +** {H12601} The sqlite3_load_extension() interface attempts to load an |
4121 | +** SQLite extension library contained in the file zFile. | | 4122 | +** SQLite extension library contained in the file zFile. |
4122 | +** | | 4123 | +** |
4123 | +** {H12602} The entry point is zProc. | | 4124 | +** {H12602} The entry point is zProc. |
4124 | +** | | 4125 | +** |
4125 | +** {H12603} zProc may be 0, in which case the name of the entry point | | 4126 | +** {H12603} zProc may be 0, in which case the name of the entry point |
4126 | +** defaults to "sqlite3_extension_init". | | 4127 | +** defaults to "sqlite3_extension_init". |
4127 | +** | | 4128 | +** |
4128 | +** {H12604} The sqlite3_load_extension() interface shall return | | 4129 | +** {H12604} The sqlite3_load_extension() interface shall return |
4129 | +** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. | | 4130 | +** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. |
4130 | +** | | 4131 | +** |
4131 | +** {H12605} If an error occurs and pzErrMsg is not 0, then the | | 4132 | +** {H12605} If an error occurs and pzErrMsg is not 0, then the |
4132 | +** [sqlite3_load_extension()] interface shall attempt to | | 4133 | +** [sqlite3_load_extension()] interface shall attempt to |
4133 | +** fill *pzErrMsg with error message text stored in memory | | 4134 | +** fill *pzErrMsg with error message text stored in memory |
4134 | +** obtained from [sqlite3_malloc()]. {END} The calling function | | 4135 | +** obtained from [sqlite3_malloc()]. {END} The calling function |
4135 | +** should free this memory by calling [sqlite3_free()]. | | 4136 | +** should free this memory by calling [sqlite3_free()]. |
4136 | +** | | 4137 | +** |
4137 | +** {H12606} Extension loading must be enabled using | | 4138 | +** {H12606} Extension loading must be enabled using |
4138 | +** [sqlite3_enable_load_extension()] prior to calling this API, | | 4139 | +** [sqlite3_enable_load_extension()] prior to calling this API, |
4139 | +** otherwise an error will be returned. | | 4140 | +** otherwise an error will be returned. |
4140 | +*/ | | 4141 | +*/ |
4141 | +SQLITE_API int sqlite3_load_extension( | | 4142 | +SQLITE_API int sqlite3_load_extension( |
4142 | + sqlite3 *db, /* Load the extension into this database connection */ | | 4143 | + sqlite3 *db, /* Load the extension into this database connection */ |
4143 | + const char *zFile, /* Name of the shared library containing extension */ | | 4144 | + const char *zFile, /* Name of the shared library containing extension */ |
4144 | + const char *zProc, /* Entry point. Derived from zFile if 0 */ | | 4145 | + const char *zProc, /* Entry point. Derived from zFile if 0 */ |
4145 | + char **pzErrMsg /* Put error message here if not 0 */ | | 4146 | + char **pzErrMsg /* Put error message here if not 0 */ |
4146 | +); | | 4147 | +); |
4147 | + | | 4148 | + |
4148 | +/* | | 4149 | +/* |
4149 | +** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500> | | 4150 | +** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500> |
4150 | +** | | 4151 | +** |
4151 | +** So as not to open security holes in older applications that are | | 4152 | +** So as not to open security holes in older applications that are |
4152 | +** unprepared to deal with extension loading, and as a means of disabling | | 4153 | +** unprepared to deal with extension loading, and as a means of disabling |
4153 | +** extension loading while evaluating user-entered SQL, the following API | | 4154 | +** extension loading while evaluating user-entered SQL, the following API |
4154 | +** is provided to turn the [sqlite3_load_extension()] mechanism on and off. | | 4155 | +** is provided to turn the [sqlite3_load_extension()] mechanism on and off. |
4155 | +** | | 4156 | +** |
4156 | +** Extension loading is off by default. See ticket #1863. | | 4157 | +** Extension loading is off by default. See ticket #1863. |
4157 | +** | | 4158 | +** |
4158 | +** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1 | | 4159 | +** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1 |
4159 | +** to turn extension loading on and call it with onoff==0 to turn | | 4160 | +** to turn extension loading on and call it with onoff==0 to turn |
4160 | +** it back off again. | | 4161 | +** it back off again. |
4161 | +** | | 4162 | +** |
4162 | +** {H12622} Extension loading is off by default. | | 4163 | +** {H12622} Extension loading is off by default. |
4163 | +*/ | | 4164 | +*/ |
4164 | +SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); | | 4165 | +SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
4165 | + | | 4166 | + |
4166 | +/* | | 4167 | +/* |
4167 | +** CAPI3REF: Automatically Load An Extensions {H12640} <S20500> | | 4168 | +** CAPI3REF: Automatically Load An Extensions {H12640} <S20500> |
4168 | +** | | 4169 | +** |
4169 | +** This API can be invoked at program startup in order to register | | 4170 | +** This API can be invoked at program startup in order to register |
4170 | +** one or more statically linked extensions that will be available | | 4171 | +** one or more statically linked extensions that will be available |
4171 | +** to all new [database connections]. {END} | | 4172 | +** to all new [database connections]. {END} |
4172 | +** | | 4173 | +** |
4173 | +** This routine stores a pointer to the extension in an array that is | | 4174 | +** This routine stores a pointer to the extension in an array that is |
4174 | +** obtained from [sqlite3_malloc()]. If you run a memory leak checker | | 4175 | +** obtained from [sqlite3_malloc()]. If you run a memory leak checker |
4175 | +** on your program and it reports a leak because of this array, invoke | | 4176 | +** on your program and it reports a leak because of this array, invoke |
4176 | +** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory. | | 4177 | +** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory. |
4177 | +** | | 4178 | +** |
4178 | +** {H12641} This function registers an extension entry point that is | | 4179 | +** {H12641} This function registers an extension entry point that is |
4179 | +** automatically invoked whenever a new [database connection] | | 4180 | +** automatically invoked whenever a new [database connection] |
4180 | +** is opened using [sqlite3_open()], [sqlite3_open16()], | | 4181 | +** is opened using [sqlite3_open()], [sqlite3_open16()], |
4181 | +** or [sqlite3_open_v2()]. | | 4182 | +** or [sqlite3_open_v2()]. |
4182 | +** | | 4183 | +** |
4183 | +** {H12642} Duplicate extensions are detected so calling this routine | | 4184 | +** {H12642} Duplicate extensions are detected so calling this routine |
4184 | +** multiple times with the same extension is harmless. | | 4185 | +** multiple times with the same extension is harmless. |
4185 | +** | | 4186 | +** |
4186 | +** {H12643} This routine stores a pointer to the extension in an array | | 4187 | +** {H12643} This routine stores a pointer to the extension in an array |
4187 | +** that is obtained from [sqlite3_malloc()]. | | 4188 | +** that is obtained from [sqlite3_malloc()]. |
4188 | +** | | 4189 | +** |
4189 | +** {H12644} Automatic extensions apply across all threads. | | 4190 | +** {H12644} Automatic extensions apply across all threads. |
4190 | +*/ | | 4191 | +*/ |
4191 | +SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); | | 4192 | +SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); |
4192 | + | | 4193 | + |
4193 | +/* | | 4194 | +/* |
4194 | +** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500> | | 4195 | +** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500> |
4195 | +** | | 4196 | +** |
4196 | +** This function disables all previously registered automatic | | 4197 | +** This function disables all previously registered automatic |
4197 | +** extensions. {END} It undoes the effect of all prior | | 4198 | +** extensions. {END} It undoes the effect of all prior |
4198 | +** [sqlite3_auto_extension()] calls. | | 4199 | +** [sqlite3_auto_extension()] calls. |
4199 | +** | | 4200 | +** |
4200 | +** {H12661} This function disables all previously registered | | 4201 | +** {H12661} This function disables all previously registered |
4201 | +** automatic extensions. | | 4202 | +** automatic extensions. |
4202 | +** | | 4203 | +** |
4203 | +** {H12662} This function disables automatic extensions in all threads. | | 4204 | +** {H12662} This function disables automatic extensions in all threads. |
4204 | +*/ | | 4205 | +*/ |
4205 | +SQLITE_API void sqlite3_reset_auto_extension(void); | | 4206 | +SQLITE_API void sqlite3_reset_auto_extension(void); |
4206 | + | | 4207 | + |
4207 | +/* | | 4208 | +/* |
4208 | +****** EXPERIMENTAL - subject to change without notice ************** | | 4209 | +****** EXPERIMENTAL - subject to change without notice ************** |
4209 | +** | | 4210 | +** |
4210 | +** The interface to the virtual-table mechanism is currently considered | | 4211 | +** The interface to the virtual-table mechanism is currently considered |
4211 | +** to be experimental. The interface might change in incompatible ways. | | 4212 | +** to be experimental. The interface might change in incompatible ways. |
4212 | +** If this is a problem for you, do not use the interface at this time. | | 4213 | +** If this is a problem for you, do not use the interface at this time. |
4213 | +** | | 4214 | +** |
4214 | +** When the virtual-table mechanism stabilizes, we will declare the | | 4215 | +** When the virtual-table mechanism stabilizes, we will declare the |
4215 | +** interface fixed, support it indefinitely, and remove this comment. | | 4216 | +** interface fixed, support it indefinitely, and remove this comment. |
4216 | +*/ | | 4217 | +*/ |
4217 | + | | 4218 | + |
4218 | +/* | | 4219 | +/* |
4219 | +** Structures used by the virtual table interface | | 4220 | +** Structures used by the virtual table interface |
4220 | +*/ | | 4221 | +*/ |
4221 | +typedef struct sqlite3_vtab sqlite3_vtab; | | 4222 | +typedef struct sqlite3_vtab sqlite3_vtab; |
4222 | +typedef struct sqlite3_index_info sqlite3_index_info; | | 4223 | +typedef struct sqlite3_index_info sqlite3_index_info; |
4223 | +typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; | | 4224 | +typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; |
4224 | +typedef struct sqlite3_module sqlite3_module; | | 4225 | +typedef struct sqlite3_module sqlite3_module; |
4225 | + | | 4226 | + |
4226 | +/* | | 4227 | +/* |
4227 | +** CAPI3REF: Virtual Table Object {H18000} <S20400> | | 4228 | +** CAPI3REF: Virtual Table Object {H18000} <S20400> |
4228 | +** KEYWORDS: sqlite3_module {virtual table module} | | 4229 | +** KEYWORDS: sqlite3_module {virtual table module} |
4229 | +** EXPERIMENTAL | | 4230 | +** EXPERIMENTAL |
4230 | +** | | 4231 | +** |
4231 | +** This structure, sometimes called a a "virtual table module", | | 4232 | +** This structure, sometimes called a a "virtual table module", |
4232 | +** defines the implementation of a [virtual tables]. | | 4233 | +** defines the implementation of a [virtual tables]. |
4233 | +** This structure consists mostly of methods for the module. | | 4234 | +** This structure consists mostly of methods for the module. |
4234 | +** | | 4235 | +** |
4235 | +** A virtual table module is created by filling in a persistent | | 4236 | +** A virtual table module is created by filling in a persistent |
4236 | +** instance of this structure and passing a pointer to that instance | | 4237 | +** instance of this structure and passing a pointer to that instance |
4237 | +** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. | | 4238 | +** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. |
4238 | +** The registration remains valid until it is replaced by a different | | 4239 | +** The registration remains valid until it is replaced by a different |
4239 | +** module or until the [database connection] closes. The content | | 4240 | +** module or until the [database connection] closes. The content |
4240 | +** of this structure must not change while it is registered with | | 4241 | +** of this structure must not change while it is registered with |
4241 | +** any database connection. | | 4242 | +** any database connection. |
4242 | +*/ | | 4243 | +*/ |
4243 | +struct sqlite3_module { | | 4244 | +struct sqlite3_module { |
4244 | + int iVersion; | | 4245 | + int iVersion; |
4245 | + int (*xCreate)(sqlite3*, void *pAux, | | 4246 | + int (*xCreate)(sqlite3*, void *pAux, |
4246 | + int argc, const char *const*argv, | | 4247 | + int argc, const char *const*argv, |
4247 | + sqlite3_vtab **ppVTab, char**); | | 4248 | + sqlite3_vtab **ppVTab, char**); |
4248 | + int (*xConnect)(sqlite3*, void *pAux, | | 4249 | + int (*xConnect)(sqlite3*, void *pAux, |
4249 | + int argc, const char *const*argv, | | 4250 | + int argc, const char *const*argv, |
4250 | + sqlite3_vtab **ppVTab, char**); | | 4251 | + sqlite3_vtab **ppVTab, char**); |
4251 | + int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); | | 4252 | + int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); |
4252 | + int (*xDisconnect)(sqlite3_vtab *pVTab); | | 4253 | + int (*xDisconnect)(sqlite3_vtab *pVTab); |
4253 | + int (*xDestroy)(sqlite3_vtab *pVTab); | | 4254 | + int (*xDestroy)(sqlite3_vtab *pVTab); |
4254 | + int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); | | 4255 | + int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); |
4255 | + int (*xClose)(sqlite3_vtab_cursor*); | | 4256 | + int (*xClose)(sqlite3_vtab_cursor*); |
4256 | + int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, | | 4257 | + int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, |
4257 | + int argc, sqlite3_value **argv); | | 4258 | + int argc, sqlite3_value **argv); |
4258 | + int (*xNext)(sqlite3_vtab_cursor*); | | 4259 | + int (*xNext)(sqlite3_vtab_cursor*); |
4259 | + int (*xEof)(sqlite3_vtab_cursor*); | | 4260 | + int (*xEof)(sqlite3_vtab_cursor*); |
4260 | + int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); | | 4261 | + int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); |
4261 | + int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); | | 4262 | + int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); |
4262 | + int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); | | 4263 | + int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); |
4263 | + int (*xBegin)(sqlite3_vtab *pVTab); | | 4264 | + int (*xBegin)(sqlite3_vtab *pVTab); |
4264 | + int (*xSync)(sqlite3_vtab *pVTab); | | 4265 | + int (*xSync)(sqlite3_vtab *pVTab); |
4265 | + int (*xCommit)(sqlite3_vtab *pVTab); | | 4266 | + int (*xCommit)(sqlite3_vtab *pVTab); |
4266 | + int (*xRollback)(sqlite3_vtab *pVTab); | | 4267 | + int (*xRollback)(sqlite3_vtab *pVTab); |
4267 | + int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, | | 4268 | + int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, |
4268 | + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), | | 4269 | + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), |
4269 | + void **ppArg); | | 4270 | + void **ppArg); |
4270 | + int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); | | 4271 | + int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); |
4271 | +}; | | 4272 | +}; |
4272 | + | | 4273 | + |
4273 | +/* | | 4274 | +/* |
4274 | +** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400> | | 4275 | +** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400> |
4275 | +** KEYWORDS: sqlite3_index_info | | 4276 | +** KEYWORDS: sqlite3_index_info |
4276 | +** EXPERIMENTAL | | 4277 | +** EXPERIMENTAL |
4277 | +** | | 4278 | +** |
4278 | +** The sqlite3_index_info structure and its substructures is used to | | 4279 | +** The sqlite3_index_info structure and its substructures is used to |
4279 | +** pass information into and receive the reply from the [xBestIndex] | | 4280 | +** pass information into and receive the reply from the [xBestIndex] |
4280 | +** method of a [virtual table module]. The fields under **Inputs** are the | | 4281 | +** method of a [virtual table module]. The fields under **Inputs** are the |
4281 | +** inputs to xBestIndex and are read-only. xBestIndex inserts its | | 4282 | +** inputs to xBestIndex and are read-only. xBestIndex inserts its |
4282 | +** results into the **Outputs** fields. | | 4283 | +** results into the **Outputs** fields. |
4283 | +** | | 4284 | +** |
4284 | +** The aConstraint[] array records WHERE clause constraints of the form: | | 4285 | +** The aConstraint[] array records WHERE clause constraints of the form: |
4285 | +** | | 4286 | +** |
4286 | +** <pre>column OP expr</pre> | | 4287 | +** <pre>column OP expr</pre> |
4287 | +** | | 4288 | +** |
4288 | +** where OP is =, <, <=, >, or >=. The particular operator is | | 4289 | +** where OP is =, <, <=, >, or >=. The particular operator is |
4289 | +** stored in aConstraint[].op. The index of the column is stored in | | 4290 | +** stored in aConstraint[].op. The index of the column is stored in |
4290 | +** aConstraint[].iColumn. aConstraint[].usable is TRUE if the | | 4291 | +** aConstraint[].iColumn. aConstraint[].usable is TRUE if the |
4291 | +** expr on the right-hand side can be evaluated (and thus the constraint | | 4292 | +** expr on the right-hand side can be evaluated (and thus the constraint |
4292 | +** is usable) and false if it cannot. | | 4293 | +** is usable) and false if it cannot. |
4293 | +** | | 4294 | +** |
4294 | +** The optimizer automatically inverts terms of the form "expr OP column" | | 4295 | +** The optimizer automatically inverts terms of the form "expr OP column" |
4295 | +** and makes other simplifications to the WHERE clause in an attempt to | | 4296 | +** and makes other simplifications to the WHERE clause in an attempt to |
4296 | +** get as many WHERE clause terms into the form shown above as possible. | | 4297 | +** get as many WHERE clause terms into the form shown above as possible. |
4297 | +** The aConstraint[] array only reports WHERE clause terms in the correct | | 4298 | +** The aConstraint[] array only reports WHERE clause terms in the correct |
4298 | +** form that refer to the particular virtual table being queried. | | 4299 | +** form that refer to the particular virtual table being queried. |
4299 | +** | | 4300 | +** |
4300 | +** Information about the ORDER BY clause is stored in aOrderBy[]. | | 4301 | +** Information about the ORDER BY clause is stored in aOrderBy[]. |
4301 | +** Each term of aOrderBy records a column of the ORDER BY clause. | | 4302 | +** Each term of aOrderBy records a column of the ORDER BY clause. |
4302 | +** | | 4303 | +** |
4303 | +** The [xBestIndex] method must fill aConstraintUsage[] with information | | 4304 | +** The [xBestIndex] method must fill aConstraintUsage[] with information |
4304 | +** about what parameters to pass to xFilter. If argvIndex>0 then | | 4305 | +** about what parameters to pass to xFilter. If argvIndex>0 then |
4305 | +** the right-hand side of the corresponding aConstraint[] is evaluated | | 4306 | +** the right-hand side of the corresponding aConstraint[] is evaluated |
4306 | +** and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit | | 4307 | +** and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit |
4307 | +** is true, then the constraint is assumed to be fully handled by the | | 4308 | +** is true, then the constraint is assumed to be fully handled by the |
4308 | +** virtual table and is not checked again by SQLite. | | 4309 | +** virtual table and is not checked again by SQLite. |
4309 | +** | | 4310 | +** |
4310 | +** The idxNum and idxPtr values are recorded and passed into the | | 4311 | +** The idxNum and idxPtr values are recorded and passed into the |
4311 | +** [xFilter] method. | | 4312 | +** [xFilter] method. |
4312 | +** [sqlite3_free()] is used to free idxPtr if and only iff | | 4313 | +** [sqlite3_free()] is used to free idxPtr if and only iff |
4313 | +** needToFreeIdxPtr is true. | | 4314 | +** needToFreeIdxPtr is true. |
4314 | +** | | 4315 | +** |
4315 | +** The orderByConsumed means that output from [xFilter]/[xNext] will occur in | | 4316 | +** The orderByConsumed means that output from [xFilter]/[xNext] will occur in |
4316 | +** the correct order to satisfy the ORDER BY clause so that no separate | | 4317 | +** the correct order to satisfy the ORDER BY clause so that no separate |
4317 | +** sorting step is required. | | 4318 | +** sorting step is required. |
4318 | +** | | 4319 | +** |
4319 | +** The estimatedCost value is an estimate of the cost of doing the | | 4320 | +** The estimatedCost value is an estimate of the cost of doing the |
4320 | +** particular lookup. A full scan of a table with N entries should have | | 4321 | +** particular lookup. A full scan of a table with N entries should have |
4321 | +** a cost of N. A binary search of a table of N entries should have a | | 4322 | +** a cost of N. A binary search of a table of N entries should have a |
4322 | +** cost of approximately log(N). | | 4323 | +** cost of approximately log(N). |
4323 | +*/ | | 4324 | +*/ |
4324 | +struct sqlite3_index_info { | | 4325 | +struct sqlite3_index_info { |
4325 | + /* Inputs */ | | 4326 | + /* Inputs */ |
4326 | + int nConstraint; /* Number of entries in aConstraint */ | | 4327 | + int nConstraint; /* Number of entries in aConstraint */ |
4327 | + struct sqlite3_index_constraint { | | 4328 | + struct sqlite3_index_constraint { |
4328 | + int iColumn; /* Column on left-hand side of constraint */ | | 4329 | + int iColumn; /* Column on left-hand side of constraint */ |
4329 | + unsigned char op; /* Constraint operator */ | | 4330 | + unsigned char op; /* Constraint operator */ |
4330 | + unsigned char usable; /* True if this constraint is usable */ | | 4331 | + unsigned char usable; /* True if this constraint is usable */ |
4331 | + int iTermOffset; /* Used internally - xBestIndex should ignore */ | | 4332 | + int iTermOffset; /* Used internally - xBestIndex should ignore */ |
4332 | + } *aConstraint; /* Table of WHERE clause constraints */ | | 4333 | + } *aConstraint; /* Table of WHERE clause constraints */ |
4333 | + int nOrderBy; /* Number of terms in the ORDER BY clause */ | | 4334 | + int nOrderBy; /* Number of terms in the ORDER BY clause */ |
4334 | + struct sqlite3_index_orderby { | | 4335 | + struct sqlite3_index_orderby { |
4335 | + int iColumn; /* Column number */ | | 4336 | + int iColumn; /* Column number */ |
4336 | + unsigned char desc; /* True for DESC. False for ASC. */ | | 4337 | + unsigned char desc; /* True for DESC. False for ASC. */ |
4337 | + } *aOrderBy; /* The ORDER BY clause */ | | 4338 | + } *aOrderBy; /* The ORDER BY clause */ |
4338 | + /* Outputs */ | | 4339 | + /* Outputs */ |
4339 | + struct sqlite3_index_constraint_usage { | | 4340 | + struct sqlite3_index_constraint_usage { |
4340 | + int argvIndex; /* if >0, constraint is part of argv to xFilter */ | | 4341 | + int argvIndex; /* if >0, constraint is part of argv to xFilter */ |
4341 | + unsigned char omit; /* Do not code a test for this constraint */ | | 4342 | + unsigned char omit; /* Do not code a test for this constraint */ |
4342 | + } *aConstraintUsage; | | 4343 | + } *aConstraintUsage; |
4343 | + int idxNum; /* Number used to identify the index */ | | 4344 | + int idxNum; /* Number used to identify the index */ |
4344 | + char *idxStr; /* String, possibly obtained from sqlite3_malloc */ | | 4345 | + char *idxStr; /* String, possibly obtained from sqlite3_malloc */ |
4345 | + int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ | | 4346 | + int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ |
4346 | + int orderByConsumed; /* True if output is already ordered */ | | 4347 | + int orderByConsumed; /* True if output is already ordered */ |
4347 | + double estimatedCost; /* Estimated cost of using this index */ | | 4348 | + double estimatedCost; /* Estimated cost of using this index */ |
4348 | +}; | | 4349 | +}; |
4349 | +#define SQLITE_INDEX_CONSTRAINT_EQ 2 | | 4350 | +#define SQLITE_INDEX_CONSTRAINT_EQ 2 |
4350 | +#define SQLITE_INDEX_CONSTRAINT_GT 4 | | 4351 | +#define SQLITE_INDEX_CONSTRAINT_GT 4 |
4351 | +#define SQLITE_INDEX_CONSTRAINT_LE 8 | | 4352 | +#define SQLITE_INDEX_CONSTRAINT_LE 8 |
4352 | +#define SQLITE_INDEX_CONSTRAINT_LT 16 | | 4353 | +#define SQLITE_INDEX_CONSTRAINT_LT 16 |
4353 | +#define SQLITE_INDEX_CONSTRAINT_GE 32 | | 4354 | +#define SQLITE_INDEX_CONSTRAINT_GE 32 |
4354 | +#define SQLITE_INDEX_CONSTRAINT_MATCH 64 | | 4355 | +#define SQLITE_INDEX_CONSTRAINT_MATCH 64 |
4355 | + | | 4356 | + |
4356 | +/* | | 4357 | +/* |
4357 | +** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400> | | 4358 | +** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400> |
4358 | +** EXPERIMENTAL | | 4359 | +** EXPERIMENTAL |
4359 | +** | | 4360 | +** |
4360 | +** This routine is used to register a new [virtual table module] name. | | 4361 | +** This routine is used to register a new [virtual table module] name. |
4361 | +** Module names must be registered before | | 4362 | +** Module names must be registered before |
4362 | +** creating a new [virtual table] using the module, or before using a | | 4363 | +** creating a new [virtual table] using the module, or before using a |
4363 | +** preexisting [virtual table] for the module. | | 4364 | +** preexisting [virtual table] for the module. |
4364 | +** | | 4365 | +** |
4365 | +** The module name is registered on the [database connection] specified | | 4366 | +** The module name is registered on the [database connection] specified |
4366 | +** by the first parameter. The name of the module is given by the | | 4367 | +** by the first parameter. The name of the module is given by the |
4367 | +** second parameter. The third parameter is a pointer to | | 4368 | +** second parameter. The third parameter is a pointer to |
4368 | +** the implementation of the [virtual table module]. The fourth | | 4369 | +** the implementation of the [virtual table module]. The fourth |
4369 | +** parameter is an arbitrary client data pointer that is passed through | | 4370 | +** parameter is an arbitrary client data pointer that is passed through |
4370 | +** into the [xCreate] and [xConnect] methods of the virtual table module | | 4371 | +** into the [xCreate] and [xConnect] methods of the virtual table module |
4371 | +** when a new virtual table is be being created or reinitialized. | | 4372 | +** when a new virtual table is be being created or reinitialized. |
4372 | +** | | 4373 | +** |
4373 | +** This interface has exactly the same effect as calling | | 4374 | +** This interface has exactly the same effect as calling |
4374 | +** [sqlite3_create_module_v2()] with a NULL client data destructor. | | 4375 | +** [sqlite3_create_module_v2()] with a NULL client data destructor. |
4375 | +*/ | | 4376 | +*/ |
4376 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module( | | 4377 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module( |
4377 | + sqlite3 *db, /* SQLite connection to register module with */ | | 4378 | + sqlite3 *db, /* SQLite connection to register module with */ |
4378 | + const char *zName, /* Name of the module */ | | 4379 | + const char *zName, /* Name of the module */ |
4379 | + const sqlite3_module *p, /* Methods for the module */ | | 4380 | + const sqlite3_module *p, /* Methods for the module */ |
4380 | + void *pClientData /* Client data for xCreate/xConnect */ | | 4381 | + void *pClientData /* Client data for xCreate/xConnect */ |
4381 | +); | | 4382 | +); |
4382 | + | | 4383 | + |
4383 | +/* | | 4384 | +/* |
4384 | +** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400> | | 4385 | +** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400> |
4385 | +** EXPERIMENTAL | | 4386 | +** EXPERIMENTAL |
4386 | +** | | 4387 | +** |
4387 | +** This routine is identical to the [sqlite3_create_module()] method, | | 4388 | +** This routine is identical to the [sqlite3_create_module()] method, |
4388 | +** except that it has an extra parameter to specify | | 4389 | +** except that it has an extra parameter to specify |
4389 | +** a destructor function for the client data pointer. SQLite will | | 4390 | +** a destructor function for the client data pointer. SQLite will |
4390 | +** invoke the destructor function (if it is not NULL) when SQLite | | 4391 | +** invoke the destructor function (if it is not NULL) when SQLite |
4391 | +** no longer needs the pClientData pointer. | | 4392 | +** no longer needs the pClientData pointer. |
4392 | +*/ | | 4393 | +*/ |
4393 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2( | | 4394 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2( |
4394 | + sqlite3 *db, /* SQLite connection to register module with */ | | 4395 | + sqlite3 *db, /* SQLite connection to register module with */ |
4395 | + const char *zName, /* Name of the module */ | | 4396 | + const char *zName, /* Name of the module */ |
4396 | + const sqlite3_module *p, /* Methods for the module */ | | 4397 | + const sqlite3_module *p, /* Methods for the module */ |
4397 | + void *pClientData, /* Client data for xCreate/xConnect */ | | 4398 | + void *pClientData, /* Client data for xCreate/xConnect */ |
4398 | + void(*xDestroy)(void*) /* Module destructor function */ | | 4399 | + void(*xDestroy)(void*) /* Module destructor function */ |
4399 | +); | | 4400 | +); |
4400 | + | | 4401 | + |
4401 | +/* | | 4402 | +/* |
4402 | +** CAPI3REF: Virtual Table Instance Object {H18010} <S20400> | | 4403 | +** CAPI3REF: Virtual Table Instance Object {H18010} <S20400> |
4403 | +** KEYWORDS: sqlite3_vtab | | 4404 | +** KEYWORDS: sqlite3_vtab |
4404 | +** EXPERIMENTAL | | 4405 | +** EXPERIMENTAL |
4405 | +** | | 4406 | +** |
4406 | +** Every [virtual table module] implementation uses a subclass | | 4407 | +** Every [virtual table module] implementation uses a subclass |
4407 | +** of the following structure to describe a particular instance | | 4408 | +** of the following structure to describe a particular instance |
4408 | +** of the [virtual table]. Each subclass will | | 4409 | +** of the [virtual table]. Each subclass will |
4409 | +** be tailored to the specific needs of the module implementation. | | 4410 | +** be tailored to the specific needs of the module implementation. |
4410 | +** The purpose of this superclass is to define certain fields that are | | 4411 | +** The purpose of this superclass is to define certain fields that are |
4411 | +** common to all module implementations. | | 4412 | +** common to all module implementations. |
4412 | +** | | 4413 | +** |
4413 | +** Virtual tables methods can set an error message by assigning a | | 4414 | +** Virtual tables methods can set an error message by assigning a |
4414 | +** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should | | 4415 | +** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should |
4415 | +** take care that any prior string is freed by a call to [sqlite3_free()] | | 4416 | +** take care that any prior string is freed by a call to [sqlite3_free()] |
4416 | +** prior to assigning a new string to zErrMsg. After the error message | | 4417 | +** prior to assigning a new string to zErrMsg. After the error message |
4417 | +** is delivered up to the client application, the string will be automatically | | 4418 | +** is delivered up to the client application, the string will be automatically |
4418 | +** freed by sqlite3_free() and the zErrMsg field will be zeroed. | | 4419 | +** freed by sqlite3_free() and the zErrMsg field will be zeroed. |
4419 | +*/ | | 4420 | +*/ |
4420 | +struct sqlite3_vtab { | | 4421 | +struct sqlite3_vtab { |
4421 | + const sqlite3_module *pModule; /* The module for this virtual table */ | | 4422 | + const sqlite3_module *pModule; /* The module for this virtual table */ |
4422 | + int nRef; /* NO LONGER USED */ | | 4423 | + int nRef; /* NO LONGER USED */ |
4423 | + char *zErrMsg; /* Error message from sqlite3_mprintf() */ | | 4424 | + char *zErrMsg; /* Error message from sqlite3_mprintf() */ |
4424 | + /* Virtual table implementations will typically add additional fields */ | | 4425 | + /* Virtual table implementations will typically add additional fields */ |
4425 | +}; | | 4426 | +}; |
4426 | + | | 4427 | + |
4427 | +/* | | 4428 | +/* |
4428 | +** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400> | | 4429 | +** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400> |
4429 | +** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} | | 4430 | +** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} |
4430 | +** EXPERIMENTAL | | 4431 | +** EXPERIMENTAL |
4431 | +** | | 4432 | +** |
4432 | +** Every [virtual table module] implementation uses a subclass of the | | 4433 | +** Every [virtual table module] implementation uses a subclass of the |
4433 | +** following structure to describe cursors that point into the | | 4434 | +** following structure to describe cursors that point into the |
4434 | +** [virtual table] and are used | | 4435 | +** [virtual table] and are used |
4435 | +** to loop through the virtual table. Cursors are created using the | | 4436 | +** to loop through the virtual table. Cursors are created using the |
4436 | +** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed | | 4437 | +** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed |
4437 | +** by the [sqlite3_module.xClose | xClose] method. Cussors are used | | 4438 | +** by the [sqlite3_module.xClose | xClose] method. Cussors are used |
4438 | +** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods | | 4439 | +** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods |
4439 | +** of the module. Each module implementation will define | | 4440 | +** of the module. Each module implementation will define |
4440 | +** the content of a cursor structure to suit its own needs. | | 4441 | +** the content of a cursor structure to suit its own needs. |
4441 | +** | | 4442 | +** |
4442 | +** This superclass exists in order to define fields of the cursor that | | 4443 | +** This superclass exists in order to define fields of the cursor that |
4443 | +** are common to all implementations. | | 4444 | +** are common to all implementations. |
4444 | +*/ | | 4445 | +*/ |
4445 | +struct sqlite3_vtab_cursor { | | 4446 | +struct sqlite3_vtab_cursor { |
4446 | + sqlite3_vtab *pVtab; /* Virtual table of this cursor */ | | 4447 | + sqlite3_vtab *pVtab; /* Virtual table of this cursor */ |
4447 | + /* Virtual table implementations will typically add additional fields */ | | 4448 | + /* Virtual table implementations will typically add additional fields */ |
4448 | +}; | | 4449 | +}; |
4449 | + | | 4450 | + |
4450 | +/* | | 4451 | +/* |
4451 | +** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400> | | 4452 | +** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400> |
4452 | +** EXPERIMENTAL | | 4453 | +** EXPERIMENTAL |
4453 | +** | | 4454 | +** |
4454 | +** The [xCreate] and [xConnect] methods of a | | 4455 | +** The [xCreate] and [xConnect] methods of a |
4455 | +** [virtual table module] call this interface | | 4456 | +** [virtual table module] call this interface |
4456 | +** to declare the format (the names and datatypes of the columns) of | | 4457 | +** to declare the format (the names and datatypes of the columns) of |
4457 | +** the virtual tables they implement. | | 4458 | +** the virtual tables they implement. |
4458 | +*/ | | 4459 | +*/ |
4459 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL); | | 4460 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL); |
4460 | + | | 4461 | + |
4461 | +/* | | 4462 | +/* |
4462 | +** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400> | | 4463 | +** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400> |
4463 | +** EXPERIMENTAL | | 4464 | +** EXPERIMENTAL |
4464 | +** | | 4465 | +** |
4465 | +** Virtual tables can provide alternative implementations of functions | | 4466 | +** Virtual tables can provide alternative implementations of functions |
4466 | +** using the [xFindFunction] method of the [virtual table module]. | | 4467 | +** using the [xFindFunction] method of the [virtual table module]. |
4467 | +** But global versions of those functions | | 4468 | +** But global versions of those functions |
4468 | +** must exist in order to be overloaded. | | 4469 | +** must exist in order to be overloaded. |
4469 | +** | | 4470 | +** |
4470 | +** This API makes sure a global version of a function with a particular | | 4471 | +** This API makes sure a global version of a function with a particular |
4471 | +** name and number of parameters exists. If no such function exists | | 4472 | +** name and number of parameters exists. If no such function exists |
4472 | +** before this API is called, a new function is created. The implementation | | 4473 | +** before this API is called, a new function is created. The implementation |
4473 | +** of the new function always causes an exception to be thrown. So | | 4474 | +** of the new function always causes an exception to be thrown. So |
4474 | +** the new function is not good for anything by itself. Its only | | 4475 | +** the new function is not good for anything by itself. Its only |
4475 | +** purpose is to be a placeholder function that can be overloaded | | 4476 | +** purpose is to be a placeholder function that can be overloaded |
4476 | +** by a [virtual table]. | | 4477 | +** by a [virtual table]. |
4477 | +*/ | | 4478 | +*/ |
4478 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); | | 4479 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); |
4479 | + | | 4480 | + |
4480 | +/* | | 4481 | +/* |
4481 | +** The interface to the virtual-table mechanism defined above (back up | | 4482 | +** The interface to the virtual-table mechanism defined above (back up |
4482 | +** to a comment remarkably similar to this one) is currently considered | | 4483 | +** to a comment remarkably similar to this one) is currently considered |
4483 | +** to be experimental. The interface might change in incompatible ways. | | 4484 | +** to be experimental. The interface might change in incompatible ways. |
4484 | +** If this is a problem for you, do not use the interface at this time. | | 4485 | +** If this is a problem for you, do not use the interface at this time. |
4485 | +** | | 4486 | +** |
4486 | +** When the virtual-table mechanism stabilizes, we will declare the | | 4487 | +** When the virtual-table mechanism stabilizes, we will declare the |
4487 | +** interface fixed, support it indefinitely, and remove this comment. | | 4488 | +** interface fixed, support it indefinitely, and remove this comment. |
4488 | +** | | 4489 | +** |
4489 | +****** EXPERIMENTAL - subject to change without notice ************** | | 4490 | +****** EXPERIMENTAL - subject to change without notice ************** |
4490 | +*/ | | 4491 | +*/ |
4491 | + | | 4492 | + |
4492 | +/* | | 4493 | +/* |
4493 | +** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230> | | 4494 | +** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230> |
4494 | +** KEYWORDS: {BLOB handle} {BLOB handles} | | 4495 | +** KEYWORDS: {BLOB handle} {BLOB handles} |
4495 | +** | | 4496 | +** |
4496 | +** An instance of this object represents an open BLOB on which | | 4497 | +** An instance of this object represents an open BLOB on which |
4497 | +** [sqlite3_blob_open | incremental BLOB I/O] can be performed. | | 4498 | +** [sqlite3_blob_open | incremental BLOB I/O] can be performed. |
4498 | +** Objects of this type are created by [sqlite3_blob_open()] | | 4499 | +** Objects of this type are created by [sqlite3_blob_open()] |
4499 | +** and destroyed by [sqlite3_blob_close()]. | | 4500 | +** and destroyed by [sqlite3_blob_close()]. |
4500 | +** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces | | 4501 | +** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces |
4501 | +** can be used to read or write small subsections of the BLOB. | | 4502 | +** can be used to read or write small subsections of the BLOB. |
4502 | +** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. | | 4503 | +** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. |
4503 | +*/ | | 4504 | +*/ |
4504 | +typedef struct sqlite3_blob sqlite3_blob; | | 4505 | +typedef struct sqlite3_blob sqlite3_blob; |
4505 | + | | 4506 | + |
4506 | +/* | | 4507 | +/* |
4507 | +** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230> | | 4508 | +** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230> |
4508 | +** | | 4509 | +** |
4509 | +** This interfaces opens a [BLOB handle | handle] to the BLOB located | | 4510 | +** This interfaces opens a [BLOB handle | handle] to the BLOB located |
4510 | +** in row iRow, column zColumn, table zTable in database zDb; | | 4511 | +** in row iRow, column zColumn, table zTable in database zDb; |
4511 | +** in other words, the same BLOB that would be selected by: | | 4512 | +** in other words, the same BLOB that would be selected by: |
4512 | +** | | 4513 | +** |
4513 | +** <pre> | | 4514 | +** <pre> |
4514 | +** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow; | | 4515 | +** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow; |
4515 | +** </pre> {END} | | 4516 | +** </pre> {END} |
4516 | +** | | 4517 | +** |
4517 | +** If the flags parameter is non-zero, then the BLOB is opened for read | | 4518 | +** If the flags parameter is non-zero, then the BLOB is opened for read |
4518 | +** and write access. If it is zero, the BLOB is opened for read access. | | 4519 | +** and write access. If it is zero, the BLOB is opened for read access. |
| | | 4520 | +** It is not possible to open a column that is part of an index or primary |
| | | 4521 | +** key for writing. ^If [foreign key constraints] are enabled, it is |
| | | 4522 | +** not possible to open a column that is part of a [child key] for writing. |
4519 | +** | | 4523 | +** |
4520 | +** Note that the database name is not the filename that contains | | 4524 | +** Note that the database name is not the filename that contains |
4521 | +** the database but rather the symbolic name of the database that | | 4525 | +** the database but rather the symbolic name of the database that |
4522 | +** is assigned when the database is connected using [ATTACH]. | | 4526 | +** is assigned when the database is connected using [ATTACH]. |
4523 | +** For the main database file, the database name is "main". | | 4527 | +** For the main database file, the database name is "main". |
4524 | +** For TEMP tables, the database name is "temp". | | 4528 | +** For TEMP tables, the database name is "temp". |
4525 | +** | | 4529 | +** |
4526 | +** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written | | 4530 | +** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written |
4527 | +** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set | | 4531 | +** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set |
4528 | +** to be a null pointer. | | 4532 | +** to be a null pointer. |
4529 | +** This function sets the [database connection] error code and message | | 4533 | +** This function sets the [database connection] error code and message |
4530 | +** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related | | 4534 | +** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related |
4531 | +** functions. Note that the *ppBlob variable is always initialized in a | | 4535 | +** functions. Note that the *ppBlob variable is always initialized in a |
4532 | +** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob | | 4536 | +** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob |
4533 | +** regardless of the success or failure of this routine. | | 4537 | +** regardless of the success or failure of this routine. |
4534 | +** | | 4538 | +** |
4535 | +** If the row that a BLOB handle points to is modified by an | | 4539 | +** If the row that a BLOB handle points to is modified by an |
4536 | +** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects | | 4540 | +** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects |
4537 | +** then the BLOB handle is marked as "expired". | | 4541 | +** then the BLOB handle is marked as "expired". |
4538 | +** This is true if any column of the row is changed, even a column | | 4542 | +** This is true if any column of the row is changed, even a column |
4539 | +** other than the one the BLOB handle is open on. | | 4543 | +** other than the one the BLOB handle is open on. |
4540 | +** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for | | 4544 | +** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for |
4541 | +** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. | | 4545 | +** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. |
4542 | +** Changes written into a BLOB prior to the BLOB expiring are not | | 4546 | +** Changes written into a BLOB prior to the BLOB expiring are not |
4543 | +** rollback by the expiration of the BLOB. Such changes will eventually | | 4547 | +** rollback by the expiration of the BLOB. Such changes will eventually |
4544 | +** commit if the transaction continues to completion. | | 4548 | +** commit if the transaction continues to completion. |
4545 | +** | | 4549 | +** |
4546 | +** Use the [sqlite3_blob_bytes()] interface to determine the size of | | 4550 | +** Use the [sqlite3_blob_bytes()] interface to determine the size of |
4547 | +** the opened blob. The size of a blob may not be changed by this | | 4551 | +** the opened blob. The size of a blob may not be changed by this |
4548 | +** interface. Use the [UPDATE] SQL command to change the size of a | | 4552 | +** interface. Use the [UPDATE] SQL command to change the size of a |
4549 | +** blob. | | 4553 | +** blob. |
4550 | +** | | 4554 | +** |
4551 | +** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces | | 4555 | +** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces |
4552 | +** and the built-in [zeroblob] SQL function can be used, if desired, | | 4556 | +** and the built-in [zeroblob] SQL function can be used, if desired, |
4553 | +** to create an empty, zero-filled blob in which to read or write using | | 4557 | +** to create an empty, zero-filled blob in which to read or write using |
4554 | +** this interface. | | 4558 | +** this interface. |
4555 | +** | | 4559 | +** |
4556 | +** To avoid a resource leak, every open [BLOB handle] should eventually | | 4560 | +** To avoid a resource leak, every open [BLOB handle] should eventually |
4557 | +** be released by a call to [sqlite3_blob_close()]. | | 4561 | +** be released by a call to [sqlite3_blob_close()]. |
4558 | +** | | 4562 | +** |
4559 | +** Requirements: | | 4563 | +** Requirements: |
4560 | +** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824] | | 4564 | +** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824] |
4561 | +*/ | | 4565 | +*/ |
4562 | +SQLITE_API int sqlite3_blob_open( | | 4566 | +SQLITE_API int sqlite3_blob_open( |
4563 | + sqlite3*, | | 4567 | + sqlite3*, |
4564 | + const char *zDb, | | 4568 | + const char *zDb, |
4565 | + const char *zTable, | | 4569 | + const char *zTable, |
4566 | + const char *zColumn, | | 4570 | + const char *zColumn, |
4567 | + sqlite3_int64 iRow, | | 4571 | + sqlite3_int64 iRow, |
4568 | + int flags, | | 4572 | + int flags, |
4569 | + sqlite3_blob **ppBlob | | 4573 | + sqlite3_blob **ppBlob |
4570 | +); | | 4574 | +); |
4571 | + | | 4575 | + |
4572 | +/* | | 4576 | +/* |
4573 | +** CAPI3REF: Close A BLOB Handle {H17830} <S30230> | | 4577 | +** CAPI3REF: Close A BLOB Handle {H17830} <S30230> |
4574 | +** | | 4578 | +** |
4575 | +** Closes an open [BLOB handle]. | | 4579 | +** Closes an open [BLOB handle]. |
4576 | +** | | 4580 | +** |
4577 | +** Closing a BLOB shall cause the current transaction to commit | | 4581 | +** Closing a BLOB shall cause the current transaction to commit |
4578 | +** if there are no other BLOBs, no pending prepared statements, and the | | 4582 | +** if there are no other BLOBs, no pending prepared statements, and the |
4579 | +** database connection is in [autocommit mode]. | | 4583 | +** database connection is in [autocommit mode]. |
4580 | +** If any writes were made to the BLOB, they might be held in cache | | 4584 | +** If any writes were made to the BLOB, they might be held in cache |
4581 | +** until the close operation if they will fit. | | 4585 | +** until the close operation if they will fit. |
4582 | +** | | 4586 | +** |
4583 | +** Closing the BLOB often forces the changes | | 4587 | +** Closing the BLOB often forces the changes |
4584 | +** out to disk and so if any I/O errors occur, they will likely occur | | 4588 | +** out to disk and so if any I/O errors occur, they will likely occur |
4585 | +** at the time when the BLOB is closed. Any errors that occur during | | 4589 | +** at the time when the BLOB is closed. Any errors that occur during |
4586 | +** closing are reported as a non-zero return value. | | 4590 | +** closing are reported as a non-zero return value. |
4587 | +** | | 4591 | +** |
4588 | +** The BLOB is closed unconditionally. Even if this routine returns | | 4592 | +** The BLOB is closed unconditionally. Even if this routine returns |
4589 | +** an error code, the BLOB is still closed. | | 4593 | +** an error code, the BLOB is still closed. |
4590 | +** | | 4594 | +** |
4591 | +** Calling this routine with a null pointer (which as would be returned | | 4595 | +** Calling this routine with a null pointer (which as would be returned |
4592 | +** by failed call to [sqlite3_blob_open()]) is a harmless no-op. | | 4596 | +** by failed call to [sqlite3_blob_open()]) is a harmless no-op. |
4593 | +** | | 4597 | +** |
4594 | +** Requirements: | | 4598 | +** Requirements: |
4595 | +** [H17833] [H17836] [H17839] | | 4599 | +** [H17833] [H17836] [H17839] |
4596 | +*/ | | 4600 | +*/ |
4597 | +SQLITE_API int sqlite3_blob_close(sqlite3_blob *); | | 4601 | +SQLITE_API int sqlite3_blob_close(sqlite3_blob *); |
4598 | + | | 4602 | + |
4599 | +/* | | 4603 | +/* |
4600 | +** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230> | | 4604 | +** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230> |
4601 | +** | | 4605 | +** |
4602 | +** Returns the size in bytes of the BLOB accessible via the | | 4606 | +** Returns the size in bytes of the BLOB accessible via the |
4603 | +** successfully opened [BLOB handle] in its only argument. The | | 4607 | +** successfully opened [BLOB handle] in its only argument. The |
4604 | +** incremental blob I/O routines can only read or overwriting existing | | 4608 | +** incremental blob I/O routines can only read or overwriting existing |
4605 | +** blob content; they cannot change the size of a blob. | | 4609 | +** blob content; they cannot change the size of a blob. |
4606 | +** | | 4610 | +** |
4607 | +** This routine only works on a [BLOB handle] which has been created | | 4611 | +** This routine only works on a [BLOB handle] which has been created |
4608 | +** by a prior successful call to [sqlite3_blob_open()] and which has not | | 4612 | +** by a prior successful call to [sqlite3_blob_open()] and which has not |
4609 | +** been closed by [sqlite3_blob_close()]. Passing any other pointer in | | 4613 | +** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
4610 | +** to this routine results in undefined and probably undesirable behavior. | | 4614 | +** to this routine results in undefined and probably undesirable behavior. |
4611 | +** | | 4615 | +** |
4612 | +** Requirements: | | 4616 | +** Requirements: |
4613 | +** [H17843] | | 4617 | +** [H17843] |
4614 | +*/ | | 4618 | +*/ |
4615 | +SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); | | 4619 | +SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); |
4616 | + | | 4620 | + |
4617 | +/* | | 4621 | +/* |
4618 | +** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230> | | 4622 | +** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230> |
4619 | +** | | 4623 | +** |
4620 | +** This function is used to read data from an open [BLOB handle] into a | | 4624 | +** This function is used to read data from an open [BLOB handle] into a |
4621 | +** caller-supplied buffer. N bytes of data are copied into buffer Z | | 4625 | +** caller-supplied buffer. N bytes of data are copied into buffer Z |
4622 | +** from the open BLOB, starting at offset iOffset. | | 4626 | +** from the open BLOB, starting at offset iOffset. |
4623 | +** | | 4627 | +** |
4624 | +** If offset iOffset is less than N bytes from the end of the BLOB, | | 4628 | +** If offset iOffset is less than N bytes from the end of the BLOB, |
4625 | +** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is | | 4629 | +** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is |
4626 | +** less than zero, [SQLITE_ERROR] is returned and no data is read. | | 4630 | +** less than zero, [SQLITE_ERROR] is returned and no data is read. |
4627 | +** The size of the blob (and hence the maximum value of N+iOffset) | | 4631 | +** The size of the blob (and hence the maximum value of N+iOffset) |
4628 | +** can be determined using the [sqlite3_blob_bytes()] interface. | | 4632 | +** can be determined using the [sqlite3_blob_bytes()] interface. |
4629 | +** | | 4633 | +** |
4630 | +** An attempt to read from an expired [BLOB handle] fails with an | | 4634 | +** An attempt to read from an expired [BLOB handle] fails with an |
4631 | +** error code of [SQLITE_ABORT]. | | 4635 | +** error code of [SQLITE_ABORT]. |
4632 | +** | | 4636 | +** |
4633 | +** On success, SQLITE_OK is returned. | | 4637 | +** On success, SQLITE_OK is returned. |
4634 | +** Otherwise, an [error code] or an [extended error code] is returned. | | 4638 | +** Otherwise, an [error code] or an [extended error code] is returned. |
4635 | +** | | 4639 | +** |
4636 | +** This routine only works on a [BLOB handle] which has been created | | 4640 | +** This routine only works on a [BLOB handle] which has been created |
4637 | +** by a prior successful call to [sqlite3_blob_open()] and which has not | | 4641 | +** by a prior successful call to [sqlite3_blob_open()] and which has not |
4638 | +** been closed by [sqlite3_blob_close()]. Passing any other pointer in | | 4642 | +** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
4639 | +** to this routine results in undefined and probably undesirable behavior. | | 4643 | +** to this routine results in undefined and probably undesirable behavior. |
4640 | +** | | 4644 | +** |
4641 | +** See also: [sqlite3_blob_write()]. | | 4645 | +** See also: [sqlite3_blob_write()]. |
4642 | +** | | 4646 | +** |
4643 | +** Requirements: | | 4647 | +** Requirements: |
4644 | +** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868] | | 4648 | +** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868] |
4645 | +*/ | | 4649 | +*/ |
4646 | +SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); | | 4650 | +SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); |
4647 | + | | 4651 | + |
4648 | +/* | | 4652 | +/* |
4649 | +** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230> | | 4653 | +** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230> |
4650 | +** | | 4654 | +** |
4651 | +** This function is used to write data into an open [BLOB handle] from a | | 4655 | +** This function is used to write data into an open [BLOB handle] from a |
4652 | +** caller-supplied buffer. N bytes of data are copied from the buffer Z | | 4656 | +** caller-supplied buffer. N bytes of data are copied from the buffer Z |
4653 | +** into the open BLOB, starting at offset iOffset. | | 4657 | +** into the open BLOB, starting at offset iOffset. |
4654 | +** | | 4658 | +** |
4655 | +** If the [BLOB handle] passed as the first argument was not opened for | | 4659 | +** If the [BLOB handle] passed as the first argument was not opened for |
4656 | +** writing (the flags parameter to [sqlite3_blob_open()] was zero), | | 4660 | +** writing (the flags parameter to [sqlite3_blob_open()] was zero), |
4657 | +** this function returns [SQLITE_READONLY]. | | 4661 | +** this function returns [SQLITE_READONLY]. |
4658 | +** | | 4662 | +** |
4659 | +** This function may only modify the contents of the BLOB; it is | | 4663 | +** This function may only modify the contents of the BLOB; it is |
4660 | +** not possible to increase the size of a BLOB using this API. | | 4664 | +** not possible to increase the size of a BLOB using this API. |
4661 | +** If offset iOffset is less than N bytes from the end of the BLOB, | | 4665 | +** If offset iOffset is less than N bytes from the end of the BLOB, |
4662 | +** [SQLITE_ERROR] is returned and no data is written. If N is | | 4666 | +** [SQLITE_ERROR] is returned and no data is written. If N is |
4663 | +** less than zero [SQLITE_ERROR] is returned and no data is written. | | 4667 | +** less than zero [SQLITE_ERROR] is returned and no data is written. |
4664 | +** The size of the BLOB (and hence the maximum value of N+iOffset) | | 4668 | +** The size of the BLOB (and hence the maximum value of N+iOffset) |
4665 | +** can be determined using the [sqlite3_blob_bytes()] interface. | | 4669 | +** can be determined using the [sqlite3_blob_bytes()] interface. |
4666 | +** | | 4670 | +** |
4667 | +** An attempt to write to an expired [BLOB handle] fails with an | | 4671 | +** An attempt to write to an expired [BLOB handle] fails with an |
4668 | +** error code of [SQLITE_ABORT]. Writes to the BLOB that occurred | | 4672 | +** error code of [SQLITE_ABORT]. Writes to the BLOB that occurred |
4669 | +** before the [BLOB handle] expired are not rolled back by the | | 4673 | +** before the [BLOB handle] expired are not rolled back by the |
4670 | +** expiration of the handle, though of course those changes might | | 4674 | +** expiration of the handle, though of course those changes might |
4671 | +** have been overwritten by the statement that expired the BLOB handle | | 4675 | +** have been overwritten by the statement that expired the BLOB handle |
4672 | +** or by other independent statements. | | 4676 | +** or by other independent statements. |
4673 | +** | | 4677 | +** |
4674 | +** On success, SQLITE_OK is returned. | | 4678 | +** On success, SQLITE_OK is returned. |
4675 | +** Otherwise, an [error code] or an [extended error code] is returned. | | 4679 | +** Otherwise, an [error code] or an [extended error code] is returned. |
4676 | +** | | 4680 | +** |
4677 | +** This routine only works on a [BLOB handle] which has been created | | 4681 | +** This routine only works on a [BLOB handle] which has been created |
4678 | +** by a prior successful call to [sqlite3_blob_open()] and which has not | | 4682 | +** by a prior successful call to [sqlite3_blob_open()] and which has not |
4679 | +** been closed by [sqlite3_blob_close()]. Passing any other pointer in | | 4683 | +** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
4680 | +** to this routine results in undefined and probably undesirable behavior. | | 4684 | +** to this routine results in undefined and probably undesirable behavior. |
4681 | +** | | 4685 | +** |
4682 | +** See also: [sqlite3_blob_read()]. | | 4686 | +** See also: [sqlite3_blob_read()]. |
4683 | +** | | 4687 | +** |
4684 | +** Requirements: | | 4688 | +** Requirements: |
4685 | +** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885] | | 4689 | +** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885] |
4686 | +** [H17888] | | 4690 | +** [H17888] |
4687 | +*/ | | 4691 | +*/ |
4688 | +SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); | | 4692 | +SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); |
4689 | + | | 4693 | + |
4690 | +/* | | 4694 | +/* |
4691 | +** CAPI3REF: Virtual File System Objects {H11200} <S20100> | | 4695 | +** CAPI3REF: Virtual File System Objects {H11200} <S20100> |
4692 | +** | | 4696 | +** |
4693 | +** A virtual filesystem (VFS) is an [sqlite3_vfs] object | | 4697 | +** A virtual filesystem (VFS) is an [sqlite3_vfs] object |
4694 | +** that SQLite uses to interact | | 4698 | +** that SQLite uses to interact |
4695 | +** with the underlying operating system. Most SQLite builds come with a | | 4699 | +** with the underlying operating system. Most SQLite builds come with a |
4696 | +** single default VFS that is appropriate for the host computer. | | 4700 | +** single default VFS that is appropriate for the host computer. |
4697 | +** New VFSes can be registered and existing VFSes can be unregistered. | | 4701 | +** New VFSes can be registered and existing VFSes can be unregistered. |
4698 | +** The following interfaces are provided. | | 4702 | +** The following interfaces are provided. |
4699 | +** | | 4703 | +** |
4700 | +** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. | | 4704 | +** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. |
4701 | +** Names are case sensitive. | | 4705 | +** Names are case sensitive. |
4702 | +** Names are zero-terminated UTF-8 strings. | | 4706 | +** Names are zero-terminated UTF-8 strings. |
4703 | +** If there is no match, a NULL pointer is returned. | | 4707 | +** If there is no match, a NULL pointer is returned. |
4704 | +** If zVfsName is NULL then the default VFS is returned. | | 4708 | +** If zVfsName is NULL then the default VFS is returned. |
4705 | +** | | 4709 | +** |
4706 | +** New VFSes are registered with sqlite3_vfs_register(). | | 4710 | +** New VFSes are registered with sqlite3_vfs_register(). |
4707 | +** Each new VFS becomes the default VFS if the makeDflt flag is set. | | 4711 | +** Each new VFS becomes the default VFS if the makeDflt flag is set. |
4708 | +** The same VFS can be registered multiple times without injury. | | 4712 | +** The same VFS can be registered multiple times without injury. |
4709 | +** To make an existing VFS into the default VFS, register it again | | 4713 | +** To make an existing VFS into the default VFS, register it again |
4710 | +** with the makeDflt flag set. If two different VFSes with the | | 4714 | +** with the makeDflt flag set. If two different VFSes with the |
4711 | +** same name are registered, the behavior is undefined. If a | | 4715 | +** same name are registered, the behavior is undefined. If a |
4712 | +** VFS is registered with a name that is NULL or an empty string, | | 4716 | +** VFS is registered with a name that is NULL or an empty string, |
4713 | +** then the behavior is undefined. | | 4717 | +** then the behavior is undefined. |
4714 | +** | | 4718 | +** |
4715 | +** Unregister a VFS with the sqlite3_vfs_unregister() interface. | | 4719 | +** Unregister a VFS with the sqlite3_vfs_unregister() interface. |
4716 | +** If the default VFS is unregistered, another VFS is chosen as | | 4720 | +** If the default VFS is unregistered, another VFS is chosen as |
4717 | +** the default. The choice for the new VFS is arbitrary. | | 4721 | +** the default. The choice for the new VFS is arbitrary. |
4718 | +** | | 4722 | +** |
4719 | +** Requirements: | | 4723 | +** Requirements: |
4720 | +** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218] | | 4724 | +** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218] |
4721 | +*/ | | 4725 | +*/ |
4722 | +SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); | | 4726 | +SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); |
4723 | +SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); | | 4727 | +SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); |
4724 | +SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); | | 4728 | +SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); |
4725 | + | | 4729 | + |
4726 | +/* | | 4730 | +/* |
4727 | +** CAPI3REF: Mutexes {H17000} <S20000> | | 4731 | +** CAPI3REF: Mutexes {H17000} <S20000> |
4728 | +** | | 4732 | +** |
4729 | +** The SQLite core uses these routines for thread | | 4733 | +** The SQLite core uses these routines for thread |
4730 | +** synchronization. Though they are intended for internal | | 4734 | +** synchronization. Though they are intended for internal |
4731 | +** use by SQLite, code that links against SQLite is | | 4735 | +** use by SQLite, code that links against SQLite is |
4732 | +** permitted to use any of these routines. | | 4736 | +** permitted to use any of these routines. |
4733 | +** | | 4737 | +** |
4734 | +** The SQLite source code contains multiple implementations | | 4738 | +** The SQLite source code contains multiple implementations |
4735 | +** of these mutex routines. An appropriate implementation | | 4739 | +** of these mutex routines. An appropriate implementation |
4736 | +** is selected automatically at compile-time. The following | | 4740 | +** is selected automatically at compile-time. The following |
4737 | +** implementations are available in the SQLite core: | | 4741 | +** implementations are available in the SQLite core: |
4738 | +** | | 4742 | +** |
4739 | +** <ul> | | 4743 | +** <ul> |
4740 | +** <li> SQLITE_MUTEX_OS2 | | 4744 | +** <li> SQLITE_MUTEX_OS2 |
4741 | +** <li> SQLITE_MUTEX_PTHREAD | | 4745 | +** <li> SQLITE_MUTEX_PTHREAD |
4742 | +** <li> SQLITE_MUTEX_W32 | | 4746 | +** <li> SQLITE_MUTEX_W32 |
4743 | +** <li> SQLITE_MUTEX_NOOP | | 4747 | +** <li> SQLITE_MUTEX_NOOP |
4744 | +** </ul> | | 4748 | +** </ul> |
4745 | +** | | 4749 | +** |
4746 | +** The SQLITE_MUTEX_NOOP implementation is a set of routines | | 4750 | +** The SQLITE_MUTEX_NOOP implementation is a set of routines |
4747 | +** that does no real locking and is appropriate for use in | | 4751 | +** that does no real locking and is appropriate for use in |
4748 | +** a single-threaded application. The SQLITE_MUTEX_OS2, | | 4752 | +** a single-threaded application. The SQLITE_MUTEX_OS2, |
4749 | +** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations | | 4753 | +** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations |
4750 | +** are appropriate for use on OS/2, Unix, and Windows. | | 4754 | +** are appropriate for use on OS/2, Unix, and Windows. |
4751 | +** | | 4755 | +** |
4752 | +** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor | | 4756 | +** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
4753 | +** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex | | 4757 | +** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
4754 | +** implementation is included with the library. In this case the | | 4758 | +** implementation is included with the library. In this case the |
4755 | +** application must supply a custom mutex implementation using the | | 4759 | +** application must supply a custom mutex implementation using the |
4756 | +** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function | | 4760 | +** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function |
4757 | +** before calling sqlite3_initialize() or any other public sqlite3_ | | 4761 | +** before calling sqlite3_initialize() or any other public sqlite3_ |
4758 | +** function that calls sqlite3_initialize(). | | 4762 | +** function that calls sqlite3_initialize(). |
4759 | +** | | 4763 | +** |
4760 | +** {H17011} The sqlite3_mutex_alloc() routine allocates a new | | 4764 | +** {H17011} The sqlite3_mutex_alloc() routine allocates a new |
4761 | +** mutex and returns a pointer to it. {H17012} If it returns NULL | | 4765 | +** mutex and returns a pointer to it. {H17012} If it returns NULL |
4762 | +** that means that a mutex could not be allocated. {H17013} SQLite | | 4766 | +** that means that a mutex could not be allocated. {H17013} SQLite |
4763 | +** will unwind its stack and return an error. {H17014} The argument | | 4767 | +** will unwind its stack and return an error. {H17014} The argument |
4764 | +** to sqlite3_mutex_alloc() is one of these integer constants: | | 4768 | +** to sqlite3_mutex_alloc() is one of these integer constants: |
4765 | +** | | 4769 | +** |
4766 | +** <ul> | | 4770 | +** <ul> |
4767 | +** <li> SQLITE_MUTEX_FAST | | 4771 | +** <li> SQLITE_MUTEX_FAST |
4768 | +** <li> SQLITE_MUTEX_RECURSIVE | | 4772 | +** <li> SQLITE_MUTEX_RECURSIVE |
4769 | +** <li> SQLITE_MUTEX_STATIC_MASTER | | 4773 | +** <li> SQLITE_MUTEX_STATIC_MASTER |
4770 | +** <li> SQLITE_MUTEX_STATIC_MEM | | 4774 | +** <li> SQLITE_MUTEX_STATIC_MEM |
4771 | +** <li> SQLITE_MUTEX_STATIC_MEM2 | | 4775 | +** <li> SQLITE_MUTEX_STATIC_MEM2 |
4772 | +** <li> SQLITE_MUTEX_STATIC_PRNG | | 4776 | +** <li> SQLITE_MUTEX_STATIC_PRNG |
4773 | +** <li> SQLITE_MUTEX_STATIC_LRU | | 4777 | +** <li> SQLITE_MUTEX_STATIC_LRU |
4774 | +** <li> SQLITE_MUTEX_STATIC_LRU2 | | 4778 | +** <li> SQLITE_MUTEX_STATIC_LRU2 |
4775 | +** </ul> | | 4779 | +** </ul> |
4776 | +** | | 4780 | +** |
4777 | +** {H17015} The first two constants cause sqlite3_mutex_alloc() to create | | 4781 | +** {H17015} The first two constants cause sqlite3_mutex_alloc() to create |
4778 | +** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE | | 4782 | +** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE |
4779 | +** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END} | | 4783 | +** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END} |
4780 | +** The mutex implementation does not need to make a distinction | | 4784 | +** The mutex implementation does not need to make a distinction |
4781 | +** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does | | 4785 | +** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does |
4782 | +** not want to. {H17016} But SQLite will only request a recursive mutex in | | 4786 | +** not want to. {H17016} But SQLite will only request a recursive mutex in |
4783 | +** cases where it really needs one. {END} If a faster non-recursive mutex | | 4787 | +** cases where it really needs one. {END} If a faster non-recursive mutex |
4784 | +** implementation is available on the host platform, the mutex subsystem | | 4788 | +** implementation is available on the host platform, the mutex subsystem |
4785 | +** might return such a mutex in response to SQLITE_MUTEX_FAST. | | 4789 | +** might return such a mutex in response to SQLITE_MUTEX_FAST. |
4786 | +** | | 4790 | +** |
4787 | +** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return | | 4791 | +** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return |
4788 | +** a pointer to a static preexisting mutex. {END} Six static mutexes are | | 4792 | +** a pointer to a static preexisting mutex. {END} Six static mutexes are |
4789 | +** used by the current version of SQLite. Future versions of SQLite | | 4793 | +** used by the current version of SQLite. Future versions of SQLite |
4790 | +** may add additional static mutexes. Static mutexes are for internal | | 4794 | +** may add additional static mutexes. Static mutexes are for internal |
4791 | +** use by SQLite only. Applications that use SQLite mutexes should | | 4795 | +** use by SQLite only. Applications that use SQLite mutexes should |
4792 | +** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or | | 4796 | +** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or |
4793 | +** SQLITE_MUTEX_RECURSIVE. | | 4797 | +** SQLITE_MUTEX_RECURSIVE. |
4794 | +** | | 4798 | +** |
4795 | +** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST | | 4799 | +** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST |
4796 | +** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() | | 4800 | +** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() |
4797 | +** returns a different mutex on every call. {H17034} But for the static | | 4801 | +** returns a different mutex on every call. {H17034} But for the static |
4798 | +** mutex types, the same mutex is returned on every call that has | | 4802 | +** mutex types, the same mutex is returned on every call that has |
4799 | +** the same type number. | | 4803 | +** the same type number. |
4800 | +** | | 4804 | +** |
4801 | +** {H17019} The sqlite3_mutex_free() routine deallocates a previously | | 4805 | +** {H17019} The sqlite3_mutex_free() routine deallocates a previously |
4802 | +** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every | | 4806 | +** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every |
4803 | +** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in | | 4807 | +** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in |
4804 | +** use when they are deallocated. {A17022} Attempting to deallocate a static | | 4808 | +** use when they are deallocated. {A17022} Attempting to deallocate a static |
4805 | +** mutex results in undefined behavior. {H17023} SQLite never deallocates | | 4809 | +** mutex results in undefined behavior. {H17023} SQLite never deallocates |
4806 | +** a static mutex. {END} | | 4810 | +** a static mutex. {END} |
4807 | +** | | 4811 | +** |
4808 | +** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt | | 4812 | +** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt |
4809 | +** to enter a mutex. {H17024} If another thread is already within the mutex, | | 4813 | +** to enter a mutex. {H17024} If another thread is already within the mutex, |
4810 | +** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return | | 4814 | +** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return |
4811 | +** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK] | | 4815 | +** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK] |
4812 | +** upon successful entry. {H17026} Mutexes created using | | 4816 | +** upon successful entry. {H17026} Mutexes created using |
4813 | +** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. | | 4817 | +** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. |
4814 | +** {H17027} In such cases the, | | 4818 | +** {H17027} In such cases the, |
4815 | +** mutex must be exited an equal number of times before another thread | | 4819 | +** mutex must be exited an equal number of times before another thread |
4816 | +** can enter. {A17028} If the same thread tries to enter any other | | 4820 | +** can enter. {A17028} If the same thread tries to enter any other |
4817 | +** kind of mutex more than once, the behavior is undefined. | | 4821 | +** kind of mutex more than once, the behavior is undefined. |
4818 | +** {H17029} SQLite will never exhibit | | 4822 | +** {H17029} SQLite will never exhibit |
4819 | +** such behavior in its own use of mutexes. | | 4823 | +** such behavior in its own use of mutexes. |
4820 | +** | | 4824 | +** |
4821 | +** Some systems (for example, Windows 95) do not support the operation | | 4825 | +** Some systems (for example, Windows 95) do not support the operation |
4822 | +** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() | | 4826 | +** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() |
4823 | +** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses | | 4827 | +** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses |
4824 | +** sqlite3_mutex_try() as an optimization so this is acceptable behavior. | | 4828 | +** sqlite3_mutex_try() as an optimization so this is acceptable behavior. |
4825 | +** | | 4829 | +** |
4826 | +** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was | | 4830 | +** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was |
4827 | +** previously entered by the same thread. {A17032} The behavior | | 4831 | +** previously entered by the same thread. {A17032} The behavior |
4828 | +** is undefined if the mutex is not currently entered by the | | 4832 | +** is undefined if the mutex is not currently entered by the |
4829 | +** calling thread or is not currently allocated. {H17033} SQLite will | | 4833 | +** calling thread or is not currently allocated. {H17033} SQLite will |
4830 | +** never do either. {END} | | 4834 | +** never do either. {END} |
4831 | +** | | 4835 | +** |
4832 | +** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or | | 4836 | +** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or |
4833 | +** sqlite3_mutex_leave() is a NULL pointer, then all three routines | | 4837 | +** sqlite3_mutex_leave() is a NULL pointer, then all three routines |
4834 | +** behave as no-ops. | | 4838 | +** behave as no-ops. |
4835 | +** | | 4839 | +** |
4836 | +** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. | | 4840 | +** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. |
4837 | +*/ | | 4841 | +*/ |
4838 | +SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); | | 4842 | +SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); |
4839 | +SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); | | 4843 | +SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); |
4840 | +SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); | | 4844 | +SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); |
4841 | +SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); | | 4845 | +SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); |
4842 | +SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); | | 4846 | +SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); |
4843 | + | | 4847 | + |
4844 | +/* | | 4848 | +/* |
4845 | +** CAPI3REF: Mutex Methods Object {H17120} <S20130> | | 4849 | +** CAPI3REF: Mutex Methods Object {H17120} <S20130> |
4846 | +** EXPERIMENTAL | | 4850 | +** EXPERIMENTAL |
4847 | +** | | 4851 | +** |
4848 | +** An instance of this structure defines the low-level routines | | 4852 | +** An instance of this structure defines the low-level routines |
4849 | +** used to allocate and use mutexes. | | 4853 | +** used to allocate and use mutexes. |
4850 | +** | | 4854 | +** |
4851 | +** Usually, the default mutex implementations provided by SQLite are | | 4855 | +** Usually, the default mutex implementations provided by SQLite are |
4852 | +** sufficient, however the user has the option of substituting a custom | | 4856 | +** sufficient, however the user has the option of substituting a custom |
4853 | +** implementation for specialized deployments or systems for which SQLite | | 4857 | +** implementation for specialized deployments or systems for which SQLite |
4854 | +** does not provide a suitable implementation. In this case, the user | | 4858 | +** does not provide a suitable implementation. In this case, the user |
4855 | +** creates and populates an instance of this structure to pass | | 4859 | +** creates and populates an instance of this structure to pass |
4856 | +** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. | | 4860 | +** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. |
4857 | +** Additionally, an instance of this structure can be used as an | | 4861 | +** Additionally, an instance of this structure can be used as an |
4858 | +** output variable when querying the system for the current mutex | | 4862 | +** output variable when querying the system for the current mutex |
4859 | +** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. | | 4863 | +** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. |
4860 | +** | | 4864 | +** |
4861 | +** The xMutexInit method defined by this structure is invoked as | | 4865 | +** The xMutexInit method defined by this structure is invoked as |
4862 | +** part of system initialization by the sqlite3_initialize() function. | | 4866 | +** part of system initialization by the sqlite3_initialize() function. |
4863 | +** {H17001} The xMutexInit routine shall be called by SQLite once for each | | 4867 | +** {H17001} The xMutexInit routine shall be called by SQLite once for each |
4864 | +** effective call to [sqlite3_initialize()]. | | 4868 | +** effective call to [sqlite3_initialize()]. |
4865 | +** | | 4869 | +** |
4866 | +** The xMutexEnd method defined by this structure is invoked as | | 4870 | +** The xMutexEnd method defined by this structure is invoked as |
4867 | +** part of system shutdown by the sqlite3_shutdown() function. The | | 4871 | +** part of system shutdown by the sqlite3_shutdown() function. The |
4868 | +** implementation of this method is expected to release all outstanding | | 4872 | +** implementation of this method is expected to release all outstanding |
4869 | +** resources obtained by the mutex methods implementation, especially | | 4873 | +** resources obtained by the mutex methods implementation, especially |
4870 | +** those obtained by the xMutexInit method. {H17003} The xMutexEnd() | | 4874 | +** those obtained by the xMutexInit method. {H17003} The xMutexEnd() |
4871 | +** interface shall be invoked once for each call to [sqlite3_shutdown()]. | | 4875 | +** interface shall be invoked once for each call to [sqlite3_shutdown()]. |
4872 | +** | | 4876 | +** |
4873 | +** The remaining seven methods defined by this structure (xMutexAlloc, | | 4877 | +** The remaining seven methods defined by this structure (xMutexAlloc, |
4874 | +** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and | | 4878 | +** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and |
4875 | +** xMutexNotheld) implement the following interfaces (respectively): | | 4879 | +** xMutexNotheld) implement the following interfaces (respectively): |
4876 | +** | | 4880 | +** |
4877 | +** <ul> | | 4881 | +** <ul> |
4878 | +** <li> [sqlite3_mutex_alloc()] </li> | | 4882 | +** <li> [sqlite3_mutex_alloc()] </li> |
4879 | +** <li> [sqlite3_mutex_free()] </li> | | 4883 | +** <li> [sqlite3_mutex_free()] </li> |
4880 | +** <li> [sqlite3_mutex_enter()] </li> | | 4884 | +** <li> [sqlite3_mutex_enter()] </li> |
4881 | +** <li> [sqlite3_mutex_try()] </li> | | 4885 | +** <li> [sqlite3_mutex_try()] </li> |
4882 | +** <li> [sqlite3_mutex_leave()] </li> | | 4886 | +** <li> [sqlite3_mutex_leave()] </li> |
4883 | +** <li> [sqlite3_mutex_held()] </li> | | 4887 | +** <li> [sqlite3_mutex_held()] </li> |
4884 | +** <li> [sqlite3_mutex_notheld()] </li> | | 4888 | +** <li> [sqlite3_mutex_notheld()] </li> |
4885 | +** </ul> | | 4889 | +** </ul> |
4886 | +** | | 4890 | +** |
4887 | +** The only difference is that the public sqlite3_XXX functions enumerated | | 4891 | +** The only difference is that the public sqlite3_XXX functions enumerated |
4888 | +** above silently ignore any invocations that pass a NULL pointer instead | | 4892 | +** above silently ignore any invocations that pass a NULL pointer instead |
4889 | +** of a valid mutex handle. The implementations of the methods defined | | 4893 | +** of a valid mutex handle. The implementations of the methods defined |
4890 | +** by this structure are not required to handle this case, the results | | 4894 | +** by this structure are not required to handle this case, the results |
4891 | +** of passing a NULL pointer instead of a valid mutex handle are undefined | | 4895 | +** of passing a NULL pointer instead of a valid mutex handle are undefined |
4892 | +** (i.e. it is acceptable to provide an implementation that segfaults if | | 4896 | +** (i.e. it is acceptable to provide an implementation that segfaults if |
4893 | +** it is passed a NULL pointer). | | 4897 | +** it is passed a NULL pointer). |
4894 | +** | | 4898 | +** |
4895 | +** The xMutexInit() method must be threadsafe. It must be harmless to | | 4899 | +** The xMutexInit() method must be threadsafe. It must be harmless to |
4896 | +** invoke xMutexInit() mutiple times within the same process and without | | 4900 | +** invoke xMutexInit() mutiple times within the same process and without |
4897 | +** intervening calls to xMutexEnd(). Second and subsequent calls to | | 4901 | +** intervening calls to xMutexEnd(). Second and subsequent calls to |
4898 | +** xMutexInit() must be no-ops. | | 4902 | +** xMutexInit() must be no-ops. |
4899 | +** | | 4903 | +** |
4900 | +** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] | | 4904 | +** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] |
4901 | +** and its associates). Similarly, xMutexAlloc() must not use SQLite memory | | 4905 | +** and its associates). Similarly, xMutexAlloc() must not use SQLite memory |
4902 | +** allocation for a static mutex. However xMutexAlloc() may use SQLite | | 4906 | +** allocation for a static mutex. However xMutexAlloc() may use SQLite |
4903 | +** memory allocation for a fast or recursive mutex. | | 4907 | +** memory allocation for a fast or recursive mutex. |
4904 | +** | | 4908 | +** |
4905 | +** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is | | 4909 | +** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is |
4906 | +** called, but only if the prior call to xMutexInit returned SQLITE_OK. | | 4910 | +** called, but only if the prior call to xMutexInit returned SQLITE_OK. |
4907 | +** If xMutexInit fails in any way, it is expected to clean up after itself | | 4911 | +** If xMutexInit fails in any way, it is expected to clean up after itself |
4908 | +** prior to returning. | | 4912 | +** prior to returning. |
4909 | +*/ | | 4913 | +*/ |
4910 | +typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; | | 4914 | +typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; |
4911 | +struct sqlite3_mutex_methods { | | 4915 | +struct sqlite3_mutex_methods { |
4912 | + int (*xMutexInit)(void); | | 4916 | + int (*xMutexInit)(void); |
4913 | + int (*xMutexEnd)(void); | | 4917 | + int (*xMutexEnd)(void); |
4914 | + sqlite3_mutex *(*xMutexAlloc)(int); | | 4918 | + sqlite3_mutex *(*xMutexAlloc)(int); |
4915 | + void (*xMutexFree)(sqlite3_mutex *); | | 4919 | + void (*xMutexFree)(sqlite3_mutex *); |
4916 | + void (*xMutexEnter)(sqlite3_mutex *); | | 4920 | + void (*xMutexEnter)(sqlite3_mutex *); |
4917 | + int (*xMutexTry)(sqlite3_mutex *); | | 4921 | + int (*xMutexTry)(sqlite3_mutex *); |
4918 | + void (*xMutexLeave)(sqlite3_mutex *); | | 4922 | + void (*xMutexLeave)(sqlite3_mutex *); |
4919 | + int (*xMutexHeld)(sqlite3_mutex *); | | 4923 | + int (*xMutexHeld)(sqlite3_mutex *); |
4920 | + int (*xMutexNotheld)(sqlite3_mutex *); | | 4924 | + int (*xMutexNotheld)(sqlite3_mutex *); |
4921 | +}; | | 4925 | +}; |
4922 | + | | 4926 | + |
4923 | +/* | | 4927 | +/* |
4924 | +** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800> | | 4928 | +** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800> |
4925 | +** | | 4929 | +** |
4926 | +** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines | | 4930 | +** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines |
4927 | +** are intended for use inside assert() statements. {H17081} The SQLite core | | 4931 | +** are intended for use inside assert() statements. {H17081} The SQLite core |
4928 | +** never uses these routines except inside an assert() and applications | | 4932 | +** never uses these routines except inside an assert() and applications |
4929 | +** are advised to follow the lead of the core. {H17082} The core only | | 4933 | +** are advised to follow the lead of the core. {H17082} The core only |
4930 | +** provides implementations for these routines when it is compiled | | 4934 | +** provides implementations for these routines when it is compiled |
4931 | +** with the SQLITE_DEBUG flag. {A17087} External mutex implementations | | 4935 | +** with the SQLITE_DEBUG flag. {A17087} External mutex implementations |
4932 | +** are only required to provide these routines if SQLITE_DEBUG is | | 4936 | +** are only required to provide these routines if SQLITE_DEBUG is |
4933 | +** defined and if NDEBUG is not defined. | | 4937 | +** defined and if NDEBUG is not defined. |
4934 | +** | | 4938 | +** |
4935 | +** {H17083} These routines should return true if the mutex in their argument | | 4939 | +** {H17083} These routines should return true if the mutex in their argument |
4936 | +** is held or not held, respectively, by the calling thread. | | 4940 | +** is held or not held, respectively, by the calling thread. |
4937 | +** | | 4941 | +** |
4938 | +** {X17084} The implementation is not required to provided versions of these | | 4942 | +** {X17084} The implementation is not required to provided versions of these |
4939 | +** routines that actually work. If the implementation does not provide working | | 4943 | +** routines that actually work. If the implementation does not provide working |
4940 | +** versions of these routines, it should at least provide stubs that always | | 4944 | +** versions of these routines, it should at least provide stubs that always |
4941 | +** return true so that one does not get spurious assertion failures. | | 4945 | +** return true so that one does not get spurious assertion failures. |
4942 | +** | | 4946 | +** |
4943 | +** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then | | 4947 | +** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then |
4944 | +** the routine should return 1. {END} This seems counter-intuitive since | | 4948 | +** the routine should return 1. {END} This seems counter-intuitive since |
4945 | +** clearly the mutex cannot be held if it does not exist. But the | | 4949 | +** clearly the mutex cannot be held if it does not exist. But the |
4946 | +** the reason the mutex does not exist is because the build is not | | 4950 | +** the reason the mutex does not exist is because the build is not |
4947 | +** using mutexes. And we do not want the assert() containing the | | 4951 | +** using mutexes. And we do not want the assert() containing the |
4948 | +** call to sqlite3_mutex_held() to fail, so a non-zero return is | | 4952 | +** call to sqlite3_mutex_held() to fail, so a non-zero return is |
4949 | +** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld() | | 4953 | +** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld() |
4950 | +** interface should also return 1 when given a NULL pointer. | | 4954 | +** interface should also return 1 when given a NULL pointer. |
4951 | +*/ | | 4955 | +*/ |
4952 | +SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); | | 4956 | +SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); |
4953 | +SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); | | 4957 | +SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); |
4954 | + | | 4958 | + |
4955 | +/* | | 4959 | +/* |
4956 | +** CAPI3REF: Mutex Types {H17001} <H17000> | | 4960 | +** CAPI3REF: Mutex Types {H17001} <H17000> |
4957 | +** | | 4961 | +** |
4958 | +** The [sqlite3_mutex_alloc()] interface takes a single argument | | 4962 | +** The [sqlite3_mutex_alloc()] interface takes a single argument |
4959 | +** which is one of these integer constants. | | 4963 | +** which is one of these integer constants. |
4960 | +** | | 4964 | +** |
4961 | +** The set of static mutexes may change from one SQLite release to the | | 4965 | +** The set of static mutexes may change from one SQLite release to the |
4962 | +** next. Applications that override the built-in mutex logic must be | | 4966 | +** next. Applications that override the built-in mutex logic must be |
4963 | +** prepared to accommodate additional static mutexes. | | 4967 | +** prepared to accommodate additional static mutexes. |
4964 | +*/ | | 4968 | +*/ |
4965 | +#define SQLITE_MUTEX_FAST 0 | | 4969 | +#define SQLITE_MUTEX_FAST 0 |
4966 | +#define SQLITE_MUTEX_RECURSIVE 1 | | 4970 | +#define SQLITE_MUTEX_RECURSIVE 1 |
4967 | +#define SQLITE_MUTEX_STATIC_MASTER 2 | | 4971 | +#define SQLITE_MUTEX_STATIC_MASTER 2 |
4968 | +#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ | | 4972 | +#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ |
4969 | +#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ | | 4973 | +#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ |
4970 | +#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ | | 4974 | +#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ |
4971 | +#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ | | 4975 | +#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ |
4972 | +#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ | | 4976 | +#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ |
4973 | +#define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ | | 4977 | +#define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ |
4974 | + | | 4978 | + |
4975 | +/* | | 4979 | +/* |
4976 | +** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000> | | 4980 | +** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000> |
4977 | +** | | 4981 | +** |
4978 | +** This interface returns a pointer the [sqlite3_mutex] object that | | 4982 | +** This interface returns a pointer the [sqlite3_mutex] object that |
4979 | +** serializes access to the [database connection] given in the argument | | 4983 | +** serializes access to the [database connection] given in the argument |
4980 | +** when the [threading mode] is Serialized. | | 4984 | +** when the [threading mode] is Serialized. |
4981 | +** If the [threading mode] is Single-thread or Multi-thread then this | | 4985 | +** If the [threading mode] is Single-thread or Multi-thread then this |
4982 | +** routine returns a NULL pointer. | | 4986 | +** routine returns a NULL pointer. |
4983 | +*/ | | 4987 | +*/ |
4984 | +SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); | | 4988 | +SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); |
4985 | + | | 4989 | + |
4986 | +/* | | 4990 | +/* |
4987 | +** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800> | | 4991 | +** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800> |
4988 | +** | | 4992 | +** |
4989 | +** {H11301} The [sqlite3_file_control()] interface makes a direct call to the | | 4993 | +** {H11301} The [sqlite3_file_control()] interface makes a direct call to the |
4990 | +** xFileControl method for the [sqlite3_io_methods] object associated | | 4994 | +** xFileControl method for the [sqlite3_io_methods] object associated |
4991 | +** with a particular database identified by the second argument. {H11302} The | | 4995 | +** with a particular database identified by the second argument. {H11302} The |
4992 | +** name of the database is the name assigned to the database by the | | 4996 | +** name of the database is the name assigned to the database by the |
4993 | +** <a href="lang_attach.html">ATTACH</a> SQL command that opened the | | 4997 | +** <a href="lang_attach.html">ATTACH</a> SQL command that opened the |
4994 | +** database. {H11303} To control the main database file, use the name "main" | | 4998 | +** database. {H11303} To control the main database file, use the name "main" |
4995 | +** or a NULL pointer. {H11304} The third and fourth parameters to this routine | | 4999 | +** or a NULL pointer. {H11304} The third and fourth parameters to this routine |
4996 | +** are passed directly through to the second and third parameters of | | 5000 | +** are passed directly through to the second and third parameters of |
4997 | +** the xFileControl method. {H11305} The return value of the xFileControl | | 5001 | +** the xFileControl method. {H11305} The return value of the xFileControl |
4998 | +** method becomes the return value of this routine. | | 5002 | +** method becomes the return value of this routine. |
4999 | +** | | 5003 | +** |
5000 | +** {H11306} If the second parameter (zDbName) does not match the name of any | | 5004 | +** {H11306} If the second parameter (zDbName) does not match the name of any |
5001 | +** open database file, then SQLITE_ERROR is returned. {H11307} This error | | 5005 | +** open database file, then SQLITE_ERROR is returned. {H11307} This error |
5002 | +** code is not remembered and will not be recalled by [sqlite3_errcode()] | | 5006 | +** code is not remembered and will not be recalled by [sqlite3_errcode()] |
5003 | +** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might | | 5007 | +** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might |
5004 | +** also return SQLITE_ERROR. {A11309} There is no way to distinguish between | | 5008 | +** also return SQLITE_ERROR. {A11309} There is no way to distinguish between |
5005 | +** an incorrect zDbName and an SQLITE_ERROR return from the underlying | | 5009 | +** an incorrect zDbName and an SQLITE_ERROR return from the underlying |
5006 | +** xFileControl method. {END} | | 5010 | +** xFileControl method. {END} |
5007 | +** | | 5011 | +** |
5008 | +** See also: [SQLITE_FCNTL_LOCKSTATE] | | 5012 | +** See also: [SQLITE_FCNTL_LOCKSTATE] |
5009 | +*/ | | 5013 | +*/ |
5010 | +SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); | | 5014 | +SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); |
5011 | + | | 5015 | + |
5012 | +/* | | 5016 | +/* |
5013 | +** CAPI3REF: Testing Interface {H11400} <S30800> | | 5017 | +** CAPI3REF: Testing Interface {H11400} <S30800> |
5014 | +** | | 5018 | +** |
5015 | +** The sqlite3_test_control() interface is used to read out internal | | 5019 | +** The sqlite3_test_control() interface is used to read out internal |
5016 | +** state of SQLite and to inject faults into SQLite for testing | | 5020 | +** state of SQLite and to inject faults into SQLite for testing |
5017 | +** purposes. The first parameter is an operation code that determines | | 5021 | +** purposes. The first parameter is an operation code that determines |
5018 | +** the number, meaning, and operation of all subsequent parameters. | | 5022 | +** the number, meaning, and operation of all subsequent parameters. |
5019 | +** | | 5023 | +** |
5020 | +** This interface is not for use by applications. It exists solely | | 5024 | +** This interface is not for use by applications. It exists solely |
5021 | +** for verifying the correct operation of the SQLite library. Depending | | 5025 | +** for verifying the correct operation of the SQLite library. Depending |
5022 | +** on how the SQLite library is compiled, this interface might not exist. | | 5026 | +** on how the SQLite library is compiled, this interface might not exist. |
5023 | +** | | 5027 | +** |
5024 | +** The details of the operation codes, their meanings, the parameters | | 5028 | +** The details of the operation codes, their meanings, the parameters |
5025 | +** they take, and what they do are all subject to change without notice. | | 5029 | +** they take, and what they do are all subject to change without notice. |
5026 | +** Unlike most of the SQLite API, this function is not guaranteed to | | 5030 | +** Unlike most of the SQLite API, this function is not guaranteed to |
5027 | +** operate consistently from one release to the next. | | 5031 | +** operate consistently from one release to the next. |
5028 | +*/ | | 5032 | +*/ |
5029 | +SQLITE_API int sqlite3_test_control(int op, ...); | | 5033 | +SQLITE_API int sqlite3_test_control(int op, ...); |
5030 | + | | 5034 | + |
5031 | +/* | | 5035 | +/* |
5032 | +** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400> | | 5036 | +** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400> |
5033 | +** | | 5037 | +** |
5034 | +** These constants are the valid operation code parameters used | | 5038 | +** These constants are the valid operation code parameters used |
5035 | +** as the first argument to [sqlite3_test_control()]. | | 5039 | +** as the first argument to [sqlite3_test_control()]. |
5036 | +** | | 5040 | +** |
5037 | +** These parameters and their meanings are subject to change | | 5041 | +** These parameters and their meanings are subject to change |
5038 | +** without notice. These values are for testing purposes only. | | 5042 | +** without notice. These values are for testing purposes only. |
5039 | +** Applications should not use any of these parameters or the | | 5043 | +** Applications should not use any of these parameters or the |
5040 | +** [sqlite3_test_control()] interface. | | 5044 | +** [sqlite3_test_control()] interface. |
5041 | +*/ | | 5045 | +*/ |
5042 | +#define SQLITE_TESTCTRL_PRNG_SAVE 5 | | 5046 | +#define SQLITE_TESTCTRL_PRNG_SAVE 5 |
5043 | +#define SQLITE_TESTCTRL_PRNG_RESTORE 6 | | 5047 | +#define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
5044 | +#define SQLITE_TESTCTRL_PRNG_RESET 7 | | 5048 | +#define SQLITE_TESTCTRL_PRNG_RESET 7 |
5045 | +#define SQLITE_TESTCTRL_BITVEC_TEST 8 | | 5049 | +#define SQLITE_TESTCTRL_BITVEC_TEST 8 |
5046 | +#define SQLITE_TESTCTRL_FAULT_INSTALL 9 | | 5050 | +#define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
5047 | +#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 | | 5051 | +#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
5048 | +#define SQLITE_TESTCTRL_PENDING_BYTE 11 | | 5052 | +#define SQLITE_TESTCTRL_PENDING_BYTE 11 |
5049 | +#define SQLITE_TESTCTRL_ASSERT 12 | | 5053 | +#define SQLITE_TESTCTRL_ASSERT 12 |
5050 | +#define SQLITE_TESTCTRL_ALWAYS 13 | | 5054 | +#define SQLITE_TESTCTRL_ALWAYS 13 |
5051 | +#define SQLITE_TESTCTRL_RESERVE 14 | | 5055 | +#define SQLITE_TESTCTRL_RESERVE 14 |
5052 | + | | 5056 | + |
5053 | +/* | | 5057 | +/* |
5054 | +** CAPI3REF: SQLite Runtime Status {H17200} <S60200> | | 5058 | +** CAPI3REF: SQLite Runtime Status {H17200} <S60200> |
5055 | +** EXPERIMENTAL | | 5059 | +** EXPERIMENTAL |
5056 | +** | | 5060 | +** |
5057 | +** This interface is used to retrieve runtime status information | | 5061 | +** This interface is used to retrieve runtime status information |
5058 | +** about the preformance of SQLite, and optionally to reset various | | 5062 | +** about the preformance of SQLite, and optionally to reset various |
5059 | +** highwater marks. The first argument is an integer code for | | 5063 | +** highwater marks. The first argument is an integer code for |
5060 | +** the specific parameter to measure. Recognized integer codes | | 5064 | +** the specific parameter to measure. Recognized integer codes |
5061 | +** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...]. | | 5065 | +** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...]. |
5062 | +** The current value of the parameter is returned into *pCurrent. | | 5066 | +** The current value of the parameter is returned into *pCurrent. |
5063 | +** The highest recorded value is returned in *pHighwater. If the | | 5067 | +** The highest recorded value is returned in *pHighwater. If the |
5064 | +** resetFlag is true, then the highest record value is reset after | | 5068 | +** resetFlag is true, then the highest record value is reset after |
5065 | +** *pHighwater is written. Some parameters do not record the highest | | 5069 | +** *pHighwater is written. Some parameters do not record the highest |
5066 | +** value. For those parameters | | 5070 | +** value. For those parameters |
5067 | +** nothing is written into *pHighwater and the resetFlag is ignored. | | 5071 | +** nothing is written into *pHighwater and the resetFlag is ignored. |
5068 | +** Other parameters record only the highwater mark and not the current | | 5072 | +** Other parameters record only the highwater mark and not the current |
5069 | +** value. For these latter parameters nothing is written into *pCurrent. | | 5073 | +** value. For these latter parameters nothing is written into *pCurrent. |
5070 | +** | | 5074 | +** |
5071 | +** This routine returns SQLITE_OK on success and a non-zero | | 5075 | +** This routine returns SQLITE_OK on success and a non-zero |
5072 | +** [error code] on failure. | | 5076 | +** [error code] on failure. |
5073 | +** | | 5077 | +** |
5074 | +** This routine is threadsafe but is not atomic. This routine can be | | 5078 | +** This routine is threadsafe but is not atomic. This routine can be |
5075 | +** called while other threads are running the same or different SQLite | | 5079 | +** called while other threads are running the same or different SQLite |
5076 | +** interfaces. However the values returned in *pCurrent and | | 5080 | +** interfaces. However the values returned in *pCurrent and |
5077 | +** *pHighwater reflect the status of SQLite at different points in time | | 5081 | +** *pHighwater reflect the status of SQLite at different points in time |
5078 | +** and it is possible that another thread might change the parameter | | 5082 | +** and it is possible that another thread might change the parameter |
5079 | +** in between the times when *pCurrent and *pHighwater are written. | | 5083 | +** in between the times when *pCurrent and *pHighwater are written. |
5080 | +** | | 5084 | +** |
5081 | +** See also: [sqlite3_db_status()] | | 5085 | +** See also: [sqlite3_db_status()] |
5082 | +*/ | | 5086 | +*/ |
5083 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); | | 5087 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); |
5084 | + | | 5088 | + |
5085 | + | | 5089 | + |
5086 | +/* | | 5090 | +/* |
5087 | +** CAPI3REF: Status Parameters {H17250} <H17200> | | 5091 | +** CAPI3REF: Status Parameters {H17250} <H17200> |
5088 | +** EXPERIMENTAL | | 5092 | +** EXPERIMENTAL |
5089 | +** | | 5093 | +** |
5090 | +** These integer constants designate various run-time status parameters | | 5094 | +** These integer constants designate various run-time status parameters |
5091 | +** that can be returned by [sqlite3_status()]. | | 5095 | +** that can be returned by [sqlite3_status()]. |
5092 | +** | | 5096 | +** |
5093 | +** <dl> | | 5097 | +** <dl> |
5094 | +** <dt>SQLITE_STATUS_MEMORY_USED</dt> | | 5098 | +** <dt>SQLITE_STATUS_MEMORY_USED</dt> |
5095 | +** <dd>This parameter is the current amount of memory checked out | | 5099 | +** <dd>This parameter is the current amount of memory checked out |
5096 | +** using [sqlite3_malloc()], either directly or indirectly. The | | 5100 | +** using [sqlite3_malloc()], either directly or indirectly. The |
5097 | +** figure includes calls made to [sqlite3_malloc()] by the application | | 5101 | +** figure includes calls made to [sqlite3_malloc()] by the application |
5098 | +** and internal memory usage by the SQLite library. Scratch memory | | 5102 | +** and internal memory usage by the SQLite library. Scratch memory |
5099 | +** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache | | 5103 | +** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache |
5100 | +** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in | | 5104 | +** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in |
5101 | +** this parameter. The amount returned is the sum of the allocation | | 5105 | +** this parameter. The amount returned is the sum of the allocation |
5102 | +** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd> | | 5106 | +** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd> |
5103 | +** | | 5107 | +** |
5104 | +** <dt>SQLITE_STATUS_MALLOC_SIZE</dt> | | 5108 | +** <dt>SQLITE_STATUS_MALLOC_SIZE</dt> |
5105 | +** <dd>This parameter records the largest memory allocation request | | 5109 | +** <dd>This parameter records the largest memory allocation request |
5106 | +** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their | | 5110 | +** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their |
5107 | +** internal equivalents). Only the value returned in the | | 5111 | +** internal equivalents). Only the value returned in the |
5108 | +** *pHighwater parameter to [sqlite3_status()] is of interest. | | 5112 | +** *pHighwater parameter to [sqlite3_status()] is of interest. |
5109 | +** The value written into the *pCurrent parameter is undefined.</dd> | | 5113 | +** The value written into the *pCurrent parameter is undefined.</dd> |
5110 | +** | | 5114 | +** |
5111 | +** <dt>SQLITE_STATUS_PAGECACHE_USED</dt> | | 5115 | +** <dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
5112 | +** <dd>This parameter returns the number of pages used out of the | | 5116 | +** <dd>This parameter returns the number of pages used out of the |
5113 | +** [pagecache memory allocator] that was configured using | | 5117 | +** [pagecache memory allocator] that was configured using |
5114 | +** [SQLITE_CONFIG_PAGECACHE]. The | | 5118 | +** [SQLITE_CONFIG_PAGECACHE]. The |
5115 | +** value returned is in pages, not in bytes.</dd> | | 5119 | +** value returned is in pages, not in bytes.</dd> |
5116 | +** | | 5120 | +** |
5117 | +** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> | | 5121 | +** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> |
5118 | +** <dd>This parameter returns the number of bytes of page cache | | 5122 | +** <dd>This parameter returns the number of bytes of page cache |
5119 | +** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] | | 5123 | +** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] |
5120 | +** buffer and where forced to overflow to [sqlite3_malloc()]. The | | 5124 | +** buffer and where forced to overflow to [sqlite3_malloc()]. The |
5121 | +** returned value includes allocations that overflowed because they | | 5125 | +** returned value includes allocations that overflowed because they |
5122 | +** where too large (they were larger than the "sz" parameter to | | 5126 | +** where too large (they were larger than the "sz" parameter to |
5123 | +** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because | | 5127 | +** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because |
5124 | +** no space was left in the page cache.</dd> | | 5128 | +** no space was left in the page cache.</dd> |
5125 | +** | | 5129 | +** |
5126 | +** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> | | 5130 | +** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> |
5127 | +** <dd>This parameter records the largest memory allocation request | | 5131 | +** <dd>This parameter records the largest memory allocation request |
5128 | +** handed to [pagecache memory allocator]. Only the value returned in the | | 5132 | +** handed to [pagecache memory allocator]. Only the value returned in the |
5129 | +** *pHighwater parameter to [sqlite3_status()] is of interest. | | 5133 | +** *pHighwater parameter to [sqlite3_status()] is of interest. |
5130 | +** The value written into the *pCurrent parameter is undefined.</dd> | | 5134 | +** The value written into the *pCurrent parameter is undefined.</dd> |
5131 | +** | | 5135 | +** |
5132 | +** <dt>SQLITE_STATUS_SCRATCH_USED</dt> | | 5136 | +** <dt>SQLITE_STATUS_SCRATCH_USED</dt> |
5133 | +** <dd>This parameter returns the number of allocations used out of the | | 5137 | +** <dd>This parameter returns the number of allocations used out of the |
5134 | +** [scratch memory allocator] configured using | | 5138 | +** [scratch memory allocator] configured using |
5135 | +** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not | | 5139 | +** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not |
5136 | +** in bytes. Since a single thread may only have one scratch allocation | | 5140 | +** in bytes. Since a single thread may only have one scratch allocation |
5137 | +** outstanding at time, this parameter also reports the number of threads | | 5141 | +** outstanding at time, this parameter also reports the number of threads |
5138 | +** using scratch memory at the same time.</dd> | | 5142 | +** using scratch memory at the same time.</dd> |
5139 | +** | | 5143 | +** |
5140 | +** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> | | 5144 | +** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> |
5141 | +** <dd>This parameter returns the number of bytes of scratch memory | | 5145 | +** <dd>This parameter returns the number of bytes of scratch memory |
5142 | +** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] | | 5146 | +** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] |
5143 | +** buffer and where forced to overflow to [sqlite3_malloc()]. The values | | 5147 | +** buffer and where forced to overflow to [sqlite3_malloc()]. The values |
5144 | +** returned include overflows because the requested allocation was too | | 5148 | +** returned include overflows because the requested allocation was too |
5145 | +** larger (that is, because the requested allocation was larger than the | | 5149 | +** larger (that is, because the requested allocation was larger than the |
5146 | +** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer | | 5150 | +** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer |
5147 | +** slots were available. | | 5151 | +** slots were available. |
5148 | +** </dd> | | 5152 | +** </dd> |
5149 | +** | | 5153 | +** |
5150 | +** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt> | | 5154 | +** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt> |
5151 | +** <dd>This parameter records the largest memory allocation request | | 5155 | +** <dd>This parameter records the largest memory allocation request |
5152 | +** handed to [scratch memory allocator]. Only the value returned in the | | 5156 | +** handed to [scratch memory allocator]. Only the value returned in the |
5153 | +** *pHighwater parameter to [sqlite3_status()] is of interest. | | 5157 | +** *pHighwater parameter to [sqlite3_status()] is of interest. |
5154 | +** The value written into the *pCurrent parameter is undefined.</dd> | | 5158 | +** The value written into the *pCurrent parameter is undefined.</dd> |
5155 | +** | | 5159 | +** |
5156 | +** <dt>SQLITE_STATUS_PARSER_STACK</dt> | | 5160 | +** <dt>SQLITE_STATUS_PARSER_STACK</dt> |
5157 | +** <dd>This parameter records the deepest parser stack. It is only | | 5161 | +** <dd>This parameter records the deepest parser stack. It is only |
5158 | +** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd> | | 5162 | +** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd> |
5159 | +** </dl> | | 5163 | +** </dl> |
5160 | +** | | 5164 | +** |
5161 | +** New status parameters may be added from time to time. | | 5165 | +** New status parameters may be added from time to time. |
5162 | +*/ | | 5166 | +*/ |
5163 | +#define SQLITE_STATUS_MEMORY_USED 0 | | 5167 | +#define SQLITE_STATUS_MEMORY_USED 0 |
5164 | +#define SQLITE_STATUS_PAGECACHE_USED 1 | | 5168 | +#define SQLITE_STATUS_PAGECACHE_USED 1 |
5165 | +#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 | | 5169 | +#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 |
5166 | +#define SQLITE_STATUS_SCRATCH_USED 3 | | 5170 | +#define SQLITE_STATUS_SCRATCH_USED 3 |
5167 | +#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 | | 5171 | +#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 |
5168 | +#define SQLITE_STATUS_MALLOC_SIZE 5 | | 5172 | +#define SQLITE_STATUS_MALLOC_SIZE 5 |
5169 | +#define SQLITE_STATUS_PARSER_STACK 6 | | 5173 | +#define SQLITE_STATUS_PARSER_STACK 6 |
5170 | +#define SQLITE_STATUS_PAGECACHE_SIZE 7 | | 5174 | +#define SQLITE_STATUS_PAGECACHE_SIZE 7 |
5171 | +#define SQLITE_STATUS_SCRATCH_SIZE 8 | | 5175 | +#define SQLITE_STATUS_SCRATCH_SIZE 8 |
5172 | + | | 5176 | + |
5173 | +/* | | 5177 | +/* |
5174 | +** CAPI3REF: Database Connection Status {H17500} <S60200> | | 5178 | +** CAPI3REF: Database Connection Status {H17500} <S60200> |
5175 | +** EXPERIMENTAL | | 5179 | +** EXPERIMENTAL |
5176 | +** | | 5180 | +** |
5177 | +** This interface is used to retrieve runtime status information | | 5181 | +** This interface is used to retrieve runtime status information |
5178 | +** about a single [database connection]. The first argument is the | | 5182 | +** about a single [database connection]. The first argument is the |
5179 | +** database connection object to be interrogated. The second argument | | 5183 | +** database connection object to be interrogated. The second argument |
5180 | +** is the parameter to interrogate. Currently, the only allowed value | | 5184 | +** is the parameter to interrogate. Currently, the only allowed value |
5181 | +** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED]. | | 5185 | +** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED]. |
5182 | +** Additional options will likely appear in future releases of SQLite. | | 5186 | +** Additional options will likely appear in future releases of SQLite. |
5183 | +** | | 5187 | +** |
5184 | +** The current value of the requested parameter is written into *pCur | | 5188 | +** The current value of the requested parameter is written into *pCur |
5185 | +** and the highest instantaneous value is written into *pHiwtr. If | | 5189 | +** and the highest instantaneous value is written into *pHiwtr. If |
5186 | +** the resetFlg is true, then the highest instantaneous value is | | 5190 | +** the resetFlg is true, then the highest instantaneous value is |
5187 | +** reset back down to the current value. | | 5191 | +** reset back down to the current value. |
5188 | +** | | 5192 | +** |
5189 | +** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. | | 5193 | +** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. |
5190 | +*/ | | 5194 | +*/ |
5191 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); | | 5195 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); |
5192 | + | | 5196 | + |
5193 | +/* | | 5197 | +/* |
5194 | +** CAPI3REF: Status Parameters for database connections {H17520} <H17500> | | 5198 | +** CAPI3REF: Status Parameters for database connections {H17520} <H17500> |
5195 | +** EXPERIMENTAL | | 5199 | +** EXPERIMENTAL |
5196 | +** | | 5200 | +** |
5197 | +** These constants are the available integer "verbs" that can be passed as | | 5201 | +** These constants are the available integer "verbs" that can be passed as |
5198 | +** the second argument to the [sqlite3_db_status()] interface. | | 5202 | +** the second argument to the [sqlite3_db_status()] interface. |
5199 | +** | | 5203 | +** |
5200 | +** New verbs may be added in future releases of SQLite. Existing verbs | | 5204 | +** New verbs may be added in future releases of SQLite. Existing verbs |
5201 | +** might be discontinued. Applications should check the return code from | | 5205 | +** might be discontinued. Applications should check the return code from |
5202 | +** [sqlite3_db_status()] to make sure that the call worked. | | 5206 | +** [sqlite3_db_status()] to make sure that the call worked. |
5203 | +** The [sqlite3_db_status()] interface will return a non-zero error code | | 5207 | +** The [sqlite3_db_status()] interface will return a non-zero error code |
5204 | +** if a discontinued or unsupported verb is invoked. | | 5208 | +** if a discontinued or unsupported verb is invoked. |
5205 | +** | | 5209 | +** |
5206 | +** <dl> | | 5210 | +** <dl> |
5207 | +** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> | | 5211 | +** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
5208 | +** <dd>This parameter returns the number of lookaside memory slots currently | | 5212 | +** <dd>This parameter returns the number of lookaside memory slots currently |
5209 | +** checked out.</dd> | | 5213 | +** checked out.</dd> |
5210 | +** </dl> | | 5214 | +** </dl> |
5211 | +*/ | | 5215 | +*/ |
5212 | +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | | 5216 | +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
5213 | + | | 5217 | + |
5214 | + | | 5218 | + |
5215 | +/* | | 5219 | +/* |
5216 | +** CAPI3REF: Prepared Statement Status {H17550} <S60200> | | 5220 | +** CAPI3REF: Prepared Statement Status {H17550} <S60200> |
5217 | +** EXPERIMENTAL | | 5221 | +** EXPERIMENTAL |
5218 | +** | | 5222 | +** |
5219 | +** Each prepared statement maintains various | | 5223 | +** Each prepared statement maintains various |
5220 | +** [SQLITE_STMTSTATUS_SORT | counters] that measure the number | | 5224 | +** [SQLITE_STMTSTATUS_SORT | counters] that measure the number |
5221 | +** of times it has performed specific operations. These counters can | | 5225 | +** of times it has performed specific operations. These counters can |
5222 | +** be used to monitor the performance characteristics of the prepared | | 5226 | +** be used to monitor the performance characteristics of the prepared |
5223 | +** statements. For example, if the number of table steps greatly exceeds | | 5227 | +** statements. For example, if the number of table steps greatly exceeds |
5224 | +** the number of table searches or result rows, that would tend to indicate | | 5228 | +** the number of table searches or result rows, that would tend to indicate |
5225 | +** that the prepared statement is using a full table scan rather than | | 5229 | +** that the prepared statement is using a full table scan rather than |
5226 | +** an index. | | 5230 | +** an index. |
5227 | +** | | 5231 | +** |
5228 | +** This interface is used to retrieve and reset counter values from | | 5232 | +** This interface is used to retrieve and reset counter values from |
5229 | +** a [prepared statement]. The first argument is the prepared statement | | 5233 | +** a [prepared statement]. The first argument is the prepared statement |
5230 | +** object to be interrogated. The second argument | | 5234 | +** object to be interrogated. The second argument |
5231 | +** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter] | | 5235 | +** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter] |
5232 | +** to be interrogated. | | 5236 | +** to be interrogated. |
5233 | +** The current value of the requested counter is returned. | | 5237 | +** The current value of the requested counter is returned. |
5234 | +** If the resetFlg is true, then the counter is reset to zero after this | | 5238 | +** If the resetFlg is true, then the counter is reset to zero after this |
5235 | +** interface call returns. | | 5239 | +** interface call returns. |
5236 | +** | | 5240 | +** |
5237 | +** See also: [sqlite3_status()] and [sqlite3_db_status()]. | | 5241 | +** See also: [sqlite3_status()] and [sqlite3_db_status()]. |
5238 | +*/ | | 5242 | +*/ |
5239 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); | | 5243 | +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); |
5240 | + | | 5244 | + |
5241 | +/* | | 5245 | +/* |
5242 | +** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550> | | 5246 | +** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550> |
5243 | +** EXPERIMENTAL | | 5247 | +** EXPERIMENTAL |
5244 | +** | | 5248 | +** |
5245 | +** These preprocessor macros define integer codes that name counter | | 5249 | +** These preprocessor macros define integer codes that name counter |
5246 | +** values associated with the [sqlite3_stmt_status()] interface. | | 5250 | +** values associated with the [sqlite3_stmt_status()] interface. |
5247 | +** The meanings of the various counters are as follows: | | 5251 | +** The meanings of the various counters are as follows: |
5248 | +** | | 5252 | +** |
5249 | +** <dl> | | 5253 | +** <dl> |
5250 | +** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt> | | 5254 | +** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt> |
5251 | +** <dd>This is the number of times that SQLite has stepped forward in | | 5255 | +** <dd>This is the number of times that SQLite has stepped forward in |
5252 | +** a table as part of a full table scan. Large numbers for this counter | | 5256 | +** a table as part of a full table scan. Large numbers for this counter |
5253 | +** may indicate opportunities for performance improvement through | | 5257 | +** may indicate opportunities for performance improvement through |
5254 | +** careful use of indices.</dd> | | 5258 | +** careful use of indices.</dd> |
5255 | +** | | 5259 | +** |
5256 | +** <dt>SQLITE_STMTSTATUS_SORT</dt> | | 5260 | +** <dt>SQLITE_STMTSTATUS_SORT</dt> |
5257 | +** <dd>This is the number of sort operations that have occurred. | | 5261 | +** <dd>This is the number of sort operations that have occurred. |
5258 | +** A non-zero value in this counter may indicate an opportunity to | | 5262 | +** A non-zero value in this counter may indicate an opportunity to |
5259 | +** improvement performance through careful use of indices.</dd> | | 5263 | +** improvement performance through careful use of indices.</dd> |
5260 | +** | | 5264 | +** |
5261 | +** </dl> | | 5265 | +** </dl> |
5262 | +*/ | | 5266 | +*/ |
5263 | +#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 | | 5267 | +#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
5264 | +#define SQLITE_STMTSTATUS_SORT 2 | | 5268 | +#define SQLITE_STMTSTATUS_SORT 2 |
5265 | + | | 5269 | + |
5266 | +/* | | 5270 | +/* |
5267 | +** CAPI3REF: Custom Page Cache Object | | 5271 | +** CAPI3REF: Custom Page Cache Object |
5268 | +** EXPERIMENTAL | | 5272 | +** EXPERIMENTAL |
5269 | +** | | 5273 | +** |
5270 | +** The sqlite3_pcache type is opaque. It is implemented by | | 5274 | +** The sqlite3_pcache type is opaque. It is implemented by |
5271 | +** the pluggable module. The SQLite core has no knowledge of | | 5275 | +** the pluggable module. The SQLite core has no knowledge of |
5272 | +** its size or internal structure and never deals with the | | 5276 | +** its size or internal structure and never deals with the |
5273 | +** sqlite3_pcache object except by holding and passing pointers | | 5277 | +** sqlite3_pcache object except by holding and passing pointers |
5274 | +** to the object. | | 5278 | +** to the object. |
5275 | +** | | 5279 | +** |
5276 | +** See [sqlite3_pcache_methods] for additional information. | | 5280 | +** See [sqlite3_pcache_methods] for additional information. |
5277 | +*/ | | 5281 | +*/ |
5278 | +typedef struct sqlite3_pcache sqlite3_pcache; | | 5282 | +typedef struct sqlite3_pcache sqlite3_pcache; |
5279 | + | | 5283 | + |
5280 | +/* | | 5284 | +/* |
5281 | +** CAPI3REF: Application Defined Page Cache. | | 5285 | +** CAPI3REF: Application Defined Page Cache. |
5282 | +** KEYWORDS: {page cache} | | 5286 | +** KEYWORDS: {page cache} |
5283 | +** EXPERIMENTAL | | 5287 | +** EXPERIMENTAL |
5284 | +** | | 5288 | +** |
5285 | +** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can | | 5289 | +** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can |
5286 | +** register an alternative page cache implementation by passing in an | | 5290 | +** register an alternative page cache implementation by passing in an |
5287 | +** instance of the sqlite3_pcache_methods structure. The majority of the | | 5291 | +** instance of the sqlite3_pcache_methods structure. The majority of the |
5288 | +** heap memory used by SQLite is used by the page cache to cache data read | | 5292 | +** heap memory used by SQLite is used by the page cache to cache data read |
5289 | +** from, or ready to be written to, the database file. By implementing a | | 5293 | +** from, or ready to be written to, the database file. By implementing a |
5290 | +** custom page cache using this API, an application can control more | | 5294 | +** custom page cache using this API, an application can control more |
5291 | +** precisely the amount of memory consumed by SQLite, the way in which | | 5295 | +** precisely the amount of memory consumed by SQLite, the way in which |
5292 | +** that memory is allocated and released, and the policies used to | | 5296 | +** that memory is allocated and released, and the policies used to |
5293 | +** determine exactly which parts of a database file are cached and for | | 5297 | +** determine exactly which parts of a database file are cached and for |
5294 | +** how long. | | 5298 | +** how long. |
5295 | +** | | 5299 | +** |
5296 | +** The contents of the sqlite3_pcache_methods structure are copied to an | | 5300 | +** The contents of the sqlite3_pcache_methods structure are copied to an |
5297 | +** internal buffer by SQLite within the call to [sqlite3_config]. Hence | | 5301 | +** internal buffer by SQLite within the call to [sqlite3_config]. Hence |
5298 | +** the application may discard the parameter after the call to | | 5302 | +** the application may discard the parameter after the call to |
5299 | +** [sqlite3_config()] returns. | | 5303 | +** [sqlite3_config()] returns. |
5300 | +** | | 5304 | +** |
5301 | +** The xInit() method is called once for each call to [sqlite3_initialize()] | | 5305 | +** The xInit() method is called once for each call to [sqlite3_initialize()] |
5302 | +** (usually only once during the lifetime of the process). It is passed | | 5306 | +** (usually only once during the lifetime of the process). It is passed |
5303 | +** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set | | 5307 | +** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set |
5304 | +** up global structures and mutexes required by the custom page cache | | 5308 | +** up global structures and mutexes required by the custom page cache |
5305 | +** implementation. | | 5309 | +** implementation. |
5306 | +** | | 5310 | +** |
5307 | +** The xShutdown() method is called from within [sqlite3_shutdown()], | | 5311 | +** The xShutdown() method is called from within [sqlite3_shutdown()], |
5308 | +** if the application invokes this API. It can be used to clean up | | 5312 | +** if the application invokes this API. It can be used to clean up |
5309 | +** any outstanding resources before process shutdown, if required. | | 5313 | +** any outstanding resources before process shutdown, if required. |
5310 | +** | | 5314 | +** |
5311 | +** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes | | 5315 | +** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes |
5312 | +** the xInit method, so the xInit method need not be threadsafe. The | | 5316 | +** the xInit method, so the xInit method need not be threadsafe. The |
5313 | +** xShutdown method is only called from [sqlite3_shutdown()] so it does | | 5317 | +** xShutdown method is only called from [sqlite3_shutdown()] so it does |
5314 | +** not need to be threadsafe either. All other methods must be threadsafe | | 5318 | +** not need to be threadsafe either. All other methods must be threadsafe |
5315 | +** in multithreaded applications. | | 5319 | +** in multithreaded applications. |
5316 | +** | | 5320 | +** |
5317 | +** SQLite will never invoke xInit() more than once without an intervening | | 5321 | +** SQLite will never invoke xInit() more than once without an intervening |
5318 | +** call to xShutdown(). | | 5322 | +** call to xShutdown(). |
5319 | +** | | 5323 | +** |
5320 | +** The xCreate() method is used to construct a new cache instance. SQLite | | 5324 | +** The xCreate() method is used to construct a new cache instance. SQLite |
5321 | +** will typically create one cache instance for each open database file, | | 5325 | +** will typically create one cache instance for each open database file, |
5322 | +** though this is not guaranteed. The | | 5326 | +** though this is not guaranteed. The |
5323 | +** first parameter, szPage, is the size in bytes of the pages that must | | 5327 | +** first parameter, szPage, is the size in bytes of the pages that must |
5324 | +** be allocated by the cache. szPage will not be a power of two. szPage | | 5328 | +** be allocated by the cache. szPage will not be a power of two. szPage |
5325 | +** will the page size of the database file that is to be cached plus an | | 5329 | +** will the page size of the database file that is to be cached plus an |
5326 | +** increment (here called "R") of about 100 or 200. SQLite will use the | | 5330 | +** increment (here called "R") of about 100 or 200. SQLite will use the |
5327 | +** extra R bytes on each page to store metadata about the underlying | | 5331 | +** extra R bytes on each page to store metadata about the underlying |
5328 | +** database page on disk. The value of R depends | | 5332 | +** database page on disk. The value of R depends |
5329 | +** on the SQLite version, the target platform, and how SQLite was compiled. | | 5333 | +** on the SQLite version, the target platform, and how SQLite was compiled. |
5330 | +** R is constant for a particular build of SQLite. The second argument to | | 5334 | +** R is constant for a particular build of SQLite. The second argument to |
5331 | +** xCreate(), bPurgeable, is true if the cache being created will | | 5335 | +** xCreate(), bPurgeable, is true if the cache being created will |
5332 | +** be used to cache database pages of a file stored on disk, or | | 5336 | +** be used to cache database pages of a file stored on disk, or |
5333 | +** false if it is used for an in-memory database. The cache implementation | | 5337 | +** false if it is used for an in-memory database. The cache implementation |
5334 | +** does not have to do anything special based with the value of bPurgeable; | | 5338 | +** does not have to do anything special based with the value of bPurgeable; |
5335 | +** it is purely advisory. On a cache where bPurgeable is false, SQLite will | | 5339 | +** it is purely advisory. On a cache where bPurgeable is false, SQLite will |
5336 | +** never invoke xUnpin() except to deliberately delete a page. | | 5340 | +** never invoke xUnpin() except to deliberately delete a page. |
5337 | +** In other words, a cache created with bPurgeable set to false will | | 5341 | +** In other words, a cache created with bPurgeable set to false will |
5338 | +** never contain any unpinned pages. | | 5342 | +** never contain any unpinned pages. |
5339 | +** | | 5343 | +** |
5340 | +** The xCachesize() method may be called at any time by SQLite to set the | | 5344 | +** The xCachesize() method may be called at any time by SQLite to set the |
5341 | +** suggested maximum cache-size (number of pages stored by) the cache | | 5345 | +** suggested maximum cache-size (number of pages stored by) the cache |
5342 | +** instance passed as the first argument. This is the value configured using | | 5346 | +** instance passed as the first argument. This is the value configured using |
5343 | +** the SQLite "[PRAGMA cache_size]" command. As with the bPurgeable parameter, | | 5347 | +** the SQLite "[PRAGMA cache_size]" command. As with the bPurgeable parameter, |
5344 | +** the implementation is not required to do anything with this | | 5348 | +** the implementation is not required to do anything with this |
5345 | +** value; it is advisory only. | | 5349 | +** value; it is advisory only. |
5346 | +** | | 5350 | +** |
5347 | +** The xPagecount() method should return the number of pages currently | | 5351 | +** The xPagecount() method should return the number of pages currently |
5348 | +** stored in the cache. | | 5352 | +** stored in the cache. |
5349 | +** | | 5353 | +** |
5350 | +** The xFetch() method is used to fetch a page and return a pointer to it. | | 5354 | +** The xFetch() method is used to fetch a page and return a pointer to it. |
5351 | +** A 'page', in this context, is a buffer of szPage bytes aligned at an | | 5355 | +** A 'page', in this context, is a buffer of szPage bytes aligned at an |
5352 | +** 8-byte boundary. The page to be fetched is determined by the key. The | | 5356 | +** 8-byte boundary. The page to be fetched is determined by the key. The |
5353 | +** mimimum key value is 1. After it has been retrieved using xFetch, the page | | 5357 | +** mimimum key value is 1. After it has been retrieved using xFetch, the page |
5354 | +** is considered to be "pinned". | | 5358 | +** is considered to be "pinned". |
5355 | +** | | 5359 | +** |
5356 | +** If the requested page is already in the page cache, then the page cache | | 5360 | +** If the requested page is already in the page cache, then the page cache |
5357 | +** implementation must return a pointer to the page buffer with its content | | 5361 | +** implementation must return a pointer to the page buffer with its content |
5358 | +** intact. If the requested page is not already in the cache, then the | | 5362 | +** intact. If the requested page is not already in the cache, then the |
5359 | +** behavior of the cache implementation is determined by the value of the | | 5363 | +** behavior of the cache implementation is determined by the value of the |
5360 | +** createFlag parameter passed to xFetch, according to the following table: | | 5364 | +** createFlag parameter passed to xFetch, according to the following table: |
5361 | +** | | 5365 | +** |
5362 | +** <table border=1 width=85% align=center> | | 5366 | +** <table border=1 width=85% align=center> |
5363 | +** <tr><th> createFlag <th> Behaviour when page is not already in cache | | 5367 | +** <tr><th> createFlag <th> Behaviour when page is not already in cache |
5364 | +** <tr><td> 0 <td> Do not allocate a new page. Return NULL. | | 5368 | +** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
5365 | +** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. | | 5369 | +** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
5366 | +** Otherwise return NULL. | | 5370 | +** Otherwise return NULL. |
5367 | +** <tr><td> 2 <td> Make every effort to allocate a new page. Only return | | 5371 | +** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
5368 | +** NULL if allocating a new page is effectively impossible. | | 5372 | +** NULL if allocating a new page is effectively impossible. |
5369 | +** </table> | | 5373 | +** </table> |
5370 | +** | | 5374 | +** |
5371 | +** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If | | 5375 | +** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If |
5372 | +** a call to xFetch() with createFlag==1 returns NULL, then SQLite will | | 5376 | +** a call to xFetch() with createFlag==1 returns NULL, then SQLite will |
5373 | +** attempt to unpin one or more cache pages by spilling the content of | | 5377 | +** attempt to unpin one or more cache pages by spilling the content of |
5374 | +** pinned pages to disk and synching the operating system disk cache. After | | 5378 | +** pinned pages to disk and synching the operating system disk cache. After |
5375 | +** attempting to unpin pages, the xFetch() method will be invoked again with | | 5379 | +** attempting to unpin pages, the xFetch() method will be invoked again with |
5376 | +** a createFlag of 2. | | 5380 | +** a createFlag of 2. |
5377 | +** | | 5381 | +** |
5378 | +** xUnpin() is called by SQLite with a pointer to a currently pinned page | | 5382 | +** xUnpin() is called by SQLite with a pointer to a currently pinned page |
5379 | +** as its second argument. If the third parameter, discard, is non-zero, | | 5383 | +** as its second argument. If the third parameter, discard, is non-zero, |
5380 | +** then the page should be evicted from the cache. In this case SQLite | | 5384 | +** then the page should be evicted from the cache. In this case SQLite |
5381 | +** assumes that the next time the page is retrieved from the cache using | | 5385 | +** assumes that the next time the page is retrieved from the cache using |
5382 | +** the xFetch() method, it will be zeroed. If the discard parameter is | | 5386 | +** the xFetch() method, it will be zeroed. If the discard parameter is |
5383 | +** zero, then the page is considered to be unpinned. The cache implementation | | 5387 | +** zero, then the page is considered to be unpinned. The cache implementation |
5384 | +** may choose to evict unpinned pages at any time. | | 5388 | +** may choose to evict unpinned pages at any time. |
5385 | +** | | 5389 | +** |
5386 | +** The cache is not required to perform any reference counting. A single | | 5390 | +** The cache is not required to perform any reference counting. A single |
5387 | +** call to xUnpin() unpins the page regardless of the number of prior calls | | 5391 | +** call to xUnpin() unpins the page regardless of the number of prior calls |
5388 | +** to xFetch(). | | 5392 | +** to xFetch(). |
5389 | +** | | 5393 | +** |
5390 | +** The xRekey() method is used to change the key value associated with the | | 5394 | +** The xRekey() method is used to change the key value associated with the |
5391 | +** page passed as the second argument from oldKey to newKey. If the cache | | 5395 | +** page passed as the second argument from oldKey to newKey. If the cache |
5392 | +** previously contains an entry associated with newKey, it should be | | 5396 | +** previously contains an entry associated with newKey, it should be |
5393 | +** discarded. Any prior cache entry associated with newKey is guaranteed not | | 5397 | +** discarded. Any prior cache entry associated with newKey is guaranteed not |
5394 | +** to be pinned. | | 5398 | +** to be pinned. |
5395 | +** | | 5399 | +** |
5396 | +** When SQLite calls the xTruncate() method, the cache must discard all | | 5400 | +** When SQLite calls the xTruncate() method, the cache must discard all |
5397 | +** existing cache entries with page numbers (keys) greater than or equal | | 5401 | +** existing cache entries with page numbers (keys) greater than or equal |
5398 | +** to the value of the iLimit parameter passed to xTruncate(). If any | | 5402 | +** to the value of the iLimit parameter passed to xTruncate(). If any |
5399 | +** of these pages are pinned, they are implicitly unpinned, meaning that | | 5403 | +** of these pages are pinned, they are implicitly unpinned, meaning that |
5400 | +** they can be safely discarded. | | 5404 | +** they can be safely discarded. |
5401 | +** | | 5405 | +** |
5402 | +** The xDestroy() method is used to delete a cache allocated by xCreate(). | | 5406 | +** The xDestroy() method is used to delete a cache allocated by xCreate(). |
5403 | +** All resources associated with the specified cache should be freed. After | | 5407 | +** All resources associated with the specified cache should be freed. After |
5404 | +** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] | | 5408 | +** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
5405 | +** handle invalid, and will not use it with any other sqlite3_pcache_methods | | 5409 | +** handle invalid, and will not use it with any other sqlite3_pcache_methods |
5406 | +** functions. | | 5410 | +** functions. |
5407 | +*/ | | 5411 | +*/ |
5408 | +typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; | | 5412 | +typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; |
5409 | +struct sqlite3_pcache_methods { | | 5413 | +struct sqlite3_pcache_methods { |
5410 | + void *pArg; | | 5414 | + void *pArg; |
5411 | + int (*xInit)(void*); | | 5415 | + int (*xInit)(void*); |
5412 | + void (*xShutdown)(void*); | | 5416 | + void (*xShutdown)(void*); |
5413 | + sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); | | 5417 | + sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); |
5414 | + void (*xCachesize)(sqlite3_pcache*, int nCachesize); | | 5418 | + void (*xCachesize)(sqlite3_pcache*, int nCachesize); |
5415 | + int (*xPagecount)(sqlite3_pcache*); | | 5419 | + int (*xPagecount)(sqlite3_pcache*); |
5416 | + void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); | | 5420 | + void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); |
5417 | + void (*xUnpin)(sqlite3_pcache*, void*, int discard); | | 5421 | + void (*xUnpin)(sqlite3_pcache*, void*, int discard); |
5418 | + void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); | | 5422 | + void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); |
5419 | + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); | | 5423 | + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); |
5420 | + void (*xDestroy)(sqlite3_pcache*); | | 5424 | + void (*xDestroy)(sqlite3_pcache*); |
5421 | +}; | | 5425 | +}; |
5422 | + | | 5426 | + |
5423 | +/* | | 5427 | +/* |
5424 | +** CAPI3REF: Online Backup Object | | 5428 | +** CAPI3REF: Online Backup Object |
5425 | +** EXPERIMENTAL | | 5429 | +** EXPERIMENTAL |
5426 | +** | | 5430 | +** |
5427 | +** The sqlite3_backup object records state information about an ongoing | | 5431 | +** The sqlite3_backup object records state information about an ongoing |
5428 | +** online backup operation. The sqlite3_backup object is created by | | 5432 | +** online backup operation. The sqlite3_backup object is created by |
5429 | +** a call to [sqlite3_backup_init()] and is destroyed by a call to | | 5433 | +** a call to [sqlite3_backup_init()] and is destroyed by a call to |
5430 | +** [sqlite3_backup_finish()]. | | 5434 | +** [sqlite3_backup_finish()]. |
5431 | +** | | 5435 | +** |
5432 | +** See Also: [Using the SQLite Online Backup API] | | 5436 | +** See Also: [Using the SQLite Online Backup API] |
5433 | +*/ | | 5437 | +*/ |
5434 | +typedef struct sqlite3_backup sqlite3_backup; | | 5438 | +typedef struct sqlite3_backup sqlite3_backup; |
5435 | + | | 5439 | + |
5436 | +/* | | 5440 | +/* |
5437 | +** CAPI3REF: Online Backup API. | | 5441 | +** CAPI3REF: Online Backup API. |
5438 | +** EXPERIMENTAL | | 5442 | +** EXPERIMENTAL |
5439 | +** | | 5443 | +** |
5440 | +** This API is used to overwrite the contents of one database with that | | 5444 | +** This API is used to overwrite the contents of one database with that |
5441 | +** of another. It is useful either for creating backups of databases or | | 5445 | +** of another. It is useful either for creating backups of databases or |
5442 | +** for copying in-memory databases to or from persistent files. | | 5446 | +** for copying in-memory databases to or from persistent files. |
5443 | +** | | 5447 | +** |
5444 | +** See Also: [Using the SQLite Online Backup API] | | 5448 | +** See Also: [Using the SQLite Online Backup API] |
5445 | +** | | 5449 | +** |
5446 | +** Exclusive access is required to the destination database for the | | 5450 | +** Exclusive access is required to the destination database for the |
5447 | +** duration of the operation. However the source database is only | | 5451 | +** duration of the operation. However the source database is only |
5448 | +** read-locked while it is actually being read, it is not locked | | 5452 | +** read-locked while it is actually being read, it is not locked |
5449 | +** continuously for the entire operation. Thus, the backup may be | | 5453 | +** continuously for the entire operation. Thus, the backup may be |
5450 | +** performed on a live database without preventing other users from | | 5454 | +** performed on a live database without preventing other users from |
5451 | +** writing to the database for an extended period of time. | | 5455 | +** writing to the database for an extended period of time. |
5452 | +** | | 5456 | +** |
5453 | +** To perform a backup operation: | | 5457 | +** To perform a backup operation: |
5454 | +** <ol> | | 5458 | +** <ol> |
5455 | +** <li><b>sqlite3_backup_init()</b> is called once to initialize the | | 5459 | +** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
5456 | +** backup, | | 5460 | +** backup, |
5457 | +** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer | | 5461 | +** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer |
5458 | +** the data between the two databases, and finally | | 5462 | +** the data between the two databases, and finally |
5459 | +** <li><b>sqlite3_backup_finish()</b> is called to release all resources | | 5463 | +** <li><b>sqlite3_backup_finish()</b> is called to release all resources |
5460 | +** associated with the backup operation. | | 5464 | +** associated with the backup operation. |
5461 | +** </ol> | | 5465 | +** </ol> |
5462 | +** There should be exactly one call to sqlite3_backup_finish() for each | | 5466 | +** There should be exactly one call to sqlite3_backup_finish() for each |
5463 | +** successful call to sqlite3_backup_init(). | | 5467 | +** successful call to sqlite3_backup_init(). |
5464 | +** | | 5468 | +** |
5465 | +** <b>sqlite3_backup_init()</b> | | 5469 | +** <b>sqlite3_backup_init()</b> |
5466 | +** | | 5470 | +** |
5467 | +** The first two arguments passed to [sqlite3_backup_init()] are the database | | 5471 | +** The first two arguments passed to [sqlite3_backup_init()] are the database |
5468 | +** handle associated with the destination database and the database name | | 5472 | +** handle associated with the destination database and the database name |
5469 | +** used to attach the destination database to the handle. The database name | | 5473 | +** used to attach the destination database to the handle. The database name |
5470 | +** is "main" for the main database, "temp" for the temporary database, or | | 5474 | +** is "main" for the main database, "temp" for the temporary database, or |
5471 | +** the name specified as part of the [ATTACH] statement if the destination is | | 5475 | +** the name specified as part of the [ATTACH] statement if the destination is |
5472 | +** an attached database. The third and fourth arguments passed to | | 5476 | +** an attached database. The third and fourth arguments passed to |
5473 | +** sqlite3_backup_init() identify the [database connection] | | 5477 | +** sqlite3_backup_init() identify the [database connection] |
5474 | +** and database name used | | 5478 | +** and database name used |
5475 | +** to access the source database. The values passed for the source and | | 5479 | +** to access the source database. The values passed for the source and |
5476 | +** destination [database connection] parameters must not be the same. | | 5480 | +** destination [database connection] parameters must not be the same. |
5477 | +** | | 5481 | +** |
5478 | +** If an error occurs within sqlite3_backup_init(), then NULL is returned | | 5482 | +** If an error occurs within sqlite3_backup_init(), then NULL is returned |
5479 | +** and an error code and error message written into the [database connection] | | 5483 | +** and an error code and error message written into the [database connection] |
5480 | +** passed as the first argument. They may be retrieved using the | | 5484 | +** passed as the first argument. They may be retrieved using the |
5481 | +** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions. | | 5485 | +** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions. |
5482 | +** Otherwise, if successful, a pointer to an [sqlite3_backup] object is | | 5486 | +** Otherwise, if successful, a pointer to an [sqlite3_backup] object is |
5483 | +** returned. This pointer may be used with the sqlite3_backup_step() and | | 5487 | +** returned. This pointer may be used with the sqlite3_backup_step() and |
5484 | +** sqlite3_backup_finish() functions to perform the specified backup | | 5488 | +** sqlite3_backup_finish() functions to perform the specified backup |
5485 | +** operation. | | 5489 | +** operation. |
5486 | +** | | 5490 | +** |
5487 | +** <b>sqlite3_backup_step()</b> | | 5491 | +** <b>sqlite3_backup_step()</b> |
5488 | +** | | 5492 | +** |
5489 | +** Function [sqlite3_backup_step()] is used to copy up to nPage pages between | | 5493 | +** Function [sqlite3_backup_step()] is used to copy up to nPage pages between |
5490 | +** the source and destination databases, where nPage is the value of the | | 5494 | +** the source and destination databases, where nPage is the value of the |
5491 | +** second parameter passed to sqlite3_backup_step(). If nPage is a negative | | 5495 | +** second parameter passed to sqlite3_backup_step(). If nPage is a negative |
5492 | +** value, all remaining source pages are copied. If the required pages are | | 5496 | +** value, all remaining source pages are copied. If the required pages are |
5493 | +** succesfully copied, but there are still more pages to copy before the | | 5497 | +** succesfully copied, but there are still more pages to copy before the |
5494 | +** backup is complete, it returns [SQLITE_OK]. If no error occured and there | | 5498 | +** backup is complete, it returns [SQLITE_OK]. If no error occured and there |
5495 | +** are no more pages to copy, then [SQLITE_DONE] is returned. If an error | | 5499 | +** are no more pages to copy, then [SQLITE_DONE] is returned. If an error |
5496 | +** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and | | 5500 | +** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and |
5497 | +** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], | | 5501 | +** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
5498 | +** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an | | 5502 | +** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an |
5499 | +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. | | 5503 | +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. |
5500 | +** | | 5504 | +** |
5501 | +** As well as the case where the destination database file was opened for | | 5505 | +** As well as the case where the destination database file was opened for |
5502 | +** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if | | 5506 | +** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if |
5503 | +** the destination is an in-memory database with a different page size | | 5507 | +** the destination is an in-memory database with a different page size |
5504 | +** from the source database. | | 5508 | +** from the source database. |
5505 | +** | | 5509 | +** |
5506 | +** If sqlite3_backup_step() cannot obtain a required file-system lock, then | | 5510 | +** If sqlite3_backup_step() cannot obtain a required file-system lock, then |
5507 | +** the [sqlite3_busy_handler | busy-handler function] | | 5511 | +** the [sqlite3_busy_handler | busy-handler function] |
5508 | +** is invoked (if one is specified). If the | | 5512 | +** is invoked (if one is specified). If the |
5509 | +** busy-handler returns non-zero before the lock is available, then | | 5513 | +** busy-handler returns non-zero before the lock is available, then |
5510 | +** [SQLITE_BUSY] is returned to the caller. In this case the call to | | 5514 | +** [SQLITE_BUSY] is returned to the caller. In this case the call to |
5511 | +** sqlite3_backup_step() can be retried later. If the source | | 5515 | +** sqlite3_backup_step() can be retried later. If the source |
5512 | +** [database connection] | | 5516 | +** [database connection] |
5513 | +** is being used to write to the source database when sqlite3_backup_step() | | 5517 | +** is being used to write to the source database when sqlite3_backup_step() |
5514 | +** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this | | 5518 | +** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this |
5515 | +** case the call to sqlite3_backup_step() can be retried later on. If | | 5519 | +** case the call to sqlite3_backup_step() can be retried later on. If |
5516 | +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or | | 5520 | +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or |
5517 | +** [SQLITE_READONLY] is returned, then | | 5521 | +** [SQLITE_READONLY] is returned, then |