Debian Codegraph @

www/capi3ref.html

raw
1 <!DOCTYPE html>
2 <html><head>
3 <meta name="viewport" content="width=device-width, initial-scale=1.0">
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 <link href="sqlite.css" rel="stylesheet">
6 <title>C/C++ Interface For SQLite Version 3</title>
7 <!-- path= -->
8 </head>
9 <body>
10 <div class=nosearch>
11 <a href="index.html">
12 <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
13 </a>
14 <div><!-- IE hack to prevent disappearing logo --></div>
15 <div class="tagline desktoponly">
16 Small. Fast. Reliable.<br>Choose any three.
17 </div>
18 <div class="menu mainmenu">
19 <ul>
20 <li><a href="index.html">Home</a>
21 <li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
22 <li class='wideonly'><a href='about.html'>About</a>
23 <li class='desktoponly'><a href="docs.html">Documentation</a>
24 <li class='desktoponly'><a href="download.html">Download</a>
25 <li class='wideonly'><a href='copyright.html'>License</a>
26 <li class='desktoponly'><a href="support.html">Support</a>
27 <li class='desktoponly'><a href="prosupport.html">Purchase</a>
28 <li class='search' id='search_menubutton'>
29 <a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
30 </ul>
31 </div>
32 <div class="menu submenu" id="submenu">
33 <ul>
34 <li><a href='about.html'>About</a>
35 <li><a href='docs.html'>Documentation</a>
36 <li><a href='download.html'>Download</a>
37 <li><a href='support.html'>Support</a>
38 <li><a href='prosupport.html'>Purchase</a>
39 </ul>
40 </div>
41 <div class="searchmenu" id="searchmenu">
42 <form method="GET" action="search">
43 <select name="s" id="searchtype">
44 <option value="d">Search Documentation</option>
45 <option value="c">Search Changelog</option>
46 </select>
47 <input type="text" name="q" id="searchbox" value="">
48 <input type="submit" value="Go">
49 </form>
50 </div>
51 </div>
52 <script>
53 function toggle_div(nm) {
54 var w = document.getElementById(nm);
55 if( w.style.display=="block" ){
56 w.style.display = "none";
57 }else{
58 w.style.display = "block";
59 }
60 }
61 function toggle_search() {
62 var w = document.getElementById("searchmenu");
63 if( w.style.display=="block" ){
64 w.style.display = "none";
65 } else {
66 w.style.display = "block";
67 setTimeout(function(){
68 document.getElementById("searchbox").focus()
69 }, 30);
70 }
71 }
72 function div_off(nm){document.getElementById(nm).style.display="none";}
73 window.onbeforeunload = function(e){div_off("submenu");}
74 /* Disable the Search feature if we are not operating from CGI, since */
75 /* Search is accomplished using CGI and will not work without it. */
76 if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
77 document.getElementById("search_menubutton").style.display = "none";
78 }
79 /* Used by the Hide/Show button beside syntax diagrams, to toggle the */
80 function hideorshow(btn,obj){
81 var x = document.getElementById(obj);
82 var b = document.getElementById(btn);
83 if( x.style.display!='none' ){
84 x.style.display = 'none';
85 b.innerHTML='show';
86 }else{
87 x.style.display = '';
88 b.innerHTML='hide';
89 }
90 return false;
91 }
92 var antiRobot = 0;
93 function antiRobotGo(){
94 if( antiRobot!=3 ) return;
95 antiRobot = 7;
96 var j = document.getElementById("mtimelink");
97 if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");
98 }
99 function antiRobotDefense(){
100 document.body.onmousedown=function(){
101 antiRobot |= 2;
102 antiRobotGo();
103 document.body.onmousedown=null;
104 }
105 document.body.onmousemove=function(){
106 antiRobot |= 2;
107 antiRobotGo();
108 document.body.onmousemove=null;
109 }
110 setTimeout(function(){
111 antiRobot |= 1;
112 antiRobotGo();
113 }, 100)
114 antiRobotGo();
115 }
116 antiRobotDefense();
117 </script>
118
119
120
121
122 <h1 align="center">
123 C-language Interface Specification for SQLite
124 </h1>
125
126 <p>This page is intended to be a precise and detailed specification.
127 For a tutorial introductions, see instead:
128 <ul>
129 <li><a href="quickstart.html">SQLite In 3 Minutes Or Less</a> and/or
130 <li>the <a href="cintro.html">Introduction To The SQLite C/C++ Interface</a>.
131 </ul>
132 This same content is also available split out into
133 <a href="../c3ref/intro.html">some smaller pages</a>.</p>
134
135 <hr>
136
137
138
139 <h2>Experimental And Deprecated Interfaces</h2>
140
141 <p>SQLite interfaces can be subdivided into three categories:</p>
142
143 <ol>
144 <li>Stable</li>
145 <li>Experimental</li>
146 <li>Deprecated</li>
147 </ol>
148
149 <p>Stable interfaces will be maintained indefinitely in a backwards
150 compatible way. An application that uses only stable interfaces
151 should always be able to relink against a newer version of SQLite
152 without any changes.</p>
153
154 <p>Experimental interfaces are subject to change.
155 Applications that use experimental interfaces
156 may need to be modified when upgrading to a newer SQLite release, though
157 this is rare.
158 When new interfaces are added to SQLite, they generally begin
159 as experimental interfaces. After an interface has been in use for
160 a while and the developers are confident that the design of the interface
161 is sound and worthy of long-term support, the interface is marked
162 as stable.</p>
163
164 <p>Deprecated interfaces have been superceded by better methods of
165 accomplishing the same thing and should be avoided in new applications.
166 Deprecated interfaces continue to be supported for the sake of
167 backwards compatibility. At some point in the future, it is possible
168 that deprecated interfaces may be removed.</p>
169
170 <p>Key points:</p>
171
172 <ul>
173 <li>Experimental interfaces are subject to change and/or removal
174 at any time.</li>
175
176 <li>Deprecated interfaces should not be used in new code and might
177 be removed in some future release.</li>
178 </ul>
179
180 <hr>
181 <h2>List Of Objects:</h2>
182 <div class='columns' style='columns: 14em auto;'>
183 <ul style='padding-top:0;'>
184 <li><a href='#sqlite3'>sqlite3</a></li>
185 <li><a href='#sqlite3_api_routines'>sqlite3_api_routines</a></li>
186 <li><a href='#sqlite3_backup'>sqlite3_backup</a></li>
187 <li><a href='#sqlite3_blob'>sqlite3_blob</a></li>
188 <li><a href='#sqlite3_context'>sqlite3_context</a></li>
189 <li><a href='#sqlite3_data_directory'>sqlite3_data_directory</a></li>
190 <li><a href='#sqlite3_file'>sqlite3_file</a></li>
191 <li><a href='#sqlite3_filename'>sqlite3_filename</a></li>
192 <li><a href='#sqlite3_index_info'>sqlite3_index_info</a></li>
193 <li><a href='#sqlite3_int64'>sqlite3_int64</a></li>
194 <li><a href='#sqlite3_int64'>sqlite3_uint64</a></li>
195 <li><a href='#sqlite3_int64'>sqlite_int64</a></li>
196 <li><a href='#sqlite3_int64'>sqlite_uint64</a></li>
197 <li><a href='#sqlite3_io_methods'>sqlite3_io_methods</a></li>
198 <li><a href='#sqlite3_mem_methods'>sqlite3_mem_methods</a></li>
199 <li><a href='#sqlite3_module'>sqlite3_module</a></li>
200 <li><a href='#sqlite3_mutex'>sqlite3_mutex</a></li>
201 <li><a href='#sqlite3_mutex_methods'>sqlite3_mutex_methods</a></li>
202 <li><a href='#sqlite3_pcache'>sqlite3_pcache</a></li>
203 <li><a href='#sqlite3_pcache_methods2'>sqlite3_pcache_methods2</a></li>
204 <li><a href='#sqlite3_pcache_page'>sqlite3_pcache_page</a></li>
205 <li><a href='#sqlite3_snapshot'>sqlite3_snapshot</a></li>
206 <li><a href='#sqlite3_stmt'>sqlite3_stmt</a></li>
207 <li><a href='#sqlite3_str'>sqlite3_str</a></li>
208 <li><a href='#sqlite3_temp_directory'>sqlite3_temp_directory</a></li>
209 <li><a href='#sqlite3_value'>sqlite3_value</a></li>
210 <li><a href='#sqlite3_vfs'>sqlite3_vfs</a></li>
211 <li><a href='#sqlite3_vtab'>sqlite3_vtab</a></li>
212 <li><a href='#sqlite3_vtab_cursor'>sqlite3_vtab_cursor</a></li>
213 </ul>
214 </div>
215 <hr>
216
217 <h2>List Of Constants:</h2>
218 <p>Also available: <a href="rescode.html">list of error codes</a></p>
219 <div class='columns' style='columns: 20em auto;'>
220 <ul style='padding-top:0;'>
221 <li><a href='#SQLITE_ABORT'>SQLITE_ABORT</a></li>
222 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_ABORT_ROLLBACK</a></li>
223 <li><a href='#SQLITE_ACCESS_EXISTS'>SQLITE_ACCESS_EXISTS</a></li>
224 <li><a href='#SQLITE_ACCESS_EXISTS'>SQLITE_ACCESS_READ</a></li>
225 <li><a href='#SQLITE_ACCESS_EXISTS'>SQLITE_ACCESS_READWRITE</a></li>
226 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_ALTER_TABLE</a></li>
227 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_ANALYZE</a></li>
228 <li><a href='#SQLITE_ANY'>SQLITE_ANY</a></li>
229 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_ATTACH</a></li>
230 <li><a href='#SQLITE_ABORT'>SQLITE_AUTH</a></li>
231 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_AUTH_USER</a></li>
232 <li><a href='#SQLITE_BLOB'>SQLITE_BLOB</a></li>
233 <li><a href='#SQLITE_ABORT'>SQLITE_BUSY</a></li>
234 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_BUSY_RECOVERY</a></li>
235 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_BUSY_SNAPSHOT</a></li>
236 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_BUSY_TIMEOUT</a></li>
237 <li><a href='#SQLITE_ABORT'>SQLITE_CANTOPEN</a></li>
238 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CANTOPEN_CONVPATH</a></li>
239 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CANTOPEN_DIRTYWAL</a></li>
240 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CANTOPEN_FULLPATH</a></li>
241 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CANTOPEN_ISDIR</a></li>
242 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CANTOPEN_NOTEMPDIR</a></li>
243 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CANTOPEN_SYMLINK</a></li>
244 <li><a href='#SQLITE_CHECKPOINT_FULL'>SQLITE_CHECKPOINT_FULL</a></li>
245 <li><a href='#SQLITE_CHECKPOINT_FULL'>SQLITE_CHECKPOINT_PASSIVE</a></li>
246 <li><a href='#SQLITE_CHECKPOINT_FULL'>SQLITE_CHECKPOINT_RESTART</a></li>
247 <li><a href='#SQLITE_CHECKPOINT_FULL'>SQLITE_CHECKPOINT_TRUNCATE</a></li>
248 <li><a href='#sqliteconfigcoveringindexscan'>SQLITE_CONFIG_COVERING_INDEX_SCAN</a></li>
249 <li><a href='#sqliteconfiggetmalloc'>SQLITE_CONFIG_GETMALLOC</a></li>
250 <li><a href='#sqliteconfiggetmutex'>SQLITE_CONFIG_GETMUTEX</a></li>
251 <li><a href='#sqliteconfiggetpcache'>SQLITE_CONFIG_GETPCACHE</a></li>
252 <li><a href='#sqliteconfiggetpcache2'>SQLITE_CONFIG_GETPCACHE2</a></li>
253 <li><a href='#sqliteconfigheap'>SQLITE_CONFIG_HEAP</a></li>
254 <li><a href='#sqliteconfiglog'>SQLITE_CONFIG_LOG</a></li>
255 <li><a href='#sqliteconfiglookaside'>SQLITE_CONFIG_LOOKASIDE</a></li>
256 <li><a href='#sqliteconfigmalloc'>SQLITE_CONFIG_MALLOC</a></li>
257 <li><a href='#sqliteconfigmemdbmaxsize'>SQLITE_CONFIG_MEMDB_MAXSIZE</a></li>
258 <li><a href='#sqliteconfigmemstatus'>SQLITE_CONFIG_MEMSTATUS</a></li>
259 <li><a href='#sqliteconfigmmapsize'>SQLITE_CONFIG_MMAP_SIZE</a></li>
260 <li><a href='#sqliteconfigmultithread'>SQLITE_CONFIG_MULTITHREAD</a></li>
261 <li><a href='#sqliteconfigmutex'>SQLITE_CONFIG_MUTEX</a></li>
262 <li><a href='#sqliteconfigpagecache'>SQLITE_CONFIG_PAGECACHE</a></li>
263 <li><a href='#sqliteconfigpcache'>SQLITE_CONFIG_PCACHE</a></li>
264 <li><a href='#sqliteconfigpcache2'>SQLITE_CONFIG_PCACHE2</a></li>
265 <li><a href='#sqliteconfigpcachehdrsz'>SQLITE_CONFIG_PCACHE_HDRSZ</a></li>
266 <li><a href='#sqliteconfigpmasz'>SQLITE_CONFIG_PMASZ</a></li>
267 <li><a href='#sqliteconfigrowidinview'>SQLITE_CONFIG_ROWID_IN_VIEW</a></li>
268 <li><a href='#sqliteconfigscratch'>SQLITE_CONFIG_SCRATCH</a></li>
269 <li><a href='#sqliteconfigserialized'>SQLITE_CONFIG_SERIALIZED</a></li>
270 <li><a href='#sqliteconfigsinglethread'>SQLITE_CONFIG_SINGLETHREAD</a></li>
271 <li><a href='#sqliteconfigsmallmalloc'>SQLITE_CONFIG_SMALL_MALLOC</a></li>
272 <li><a href='#sqliteconfigsorterrefsize'>SQLITE_CONFIG_SORTERREF_SIZE</a></li>
273 <li><a href='#sqliteconfigsqllog'>SQLITE_CONFIG_SQLLOG</a></li>
274 <li><a href='#sqliteconfigstmtjrnlspill'>SQLITE_CONFIG_STMTJRNL_SPILL</a></li>
275 <li><a href='#sqliteconfiguri'>SQLITE_CONFIG_URI</a></li>
276 <li><a href='#sqliteconfigwin32heapsize'>SQLITE_CONFIG_WIN32_HEAPSIZE</a></li>
277 <li><a href='#SQLITE_ABORT'>SQLITE_CONSTRAINT</a></li>
278 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_CHECK</a></li>
279 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_COMMITHOOK</a></li>
280 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_DATATYPE</a></li>
281 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_FOREIGNKEY</a></li>
282 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_FUNCTION</a></li>
283 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_NOTNULL</a></li>
284 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_PINNED</a></li>
285 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_PRIMARYKEY</a></li>
286 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_ROWID</a></li>
287 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_TRIGGER</a></li>
288 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_UNIQUE</a></li>
289 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CONSTRAINT_VTAB</a></li>
290 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_COPY</a></li>
291 <li><a href='#SQLITE_ABORT'>SQLITE_CORRUPT</a></li>
292 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CORRUPT_INDEX</a></li>
293 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CORRUPT_SEQUENCE</a></li>
294 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_CORRUPT_VTAB</a></li>
295 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_INDEX</a></li>
296 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_TABLE</a></li>
297 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_TEMP_INDEX</a></li>
298 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_TEMP_TABLE</a></li>
299 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_TEMP_TRIGGER</a></li>
300 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_TEMP_VIEW</a></li>
301 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_TRIGGER</a></li>
302 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_VIEW</a></li>
303 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_CREATE_VTABLE</a></li>
304 <li><a href='#sqlitedbconfigdefensive'>SQLITE_DBCONFIG_DEFENSIVE</a></li>
305 <li><a href='#sqlitedbconfigdqsddl'>SQLITE_DBCONFIG_DQS_DDL</a></li>
306 <li><a href='#sqlitedbconfigdqsdml'>SQLITE_DBCONFIG_DQS_DML</a></li>
307 <li><a href='#sqlitedbconfigenablefkey'>SQLITE_DBCONFIG_ENABLE_FKEY</a></li>
308 <li><a href='#sqlitedbconfigenablefts3tokenizer'>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</a></li>
309 <li><a href='#sqlitedbconfigenableloadextension'>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</a></li>
310 <li><a href='#sqlitedbconfigenableqpsg'>SQLITE_DBCONFIG_ENABLE_QPSG</a></li>
311 <li><a href='#sqlitedbconfigenabletrigger'>SQLITE_DBCONFIG_ENABLE_TRIGGER</a></li>
312 <li><a href='#sqlitedbconfigenableview'>SQLITE_DBCONFIG_ENABLE_VIEW</a></li>
313 <li><a href='#sqlitedbconfiglegacyaltertable'>SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</a></li>
314 <li><a href='#sqlitedbconfiglegacyfileformat'>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</a></li>
315 <li><a href='#sqlitedbconfiglookaside'>SQLITE_DBCONFIG_LOOKASIDE</a></li>
316 <li><a href='#sqlitedbconfigmaindbname'>SQLITE_DBCONFIG_MAINDBNAME</a></li>
317 <li><a href='#SQLITE_DBCONFIG_DEFENSIVE'>SQLITE_DBCONFIG_MAX</a></li>
318 <li><a href='#sqlitedbconfignockptonclose'>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</a></li>
319 <li><a href='#sqlitedbconfigresetdatabase'>SQLITE_DBCONFIG_RESET_DATABASE</a></li>
320 <li><a href='#sqlitedbconfigreversescanorder'>SQLITE_DBCONFIG_REVERSE_SCANORDER</a></li>
321 <li><a href='#sqlitedbconfigstmtscanstatus'>SQLITE_DBCONFIG_STMT_SCANSTATUS</a></li>
322 <li><a href='#sqlitedbconfigtriggereqp'>SQLITE_DBCONFIG_TRIGGER_EQP</a></li>
323 <li><a href='#sqlitedbconfigtrustedschema'>SQLITE_DBCONFIG_TRUSTED_SCHEMA</a></li>
324 <li><a href='#sqlitedbconfigwritableschema'>SQLITE_DBCONFIG_WRITABLE_SCHEMA</a></li>
325 <li><a href='#sqlitedbstatuscachehit'>SQLITE_DBSTATUS_CACHE_HIT</a></li>
326 <li><a href='#sqlitedbstatuscachemiss'>SQLITE_DBSTATUS_CACHE_MISS</a></li>
327 <li><a href='#sqlitedbstatuscachespill'>SQLITE_DBSTATUS_CACHE_SPILL</a></li>
328 <li><a href='#sqlitedbstatuscacheused'>SQLITE_DBSTATUS_CACHE_USED</a></li>
329 <li><a href='#sqlitedbstatuscacheusedshared'>SQLITE_DBSTATUS_CACHE_USED_SHARED</a></li>
330 <li><a href='#sqlitedbstatuscachewrite'>SQLITE_DBSTATUS_CACHE_WRITE</a></li>
331 <li><a href='#sqlitedbstatusdeferredfks'>SQLITE_DBSTATUS_DEFERRED_FKS</a></li>
332 <li><a href='#sqlitedbstatuslookasidehit'>SQLITE_DBSTATUS_LOOKASIDE_HIT</a></li>
333 <li><a href='#sqlitedbstatuslookasidemissfull'>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</a></li>
334 <li><a href='#sqlitedbstatuslookasidemisssize'>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</a></li>
335 <li><a href='#sqlitedbstatuslookasideused'>SQLITE_DBSTATUS_LOOKASIDE_USED</a></li>
336 <li><a href='#SQLITE_DBSTATUS options'>SQLITE_DBSTATUS_MAX</a></li>
337 <li><a href='#sqlitedbstatusschemaused'>SQLITE_DBSTATUS_SCHEMA_USED</a></li>
338 <li><a href='#sqlitedbstatusstmtused'>SQLITE_DBSTATUS_STMT_USED</a></li>
339 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DELETE</a></li>
340 <li><a href='#SQLITE_DENY'>SQLITE_DENY</a></li>
341 <li><a href='#SQLITE_DESERIALIZE_FREEONCLOSE'>SQLITE_DESERIALIZE_FREEONCLOSE</a></li>
342 <li><a href='#SQLITE_DESERIALIZE_FREEONCLOSE'>SQLITE_DESERIALIZE_READONLY</a></li>
343 <li><a href='#SQLITE_DESERIALIZE_FREEONCLOSE'>SQLITE_DESERIALIZE_RESIZEABLE</a></li>
344 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DETACH</a></li>
345 <li><a href='#sqlitedeterministic'>SQLITE_DETERMINISTIC</a></li>
346 <li><a href='#sqlitedirectonly'>SQLITE_DIRECTONLY</a></li>
347 <li><a href='#SQLITE_ABORT'>SQLITE_DONE</a></li>
348 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_INDEX</a></li>
349 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_TABLE</a></li>
350 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_TEMP_INDEX</a></li>
351 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_TEMP_TABLE</a></li>
352 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_TEMP_TRIGGER</a></li>
353 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_TEMP_VIEW</a></li>
354 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_TRIGGER</a></li>
355 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_VIEW</a></li>
356 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_DROP_VTABLE</a></li>
357 <li><a href='#SQLITE_ABORT'>SQLITE_EMPTY</a></li>
358 <li><a href='#SQLITE_ABORT'>SQLITE_ERROR</a></li>
359 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_ERROR_MISSING_COLLSEQ</a></li>
360 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_ERROR_RETRY</a></li>
361 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_ERROR_SNAPSHOT</a></li>
362 <li><a href='#SQLITE_FAIL'>SQLITE_FAIL</a></li>
363 <li><a href='#sqlitefcntlbeginatomicwrite'>SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a></li>
364 <li><a href='#sqlitefcntlbusyhandler'>SQLITE_FCNTL_BUSYHANDLER</a></li>
365 <li><a href='#sqlitefcntlchunksize'>SQLITE_FCNTL_CHUNK_SIZE</a></li>
366 <li><a href='#sqlitefcntlckptdone'>SQLITE_FCNTL_CKPT_DONE</a></li>
367 <li><a href='#sqlitefcntlckptstart'>SQLITE_FCNTL_CKPT_START</a></li>
368 <li><a href='#sqlitefcntlcksmfile'>SQLITE_FCNTL_CKSM_FILE</a></li>
369 <li><a href='#sqlitefcntlcommitatomicwrite'>SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a></li>
370 <li><a href='#sqlitefcntlcommitphasetwo'>SQLITE_FCNTL_COMMIT_PHASETWO</a></li>
371 <li><a href='#sqlitefcntldataversion'>SQLITE_FCNTL_DATA_VERSION</a></li>
372 <li><a href='#sqlitefcntlexternalreader'>SQLITE_FCNTL_EXTERNAL_READER</a></li>
373 <li><a href='#sqlitefcntlfilepointer'>SQLITE_FCNTL_FILE_POINTER</a></li>
374 <li><a href='#SQLITE_FCNTL_BEGIN_ATOMIC_WRITE'>SQLITE_FCNTL_GET_LOCKPROXYFILE</a></li>
375 <li><a href='#sqlitefcntlhasmoved'>SQLITE_FCNTL_HAS_MOVED</a></li>
376 <li><a href='#sqlitefcntljournalpointer'>SQLITE_FCNTL_JOURNAL_POINTER</a></li>
377 <li><a href='#SQLITE_FCNTL_BEGIN_ATOMIC_WRITE'>SQLITE_FCNTL_LAST_ERRNO</a></li>
378 <li><a href='#sqlitefcntllockstate'>SQLITE_FCNTL_LOCKSTATE</a></li>
379 <li><a href='#sqlitefcntllocktimeout'>SQLITE_FCNTL_LOCK_TIMEOUT</a></li>
380 <li><a href='#sqlitefcntlmmapsize'>SQLITE_FCNTL_MMAP_SIZE</a></li>
381 <li><a href='#sqlitefcntloverwrite'>SQLITE_FCNTL_OVERWRITE</a></li>
382 <li><a href='#SQLITE_FCNTL_BEGIN_ATOMIC_WRITE'>SQLITE_FCNTL_PDB</a></li>
383 <li><a href='#sqlitefcntlpersistwal'>SQLITE_FCNTL_PERSIST_WAL</a></li>
384 <li><a href='#sqlitefcntlpowersafeoverwrite'>SQLITE_FCNTL_POWERSAFE_OVERWRITE</a></li>
385 <li><a href='#sqlitefcntlpragma'>SQLITE_FCNTL_PRAGMA</a></li>
386 <li><a href='#sqlitefcntlrbu'>SQLITE_FCNTL_RBU</a></li>
387 <li><a href='#SQLITE_FCNTL_BEGIN_ATOMIC_WRITE'>SQLITE_FCNTL_RESERVE_BYTES</a></li>
388 <li><a href='#sqlitefcntlresetcache'>SQLITE_FCNTL_RESET_CACHE</a></li>
389 <li><a href='#sqlitefcntlrollbackatomicwrite'>SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE</a></li>
390 <li><a href='#SQLITE_FCNTL_BEGIN_ATOMIC_WRITE'>SQLITE_FCNTL_SET_LOCKPROXYFILE</a></li>
391 <li><a href='#sqlitefcntlsizehint'>SQLITE_FCNTL_SIZE_HINT</a></li>
392 <li><a href='#sqlitefcntlsizelimit'>SQLITE_FCNTL_SIZE_LIMIT</a></li>
393 <li><a href='#sqlitefcntlsync'>SQLITE_FCNTL_SYNC</a></li>
394 <li><a href='#sqlitefcntlsyncomitted'>SQLITE_FCNTL_SYNC_OMITTED</a></li>
395 <li><a href='#sqlitefcntltempfilename'>SQLITE_FCNTL_TEMPFILENAME</a></li>
396 <li><a href='#sqlitefcntltrace'>SQLITE_FCNTL_TRACE</a></li>
397 <li><a href='#sqlitefcntlvfsname'>SQLITE_FCNTL_VFSNAME</a></li>
398 <li><a href='#sqlitefcntlvfspointer'>SQLITE_FCNTL_VFS_POINTER</a></li>
399 <li><a href='#sqlitefcntlwalblock'>SQLITE_FCNTL_WAL_BLOCK</a></li>
400 <li><a href='#sqlitefcntlwin32avretry'>SQLITE_FCNTL_WIN32_AV_RETRY</a></li>
401 <li><a href='#sqlitefcntlwin32gethandle'>SQLITE_FCNTL_WIN32_GET_HANDLE</a></li>
402 <li><a href='#sqlitefcntlwin32sethandle'>SQLITE_FCNTL_WIN32_SET_HANDLE</a></li>
403 <li><a href='#sqlitefcntlzipvfs'>SQLITE_FCNTL_ZIPVFS</a></li>
404 <li><a href='#SQLITE_BLOB'>SQLITE_FLOAT</a></li>
405 <li><a href='#SQLITE_ABORT'>SQLITE_FORMAT</a></li>
406 <li><a href='#SQLITE_ABORT'>SQLITE_FULL</a></li>
407 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_FUNCTION</a></li>
408 <li><a href='#SQLITE_DENY'>SQLITE_IGNORE</a></li>
409 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_EQ</a></li>
410 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_FUNCTION</a></li>
411 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_GE</a></li>
412 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_GLOB</a></li>
413 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_GT</a></li>
414 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_IS</a></li>
415 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_ISNOT</a></li>
416 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_ISNOTNULL</a></li>
417 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_ISNULL</a></li>
418 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_LE</a></li>
419 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_LIKE</a></li>
420 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_LIMIT</a></li>
421 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_LT</a></li>
422 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_MATCH</a></li>
423 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_NE</a></li>
424 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_OFFSET</a></li>
425 <li><a href='#SQLITE_INDEX_CONSTRAINT_EQ'>SQLITE_INDEX_CONSTRAINT_REGEXP</a></li>
426 <li><a href='#SQLITE_INDEX_SCAN_UNIQUE'>SQLITE_INDEX_SCAN_UNIQUE</a></li>
427 <li><a href='#sqliteinnocuous'>SQLITE_INNOCUOUS</a></li>
428 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_INSERT</a></li>
429 <li><a href='#SQLITE_BLOB'>SQLITE_INTEGER</a></li>
430 <li><a href='#SQLITE_ABORT'>SQLITE_INTERNAL</a></li>
431 <li><a href='#SQLITE_ABORT'>SQLITE_INTERRUPT</a></li>
432 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC</a></li>
433 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC16K</a></li>
434 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC1K</a></li>
435 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC2K</a></li>
436 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC32K</a></li>
437 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC4K</a></li>
438 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC512</a></li>
439 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC64K</a></li>
440 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_ATOMIC8K</a></li>
441 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_BATCH_ATOMIC</a></li>
442 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_IMMUTABLE</a></li>
443 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_POWERSAFE_OVERWRITE</a></li>
444 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_SAFE_APPEND</a></li>
445 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_SEQUENTIAL</a></li>
446 <li><a href='#SQLITE_IOCAP_ATOMIC'>SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN</a></li>
447 <li><a href='#SQLITE_ABORT'>SQLITE_IOERR</a></li>
448 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_ACCESS</a></li>
449 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_AUTH</a></li>
450 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_BEGIN_ATOMIC</a></li>
451 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_BLOCKED</a></li>
452 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_CHECKRESERVEDLOCK</a></li>
453 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_CLOSE</a></li>
454 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_COMMIT_ATOMIC</a></li>
455 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_CONVPATH</a></li>
456 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_CORRUPTFS</a></li>
457 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_DATA</a></li>
458 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_DELETE</a></li>
459 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_DELETE_NOENT</a></li>
460 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_DIR_CLOSE</a></li>
461 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_DIR_FSYNC</a></li>
462 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_FSTAT</a></li>
463 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_FSYNC</a></li>
464 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_GETTEMPPATH</a></li>
465 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_IN_PAGE</a></li>
466 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_LOCK</a></li>
467 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_MMAP</a></li>
468 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_NOMEM</a></li>
469 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_RDLOCK</a></li>
470 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_READ</a></li>
471 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_ROLLBACK_ATOMIC</a></li>
472 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_SEEK</a></li>
473 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_SHMLOCK</a></li>
474 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_SHMMAP</a></li>
475 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_SHMOPEN</a></li>
476 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_SHMSIZE</a></li>
477 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_SHORT_READ</a></li>
478 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_TRUNCATE</a></li>
479 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_UNLOCK</a></li>
480 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_VNODE</a></li>
481 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_IOERR_WRITE</a></li>
482 <li><a href='#sqlitelimitattached'>SQLITE_LIMIT_ATTACHED</a></li>
483 <li><a href='#sqlitelimitcolumn'>SQLITE_LIMIT_COLUMN</a></li>
484 <li><a href='#sqlitelimitcompoundselect'>SQLITE_LIMIT_COMPOUND_SELECT</a></li>
485 <li><a href='#sqlitelimitexprdepth'>SQLITE_LIMIT_EXPR_DEPTH</a></li>
486 <li><a href='#sqlitelimitfunctionarg'>SQLITE_LIMIT_FUNCTION_ARG</a></li>
487 <li><a href='#sqlitelimitlength'>SQLITE_LIMIT_LENGTH</a></li>
488 <li><a href='#sqlitelimitlikepatternlength'>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</a></li>
489 <li><a href='#sqlitelimitsqllength'>SQLITE_LIMIT_SQL_LENGTH</a></li>
490 <li><a href='#sqlitelimittriggerdepth'>SQLITE_LIMIT_TRIGGER_DEPTH</a></li>
491 <li><a href='#sqlitelimitvariablenumber'>SQLITE_LIMIT_VARIABLE_NUMBER</a></li>
492 <li><a href='#sqlitelimitvdbeop'>SQLITE_LIMIT_VDBE_OP</a></li>
493 <li><a href='#sqlitelimitworkerthreads'>SQLITE_LIMIT_WORKER_THREADS</a></li>
494 <li><a href='#SQLITE_ABORT'>SQLITE_LOCKED</a></li>
495 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_LOCKED_SHAREDCACHE</a></li>
496 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_LOCKED_VTAB</a></li>
497 <li><a href='#SQLITE_LOCK_EXCLUSIVE'>SQLITE_LOCK_EXCLUSIVE</a></li>
498 <li><a href='#SQLITE_LOCK_EXCLUSIVE'>SQLITE_LOCK_NONE</a></li>
499 <li><a href='#SQLITE_LOCK_EXCLUSIVE'>SQLITE_LOCK_PENDING</a></li>
500 <li><a href='#SQLITE_LOCK_EXCLUSIVE'>SQLITE_LOCK_RESERVED</a></li>
501 <li><a href='#SQLITE_LOCK_EXCLUSIVE'>SQLITE_LOCK_SHARED</a></li>
502 <li><a href='#SQLITE_ABORT'>SQLITE_MISMATCH</a></li>
503 <li><a href='#SQLITE_ABORT'>SQLITE_MISUSE</a></li>
504 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_FAST</a></li>
505 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_RECURSIVE</a></li>
506 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_APP1</a></li>
507 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_APP2</a></li>
508 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_APP3</a></li>
509 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_LRU</a></li>
510 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_LRU2</a></li>
511 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_MAIN</a></li>
512 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_MEM</a></li>
513 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_MEM2</a></li>
514 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_OPEN</a></li>
515 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_PMEM</a></li>
516 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_PRNG</a></li>
517 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_VFS1</a></li>
518 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_VFS2</a></li>
519 <li><a href='#SQLITE_MUTEX_FAST'>SQLITE_MUTEX_STATIC_VFS3</a></li>
520 <li><a href='#SQLITE_ABORT'>SQLITE_NOLFS</a></li>
521 <li><a href='#SQLITE_ABORT'>SQLITE_NOMEM</a></li>
522 <li><a href='#SQLITE_ABORT'>SQLITE_NOTADB</a></li>
523 <li><a href='#SQLITE_ABORT'>SQLITE_NOTFOUND</a></li>
524 <li><a href='#SQLITE_ABORT'>SQLITE_NOTICE</a></li>
525 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_NOTICE_RBU</a></li>
526 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_NOTICE_RECOVER_ROLLBACK</a></li>
527 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_NOTICE_RECOVER_WAL</a></li>
528 <li><a href='#SQLITE_BLOB'>SQLITE_NULL</a></li>
529 <li><a href='#SQLITE_ABORT'>SQLITE_OK</a></li>
530 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_OK_LOAD_PERMANENTLY</a></li>
531 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_OK_SYMLINK</a></li>
532 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_AUTOPROXY</a></li>
533 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_CREATE</a></li>
534 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_DELETEONCLOSE</a></li>
535 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_EXCLUSIVE</a></li>
536 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_EXRESCODE</a></li>
537 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_FULLMUTEX</a></li>
538 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_MAIN_DB</a></li>
539 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_MAIN_JOURNAL</a></li>
540 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_MEMORY</a></li>
541 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_NOFOLLOW</a></li>
542 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_NOMUTEX</a></li>
543 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_PRIVATECACHE</a></li>
544 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_READONLY</a></li>
545 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_READWRITE</a></li>
546 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_SHAREDCACHE</a></li>
547 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_SUBJOURNAL</a></li>
548 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_SUPER_JOURNAL</a></li>
549 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_TEMP_DB</a></li>
550 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_TEMP_JOURNAL</a></li>
551 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_TRANSIENT_DB</a></li>
552 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_URI</a></li>
553 <li><a href='#SQLITE_OPEN_AUTOPROXY'>SQLITE_OPEN_WAL</a></li>
554 <li><a href='#SQLITE_ABORT'>SQLITE_PERM</a></li>
555 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_PRAGMA</a></li>
556 <li><a href='#sqlitepreparenormalize'>SQLITE_PREPARE_NORMALIZE</a></li>
557 <li><a href='#sqlitepreparenovtab'>SQLITE_PREPARE_NO_VTAB</a></li>
558 <li><a href='#sqlitepreparepersistent'>SQLITE_PREPARE_PERSISTENT</a></li>
559 <li><a href='#SQLITE_ABORT'>SQLITE_PROTOCOL</a></li>
560 <li><a href='#SQLITE_ABORT'>SQLITE_RANGE</a></li>
561 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_READ</a></li>
562 <li><a href='#SQLITE_ABORT'>SQLITE_READONLY</a></li>
563 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_READONLY_CANTINIT</a></li>
564 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_READONLY_CANTLOCK</a></li>
565 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_READONLY_DBMOVED</a></li>
566 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_READONLY_DIRECTORY</a></li>
567 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_READONLY_RECOVERY</a></li>
568 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_READONLY_ROLLBACK</a></li>
569 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_RECURSIVE</a></li>
570 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_REINDEX</a></li>
571 <li><a href='#SQLITE_FAIL'>SQLITE_REPLACE</a></li>
572 <li><a href='#sqliteresultsubtype'>SQLITE_RESULT_SUBTYPE</a></li>
573 <li><a href='#SQLITE_FAIL'>SQLITE_ROLLBACK</a></li>
574 <li><a href='#SQLITE_ABORT'>SQLITE_ROW</a></li>
575 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_SAVEPOINT</a></li>
576 <li><a href='#SQLITE_SCANSTAT_COMPLEX'>SQLITE_SCANSTAT_COMPLEX</a></li>
577 <li><a href='#sqlitescanstatest'>SQLITE_SCANSTAT_EST</a></li>
578 <li><a href='#sqlitescanstatexplain'>SQLITE_SCANSTAT_EXPLAIN</a></li>
579 <li><a href='#sqlitescanstatname'>SQLITE_SCANSTAT_NAME</a></li>
580 <li><a href='#sqlitescanstatncycle'>SQLITE_SCANSTAT_NCYCLE</a></li>
581 <li><a href='#sqlitescanstatnloop'>SQLITE_SCANSTAT_NLOOP</a></li>
582 <li><a href='#sqlitescanstatnvisit'>SQLITE_SCANSTAT_NVISIT</a></li>
583 <li><a href='#sqlitescanstatparentid'>SQLITE_SCANSTAT_PARENTID</a></li>
584 <li><a href='#sqlitescanstatselectid'>SQLITE_SCANSTAT_SELECTID</a></li>
585 <li><a href='#SQLITE_ABORT'>SQLITE_SCHEMA</a></li>
586 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_SELECT</a></li>
587 <li><a href='#SQLITE_SERIALIZE_NOCOPY'>SQLITE_SERIALIZE_NOCOPY</a></li>
588 <li><a href='#SQLITE_SHM_EXCLUSIVE'>SQLITE_SHM_EXCLUSIVE</a></li>
589 <li><a href='#SQLITE_SHM_EXCLUSIVE'>SQLITE_SHM_LOCK</a></li>
590 <li><a href='#SQLITE_SHM_NLOCK'>SQLITE_SHM_NLOCK</a></li>
591 <li><a href='#SQLITE_SHM_EXCLUSIVE'>SQLITE_SHM_SHARED</a></li>
592 <li><a href='#SQLITE_SHM_EXCLUSIVE'>SQLITE_SHM_UNLOCK</a></li>
593 <li><a href='#SQLITE_SOURCE_ID'>SQLITE_SOURCE_ID</a></li>
594 <li><a href='#SQLITE_STATIC'>SQLITE_STATIC</a></li>
595 <li><a href='#sqlitestatusmalloccount'>SQLITE_STATUS_MALLOC_COUNT</a></li>
596 <li><a href='#sqlitestatusmallocsize'>SQLITE_STATUS_MALLOC_SIZE</a></li>
597 <li><a href='#sqlitestatusmemoryused'>SQLITE_STATUS_MEMORY_USED</a></li>
598 <li><a href='#sqlitestatuspagecacheoverflow'>SQLITE_STATUS_PAGECACHE_OVERFLOW</a></li>
599 <li><a href='#sqlitestatuspagecachesize'>SQLITE_STATUS_PAGECACHE_SIZE</a></li>
600 <li><a href='#sqlitestatuspagecacheused'>SQLITE_STATUS_PAGECACHE_USED</a></li>
601 <li><a href='#sqlitestatusparserstack'>SQLITE_STATUS_PARSER_STACK</a></li>
602 <li><a href='#sqlitestatusscratchoverflow'>SQLITE_STATUS_SCRATCH_OVERFLOW</a></li>
603 <li><a href='#sqlitestatusscratchsize'>SQLITE_STATUS_SCRATCH_SIZE</a></li>
604 <li><a href='#sqlitestatusscratchused'>SQLITE_STATUS_SCRATCH_USED</a></li>
605 <li><a href='#sqlitestmtstatusautoindex'>SQLITE_STMTSTATUS_AUTOINDEX</a></li>
606 <li><a href='#SQLITE_STMTSTATUS counter'>SQLITE_STMTSTATUS_FILTER_HIT</a></li>
607 <li><a href='#sqlitestmtstatusfiltermiss'>SQLITE_STMTSTATUS_FILTER_MISS</a></li>
608 <li><a href='#sqlitestmtstatusfullscanstep'>SQLITE_STMTSTATUS_FULLSCAN_STEP</a></li>
609 <li><a href='#sqlitestmtstatusmemused'>SQLITE_STMTSTATUS_MEMUSED</a></li>
610 <li><a href='#sqlitestmtstatusreprepare'>SQLITE_STMTSTATUS_REPREPARE</a></li>
611 <li><a href='#sqlitestmtstatusrun'>SQLITE_STMTSTATUS_RUN</a></li>
612 <li><a href='#sqlitestmtstatussort'>SQLITE_STMTSTATUS_SORT</a></li>
613 <li><a href='#sqlitestmtstatusvmstep'>SQLITE_STMTSTATUS_VM_STEP</a></li>
614 <li><a href='#sqlitesubtype'>SQLITE_SUBTYPE</a></li>
615 <li><a href='#SQLITE_SYNC_DATAONLY'>SQLITE_SYNC_DATAONLY</a></li>
616 <li><a href='#SQLITE_SYNC_DATAONLY'>SQLITE_SYNC_FULL</a></li>
617 <li><a href='#SQLITE_SYNC_DATAONLY'>SQLITE_SYNC_NORMAL</a></li>
618 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_ALWAYS</a></li>
619 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_ASSERT</a></li>
620 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS</a></li>
621 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_BITVEC_TEST</a></li>
622 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_BYTEORDER</a></li>
623 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_EXPLAIN_STMT</a></li>
624 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS</a></li>
625 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_FAULT_INSTALL</a></li>
626 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_FIRST</a></li>
627 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_FK_NO_ACTION</a></li>
628 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_IMPOSTER</a></li>
629 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_INTERNAL_FUNCTIONS</a></li>
630 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_ISINIT</a></li>
631 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_ISKEYWORD</a></li>
632 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_JSON_SELFCHECK</a></li>
633 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_LAST</a></li>
634 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_LOCALTIME_FAULT</a></li>
635 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_LOGEST</a></li>
636 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_NEVER_CORRUPT</a></li>
637 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD</a></li>
638 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_OPTIMIZATIONS</a></li>
639 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_PARSER_COVERAGE</a></li>
640 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_PENDING_BYTE</a></li>
641 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_PRNG_RESET</a></li>
642 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_PRNG_RESTORE</a></li>
643 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_PRNG_SAVE</a></li>
644 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_PRNG_SEED</a></li>
645 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_RESERVE</a></li>
646 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_RESULT_INTREAL</a></li>
647 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_SCRATCHMALLOC</a></li>
648 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_SEEK_COUNT</a></li>
649 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_SORTER_MMAP</a></li>
650 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_TRACEFLAGS</a></li>
651 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_TUNE</a></li>
652 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_USELONGDOUBLE</a></li>
653 <li><a href='#SQLITE_TESTCTRL_ALWAYS'>SQLITE_TESTCTRL_VDBE_COVERAGE</a></li>
654 <li><a href='#SQLITE_BLOB'>SQLITE_TEXT</a></li>
655 <li><a href='#SQLITE_ABORT'>SQLITE_TOOBIG</a></li>
656 <li><a href='#SQLITE_TRACE'>SQLITE_TRACE</a></li>
657 <li><a href='#sqlitetraceclose'>SQLITE_TRACE_CLOSE</a></li>
658 <li><a href='#sqlitetraceprofile'>SQLITE_TRACE_PROFILE</a></li>
659 <li><a href='#sqlitetracerow'>SQLITE_TRACE_ROW</a></li>
660 <li><a href='#sqlitetracestmt'>SQLITE_TRACE_STMT</a></li>
661 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_TRANSACTION</a></li>
662 <li><a href='#SQLITE_STATIC'>SQLITE_TRANSIENT</a></li>
663 <li><a href='#sqlitetxnnone'>SQLITE_TXN_NONE</a></li>
664 <li><a href='#sqlitetxnread'>SQLITE_TXN_READ</a></li>
665 <li><a href='#sqlitetxnwrite'>SQLITE_TXN_WRITE</a></li>
666 <li><a href='#SQLITE_ALTER_TABLE'>SQLITE_UPDATE</a></li>
667 <li><a href='#SQLITE_ANY'>SQLITE_UTF16</a></li>
668 <li><a href='#SQLITE_ANY'>SQLITE_UTF16BE</a></li>
669 <li><a href='#SQLITE_ANY'>SQLITE_UTF16LE</a></li>
670 <li><a href='#SQLITE_ANY'>SQLITE_UTF16_ALIGNED</a></li>
671 <li><a href='#SQLITE_ANY'>SQLITE_UTF8</a></li>
672 <li><a href='#SQLITE_SOURCE_ID'>SQLITE_VERSION</a></li>
673 <li><a href='#SQLITE_SOURCE_ID'>SQLITE_VERSION_NUMBER</a></li>
674 <li><a href='#sqlitevtabconstraintsupport'>SQLITE_VTAB_CONSTRAINT_SUPPORT</a></li>
675 <li><a href='#sqlitevtabdirectonly'>SQLITE_VTAB_DIRECTONLY</a></li>
676 <li><a href='#sqlitevtabinnocuous'>SQLITE_VTAB_INNOCUOUS</a></li>
677 <li><a href='#sqlitevtabusesallschemas'>SQLITE_VTAB_USES_ALL_SCHEMAS</a></li>
678 <li><a href='#SQLITE_ABORT'>SQLITE_WARNING</a></li>
679 <li><a href='#SQLITE_ABORT_ROLLBACK'>SQLITE_WARNING_AUTOINDEX</a></li>
680 <li><a href='#SQLITE_WIN32_DATA_DIRECTORY_TYPE'>SQLITE_WIN32_DATA_DIRECTORY_TYPE</a></li>
681 <li><a href='#SQLITE_WIN32_DATA_DIRECTORY_TYPE'>SQLITE_WIN32_TEMP_DIRECTORY_TYPE</a></li>
682 </ul>
683 </div>
684 <hr>
685
686 <h2>List Of Functions:</h2>
687 <p>Note: Functions marked with "<small><i>(exp)</i></small>"
688 are <a href="capi3ref.html">experimental</a> and functions whose names are
689 <s>struck through</s> are <a href="capi3ref.html">deprecated</a>.</p>
690 <!-- number of functions: 288 -->
691 <!-- number of deprecated functions: 9 -->
692 <!-- number of experimental functions: 0 -->
693 <div class='columns' style='columns: 15em auto;'>
694 <ul style='padding-top:0;'>
695 <li><a href='#sqlite3_aggregate_context'>sqlite3_aggregate_context</a></li>
696 <li><s>sqlite3_aggregate_count</s></li>
697 <li><a href='#sqlite3_auto_extension'>sqlite3_auto_extension</a></li>
698 <li><a href='#sqlite3_autovacuum_pages'>sqlite3_autovacuum_pages</a></li>
699 <li><a href='#sqlite3backupfinish'>sqlite3_backup_finish</a></li>
700 <li><a href='#sqlite3backupinit'>sqlite3_backup_init</a></li>
701 <li><a href='#sqlite3backuppagecount'>sqlite3_backup_pagecount</a></li>
702 <li><a href='#sqlite3backupremaining'>sqlite3_backup_remaining</a></li>
703 <li><a href='#sqlite3backupstep'>sqlite3_backup_step</a></li>
704 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_blob</a></li>
705 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_blob64</a></li>
706 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_double</a></li>
707 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_int</a></li>
708 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_int64</a></li>
709 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_null</a></li>
710 <li><a href='#sqlite3_bind_parameter_count'>sqlite3_bind_parameter_count</a></li>
711 <li><a href='#sqlite3_bind_parameter_index'>sqlite3_bind_parameter_index</a></li>
712 <li><a href='#sqlite3_bind_parameter_name'>sqlite3_bind_parameter_name</a></li>
713 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_pointer</a></li>
714 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_text</a></li>
715 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_text16</a></li>
716 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_text64</a></li>
717 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_value</a></li>
718 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_zeroblob</a></li>
719 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_zeroblob64</a></li>
720 <li><a href='#sqlite3_blob_bytes'>sqlite3_blob_bytes</a></li>
721 <li><a href='#sqlite3_blob_close'>sqlite3_blob_close</a></li>
722 <li><a href='#sqlite3_blob_open'>sqlite3_blob_open</a></li>
723 <li><a href='#sqlite3_blob_read'>sqlite3_blob_read</a></li>
724 <li><a href='#sqlite3_blob_reopen'>sqlite3_blob_reopen</a></li>
725 <li><a href='#sqlite3_blob_write'>sqlite3_blob_write</a></li>
726 <li><a href='#sqlite3_busy_handler'>sqlite3_busy_handler</a></li>
727 <li><a href='#sqlite3_busy_timeout'>sqlite3_busy_timeout</a></li>
728 <li><a href='#sqlite3_cancel_auto_extension'>sqlite3_cancel_auto_extension</a></li>
729 <li><a href='#sqlite3_changes'>sqlite3_changes</a></li>
730 <li><a href='#sqlite3_changes'>sqlite3_changes64</a></li>
731 <li><a href='#sqlite3_clear_bindings'>sqlite3_clear_bindings</a></li>
732 <li><a href='#sqlite3_close'>sqlite3_close</a></li>
733 <li><a href='#sqlite3_close'>sqlite3_close_v2</a></li>
734 <li><a href='#sqlite3_collation_needed'>sqlite3_collation_needed</a></li>
735 <li><a href='#sqlite3_collation_needed'>sqlite3_collation_needed16</a></li>
736 <li><a href='#sqlite3_column_blob'>sqlite3_column_blob</a></li>
737 <li><a href='#sqlite3_column_blob'>sqlite3_column_bytes</a></li>
738 <li><a href='#sqlite3_column_blob'>sqlite3_column_bytes16</a></li>
739 <li><a href='#sqlite3_column_count'>sqlite3_column_count</a></li>
740 <li><a href='#sqlite3_column_database_name'>sqlite3_column_database_name</a></li>
741 <li><a href='#sqlite3_column_database_name'>sqlite3_column_database_name16</a></li>
742 <li><a href='#sqlite3_column_decltype'>sqlite3_column_decltype</a></li>
743 <li><a href='#sqlite3_column_decltype'>sqlite3_column_decltype16</a></li>
744 <li><a href='#sqlite3_column_blob'>sqlite3_column_double</a></li>
745 <li><a href='#sqlite3_column_blob'>sqlite3_column_int</a></li>
746 <li><a href='#sqlite3_column_blob'>sqlite3_column_int64</a></li>
747 <li><a href='#sqlite3_column_name'>sqlite3_column_name</a></li>
748 <li><a href='#sqlite3_column_name'>sqlite3_column_name16</a></li>
749 <li><a href='#sqlite3_column_database_name'>sqlite3_column_origin_name</a></li>
750 <li><a href='#sqlite3_column_database_name'>sqlite3_column_origin_name16</a></li>
751 <li><a href='#sqlite3_column_database_name'>sqlite3_column_table_name</a></li>
752 <li><a href='#sqlite3_column_database_name'>sqlite3_column_table_name16</a></li>
753 <li><a href='#sqlite3_column_blob'>sqlite3_column_text</a></li>
754 <li><a href='#sqlite3_column_blob'>sqlite3_column_text16</a></li>
755 <li><a href='#sqlite3_column_blob'>sqlite3_column_type</a></li>
756 <li><a href='#sqlite3_column_blob'>sqlite3_column_value</a></li>
757 <li><a href='#sqlite3_commit_hook'>sqlite3_commit_hook</a></li>
758 <li><a href='#sqlite3_compileoption_get'>sqlite3_compileoption_get</a></li>
759 <li><a href='#sqlite3_compileoption_get'>sqlite3_compileoption_used</a></li>
760 <li><a href='#sqlite3_complete'>sqlite3_complete</a></li>
761 <li><a href='#sqlite3_complete'>sqlite3_complete16</a></li>
762 <li><a href='#sqlite3_config'>sqlite3_config</a></li>
763 <li><a href='#sqlite3_context_db_handle'>sqlite3_context_db_handle</a></li>
764 <li><a href='#sqlite3_create_collation'>sqlite3_create_collation</a></li>
765 <li><a href='#sqlite3_create_collation'>sqlite3_create_collation16</a></li>
766 <li><a href='#sqlite3_create_collation'>sqlite3_create_collation_v2</a></li>
767 <li><a href='#sqlite3_create_filename'>sqlite3_create_filename</a></li>
768 <li><a href='#sqlite3_create_function'>sqlite3_create_function</a></li>
769 <li><a href='#sqlite3_create_function'>sqlite3_create_function16</a></li>
770 <li><a href='#sqlite3_create_function'>sqlite3_create_function_v2</a></li>
771 <li><a href='#sqlite3_create_module'>sqlite3_create_module</a></li>
772 <li><a href='#sqlite3_create_module'>sqlite3_create_module_v2</a></li>
773 <li><a href='#sqlite3_create_function'>sqlite3_create_window_function</a></li>
774 <li><a href='#sqlite3_data_count'>sqlite3_data_count</a></li>
775 <li><a href='#sqlite3_database_file_object'>sqlite3_database_file_object</a></li>
776 <li><a href='#sqlite3_db_cacheflush'>sqlite3_db_cacheflush</a></li>
777 <li><a href='#sqlite3_db_config'>sqlite3_db_config</a></li>
778 <li><a href='#sqlite3_db_filename'>sqlite3_db_filename</a></li>
779 <li><a href='#sqlite3_db_handle'>sqlite3_db_handle</a></li>
780 <li><a href='#sqlite3_db_mutex'>sqlite3_db_mutex</a></li>
781 <li><a href='#sqlite3_db_name'>sqlite3_db_name</a></li>
782 <li><a href='#sqlite3_db_readonly'>sqlite3_db_readonly</a></li>
783 <li><a href='#sqlite3_db_release_memory'>sqlite3_db_release_memory</a></li>
784 <li><a href='#sqlite3_db_status'>sqlite3_db_status</a></li>
785 <li><a href='#sqlite3_declare_vtab'>sqlite3_declare_vtab</a></li>
786 <li><a href='#sqlite3_deserialize'>sqlite3_deserialize</a></li>
787 <li><a href='#sqlite3_drop_modules'>sqlite3_drop_modules</a></li>
788 <li><a href='#sqlite3_enable_load_extension'>sqlite3_enable_load_extension</a></li>
789 <li><a href='#sqlite3_enable_shared_cache'>sqlite3_enable_shared_cache</a></li>
790 <li><a href='#sqlite3_errcode'>sqlite3_errcode</a></li>
791 <li><a href='#sqlite3_errcode'>sqlite3_errmsg</a></li>
792 <li><a href='#sqlite3_errcode'>sqlite3_errmsg16</a></li>
793 <li><a href='#sqlite3_errcode'>sqlite3_error_offset</a></li>
794 <li><a href='#sqlite3_errcode'>sqlite3_errstr</a></li>
795 <li><a href='#sqlite3_exec'>sqlite3_exec</a></li>
796 <li><a href='#sqlite3_expanded_sql'>sqlite3_expanded_sql</a></li>
797 <li><s>sqlite3_expired</s></li>
798 <li><a href='#sqlite3_errcode'>sqlite3_extended_errcode</a></li>
799 <li><a href='#sqlite3_extended_result_codes'>sqlite3_extended_result_codes</a></li>
800 <li><a href='#sqlite3_file_control'>sqlite3_file_control</a></li>
801 <li><a href='#sqlite3_filename_database'>sqlite3_filename_database</a></li>
802 <li><a href='#sqlite3_filename_database'>sqlite3_filename_journal</a></li>
803 <li><a href='#sqlite3_filename_database'>sqlite3_filename_wal</a></li>
804 <li><a href='#sqlite3_finalize'>sqlite3_finalize</a></li>
805 <li><a href='#sqlite3_free'>sqlite3_free</a></li>
806 <li><a href='#sqlite3_create_filename'>sqlite3_free_filename</a></li>
807 <li><a href='#sqlite3_free_table'>sqlite3_free_table</a></li>
808 <li><a href='#sqlite3_get_autocommit'>sqlite3_get_autocommit</a></li>
809 <li><a href='#sqlite3_get_auxdata'>sqlite3_get_auxdata</a></li>
810 <li><a href='#sqlite3_get_clientdata'>sqlite3_get_clientdata</a></li>
811 <li><a href='#sqlite3_free_table'>sqlite3_get_table</a></li>
812 <li><s>sqlite3_global_recover</s></li>
813 <li><a href='#sqlite3_hard_heap_limit64'>sqlite3_hard_heap_limit64</a></li>
814 <li><a href='#sqlite3_initialize'>sqlite3_initialize</a></li>
815 <li><a href='#sqlite3_interrupt'>sqlite3_interrupt</a></li>
816 <li><a href='#sqlite3_interrupt'>sqlite3_is_interrupted</a></li>
817 <li><a href='#sqlite3_keyword_check'>sqlite3_keyword_check</a></li>
818 <li><a href='#sqlite3_keyword_check'>sqlite3_keyword_count</a></li>
819 <li><a href='#sqlite3_keyword_check'>sqlite3_keyword_name</a></li>
820 <li><a href='#sqlite3_last_insert_rowid'>sqlite3_last_insert_rowid</a></li>
821 <li><a href='#sqlite3_libversion'>sqlite3_libversion</a></li>
822 <li><a href='#sqlite3_libversion'>sqlite3_libversion_number</a></li>
823 <li><a href='#sqlite3_limit'>sqlite3_limit</a></li>
824 <li><a href='#sqlite3_load_extension'>sqlite3_load_extension</a></li>
825 <li><a href='#sqlite3_log'>sqlite3_log</a></li>
826 <li><a href='#sqlite3_free'>sqlite3_malloc</a></li>
827 <li><a href='#sqlite3_free'>sqlite3_malloc64</a></li>
828 <li><s>sqlite3_memory_alarm</s></li>
829 <li><a href='#sqlite3_memory_highwater'>sqlite3_memory_highwater</a></li>
830 <li><a href='#sqlite3_memory_highwater'>sqlite3_memory_used</a></li>
831 <li><a href='#sqlite3_mprintf'>sqlite3_mprintf</a></li>
832 <li><a href='#sqlite3_free'>sqlite3_msize</a></li>
833 <li><a href='#sqlite3_mutex_alloc'>sqlite3_mutex_alloc</a></li>
834 <li><a href='#sqlite3_mutex_alloc'>sqlite3_mutex_enter</a></li>
835 <li><a href='#sqlite3_mutex_alloc'>sqlite3_mutex_free</a></li>
836 <li><a href='#sqlite3_mutex_held'>sqlite3_mutex_held</a></li>
837 <li><a href='#sqlite3_mutex_alloc'>sqlite3_mutex_leave</a></li>
838 <li><a href='#sqlite3_mutex_held'>sqlite3_mutex_notheld</a></li>
839 <li><a href='#sqlite3_mutex_alloc'>sqlite3_mutex_try</a></li>
840 <li><a href='#sqlite3_next_stmt'>sqlite3_next_stmt</a></li>
841 <li><a href='#sqlite3_expanded_sql'>sqlite3_normalized_sql</a></li>
842 <li><a href='#sqlite3_open'>sqlite3_open</a></li>
843 <li><a href='#sqlite3_open'>sqlite3_open16</a></li>
844 <li><a href='#sqlite3_open'>sqlite3_open_v2</a></li>
845 <li><a href='#sqlite3_initialize'>sqlite3_os_end</a></li>
846 <li><a href='#sqlite3_initialize'>sqlite3_os_init</a></li>
847 <li><a href='#sqlite3_overload_function'>sqlite3_overload_function</a></li>
848 <li><a href='#sqlite3_prepare'>sqlite3_prepare</a></li>
849 <li><a href='#sqlite3_prepare'>sqlite3_prepare16</a></li>
850 <li><a href='#sqlite3_prepare'>sqlite3_prepare16_v2</a></li>
851 <li><a href='#sqlite3_prepare'>sqlite3_prepare16_v3</a></li>
852 <li><a href='#sqlite3_prepare'>sqlite3_prepare_v2</a></li>
853 <li><a href='#sqlite3_prepare'>sqlite3_prepare_v3</a></li>
854 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_blobwrite</a></li>
855 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_count</a></li>
856 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_depth</a></li>
857 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_hook</a></li>
858 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_new</a></li>
859 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_old</a></li>
860 <li><s>sqlite3_profile</s></li>
861 <li><a href='#sqlite3_progress_handler'>sqlite3_progress_handler</a></li>
862 <li><a href='#sqlite3_randomness'>sqlite3_randomness</a></li>
863 <li><a href='#sqlite3_free'>sqlite3_realloc</a></li>
864 <li><a href='#sqlite3_free'>sqlite3_realloc64</a></li>
865 <li><a href='#sqlite3_release_memory'>sqlite3_release_memory</a></li>
866 <li><a href='#sqlite3_reset'>sqlite3_reset</a></li>
867 <li><a href='#sqlite3_reset_auto_extension'>sqlite3_reset_auto_extension</a></li>
868 <li><a href='#sqlite3_result_blob'>sqlite3_result_blob</a></li>
869 <li><a href='#sqlite3_result_blob'>sqlite3_result_blob64</a></li>
870 <li><a href='#sqlite3_result_blob'>sqlite3_result_double</a></li>
871 <li><a href='#sqlite3_result_blob'>sqlite3_result_error</a></li>
872 <li><a href='#sqlite3_result_blob'>sqlite3_result_error16</a></li>
873 <li><a href='#sqlite3_result_blob'>sqlite3_result_error_code</a></li>
874 <li><a href='#sqlite3_result_blob'>sqlite3_result_error_nomem</a></li>
875 <li><a href='#sqlite3_result_blob'>sqlite3_result_error_toobig</a></li>
876 <li><a href='#sqlite3_result_blob'>sqlite3_result_int</a></li>
877 <li><a href='#sqlite3_result_blob'>sqlite3_result_int64</a></li>
878 <li><a href='#sqlite3_result_blob'>sqlite3_result_null</a></li>
879 <li><a href='#sqlite3_result_blob'>sqlite3_result_pointer</a></li>
880 <li><a href='#sqlite3_result_subtype'>sqlite3_result_subtype</a></li>
881 <li><a href='#sqlite3_result_blob'>sqlite3_result_text</a></li>
882 <li><a href='#sqlite3_result_blob'>sqlite3_result_text16</a></li>
883 <li><a href='#sqlite3_result_blob'>sqlite3_result_text16be</a></li>
884 <li><a href='#sqlite3_result_blob'>sqlite3_result_text16le</a></li>
885 <li><a href='#sqlite3_result_blob'>sqlite3_result_text64</a></li>
886 <li><a href='#sqlite3_result_blob'>sqlite3_result_value</a></li>
887 <li><a href='#sqlite3_result_blob'>sqlite3_result_zeroblob</a></li>
888 <li><a href='#sqlite3_result_blob'>sqlite3_result_zeroblob64</a></li>
889 <li><a href='#sqlite3_commit_hook'>sqlite3_rollback_hook</a></li>
890 <li><a href='#sqlite3_serialize'>sqlite3_serialize</a></li>
891 <li><a href='#sqlite3_set_authorizer'>sqlite3_set_authorizer</a></li>
892 <li><a href='#sqlite3_get_auxdata'>sqlite3_set_auxdata</a></li>
893 <li><a href='#sqlite3_get_clientdata'>sqlite3_set_clientdata</a></li>
894 <li><a href='#sqlite3_set_last_insert_rowid'>sqlite3_set_last_insert_rowid</a></li>
895 <li><a href='#sqlite3_initialize'>sqlite3_shutdown</a></li>
896 <li><a href='#sqlite3_sleep'>sqlite3_sleep</a></li>
897 <li><a href='#sqlite3_snapshot_cmp'>sqlite3_snapshot_cmp</a></li>
898 <li><a href='#sqlite3_snapshot_free'>sqlite3_snapshot_free</a></li>
899 <li><a href='#sqlite3_snapshot_get'>sqlite3_snapshot_get</a></li>
900 <li><a href='#sqlite3_snapshot_open'>sqlite3_snapshot_open</a></li>
901 <li><a href='#sqlite3_snapshot_recover'>sqlite3_snapshot_recover</a></li>
902 <li><a href='#sqlite3_mprintf'>sqlite3_snprintf</a></li>
903 <li><s>sqlite3_soft_heap_limit</s></li>
904 <li><a href='#sqlite3_hard_heap_limit64'>sqlite3_soft_heap_limit64</a></li>
905 <li><a href='#sqlite3_libversion'>sqlite3_sourceid</a></li>
906 <li><a href='#sqlite3_expanded_sql'>sqlite3_sql</a></li>
907 <li><a href='#sqlite3_status'>sqlite3_status</a></li>
908 <li><a href='#sqlite3_status'>sqlite3_status64</a></li>
909 <li><a href='#sqlite3_step'>sqlite3_step</a></li>
910 <li><a href='#sqlite3_stmt_busy'>sqlite3_stmt_busy</a></li>
911 <li><a href='#sqlite3_stmt_explain'>sqlite3_stmt_explain</a></li>
912 <li><a href='#sqlite3_stmt_isexplain'>sqlite3_stmt_isexplain</a></li>
913 <li><a href='#sqlite3_stmt_readonly'>sqlite3_stmt_readonly</a></li>
914 <li><a href='#sqlite3_stmt_scanstatus'>sqlite3_stmt_scanstatus</a></li>
915 <li><a href='#sqlite3_stmt_scanstatus_reset'>sqlite3_stmt_scanstatus_reset</a></li>
916 <li><a href='#sqlite3_stmt_scanstatus'>sqlite3_stmt_scanstatus_v2</a></li>
917 <li><a href='#sqlite3_stmt_status'>sqlite3_stmt_status</a></li>
918 <li><a href='#sqlite3_str_append'>sqlite3_str_append</a></li>
919 <li><a href='#sqlite3_str_append'>sqlite3_str_appendall</a></li>
920 <li><a href='#sqlite3_str_append'>sqlite3_str_appendchar</a></li>
921 <li><a href='#sqlite3_str_append'>sqlite3_str_appendf</a></li>
922 <li><a href='#sqlite3_str_errcode'>sqlite3_str_errcode</a></li>
923 <li><a href='#sqlite3_str_finish'>sqlite3_str_finish</a></li>
924 <li><a href='#sqlite3_str_errcode'>sqlite3_str_length</a></li>
925 <li><a href='#sqlite3_str_new'>sqlite3_str_new</a></li>
926 <li><a href='#sqlite3_str_append'>sqlite3_str_reset</a></li>
927 <li><a href='#sqlite3_str_errcode'>sqlite3_str_value</a></li>
928 <li><a href='#sqlite3_str_append'>sqlite3_str_vappendf</a></li>
929 <li><a href='#sqlite3_strglob'>sqlite3_strglob</a></li>
930 <li><a href='#sqlite3_stricmp'>sqlite3_stricmp</a></li>
931 <li><a href='#sqlite3_strlike'>sqlite3_strlike</a></li>
932 <li><a href='#sqlite3_stricmp'>sqlite3_strnicmp</a></li>
933 <li><a href='#sqlite3_system_errno'>sqlite3_system_errno</a></li>
934 <li><a href='#sqlite3_table_column_metadata'>sqlite3_table_column_metadata</a></li>
935 <li><a href='#sqlite3_test_control'>sqlite3_test_control</a></li>
936 <li><s>sqlite3_thread_cleanup</s></li>
937 <li><a href='#sqlite3_threadsafe'>sqlite3_threadsafe</a></li>
938 <li><a href='#sqlite3_total_changes'>sqlite3_total_changes</a></li>
939 <li><a href='#sqlite3_total_changes'>sqlite3_total_changes64</a></li>
940 <li><s>sqlite3_trace</s></li>
941 <li><a href='#sqlite3_trace_v2'>sqlite3_trace_v2</a></li>
942 <li><s>sqlite3_transfer_bindings</s></li>
943 <li><a href='#sqlite3_txn_state'>sqlite3_txn_state</a></li>
944 <li><a href='#sqlite3_unlock_notify'>sqlite3_unlock_notify</a></li>
945 <li><a href='#sqlite3_update_hook'>sqlite3_update_hook</a></li>
946 <li><a href='#sqlite3_uri_boolean'>sqlite3_uri_boolean</a></li>
947 <li><a href='#sqlite3_uri_boolean'>sqlite3_uri_int64</a></li>
948 <li><a href='#sqlite3_uri_boolean'>sqlite3_uri_key</a></li>
949 <li><a href='#sqlite3_uri_boolean'>sqlite3_uri_parameter</a></li>
950 <li><a href='#sqlite3_user_data'>sqlite3_user_data</a></li>
951 <li><a href='#sqlite3_value_blob'>sqlite3_value_blob</a></li>
952 <li><a href='#sqlite3_value_blob'>sqlite3_value_bytes</a></li>
953 <li><a href='#sqlite3_value_blob'>sqlite3_value_bytes16</a></li>
954 <li><a href='#sqlite3_value_blob'>sqlite3_value_double</a></li>
955 <li><a href='#sqlite3_value_dup'>sqlite3_value_dup</a></li>
956 <li><a href='#sqlite3_value_encoding'>sqlite3_value_encoding</a></li>
957 <li><a href='#sqlite3_value_dup'>sqlite3_value_free</a></li>
958 <li><a href='#sqlite3_value_blob'>sqlite3_value_frombind</a></li>
959 <li><a href='#sqlite3_value_blob'>sqlite3_value_int</a></li>
960 <li><a href='#sqlite3_value_blob'>sqlite3_value_int64</a></li>
961 <li><a href='#sqlite3_value_blob'>sqlite3_value_nochange</a></li>
962 <li><a href='#sqlite3_value_blob'>sqlite3_value_numeric_type</a></li>
963 <li><a href='#sqlite3_value_blob'>sqlite3_value_pointer</a></li>
964 <li><a href='#sqlite3_value_subtype'>sqlite3_value_subtype</a></li>
965 <li><a href='#sqlite3_value_blob'>sqlite3_value_text</a></li>
966 <li><a href='#sqlite3_value_blob'>sqlite3_value_text16</a></li>
967 <li><a href='#sqlite3_value_blob'>sqlite3_value_text16be</a></li>
968 <li><a href='#sqlite3_value_blob'>sqlite3_value_text16le</a></li>
969 <li><a href='#sqlite3_value_blob'>sqlite3_value_type</a></li>
970 <li><a href='#sqlite3_libversion'>sqlite3_version</a></li>
971 <li><a href='#sqlite3_vfs_find'>sqlite3_vfs_find</a></li>
972 <li><a href='#sqlite3_vfs_find'>sqlite3_vfs_register</a></li>
973 <li><a href='#sqlite3_vfs_find'>sqlite3_vfs_unregister</a></li>
974 <li><a href='#sqlite3_mprintf'>sqlite3_vmprintf</a></li>
975 <li><a href='#sqlite3_mprintf'>sqlite3_vsnprintf</a></li>
976 <li><a href='#sqlite3_vtab_collation'>sqlite3_vtab_collation</a></li>
977 <li><a href='#sqlite3_vtab_config'>sqlite3_vtab_config</a></li>
978 <li><a href='#sqlite3_vtab_distinct'>sqlite3_vtab_distinct</a></li>
979 <li><a href='#sqlite3_vtab_in'>sqlite3_vtab_in</a></li>
980 <li><a href='#sqlite3_vtab_in_first'>sqlite3_vtab_in_first</a></li>
981 <li><a href='#sqlite3_vtab_in_first'>sqlite3_vtab_in_next</a></li>
982 <li><a href='#sqlite3_vtab_nochange'>sqlite3_vtab_nochange</a></li>
983 <li><a href='#sqlite3_vtab_on_conflict'>sqlite3_vtab_on_conflict</a></li>
984 <li><a href='#sqlite3_vtab_rhs_value'>sqlite3_vtab_rhs_value</a></li>
985 <li><a href='#sqlite3_wal_autocheckpoint'>sqlite3_wal_autocheckpoint</a></li>
986 <li><a href='#sqlite3_wal_checkpoint'>sqlite3_wal_checkpoint</a></li>
987 <li><a href='#sqlite3_wal_checkpoint_v2'>sqlite3_wal_checkpoint_v2</a></li>
988 <li><a href='#sqlite3_wal_hook'>sqlite3_wal_hook</a></li>
989 <li><a href='#sqlite3_win32_set_directory'>sqlite3_win32_set_directory</a></li>
990 <li><a href='#sqlite3_win32_set_directory'>sqlite3_win32_set_directory16</a></li>
991 <li><a href='#sqlite3_win32_set_directory'>sqlite3_win32_set_directory8</a></li>
992 </ul>
993 </div>
994 <hr>
995 <a name="SQLITE_INDEX_SCAN_UNIQUE"></a>
996 <h2>Virtual Table Scan Flags</h2>
997 </div>
998 <blockquote><pre>
999 #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
1000 </pre></blockquote>
1001 <p>
1002 Virtual table implementations are allowed to set the
1003 <a href="#sqlite3_index_info">sqlite3_index_info</a>.idxFlags field to some combination of
1004 these bits.
1005 </p><hr><a name="SQLITE_SERIALIZE_NOCOPY"></a>
1006 <h2>Flags for sqlite3_serialize</h2>
1007 </div>
1008 <blockquote><pre>
1009 #define SQLITE_SERIALIZE_NOCOPY 0x001 /* Do no memory allocations */
1010 </pre></blockquote>
1011 <p>
1012 Zero or more of the following constants can be OR-ed together for
1013 the F argument to <a href="#sqlite3_serialize">sqlite3_serialize(D,S,P,F)</a>.</p>
1014
1015 <p>SQLITE_SERIALIZE_NOCOPY means that <a href="#sqlite3_serialize">sqlite3_serialize()</a> will return
1016 a pointer to contiguous in-memory database that it is currently using,
1017 without making a copy of the database. If SQLite is not currently using
1018 a contiguous in-memory database, then this option causes
1019 <a href="#sqlite3_serialize">sqlite3_serialize()</a> to return a NULL pointer. SQLite will only be
1020 using a contiguous in-memory database if it has been initialized by a
1021 prior call to <a href="#sqlite3_deserialize">sqlite3_deserialize()</a>.
1022 </p><hr><a name="SQLITE_SHM_NLOCK"></a>
1023 <h2>Maximum xShmLock index</h2>
1024 </div>
1025 <blockquote><pre>
1026 #define SQLITE_SHM_NLOCK 8
1027 </pre></blockquote>
1028 <p>
1029 The xShmLock method on <a href="#sqlite3_io_methods">sqlite3_io_methods</a> may use values
1030 between 0 and this upper bound as its "offset" argument.
1031 The SQLite core will never attempt to acquire or release a
1032 lock outside of this range
1033 </p><hr><a name="sqlite3_api_routines"></a>
1034 <h2>Loadable Extension Thunk</h2>
1035 </div>
1036 <blockquote><pre>
1037 typedef struct sqlite3_api_routines sqlite3_api_routines;
1038 </pre></blockquote>
1039 <p>
1040 A pointer to the opaque sqlite3_api_routines structure is passed as
1041 the third parameter to entry points of <a href="loadext.html">loadable extensions</a>. This
1042 structure must be typedefed in order to work around compiler warnings
1043 on some platforms.
1044 </p><hr><a name="sqlite3_backup"></a>
1045 <h2>Online Backup Object</h2>
1046 </div>
1047 <blockquote><pre>
1048 typedef struct sqlite3_backup sqlite3_backup;
1049 </pre></blockquote>
1050 <p>
1051 The sqlite3_backup object records state information about an ongoing
1052 online backup operation. The sqlite3_backup object is created by
1053 a call to <a href="#sqlite3backupinit">sqlite3_backup_init()</a> and is destroyed by a call to
1054 <a href="#sqlite3backupfinish">sqlite3_backup_finish()</a>.</p>
1055
1056 <p>See Also: <a href="backup.html">Using the SQLite Online Backup API</a>
1057 </p><hr><a name="sqlite3_context"></a>
1058 <h2>SQL Function Context Object</h2>
1059 </div>
1060 <blockquote><pre>
1061 typedef struct sqlite3_context sqlite3_context;
1062 </pre></blockquote>
1063 <p>
1064 The context in which an SQL function executes is stored in an
1065 sqlite3_context object. A pointer to an sqlite3_context object
1066 is always first parameter to <a href="appfunc.html">application-defined SQL functions</a>.
1067 The application-defined SQL function implementation will pass this
1068 pointer through into calls to <a href="#sqlite3_result_blob">sqlite3_result()</a>,
1069 <a href="#sqlite3_aggregate_context">sqlite3_aggregate_context()</a>, <a href="#sqlite3_user_data">sqlite3_user_data()</a>,
1070 <a href="#sqlite3_context_db_handle">sqlite3_context_db_handle()</a>, <a href="#sqlite3_get_auxdata">sqlite3_get_auxdata()</a>,
1071 and/or <a href="#sqlite3_get_auxdata">sqlite3_set_auxdata()</a>.
1072 </p><p>26 Methods using this object:
1073 <div class='columns' style='columns: 17em auto;'>
1074 <ul style='padding-top:0;'>
1075 <li><a href='#sqlite3_aggregate_context'>sqlite3_aggregate_context</a></li>
1076 <li><a href='#sqlite3_context_db_handle'>sqlite3_context_db_handle</a></li>
1077 <li><a href='#sqlite3_get_auxdata'>sqlite3_get_auxdata</a></li>
1078 <li><a href='#sqlite3_result_blob'>sqlite3_result_blob</a></li>
1079 <li><a href='#sqlite3_result_blob'>sqlite3_result_blob64</a></li>
1080 <li><a href='#sqlite3_result_blob'>sqlite3_result_double</a></li>
1081 <li><a href='#sqlite3_result_blob'>sqlite3_result_error</a></li>
1082 <li><a href='#sqlite3_result_blob'>sqlite3_result_error16</a></li>
1083 <li><a href='#sqlite3_result_blob'>sqlite3_result_error_code</a></li>
1084 <li><a href='#sqlite3_result_blob'>sqlite3_result_error_nomem</a></li>
1085 <li><a href='#sqlite3_result_blob'>sqlite3_result_error_toobig</a></li>
1086 <li><a href='#sqlite3_result_blob'>sqlite3_result_int</a></li>
1087 <li><a href='#sqlite3_result_blob'>sqlite3_result_int64</a></li>
1088 <li><a href='#sqlite3_result_blob'>sqlite3_result_null</a></li>
1089 <li><a href='#sqlite3_result_blob'>sqlite3_result_pointer</a></li>
1090 <li><a href='#sqlite3_result_subtype'>sqlite3_result_subtype</a></li>
1091 <li><a href='#sqlite3_result_blob'>sqlite3_result_text</a></li>
1092 <li><a href='#sqlite3_result_blob'>sqlite3_result_text16</a></li>
1093 <li><a href='#sqlite3_result_blob'>sqlite3_result_text16be</a></li>
1094 <li><a href='#sqlite3_result_blob'>sqlite3_result_text16le</a></li>
1095 <li><a href='#sqlite3_result_blob'>sqlite3_result_text64</a></li>
1096 <li><a href='#sqlite3_result_blob'>sqlite3_result_value</a></li>
1097 <li><a href='#sqlite3_result_blob'>sqlite3_result_zeroblob</a></li>
1098 <li><a href='#sqlite3_result_blob'>sqlite3_result_zeroblob64</a></li>
1099 <li><a href='#sqlite3_get_auxdata'>sqlite3_set_auxdata</a></li>
1100 <li><a href='#sqlite3_user_data'>sqlite3_user_data</a></li>
1101 </ul>
1102 </div>
1103 </p>
1104 <hr><a name="sqlite3_data_directory"></a>
1105 <h2>Name Of The Folder Holding Database Files</h2>
1106 </div>
1107 <blockquote><pre>
1108 SQLITE_EXTERN char *sqlite3_data_directory;
1109 </pre></blockquote>
1110 <p>
1111 If this global variable is made to point to a string which is
1112 the name of a folder (a.k.a. directory), then all database files
1113 specified with a relative pathname and created or accessed by
1114 SQLite when using a built-in windows <a href="#sqlite3_vfs">VFS</a> will be assumed
1115 to be relative to that directory. If this variable is a NULL
1116 pointer, then SQLite assumes that all database files specified
1117 with a relative pathname are relative to the current directory
1118 for the process. Only the windows VFS makes use of this global
1119 variable; it is ignored by the unix VFS.</p>
1120
1121 <p>Changing the value of this variable while a database connection is
1122 open can result in a corrupt database.</p>
1123
1124 <p>It is not safe to read or modify this variable in more than one
1125 thread at a time. It is not safe to read or modify this variable
1126 if a <a href="#sqlite3">database connection</a> is being used at the same time in a separate
1127 thread.
1128 It is intended that this variable be set once
1129 as part of process initialization and before any SQLite interface
1130 routines have been called and that this variable remain unchanged
1131 thereafter.</p>
1132
1133 <p>The <a href="pragma.html#pragma_data_store_directory">data_store_directory pragma</a> may modify this variable and cause
1134 it to point to memory obtained from <a href="#sqlite3_free">sqlite3_malloc</a>. Furthermore,
1135 the <a href="pragma.html#pragma_data_store_directory">data_store_directory pragma</a> always assumes that any string
1136 that this variable points to is held in memory obtained from
1137 <a href="#sqlite3_free">sqlite3_malloc</a> and the pragma may attempt to free that memory
1138 using <a href="#sqlite3_free">sqlite3_free</a>.
1139 Hence, if this variable is modified directly, either it should be
1140 made NULL or made to point to memory obtained from <a href="#sqlite3_free">sqlite3_malloc</a>
1141 or else the use of the <a href="pragma.html#pragma_data_store_directory">data_store_directory pragma</a> should be avoided.
1142 </p><hr><a name="sqlite3_file"></a>
1143 <h2>OS Interface Open File Handle</h2>
1144 </div>
1145 <blockquote><pre>
1146 typedef struct sqlite3_file sqlite3_file;
1147 struct sqlite3_file {
1148 const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
1149 };
1150 </pre></blockquote>
1151 <p>
1152 An <a href="#sqlite3_file">sqlite3_file</a> object represents an open file in the
1153 <a href="#sqlite3_vfs">OS interface layer</a>. Individual OS interface
1154 implementations will
1155 want to subclass this object by appending additional fields
1156 for their own use. The pMethods entry is a pointer to an
1157 <a href="#sqlite3_io_methods">sqlite3_io_methods</a> object that defines methods for performing
1158 I/O operations on the open file.
1159 </p><hr><a name="sqlite3_filename"></a>
1160 <h2>File Name</h2>
1161 </div>
1162 <blockquote><pre>
1163 typedef const char *sqlite3_filename;
1164 </pre></blockquote>
1165 <p>
1166 Type <a href="#sqlite3_filename">sqlite3_filename</a> is used by SQLite to pass filenames to the
1167 xOpen method of a <a href="vfs.html">VFS</a>. It may be cast to (const char*) and treated
1168 as a normal, nul-terminated, UTF-8 buffer containing the filename, but
1169 may also be passed to special APIs such as:</p>
1170
1171 <p><ul>
1172 <li> sqlite3_filename_database()
1173 <li> sqlite3_filename_journal()
1174 <li> sqlite3_filename_wal()
1175 <li> sqlite3_uri_parameter()
1176 <li> sqlite3_uri_boolean()
1177 <li> sqlite3_uri_int64()
1178 <li> sqlite3_uri_key()
1179 </ul>
1180 </p><hr><a name="sqlite3_index_info"></a>
1181 <h2>Virtual Table Indexing Information</h2>
1182 </div>
1183 <blockquote><pre>
1184 struct sqlite3_index_info {
1185 /* Inputs */
1186 int nConstraint; /* Number of entries in aConstraint */
1187 struct sqlite3_index_constraint {
1188 int iColumn; /* Column constrained. -1 for ROWID */
1189 unsigned char op; /* Constraint operator */
1190 unsigned char usable; /* True if this constraint is usable */
1191 int iTermOffset; /* Used internally - xBestIndex should ignore */
1192 } *aConstraint; /* Table of WHERE clause constraints */
1193 int nOrderBy; /* Number of terms in the ORDER BY clause */
1194 struct sqlite3_index_orderby {
1195 int iColumn; /* Column number */
1196 unsigned char desc; /* True for DESC. False for ASC. */
1197 } *aOrderBy; /* The ORDER BY clause */
1198 /* Outputs */
1199 struct sqlite3_index_constraint_usage {
1200 int argvIndex; /* if &gt;0, constraint is part of argv to xFilter */
1201 unsigned char omit; /* Do not code a test for this constraint */
1202 } *aConstraintUsage;
1203 int idxNum; /* Number used to identify the index */
1204 char *idxStr; /* String, possibly obtained from sqlite3_malloc */
1205 int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
1206 int orderByConsumed; /* True if output is already ordered */
1207 double estimatedCost; /* Estimated cost of using this index */
1208 /* Fields below are only available in SQLite 3.8.2 and later */
1209 sqlite3_int64 estimatedRows; /* Estimated number of rows returned */
1210 /* Fields below are only available in SQLite 3.9.0 and later */
1211 int idxFlags; /* Mask of SQLITE_INDEX_SCAN_* flags */
1212 /* Fields below are only available in SQLite 3.10.0 and later */
1213 sqlite3_uint64 colUsed; /* Input: Mask of columns used by statement */
1214 };
1215 </pre></blockquote>
1216 <p>
1217 The sqlite3_index_info structure and its substructures is used as part
1218 of the <a href="vtab.html">virtual table</a> interface to
1219 pass information into and receive the reply from the <a href="vtab.html#xbestindex">xBestIndex</a>
1220 method of a <a href="#sqlite3_module">virtual table module</a>. The fields under **Inputs** are the
1221 inputs to xBestIndex and are read-only. xBestIndex inserts its
1222 results into the **Outputs** fields.</p>
1223
1224 <p>The aConstraint[] array records WHERE clause constraints of the form:</p>
1225
1226 <p><blockquote>column OP expr</blockquote></p>
1227
1228 <p>where OP is =, &lt;, &lt;=, &gt;, or &gt;=. The particular operator is
1229 stored in aConstraint[].op using one of the
1230 <a href="#SQLITE_INDEX_CONSTRAINT_EQ">SQLITE_INDEX_CONSTRAINT_ values</a>.
1231 The index of the column is stored in
1232 aConstraint[].iColumn. aConstraint[].usable is TRUE if the
1233 expr on the right-hand side can be evaluated (and thus the constraint
1234 is usable) and false if it cannot.</p>
1235
1236 <p>The optimizer automatically inverts terms of the form "expr OP column"
1237 and makes other simplifications to the WHERE clause in an attempt to
1238 get as many WHERE clause terms into the form shown above as possible.
1239 The aConstraint[] array only reports WHERE clause terms that are
1240 relevant to the particular virtual table being queried.</p>
1241
1242 <p>Information about the ORDER BY clause is stored in aOrderBy[].
1243 Each term of aOrderBy records a column of the ORDER BY clause.</p>
1244
1245 <p>The colUsed field indicates which columns of the virtual table may be
1246 required by the current scan. Virtual table columns are numbered from
1247 zero in the order in which they appear within the CREATE TABLE statement
1248 passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
1249 the corresponding bit is set within the colUsed mask if the column may be
1250 required by SQLite. If the table has at least 64 columns and any column
1251 to the right of the first 63 is required, then bit 63 of colUsed is also
1252 set. In other words, column iCol may be required if the expression
1253 (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to
1254 non-zero.</p>
1255
1256 <p>The <a href="vtab.html#xbestindex">xBestIndex</a> method must fill aConstraintUsage[] with information
1257 about what parameters to pass to xFilter. If argvIndex>0 then
1258 the right-hand side of the corresponding aConstraint[] is evaluated
1259 and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit
1260 is true, then the constraint is assumed to be fully handled by the
1261 virtual table and might not be checked again by the byte code. The
1262 aConstraintUsage[].omit flag is an optimization hint. When the omit flag
1263 is left in its default setting of false, the constraint will always be
1264 checked separately in byte code. If the omit flag is change to true, then
1265 the constraint may or may not be checked in byte code. In other words,
1266 when the omit flag is true there is no guarantee that the constraint will
1267 not be checked again using byte code.</p>
1268
1269 <p>The idxNum and idxStr values are recorded and passed into the
1270 <a href="vtab.html#xfilter">xFilter</a> method.
1271 <a href="#sqlite3_free">sqlite3_free()</a> is used to free idxStr if and only if
1272 needToFreeIdxStr is true.</p>
1273
1274 <p>The orderByConsumed means that output from <a href="vtab.html#xfilter">xFilter</a>/<a href="vtab.html#xnext">xNext</a> will occur in
1275 the correct order to satisfy the ORDER BY clause so that no separate
1276 sorting step is required.</p>
1277
1278 <p>The estimatedCost value is an estimate of the cost of a particular
1279 strategy. A cost of N indicates that the cost of the strategy is similar
1280 to a linear scan of an SQLite table with N rows. A cost of log(N)
1281 indicates that the expense of the operation is similar to that of a
1282 binary search on a unique indexed field of an SQLite table with N rows.</p>
1283
1284 <p>The estimatedRows value is an estimate of the number of rows that
1285 will be returned by the strategy.</p>
1286
1287 <p>The xBestIndex method may optionally populate the idxFlags field with a
1288 mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -
1289 SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
1290 assumes that the strategy may visit at most one row.</p>
1291
1292 <p>Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
1293 SQLite also assumes that if a call to the xUpdate() method is made as
1294 part of the same statement to delete or update a virtual table row and the
1295 implementation returns SQLITE_CONSTRAINT, then there is no need to rollback
1296 any database changes. In other words, if the xUpdate() returns
1297 SQLITE_CONSTRAINT, the database contents must be exactly as they were
1298 before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not
1299 set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by
1300 the xUpdate method are automatically rolled back by SQLite.</p>
1301
1302 <p>IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
1303 structure for SQLite <a href="releaselog/3_8_2.html">version 3.8.2</a> (2013-12-06).
1304 If a virtual table extension is
1305 used with an SQLite version earlier than 3.8.2, the results of attempting
1306 to read or write the estimatedRows field are undefined (but are likely
1307 to include crashing the application). The estimatedRows field should
1308 therefore only be used if <a href="#sqlite3_libversion">sqlite3_libversion_number()</a> returns a
1309 value greater than or equal to 3008002. Similarly, the idxFlags field
1310 was added for <a href="releaselog/3_9_0.html">version 3.9.0</a> (2015-10-14).
1311 It may therefore only be used if
1312 sqlite3_libversion_number() returns a value greater than or equal to
1313 3009000.
1314 </p><p>3 Methods using this object:
1315 <a href="#sqlite3_vtab_collation">sqlite3_vtab_collation()</a>,
1316 <a href="#sqlite3_vtab_distinct">sqlite3_vtab_distinct()</a>,
1317 <a href="#sqlite3_vtab_rhs_value">sqlite3_vtab_rhs_value()</a></p>
1318 <hr><a name="sqlite3_io_methods"></a>
1319 <h2>OS Interface File Virtual Methods Object</h2>
1320 </div>
1321 <blockquote><pre>
1322 typedef struct sqlite3_io_methods sqlite3_io_methods;
1323 struct sqlite3_io_methods {
1324 int iVersion;
1325 int (*xClose)(sqlite3_file*);
1326 int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
1327 int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
1328 int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
1329 int (*xSync)(sqlite3_file*, int flags);
1330 int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
1331 int (*xLock)(sqlite3_file*, int);
1332 int (*xUnlock)(sqlite3_file*, int);
1333 int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
1334 int (*xFileControl)(sqlite3_file*, int op, void *pArg);
1335 int (*xSectorSize)(sqlite3_file*);
1336 int (*xDeviceCharacteristics)(sqlite3_file*);
1337 /* Methods above are valid for version 1 */
1338 int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
1339 int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
1340 void (*xShmBarrier)(sqlite3_file*);
1341 int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
1342 /* Methods above are valid for version 2 */
1343 int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
1344 int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
1345 /* Methods above are valid for version 3 */
1346 /* Additional methods may be added in future releases */
1347 };
1348 </pre></blockquote>
1349 <p>
1350 Every file opened by the <a href="#sqlite3vfsxopen">sqlite3_vfs.xOpen</a> method populates an
1351 <a href="#sqlite3_file">sqlite3_file</a> object (or, more commonly, a subclass of the
1352 <a href="#sqlite3_file">sqlite3_file</a> object) with a pointer to an instance of this object.
1353 This object defines the methods used to perform various operations
1354 against the open file represented by the <a href="#sqlite3_file">sqlite3_file</a> object.</p>
1355
1356 <p>If the <a href="#sqlite3vfsxopen">sqlite3_vfs.xOpen</a> method sets the sqlite3_file.pMethods element
1357 to a non-NULL pointer, then the sqlite3_io_methods.xClose method
1358 may be invoked even if the <a href="#sqlite3vfsxopen">sqlite3_vfs.xOpen</a> reported that it failed. The
1359 only way to prevent a call to xClose following a failed <a href="#sqlite3vfsxopen">sqlite3_vfs.xOpen</a>
1360 is for the <a href="#sqlite3vfsxopen">sqlite3_vfs.xOpen</a> to set the sqlite3_file.pMethods element
1361 to NULL.</p>
1362
1363 <p>The flags argument to xSync may be one of <a href="#SQLITE_SYNC_DATAONLY">SQLITE_SYNC_NORMAL</a> or
1364 <a href="#SQLITE_SYNC_DATAONLY">SQLITE_SYNC_FULL</a>. The first choice is the normal fsync().
1365 The second choice is a Mac OS X style fullsync. The <a href="#SQLITE_SYNC_DATAONLY">SQLITE_SYNC_DATAONLY</a>
1366 flag may be ORed in to indicate that only the data of the file
1367 and not its inode needs to be synced.</p>
1368
1369 <p>The integer values to xLock() and xUnlock() are one of
1370 <ul>
1371 <li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_NONE</a>,
1372 <li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_SHARED</a>,
1373 <li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_RESERVED</a>,
1374 <li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_PENDING</a>, or
1375 <li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_EXCLUSIVE</a>.
1376 </ul>
1377 xLock() upgrades the database file lock. In other words, xLock() moves the
1378 database file lock in the direction NONE toward EXCLUSIVE. The argument to
1379 xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
1380 SQLITE_LOCK_NONE. If the database file lock is already at or above the
1381 requested lock, then the call to xLock() is a no-op.
1382 xUnlock() downgrades the database file lock to either SHARED or NONE.
1383 If the lock is already at or below the requested lock state, then the call
1384 to xUnlock() is a no-op.
1385 The xCheckReservedLock() method checks whether any database connection,
1386 either in this process or in some other process, is holding a RESERVED,
1387 PENDING, or EXCLUSIVE lock on the file. It returns true
1388 if such a lock exists and false otherwise.</p>
1389
1390 <p>The xFileControl() method is a generic interface that allows custom
1391 VFS implementations to directly control an open file using the
1392 <a href="#sqlite3_file_control">sqlite3_file_control()</a> interface. The second "op" argument is an
1393 integer opcode. The third argument is a generic pointer intended to
1394 point to a structure that may contain arguments or space in which to
1395 write return values. Potential uses for xFileControl() might be
1396 functions to enable blocking locks with timeouts, to change the
1397 locking strategy (for example to use dot-file locks), to inquire
1398 about the status of a lock, or to break stale locks. The SQLite
1399 core reserves all opcodes less than 100 for its own use.
1400 A <a href="#SQLITE_FCNTL_BEGIN_ATOMIC_WRITE">list of opcodes</a> less than 100 is available.
1401 Applications that define a custom xFileControl method should use opcodes
1402 greater than 100 to avoid conflicts. VFS implementations should
1403 return <a href="#SQLITE_ABORT">SQLITE_NOTFOUND</a> for file control opcodes that they do not
1404 recognize.</p>
1405
1406 <p>The xSectorSize() method returns the sector size of the
1407 device that underlies the file. The sector size is the
1408 minimum write that can be performed without disturbing
1409 other bytes in the file. The xDeviceCharacteristics()
1410 method returns a bit vector describing behaviors of the
1411 underlying device:</p>
1412
1413 <p><ul>
1414 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC</a>
1415 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC512</a>
1416 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC1K</a>
1417 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC2K</a>
1418 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC4K</a>
1419 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC8K</a>
1420 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC16K</a>
1421 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC32K</a>
1422 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC64K</a>
1423 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_SAFE_APPEND</a>
1424 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_SEQUENTIAL</a>
1425 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN</a>
1426 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_POWERSAFE_OVERWRITE</a>
1427 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_IMMUTABLE</a>
1428 <li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_BATCH_ATOMIC</a>
1429 </ul></p>
1430
1431 <p>The SQLITE_IOCAP_ATOMIC property means that all writes of
1432 any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
1433 mean that writes of blocks that are nnn bytes in size and
1434 are aligned to an address which is an integer multiple of
1435 nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
1436 that when data is appended to a file, the data is appended
1437 first then the size of the file is extended, never the other
1438 way around. The SQLITE_IOCAP_SEQUENTIAL property means that
1439 information is written to disk in the same order as calls
1440 to xWrite().</p>
1441
1442 <p>If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
1443 in the unread portions of the buffer with zeros. A VFS that
1444 fails to zero-fill short reads might seem to work. However,
1445 failure to zero-fill short reads will eventually lead to
1446 database corruption.
1447 </p><hr><a name="sqlite3_mem_methods"></a>
1448 <h2>Memory Allocation Routines</h2>
1449 </div>
1450 <blockquote><pre>
1451 typedef struct sqlite3_mem_methods sqlite3_mem_methods;
1452 struct sqlite3_mem_methods {
1453 void *(*xMalloc)(int); /* Memory allocation function */
1454 void (*xFree)(void*); /* Free a prior allocation */
1455 void *(*xRealloc)(void*,int); /* Resize an allocation */
1456 int (*xSize)(void*); /* Return the size of an allocation */
1457 int (*xRoundup)(int); /* Round up request size to allocation size */
1458 int (*xInit)(void*); /* Initialize the memory allocator */
1459 void (*xShutdown)(void*); /* Deinitialize the memory allocator */
1460 void *pAppData; /* Argument to xInit() and xShutdown() */
1461 };
1462 </pre></blockquote>
1463 <p>
1464 An instance of this object defines the interface between SQLite
1465 and low-level memory allocation routines.</p>
1466
1467 <p>This object is used in only one place in the SQLite interface.
1468 A pointer to an instance of this object is the argument to
1469 <a href="#sqlite3_config">sqlite3_config()</a> when the configuration option is
1470 <a href="#sqliteconfigmalloc">SQLITE_CONFIG_MALLOC</a> or <a href="#sqliteconfiggetmalloc">SQLITE_CONFIG_GETMALLOC</a>.
1471 By creating an instance of this object
1472 and passing it to <a href="#sqlite3_config">sqlite3_config</a>(<a href="#sqliteconfigmalloc">SQLITE_CONFIG_MALLOC</a>)
1473 during configuration, an application can specify an alternative
1474 memory allocation subsystem for SQLite to use for all of its
1475 dynamic memory needs.</p>
1476
1477 <p>Note that SQLite comes with several <a href="malloc.html#altalloc">built-in memory allocators</a>
1478 that are perfectly adequate for the overwhelming majority of applications
1479 and that this object is only useful to a tiny minority of applications
1480 with specialized memory allocation requirements. This object is
1481 also used during testing of SQLite in order to specify an alternative
1482 memory allocator that simulates memory out-of-memory conditions in
1483 order to verify that SQLite recovers gracefully from such
1484 conditions.</p>
1485
1486 <p>The xMalloc, xRealloc, and xFree methods must work like the
1487 malloc(), realloc() and free() functions from the standard C library.
1488 SQLite guarantees that the second argument to
1489 xRealloc is always a value returned by a prior call to xRoundup.</p>
1490
1491 <p>xSize should return the allocated size of a memory allocation
1492 previously obtained from xMalloc or xRealloc. The allocated size
1493 is always at least as big as the requested size but may be larger.</p>
1494
1495 <p>The xRoundup method returns what would be the allocated size of
1496 a memory allocation given a particular requested size. Most memory
1497 allocators round up memory allocations at least to the next multiple
1498 of 8. Some allocators round up to a larger multiple or to a power of 2.
1499 Every memory allocation request coming in through <a href="#sqlite3_free">sqlite3_malloc()</a>
1500 or <a href="#sqlite3_free">sqlite3_realloc()</a> first calls xRoundup. If xRoundup returns 0,
1501 that causes the corresponding memory allocation to fail.</p>
1502
1503 <p>The xInit method initializes the memory allocator. For example,
1504 it might allocate any required mutexes or initialize internal data
1505 structures. The xShutdown method is invoked (indirectly) by
1506 <a href="#sqlite3_initialize">sqlite3_shutdown()</a> and should deallocate any resources acquired
1507 by xInit. The pAppData pointer is used as the only parameter to
1508 xInit and xShutdown.</p>
1509
1510 <p>SQLite holds the <a href="#SQLITE_MUTEX_FAST">SQLITE_MUTEX_STATIC_MAIN</a> mutex when it invokes
1511 the xInit method, so the xInit method need not be threadsafe. The
1512 xShutdown method is only called from <a href="#sqlite3_initialize">sqlite3_shutdown()</a> so it does
1513 not need to be threadsafe either. For all other methods, SQLite
1514 holds the <a href="#SQLITE_MUTEX_FAST">SQLITE_MUTEX_STATIC_MEM</a> mutex as long as the
1515 <a href="#sqliteconfigmemstatus">SQLITE_CONFIG_MEMSTATUS</a> configuration option is turned on (which
1516 it is by default) and so the methods are automatically serialized.
1517 However, if <a href="#sqliteconfigmemstatus">SQLITE_CONFIG_MEMSTATUS</a> is disabled, then the other
1518 methods must be threadsafe or else make their own arrangements for
1519 serialization.</p>
1520
1521 <p>SQLite will never invoke xInit() more than once without an intervening
1522 call to xShutdown().
1523 </p><hr><a name="sqlite3_mutex"></a>
1524 <h2>Mutex Handle</h2>
1525 </div>
1526 <blockquote><pre>
1527 typedef struct sqlite3_mutex sqlite3_mutex;
1528 </pre></blockquote>
1529 <p>
1530 The mutex module within SQLite defines <a href="#sqlite3_mutex">sqlite3_mutex</a> to be an
1531 abstract type for a mutex object. The SQLite core never looks
1532 at the internal representation of an <a href="#sqlite3_mutex">sqlite3_mutex</a>. It only
1533 deals with pointers to the <a href="#sqlite3_mutex">sqlite3_mutex</a> object.</p>
1534
1535 <p>Mutexes are created using <a href="#sqlite3_mutex_alloc">sqlite3_mutex_alloc()</a>.
1536 </p><hr><a name="sqlite3_mutex_methods"></a>
1537 <h2>Mutex Methods Object</h2>
1538 </div>
1539 <blockquote><pre>
1540 typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
1541 struct sqlite3_mutex_methods {
1542 int (*xMutexInit)(void);
1543 int (*xMutexEnd)(void);
1544 sqlite3_mutex *(*xMutexAlloc)(int);
1545 void (*xMutexFree)(sqlite3_mutex *);
1546 void (*xMutexEnter)(sqlite3_mutex *);
1547 int (*xMutexTry)(sqlite3_mutex *);
1548 void (*xMutexLeave)(sqlite3_mutex *);
1549 int (*xMutexHeld)(sqlite3_mutex *);
1550 int (*xMutexNotheld)(sqlite3_mutex *);
1551 };
1552 </pre></blockquote>
1553 <p>
1554 An instance of this structure defines the low-level routines
1555 used to allocate and use mutexes.</p>
1556
1557 <p>Usually, the default mutex implementations provided by SQLite are
1558 sufficient, however the application has the option of substituting a custom
1559 implementation for specialized deployments or systems for which SQLite
1560 does not provide a suitable implementation. In this case, the application
1561 creates and populates an instance of this structure to pass
1562 to sqlite3_config() along with the <a href="#sqliteconfigmutex">SQLITE_CONFIG_MUTEX</a> option.
1563 Additionally, an instance of this structure can be used as an
1564 output variable when querying the system for the current mutex
1565 implementation, using the <a href="#sqliteconfiggetmutex">SQLITE_CONFIG_GETMUTEX</a> option.</p>
1566
1567 <p>The xMutexInit method defined by this structure is invoked as
1568 part of system initialization by the sqlite3_initialize() function.
1569 The xMutexInit routine is called by SQLite exactly once for each
1570 effective call to <a href="#sqlite3_initialize">sqlite3_initialize()</a>.</p>
1571
1572 <p>The xMutexEnd method defined by this structure is invoked as
1573 part of system shutdown by the sqlite3_shutdown() function. The
1574 implementation of this method is expected to release all outstanding
1575 resources obtained by the mutex methods implementation, especially
1576 those obtained by the xMutexInit method. The xMutexEnd()
1577 interface is invoked exactly once for each call to <a href="#sqlite3_initialize">sqlite3_shutdown()</a>.</p>
1578
1579 <p>The remaining seven methods defined by this structure (xMutexAlloc,
1580 xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
1581 xMutexNotheld) implement the following interfaces (respectively):</p>
1582
1583 <p><ul>
1584 <li> <a href="#sqlite3_mutex_alloc">sqlite3_mutex_alloc()</a> </li>
1585 <li> <a href="#sqlite3_mutex_alloc">sqlite3_mutex_free()</a> </li>
1586 <li> <a href="#sqlite3_mutex_alloc">sqlite3_mutex_enter()</a> </li>
1587 <li> <a href="#sqlite3_mutex_alloc">sqlite3_mutex_try()</a> </li>
1588 <li> <a href="#sqlite3_mutex_alloc">sqlite3_mutex_leave()</a> </li>
1589 <li> <a href="#sqlite3_mutex_held">sqlite3_mutex_held()</a> </li>
1590 <li> <a href="#sqlite3_mutex_held">sqlite3_mutex_notheld()</a> </li>
1591 </ul></p>
1592
1593 <p>The only difference is that the public sqlite3_XXX functions enumerated
1594 above silently ignore any invocations that pass a NULL pointer instead
1595 of a valid mutex handle. The implementations of the methods defined
1596 by this structure are not required to handle this case. The results
1597 of passing a NULL pointer instead of a valid mutex handle are undefined
1598 (i.e. it is acceptable to provide an implementation that segfaults if
1599 it is passed a NULL pointer).</p>
1600
1601 <p>The xMutexInit() method must be threadsafe. It must be harmless to
1602 invoke xMutexInit() multiple times within the same process and without
1603 intervening calls to xMutexEnd(). Second and subsequent calls to
1604 xMutexInit() must be no-ops.</p>
1605
1606 <p>xMutexInit() must not use SQLite memory allocation (<a href="#sqlite3_free">sqlite3_malloc()</a>
1607 and its associates). Similarly, xMutexAlloc() must not use SQLite memory
1608 allocation for a static mutex. However xMutexAlloc() may use SQLite
1609 memory allocation for a fast or recursive mutex.</p>
1610
1611 <p>SQLite will invoke the xMutexEnd() method when <a href="#sqlite3_initialize">sqlite3_shutdown()</a> is
1612 called, but only if the prior call to xMutexInit returned SQLITE_OK.
1613 If xMutexInit fails in any way, it is expected to clean up after itself
1614 prior to returning.
1615 </p><hr><a name="sqlite3_pcache"></a>
1616 <h2>Custom Page Cache Object</h2>
1617 </div>
1618 <blockquote><pre>
1619 typedef struct sqlite3_pcache sqlite3_pcache;
1620 </pre></blockquote>
1621 <p>
1622 The sqlite3_pcache type is opaque. It is implemented by
1623 the pluggable module. The SQLite core has no knowledge of
1624 its size or internal structure and never deals with the
1625 sqlite3_pcache object except by holding and passing pointers
1626 to the object.</p>
1627
1628 <p>See <a href="#sqlite3_pcache_methods2">sqlite3_pcache_methods2</a> for additional information.
1629 </p><hr><a name="sqlite3_pcache_page"></a>
1630 <h2>Custom Page Cache Object</h2>
1631 </div>
1632 <blockquote><pre>
1633 typedef struct sqlite3_pcache_page sqlite3_pcache_page;
1634 struct sqlite3_pcache_page {
1635 void *pBuf; /* The content of the page */
1636 void *pExtra; /* Extra information associated with the page */
1637 };
1638 </pre></blockquote>
1639 <p>
1640 The sqlite3_pcache_page object represents a single page in the
1641 page cache. The page cache will allocate instances of this
1642 object. Various methods of the page cache use pointers to instances
1643 of this object as parameters or as their return value.</p>
1644
1645 <p>See <a href="#sqlite3_pcache_methods2">sqlite3_pcache_methods2</a> for additional information.
1646 </p><hr><a name="sqlite3_temp_directory"></a>
1647 <h2>Name Of The Folder Holding Temporary Files</h2>
1648 </div>
1649 <blockquote><pre>
1650 SQLITE_EXTERN char *sqlite3_temp_directory;
1651 </pre></blockquote>
1652 <p>
1653 If this global variable is made to point to a string which is
1654 the name of a folder (a.k.a. directory), then all temporary files
1655 created by SQLite when using a built-in <a href="#sqlite3_vfs">VFS</a>
1656 will be placed in that directory. If this variable
1657 is a NULL pointer, then SQLite performs a search for an appropriate
1658 temporary file directory.</p>
1659
1660 <p>Applications are strongly discouraged from using this global variable.
1661 It is required to set a temporary folder on Windows Runtime (WinRT).
1662 But for all other platforms, it is highly recommended that applications
1663 neither read nor write this variable. This global variable is a relic
1664 that exists for backwards compatibility of legacy applications and should
1665 be avoided in new projects.</p>
1666
1667 <p>It is not safe to read or modify this variable in more than one
1668 thread at a time. It is not safe to read or modify this variable
1669 if a <a href="#sqlite3">database connection</a> is being used at the same time in a separate
1670 thread.
1671 It is intended that this variable be set once
1672 as part of process initialization and before any SQLite interface
1673 routines have been called and that this variable remain unchanged
1674 thereafter.</p>
1675
1676 <p>The <a href="pragma.html#pragma_temp_store_directory">temp_store_directory pragma</a> may modify this variable and cause
1677 it to point to memory obtained from <a href="#sqlite3_free">sqlite3_malloc</a>. Furthermore,
1678 the <a href="pragma.html#pragma_temp_store_directory">temp_store_directory pragma</a> always assumes that any string
1679 that this variable points to is held in memory obtained from
1680 <a href="#sqlite3_free">sqlite3_malloc</a> and the pragma may attempt to free that memory
1681 using <a href="#sqlite3_free">sqlite3_free</a>.
1682 Hence, if this variable is modified directly, either it should be
1683 made NULL or made to point to memory obtained from <a href="#sqlite3_free">sqlite3_malloc</a>
1684 or else the use of the <a href="pragma.html#pragma_temp_store_directory">temp_store_directory pragma</a> should be avoided.
1685 Except when requested by the <a href="pragma.html#pragma_temp_store_directory">temp_store_directory pragma</a>, SQLite
1686 does not free the memory that sqlite3_temp_directory points to. If
1687 the application wants that memory to be freed, it must do
1688 so itself, taking care to only do so after all <a href="#sqlite3">database connection</a>
1689 objects have been destroyed.</p>
1690
1691 <p><b>Note to Windows Runtime users:</b> The temporary directory must be set
1692 prior to calling <a href="#sqlite3_open">sqlite3_open</a> or <a href="#sqlite3_open">sqlite3_open_v2</a>. Otherwise, various
1693 features that require the use of temporary files may fail. Here is an
1694 example of how to do this using C++ with the Windows Runtime:</p>
1695
1696 <p><blockquote><pre>
1697 LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
1698 &nbsp; TemporaryFolder->Path->Data();
1699 char zPathBuf&#91;MAX_PATH + 1&#93;;
1700 memset(zPathBuf, 0, sizeof(zPathBuf));
1701 WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
1702 &nbsp; NULL, NULL);
1703 sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
1704 </pre></blockquote>
1705 </p><hr><a name="sqlite3_vfs"></a>
1706 <h2>OS Interface Object</h2>
1707 </div>
1708 <blockquote><pre>
1709 typedef struct sqlite3_vfs sqlite3_vfs;
1710 typedef void (*sqlite3_syscall_ptr)(void);
1711 struct sqlite3_vfs {
1712 int iVersion; /* Structure version number (currently 3) */
1713 int szOsFile; /* Size of subclassed sqlite3_file */
1714 int mxPathname; /* Maximum file pathname length */
1715 sqlite3_vfs *pNext; /* Next registered VFS */
1716 const char *zName; /* Name of this virtual file system */
1717 void *pAppData; /* Pointer to application-specific data */
1718 int (*xOpen)(sqlite3_vfs*, sqlite3_filename zName, sqlite3_file*,
1719 int flags, int *pOutFlags);
1720 int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
1721 int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
1722 int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
1723 void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
1724 void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
1725 void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
1726 void (*xDlClose)(sqlite3_vfs*, void*);
1727 int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
1728 int (*xSleep)(sqlite3_vfs*, int microseconds);
1729 int (*xCurrentTime)(sqlite3_vfs*, double*);
1730 int (*xGetLastError)(sqlite3_vfs*, int, char *);
1731 /*
1732 ** The methods above are in version 1 of the sqlite_vfs object
1733 ** definition. Those that follow are added in version 2 or later
1734 */
1735 int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
1736 /*
1737 ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
1738 ** Those below are for version 3 and greater.
1739 */
1740 int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
1741 sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
1742 const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
1743 /*
1744 ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
1745 ** New fields may be appended in future versions. The iVersion
1746 ** value will increment whenever this happens.
1747 */
1748 };
1749 </pre></blockquote>
1750 <p>
1751 An instance of the sqlite3_vfs object defines the interface between
1752 the SQLite core and the underlying operating system. The "vfs"
1753 in the name of the object stands for "virtual file system". See
1754 the <a href="vfs.html">VFS documentation</a> for further information.</p>
1755
1756 <p>The VFS interface is sometimes extended by adding new methods onto
1757 the end. Each time such an extension occurs, the iVersion field
1758 is incremented. The iVersion value started out as 1 in
1759 SQLite <a href="releaselog/3_5_0.html">version 3.5.0</a> on 2007-09-04, then increased to 2
1760 with SQLite <a href="releaselog/3_7_0.html">version 3.7.0</a> on 2010-07-21, and then increased
1761 to 3 with SQLite <a href="releaselog/3_7_6.html">version 3.7.6</a> on 2011-04-12. Additional fields
1762 may be appended to the sqlite3_vfs object and the iVersion value
1763 may increase again in future versions of SQLite.
1764 Note that due to an oversight, the structure
1765 of the sqlite3_vfs object changed in the transition from
1766 SQLite <a href="releaselog/3_5_9.html">version 3.5.9</a> to <a href="releaselog/3_6_0.html">version 3.6.0</a> on 2008-07-16
1767 and yet the iVersion field was not increased.</p>
1768
1769 <p>The szOsFile field is the size of the subclassed <a href="#sqlite3_file">sqlite3_file</a>
1770 structure used by this VFS. mxPathname is the maximum length of
1771 a pathname in this VFS.</p>
1772
1773 <p>Registered sqlite3_vfs objects are kept on a linked list formed by
1774 the pNext pointer. The <a href="#sqlite3_vfs_find">sqlite3_vfs_register()</a>
1775 and <a href="#sqlite3_vfs_find">sqlite3_vfs_unregister()</a> interfaces manage this list
1776 in a thread-safe way. The <a href="#sqlite3_vfs_find">sqlite3_vfs_find()</a> interface
1777 searches the list. Neither the application code nor the VFS
1778 implementation should use the pNext pointer.</p>
1779
1780 <p>The pNext field is the only field in the sqlite3_vfs
1781 structure that SQLite will ever modify. SQLite will only access
1782 or modify this field while holding a particular static mutex.
1783 The application should never modify anything within the sqlite3_vfs
1784 object once the object has been registered.</p>
1785
1786 <p>The zName field holds the name of the VFS module. The name must
1787 be unique across all VFS modules.</p>
1788
1789 <p><a name="sqlite3vfsxopen"></a>
1790
1791 SQLite guarantees that the zFilename parameter to xOpen
1792 is either a NULL pointer or string obtained
1793 from xFullPathname() with an optional suffix added.
1794 If a suffix is added to the zFilename parameter, it will
1795 consist of a single "-" character followed by no more than
1796 11 alphanumeric and/or "-" characters.
1797 SQLite further guarantees that
1798 the string will be valid and unchanged until xClose() is
1799 called. Because of the previous sentence,
1800 the <a href="#sqlite3_file">sqlite3_file</a> can safely store a pointer to the
1801 filename if it needs to remember the filename for some reason.
1802 If the zFilename parameter to xOpen is a NULL pointer then xOpen
1803 must invent its own temporary name for the file. Whenever the
1804 xFilename parameter is NULL it will also be the case that the
1805 flags parameter will include <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_DELETEONCLOSE</a>.</p>
1806
1807 <p>The flags argument to xOpen() includes all bits set in
1808 the flags argument to <a href="#sqlite3_open">sqlite3_open_v2()</a>. Or if <a href="#sqlite3_open">sqlite3_open()</a>
1809 or <a href="#sqlite3_open">sqlite3_open16()</a> is used, then flags includes at least
1810 <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_READWRITE</a> | <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_CREATE</a>.
1811 If xOpen() opens a file read-only then it sets *pOutFlags to
1812 include <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_READONLY</a>. Other bits in *pOutFlags may be set.</p>
1813
1814 <p>SQLite will also add one of the following flags to the xOpen()
1815 call, depending on the object being opened:</p>
1816
1817 <p><ul>
1818 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_MAIN_DB</a>
1819 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_MAIN_JOURNAL</a>
1820 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_TEMP_DB</a>
1821 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_TEMP_JOURNAL</a>
1822 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_TRANSIENT_DB</a>
1823 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_SUBJOURNAL</a>
1824 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_SUPER_JOURNAL</a>
1825 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_WAL</a>
1826 </ul></p>
1827
1828 <p>The file I/O implementation can use the object type flags to
1829 change the way it deals with files. For example, an application
1830 that does not care about crash recovery or rollback might make
1831 the open of a journal file a no-op. Writes to this journal would
1832 also be no-ops, and any attempt to read the journal would return
1833 SQLITE_IOERR. Or the implementation might recognize that a database
1834 file will be doing page-aligned sector reads and writes in a random
1835 order and set up its I/O subsystem accordingly.</p>
1836
1837 <p>SQLite might also add one of the following flags to the xOpen method:</p>
1838
1839 <p><ul>
1840 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_DELETEONCLOSE</a>
1841 <li> <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_EXCLUSIVE</a>
1842 </ul></p>
1843
1844 <p>The <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_DELETEONCLOSE</a> flag means the file should be
1845 deleted when it is closed. The <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_DELETEONCLOSE</a>
1846 will be set for TEMP databases and their journals, transient
1847 databases, and subjournals.</p>
1848
1849 <p>The <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_EXCLUSIVE</a> flag is always used in conjunction
1850 with the <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_CREATE</a> flag, which are both directly
1851 analogous to the O_EXCL and O_CREAT flags of the POSIX open()
1852 API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
1853 SQLITE_OPEN_CREATE, is used to indicate that file should always
1854 be created, and that it is an error if it already exists.
1855 It is <i>not</i> used to indicate the file should be opened
1856 for exclusive access.</p>
1857
1858 <p>At least szOsFile bytes of memory are allocated by SQLite
1859 to hold the <a href="#sqlite3_file">sqlite3_file</a> structure passed as the third
1860 argument to xOpen. The xOpen method does not have to
1861 allocate the structure; it should just fill it in. Note that
1862 the xOpen method must set the sqlite3_file.pMethods to either
1863 a valid <a href="#sqlite3_io_methods">sqlite3_io_methods</a> object or to NULL. xOpen must do
1864 this even if the open fails. SQLite expects that the sqlite3_file.pMethods
1865 element will be valid after xOpen returns regardless of the success
1866 or failure of the xOpen call.</p>
1867
1868 <p><a name="sqlite3vfsxaccess"></a>
1869
1870 The flags argument to xAccess() may be <a href="#SQLITE_ACCESS_EXISTS">SQLITE_ACCESS_EXISTS</a>
1871 to test for the existence of a file, or <a href="#SQLITE_ACCESS_EXISTS">SQLITE_ACCESS_READWRITE</a> to
1872 test whether a file is readable and writable, or <a href="#SQLITE_ACCESS_EXISTS">SQLITE_ACCESS_READ</a>
1873 to test whether a file is at least readable. The SQLITE_ACCESS_READ
1874 flag is never actually used and is not implemented in the built-in
1875 VFSes of SQLite. The file is named by the second argument and can be a
1876 directory. The xAccess method returns <a href="#SQLITE_ABORT">SQLITE_OK</a> on success or some
1877 non-zero error code if there is an I/O error or if the name of
1878 the file given in the second argument is illegal. If SQLITE_OK
1879 is returned, then non-zero or zero is written into *pResOut to indicate
1880 whether or not the file is accessible.</p>
1881
1882 <p>SQLite will always allocate at least mxPathname+1 bytes for the
1883 output buffer xFullPathname. The exact size of the output buffer
1884 is also passed as a parameter to both methods. If the output buffer
1885 is not large enough, <a href="#SQLITE_ABORT">SQLITE_CANTOPEN</a> should be returned. Since this is
1886 handled as a fatal error by SQLite, vfs implementations should endeavor
1887 to prevent this by setting mxPathname to a sufficiently large value.</p>
1888
1889 <p>The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
1890 interfaces are not strictly a part of the filesystem, but they are
1891 included in the VFS structure for completeness.
1892 The xRandomness() function attempts to return nBytes bytes
1893 of good-quality randomness into zOut. The return value is
1894 the actual number of bytes of randomness obtained.
1895 The xSleep() method causes the calling thread to sleep for at
1896 least the number of microseconds given. The xCurrentTime()
1897 method returns a Julian Day Number for the current date and time as
1898 a floating point value.
1899 The xCurrentTimeInt64() method returns, as an integer, the Julian
1900 Day Number multiplied by 86400000 (the number of milliseconds in
1901 a 24-hour day).
1902 SQLite will use the xCurrentTimeInt64() method to get the current
1903 date and time if that method is available (if iVersion is 2 or
1904 greater and the function pointer is not NULL) and will fall back
1905 to xCurrentTime() if xCurrentTimeInt64() is unavailable.</p>
1906
1907 <p>The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
1908 are not used by the SQLite core. These optional interfaces are provided
1909 by some VFSes to facilitate testing of the VFS code. By overriding
1910 system calls with functions under its control, a test program can
1911 simulate faults and error conditions that would otherwise be difficult
1912 or impossible to induce. The set of system calls that can be overridden
1913 varies from one VFS to another, and from one version of the same VFS to the
1914 next. Applications that use these interfaces must be prepared for any
1915 or all of these interfaces to be NULL or for their behavior to change
1916 from one release to the next. Applications must not attempt to access
1917 any of these methods if the iVersion of the VFS is less than 3.
1918 </p><hr><a name="sqlite3_vtab"></a>
1919 <h2>Virtual Table Instance Object</h2>
1920 </div>
1921 <blockquote><pre>
1922 struct sqlite3_vtab {
1923 const sqlite3_module *pModule; /* The module for this virtual table */
1924 int nRef; /* Number of open cursors */
1925 char *zErrMsg; /* Error message from sqlite3_mprintf() */
1926 /* Virtual table implementations will typically add additional fields */
1927 };
1928 </pre></blockquote>
1929 <p>
1930 Every <a href="#sqlite3_module">virtual table module</a> implementation uses a subclass
1931 of this object to describe a particular instance
1932 of the <a href="vtab.html">virtual table</a>. Each subclass will
1933 be tailored to the specific needs of the module implementation.
1934 The purpose of this superclass is to define certain fields that are
1935 common to all module implementations.</p>
1936
1937 <p>Virtual tables methods can set an error message by assigning a
1938 string obtained from <a href="#sqlite3_mprintf">sqlite3_mprintf()</a> to zErrMsg. The method should
1939 take care that any prior string is freed by a call to <a href="#sqlite3_free">sqlite3_free()</a>
1940 prior to assigning a new string to zErrMsg. After the error message
1941 is delivered up to the client application, the string will be automatically
1942 freed by sqlite3_free() and the zErrMsg field will be zeroed.
1943 </p><hr><a name="sqlite3_aggregate_context"></a>
1944 <h2>Obtain Aggregate Function Context</h2>
1945 </div>
1946 <blockquote><pre>
1947 void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
1948 </pre></blockquote>
1949 <p>
1950 Implementations of aggregate SQL functions use this
1951 routine to allocate memory for storing their state.</p>
1952
1953 <p>The first time the sqlite3_aggregate_context(C,N) routine is called
1954 for a particular aggregate function, SQLite allocates
1955 N bytes of memory, zeroes out that memory, and returns a pointer
1956 to the new memory. On second and subsequent calls to
1957 sqlite3_aggregate_context() for the same aggregate function instance,
1958 the same buffer is returned. Sqlite3_aggregate_context() is normally
1959 called once for each invocation of the xStep callback and then one
1960 last time when the xFinal callback is invoked. When no rows match
1961 an aggregate query, the xStep() callback of the aggregate function
1962 implementation is never called and xFinal() is called exactly once.
1963 In those cases, sqlite3_aggregate_context() might be called for the
1964 first time from within xFinal().</p>
1965
1966 <p>The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
1967 when first called if N is less than or equal to zero or if a memory
1968 allocation error occurs.</p>
1969
1970 <p>The amount of space allocated by sqlite3_aggregate_context(C,N) is
1971 determined by the N parameter on first successful call. Changing the
1972 value of N in any subsequent call to sqlite3_aggregate_context() within
1973 the same aggregate function instance will not resize the memory
1974 allocation. Within the xFinal callback, it is customary to set
1975 N=0 in calls to sqlite3_aggregate_context(C,N) so that no
1976 pointless memory allocations occur.</p>
1977
1978 <p>SQLite automatically frees the memory allocated by
1979 sqlite3_aggregate_context() when the aggregate query concludes.</p>
1980
1981 <p>The first parameter must be a copy of the
1982 <a href="#sqlite3_context">SQL function context</a> that is the first parameter
1983 to the xStep or xFinal callback routine that implements the aggregate
1984 function.</p>
1985
1986 <p>This routine must be called from the same thread in which
1987 the aggregate SQL function is running.
1988 </p><hr><a name="sqlite3_auto_extension"></a>
1989 <h2>Automatically Load Statically Linked Extensions</h2>
1990 </div>
1991 <blockquote><pre>
1992 int sqlite3_auto_extension(void(*xEntryPoint)(void));
1993 </pre></blockquote>
1994 <p>
1995 This interface causes the xEntryPoint() function to be invoked for
1996 each new <a href="#sqlite3">database connection</a> that is created. The idea here is that
1997 xEntryPoint() is the entry point for a statically linked <a href="loadext.html">SQLite extension</a>
1998 that is to be automatically loaded into all new database connections.</p>
1999
2000 <p>Even though the function prototype shows that xEntryPoint() takes
2001 no arguments and returns void, SQLite invokes xEntryPoint() with three
2002 arguments and expects an integer result as if the signature of the
2003 entry point where as follows:</p>
2004
2005 <p><blockquote><pre>
2006 &nbsp; int xEntryPoint(
2007 &nbsp; sqlite3 *db,
2008 &nbsp; const char **pzErrMsg,
2009 &nbsp; const struct sqlite3_api_routines *pThunk
2010 &nbsp; );
2011 </pre></blockquote></p>
2012
2013 <p>If the xEntryPoint routine encounters an error, it should make *pzErrMsg
2014 point to an appropriate error message (obtained from <a href="#sqlite3_mprintf">sqlite3_mprintf()</a>)
2015 and return an appropriate <a href="rescode.html">error code</a>. SQLite ensures that *pzErrMsg
2016 is NULL before calling the xEntryPoint(). SQLite will invoke
2017 <a href="#sqlite3_free">sqlite3_free()</a> on *pzErrMsg after xEntryPoint() returns. If any
2018 xEntryPoint() returns an error, the <a href="#sqlite3_open">sqlite3_open()</a>, <a href="#sqlite3_open">sqlite3_open16()</a>,
2019 or <a href="#sqlite3_open">sqlite3_open_v2()</a> call that provoked the xEntryPoint() will fail.</p>
2020
2021 <p>Calling sqlite3_auto_extension(X) with an entry point X that is already
2022 on the list of automatic extensions is a harmless no-op. No entry point
2023 will be called more than once for each database connection that is opened.</p>
2024
2025 <p>See also: <a href="#sqlite3_reset_auto_extension">sqlite3_reset_auto_extension()</a>
2026 and <a href="#sqlite3_cancel_auto_extension">sqlite3_cancel_auto_extension()</a>
2027 </p><hr><a name="sqlite3_autovacuum_pages"></a>
2028 <h2>Autovacuum Compaction Amount Callback</h2>
2029 </div>
2030 <blockquote><pre>
2031 int sqlite3_autovacuum_pages(
2032 sqlite3 *db,
2033 unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
2034 void*,
2035 void(*)(void*)
2036 );
2037 </pre></blockquote>
2038 <p>
2039 The sqlite3_autovacuum_pages(D,C,P,X) interface registers a callback
2040 function C that is invoked prior to each autovacuum of the database
2041 file. The callback is passed a copy of the generic data pointer (P),
2042 the schema-name of the attached database that is being autovacuumed,
2043 the size of the database file in pages, the number of free pages,
2044 and the number of bytes per page, respectively. The callback should
2045 return the number of free pages that should be removed by the
2046 autovacuum. If the callback returns zero, then no autovacuum happens.
2047 If the value returned is greater than or equal to the number of
2048 free pages, then a complete autovacuum happens.</p>
2049
2050 <p><p>If there are multiple ATTACH-ed database files that are being
2051 modified as part of a transaction commit, then the autovacuum pages
2052 callback is invoked separately for each file.</p>
2053
2054 <p><p><b>The callback is not reentrant.</b> The callback function should
2055 not attempt to invoke any other SQLite interface. If it does, bad
2056 things may happen, including segmentation faults and corrupt database
2057 files. The callback function should be a simple function that
2058 does some arithmetic on its input parameters and returns a result.</p>
2059
2060 <p>The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional
2061 destructor for the P parameter. If X is not NULL, then X(P) is
2062 invoked whenever the database connection closes or when the callback
2063 is overwritten by another invocation of sqlite3_autovacuum_pages().</p>
2064
2065 <p><p>There is only one autovacuum pages callback per database connection.
2066 Each call to the sqlite3_autovacuum_pages() interface overrides all
2067 previous invocations for that database connection. If the callback
2068 argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
2069 then the autovacuum steps callback is canceled. The return value
2070 from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
2071 be some other error code if something goes wrong. The current
2072 implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
2073 return codes might be added in future releases.</p>
2074
2075 <p><p>If no autovacuum pages callback is specified (the usual case) or
2076 a NULL pointer is provided for the callback,
2077 then the default behavior is to vacuum all free pages. So, in other
2078 words, the default behavior is the same as if the callback function
2079 were something like this:</p>
2080
2081 <p><blockquote><pre>
2082 &nbsp; unsigned int demonstration_autovac_pages_callback(
2083 &nbsp; void *pClientData,
2084 &nbsp; const char *zSchema,
2085 &nbsp; unsigned int nDbPage,
2086 &nbsp; unsigned int nFreePage,
2087 &nbsp; unsigned int nBytePerPage
2088 &nbsp; ){
2089 &nbsp; return nFreePage;
2090 &nbsp; }
2091 </pre></blockquote>
2092 </p><hr><a name="sqlite3_bind_parameter_count"></a>
2093 <h2>Number Of SQL Parameters</h2>
2094 </div>
2095 <blockquote><pre>
2096 int sqlite3_bind_parameter_count(sqlite3_stmt*);
2097 </pre></blockquote>
2098 <p>
2099 This routine can be used to find the number of <a href="#sqlite3_bind_blob">SQL parameters</a>
2100 in a <a href="#sqlite3_stmt">prepared statement</a>. SQL parameters are tokens of the
2101 form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
2102 placeholders for values that are <a href="#sqlite3_bind_blob">bound</a>
2103 to the parameters at a later time.</p>
2104
2105 <p>This routine actually returns the index of the largest (rightmost)
2106 parameter. For all forms except ?NNN, this will correspond to the
2107 number of unique parameters. If parameters of the ?NNN form are used,
2108 there may be gaps in the list.</p>
2109
2110 <p>See also: <a href="#sqlite3_bind_blob">sqlite3_bind()</a>,
2111 <a href="#sqlite3_bind_parameter_name">sqlite3_bind_parameter_name()</a>, and
2112 <a href="#sqlite3_bind_parameter_index">sqlite3_bind_parameter_index()</a>.
2113 </p><hr><a name="sqlite3_bind_parameter_index"></a>
2114 <h2>Index Of A Parameter With A Given Name</h2>
2115 </div>
2116 <blockquote><pre>
2117 int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
2118 </pre></blockquote>
2119 <p>
2120 Return the index of an SQL parameter given its name. The
2121 index value returned is suitable for use as the second
2122 parameter to <a href="#sqlite3_bind_blob">sqlite3_bind()</a>. A zero
2123 is returned if no matching parameter is found. The parameter
2124 name must be given in UTF-8 even if the original statement
2125 was prepared from UTF-16 text using <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a> or
2126 <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a>.</p>
2127
2128 <p>See also: <a href="#sqlite3_bind_blob">sqlite3_bind()</a>,
2129 <a href="#sqlite3_bind_parameter_count">sqlite3_bind_parameter_count()</a>, and
2130 <a href="#sqlite3_bind_parameter_name">sqlite3_bind_parameter_name()</a>.
2131 </p><hr><a name="sqlite3_bind_parameter_name"></a>
2132 <h2>Name Of A Host Parameter</h2>
2133 </div>
2134 <blockquote><pre>
2135 const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
2136 </pre></blockquote>
2137 <p>
2138 The sqlite3_bind_parameter_name(P,N) interface returns
2139 the name of the N-th <a href="#sqlite3_bind_blob">SQL parameter</a> in the <a href="#sqlite3_stmt">prepared statement</a> P.
2140 SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
2141 have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
2142 respectively.
2143 In other words, the initial ":" or "$" or "@" or "?"
2144 is included as part of the name.
2145 Parameters of the form "?" without a following integer have no name
2146 and are referred to as "nameless" or "anonymous parameters".</p>
2147
2148 <p>The first host parameter has an index of 1, not 0.</p>
2149
2150 <p>If the value N is out of range or if the N-th parameter is
2151 nameless, then NULL is returned. The returned string is
2152 always in UTF-8 encoding even if the named parameter was
2153 originally specified as UTF-16 in <a href="#sqlite3_prepare">sqlite3_prepare16()</a>,
2154 <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a>, or <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a>.</p>
2155
2156 <p>See also: <a href="#sqlite3_bind_blob">sqlite3_bind()</a>,
2157 <a href="#sqlite3_bind_parameter_count">sqlite3_bind_parameter_count()</a>, and
2158 <a href="#sqlite3_bind_parameter_index">sqlite3_bind_parameter_index()</a>.
2159 </p><hr><a name="sqlite3_blob_bytes"></a>
2160 <h2>Return The Size Of An Open BLOB</h2>
2161 </div>
2162 <blockquote><pre>
2163 int sqlite3_blob_bytes(sqlite3_blob *);
2164 </pre></blockquote>
2165 <p>
2166 Returns the size in bytes of the BLOB accessible via the
2167 successfully opened <a href="#sqlite3_blob">BLOB handle</a> in its only argument. The
2168 incremental blob I/O routines can only read or overwriting existing
2169 blob content; they cannot change the size of a blob.</p>
2170
2171 <p>This routine only works on a <a href="#sqlite3_blob">BLOB handle</a> which has been created
2172 by a prior successful call to <a href="#sqlite3_blob_open">sqlite3_blob_open()</a> and which has not
2173 been closed by <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>. Passing any other pointer in
2174 to this routine results in undefined and probably undesirable behavior.
2175 </p><hr><a name="sqlite3_blob_close"></a>
2176 <h2>Close A BLOB Handle</h2>
2177 </div>
2178 <blockquote><pre>
2179 int sqlite3_blob_close(sqlite3_blob *);
2180 </pre></blockquote>
2181 <p>
2182 This function closes an open <a href="#sqlite3_blob">BLOB handle</a>. The BLOB handle is closed
2183 unconditionally. Even if this routine returns an error code, the
2184 handle is still closed.</p>
2185
2186 <p>If the blob handle being closed was opened for read-write access, and if
2187 the database is in auto-commit mode and there are no other open read-write
2188 blob handles or active write statements, the current transaction is
2189 committed. If an error occurs while committing the transaction, an error
2190 code is returned and the transaction rolled back.</p>
2191
2192 <p>Calling this function with an argument that is not a NULL pointer or an
2193 open blob handle results in undefined behavior. Calling this routine
2194 with a null pointer (such as would be returned by a failed call to
2195 <a href="#sqlite3_blob_open">sqlite3_blob_open()</a>) is a harmless no-op. Otherwise, if this function
2196 is passed a valid open blob handle, the values returned by the
2197 sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
2198 </p><hr><a name="sqlite3_blob_open"></a>
2199 <h2>Open A BLOB For Incremental I/O</h2>
2200 </div>
2201 <blockquote><pre>
2202 int sqlite3_blob_open(
2203 sqlite3*,
2204 const char *zDb,
2205 const char *zTable,
2206 const char *zColumn,
2207 sqlite3_int64 iRow,
2208 int flags,
2209 sqlite3_blob **ppBlob
2210 );
2211 </pre></blockquote>
2212 <p>
2213 This interfaces opens a <a href="#sqlite3_blob">handle</a> to the BLOB located
2214 in row iRow, column zColumn, table zTable in database zDb;
2215 in other words, the same BLOB that would be selected by:</p>
2216
2217 <p><pre>
2218 SELECT zColumn FROM zDb.zTable WHERE <a href="lang_createtable.html#rowid">rowid</a> = iRow;
2219 </pre></p>
2220
2221 <p>Parameter zDb is not the filename that contains the database, but
2222 rather the symbolic name of the database. For attached databases, this is
2223 the name that appears after the AS keyword in the <a href="lang_attach.html">ATTACH</a> statement.
2224 For the main database file, the database name is "main". For TEMP
2225 tables, the database name is "temp".</p>
2226
2227 <p>If the flags parameter is non-zero, then the BLOB is opened for read
2228 and write access. If the flags parameter is zero, the BLOB is opened for
2229 read-only access.</p>
2230
2231 <p>On success, <a href="#SQLITE_ABORT">SQLITE_OK</a> is returned and the new <a href="#sqlite3_blob">BLOB handle</a> is stored
2232 in *ppBlob. Otherwise an <a href="rescode.html">error code</a> is returned and, unless the error
2233 code is SQLITE_MISUSE, *ppBlob is set to NULL. This means that, provided
2234 the API is not misused, it is always safe to call <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>
2235 on *ppBlob after this function it returns.</p>
2236
2237 <p>This function fails with SQLITE_ERROR if any of the following are true:
2238 <ul>
2239 <li> Database zDb does not exist,
2240 <li> Table zTable does not exist within database zDb,
2241 <li> Table zTable is a WITHOUT ROWID table,
2242 <li> Column zColumn does not exist,
2243 <li> Row iRow is not present in the table,
2244 <li> The specified column of row iRow contains a value that is not
2245 a TEXT or BLOB value,
2246 <li> Column zColumn is part of an index, PRIMARY KEY or UNIQUE
2247 constraint and the blob is being opened for read/write access,
2248 <li> <a href="foreignkeys.html">Foreign key constraints</a> are enabled,
2249 column zColumn is part of a <a href="foreignkeys.html#parentchild">child key</a> definition and the blob is
2250 being opened for read/write access.
2251 </ul></p>
2252
2253 <p>Unless it returns SQLITE_MISUSE, this function sets the
2254 <a href="#sqlite3">database connection</a> error code and message accessible via
2255 <a href="#sqlite3_errcode">sqlite3_errcode()</a> and <a href="#sqlite3_errcode">sqlite3_errmsg()</a> and related functions.</p>
2256
2257 <p>A BLOB referenced by sqlite3_blob_open() may be read using the
2258 <a href="#sqlite3_blob_read">sqlite3_blob_read()</a> interface and modified by using
2259 <a href="#sqlite3_blob_write">sqlite3_blob_write()</a>. The <a href="#sqlite3_blob">BLOB handle</a> can be moved to a
2260 different row of the same table using the <a href="#sqlite3_blob_reopen">sqlite3_blob_reopen()</a>
2261 interface. However, the column, table, or database of a <a href="#sqlite3_blob">BLOB handle</a>
2262 cannot be changed after the <a href="#sqlite3_blob">BLOB handle</a> is opened.</p>
2263
2264 <p>If the row that a BLOB handle points to is modified by an
2265 <a href="lang_update.html">UPDATE</a>, <a href="lang_delete.html">DELETE</a>, or by <a href="lang_conflict.html">ON CONFLICT</a> side-effects
2266 then the BLOB handle is marked as "expired".
2267 This is true if any column of the row is changed, even a column
2268 other than the one the BLOB handle is open on.
2269 Calls to <a href="#sqlite3_blob_read">sqlite3_blob_read()</a> and <a href="#sqlite3_blob_write">sqlite3_blob_write()</a> for
2270 an expired BLOB handle fail with a return code of <a href="#SQLITE_ABORT">SQLITE_ABORT</a>.
2271 Changes written into a BLOB prior to the BLOB expiring are not
2272 rolled back by the expiration of the BLOB. Such changes will eventually
2273 commit if the transaction continues to completion.</p>
2274
2275 <p>Use the <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a> interface to determine the size of
2276 the opened blob. The size of a blob may not be changed by this
2277 interface. Use the <a href="lang_update.html">UPDATE</a> SQL command to change the size of a
2278 blob.</p>
2279
2280 <p>The <a href="#sqlite3_bind_blob">sqlite3_bind_zeroblob()</a> and <a href="#sqlite3_result_blob">sqlite3_result_zeroblob()</a> interfaces
2281 and the built-in <a href="lang_corefunc.html#zeroblob">zeroblob</a> SQL function may be used to create a
2282 zero-filled blob to read or write using the incremental-blob interface.</p>
2283
2284 <p>To avoid a resource leak, every open <a href="#sqlite3_blob">BLOB handle</a> should eventually
2285 be released by a call to <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>.</p>
2286
2287 <p>See also: <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>,
2288 <a href="#sqlite3_blob_reopen">sqlite3_blob_reopen()</a>, <a href="#sqlite3_blob_read">sqlite3_blob_read()</a>,
2289 <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a>, <a href="#sqlite3_blob_write">sqlite3_blob_write()</a>.
2290 </p><hr><a name="sqlite3_blob_read"></a>
2291 <h2>Read Data From A BLOB Incrementally</h2>
2292 </div>
2293 <blockquote><pre>
2294 int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
2295 </pre></blockquote>
2296 <p>
2297 This function is used to read data from an open <a href="#sqlite3_blob">BLOB handle</a> into a
2298 caller-supplied buffer. N bytes of data are copied into buffer Z
2299 from the open BLOB, starting at offset iOffset.</p>
2300
2301 <p>If offset iOffset is less than N bytes from the end of the BLOB,
2302 <a href="#SQLITE_ABORT">SQLITE_ERROR</a> is returned and no data is read. If N or iOffset is
2303 less than zero, <a href="#SQLITE_ABORT">SQLITE_ERROR</a> is returned and no data is read.
2304 The size of the blob (and hence the maximum value of N+iOffset)
2305 can be determined using the <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a> interface.</p>
2306
2307 <p>An attempt to read from an expired <a href="#sqlite3_blob">BLOB handle</a> fails with an
2308 error code of <a href="#SQLITE_ABORT">SQLITE_ABORT</a>.</p>
2309
2310 <p>On success, sqlite3_blob_read() returns SQLITE_OK.
2311 Otherwise, an <a href="rescode.html">error code</a> or an <a href="rescode.html#extrc">extended error code</a> is returned.</p>
2312
2313 <p>This routine only works on a <a href="#sqlite3_blob">BLOB handle</a> which has been created
2314 by a prior successful call to <a href="#sqlite3_blob_open">sqlite3_blob_open()</a> and which has not
2315 been closed by <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>. Passing any other pointer in
2316 to this routine results in undefined and probably undesirable behavior.</p>
2317
2318 <p>See also: <a href="#sqlite3_blob_write">sqlite3_blob_write()</a>.
2319 </p><hr><a name="sqlite3_blob_reopen"></a>
2320 <h2>Move a BLOB Handle to a New Row</h2>
2321 </div>
2322 <blockquote><pre>
2323 int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
2324 </pre></blockquote>
2325 <p>
2326 This function is used to move an existing <a href="#sqlite3_blob">BLOB handle</a> so that it points
2327 to a different row of the same database table. The new row is identified
2328 by the rowid value passed as the second argument. Only the row can be
2329 changed. The database, table and column on which the blob handle is open
2330 remain the same. Moving an existing <a href="#sqlite3_blob">BLOB handle</a> to a new row is
2331 faster than closing the existing handle and opening a new one.</p>
2332
2333 <p>The new row must meet the same criteria as for <a href="#sqlite3_blob_open">sqlite3_blob_open()</a> -
2334 it must exist and there must be either a blob or text value stored in
2335 the nominated column. If the new row is not present in the table, or if
2336 it does not contain a blob or text value, or if another error occurs, an
2337 SQLite error code is returned and the blob handle is considered aborted.
2338 All subsequent calls to <a href="#sqlite3_blob_read">sqlite3_blob_read()</a>, <a href="#sqlite3_blob_write">sqlite3_blob_write()</a> or
2339 <a href="#sqlite3_blob_reopen">sqlite3_blob_reopen()</a> on an aborted blob handle immediately return
2340 SQLITE_ABORT. Calling <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a> on an aborted blob handle
2341 always returns zero.</p>
2342
2343 <p>This function sets the database handle error code and message.
2344 </p><hr><a name="sqlite3_blob_write"></a>
2345 <h2>Write Data Into A BLOB Incrementally</h2>
2346 </div>
2347 <blockquote><pre>
2348 int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
2349 </pre></blockquote>
2350 <p>
2351 This function is used to write data into an open <a href="#sqlite3_blob">BLOB handle</a> from a
2352 caller-supplied buffer. N bytes of data are copied from the buffer Z
2353 into the open BLOB, starting at offset iOffset.</p>
2354
2355 <p>On success, sqlite3_blob_write() returns SQLITE_OK.
2356 Otherwise, an <a href="rescode.html">error code</a> or an <a href="rescode.html#extrc">extended error code</a> is returned.
2357 Unless SQLITE_MISUSE is returned, this function sets the
2358 <a href="#sqlite3">database connection</a> error code and message accessible via
2359 <a href="#sqlite3_errcode">sqlite3_errcode()</a> and <a href="#sqlite3_errcode">sqlite3_errmsg()</a> and related functions.</p>
2360
2361 <p>If the <a href="#sqlite3_blob">BLOB handle</a> passed as the first argument was not opened for
2362 writing (the flags parameter to <a href="#sqlite3_blob_open">sqlite3_blob_open()</a> was zero),
2363 this function returns <a href="#SQLITE_ABORT">SQLITE_READONLY</a>.</p>
2364
2365 <p>This function may only modify the contents of the BLOB; it is
2366 not possible to increase the size of a BLOB using this API.
2367 If offset iOffset is less than N bytes from the end of the BLOB,
2368 <a href="#SQLITE_ABORT">SQLITE_ERROR</a> is returned and no data is written. The size of the
2369 BLOB (and hence the maximum value of N+iOffset) can be determined
2370 using the <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a> interface. If N or iOffset are less
2371 than zero <a href="#SQLITE_ABORT">SQLITE_ERROR</a> is returned and no data is written.</p>
2372
2373 <p>An attempt to write to an expired <a href="#sqlite3_blob">BLOB handle</a> fails with an
2374 error code of <a href="#SQLITE_ABORT">SQLITE_ABORT</a>. Writes to the BLOB that occurred
2375 before the <a href="#sqlite3_blob">BLOB handle</a> expired are not rolled back by the
2376 expiration of the handle, though of course those changes might
2377 have been overwritten by the statement that expired the BLOB handle
2378 or by other independent statements.</p>
2379
2380 <p>This routine only works on a <a href="#sqlite3_blob">BLOB handle</a> which has been created
2381 by a prior successful call to <a href="#sqlite3_blob_open">sqlite3_blob_open()</a> and which has not
2382 been closed by <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>. Passing any other pointer in
2383 to this routine results in undefined and probably undesirable behavior.</p>
2384
2385 <p>See also: <a href="#sqlite3_blob_read">sqlite3_blob_read()</a>.
2386 </p><hr><a name="sqlite3_busy_timeout"></a>
2387 <h2>Set A Busy Timeout</h2>
2388 </div>
2389 <blockquote><pre>
2390 int sqlite3_busy_timeout(sqlite3*, int ms);
2391 </pre></blockquote>
2392 <p>
2393 This routine sets a <a href="#sqlite3_busy_handler">busy handler</a> that sleeps
2394 for a specified amount of time when a table is locked. The handler
2395 will sleep multiple times until at least "ms" milliseconds of sleeping
2396 have accumulated. After at least "ms" milliseconds of sleeping,
2397 the handler returns 0 which causes <a href="#sqlite3_step">sqlite3_step()</a> to return
2398 <a href="#SQLITE_ABORT">SQLITE_BUSY</a>.</p>
2399
2400 <p>Calling this routine with an argument less than or equal to zero
2401 turns off all busy handlers.</p>
2402
2403 <p>There can only be a single busy handler for a particular
2404 <a href="#sqlite3">database connection</a> at any given moment. If another busy handler
2405 was defined (using <a href="#sqlite3_busy_handler">sqlite3_busy_handler()</a>) prior to calling
2406 this routine, that other busy handler is cleared.</p>
2407
2408 <p>See also: <a href="pragma.html#pragma_busy_timeout">PRAGMA busy_timeout</a>
2409 </p><hr><a name="sqlite3_cancel_auto_extension"></a>
2410 <h2>Cancel Automatic Extension Loading</h2>
2411 </div>
2412 <blockquote><pre>
2413 int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
2414 </pre></blockquote>
2415 <p>
2416 The <a href="#sqlite3_cancel_auto_extension">sqlite3_cancel_auto_extension(X)</a> interface unregisters the
2417 initialization routine X that was registered using a prior call to
2418 <a href="#sqlite3_auto_extension">sqlite3_auto_extension(X)</a>. The <a href="#sqlite3_cancel_auto_extension">sqlite3_cancel_auto_extension(X)</a>
2419 routine returns 1 if initialization routine X was successfully
2420 unregistered and it returns 0 if X was not on the list of initialization
2421 routines.
2422 </p><hr><a name="sqlite3_clear_bindings"></a>
2423 <h2>Reset All Bindings On A Prepared Statement</h2>
2424 </div>
2425 <blockquote><pre>
2426 int sqlite3_clear_bindings(sqlite3_stmt*);
2427 </pre></blockquote>
2428 <p>
2429 Contrary to the intuition of many, <a href="#sqlite3_reset">sqlite3_reset()</a> does not reset
2430 the <a href="#sqlite3_bind_blob">bindings</a> on a <a href="#sqlite3_stmt">prepared statement</a>.
2431 Use this routine to reset all host parameters to NULL.
2432 </p><hr><a name="sqlite3_column_count"></a>
2433 <h2>Number Of Columns In A Result Set</h2>
2434 </div>
2435 <blockquote><pre>
2436 int sqlite3_column_count(sqlite3_stmt *pStmt);
2437 </pre></blockquote>
2438 <p>
2439 Return the number of columns in the result set returned by the
2440 <a href="#sqlite3_stmt">prepared statement</a>. If this routine returns 0, that means the
2441 <a href="#sqlite3_stmt">prepared statement</a> returns no data (for example an <a href="lang_update.html">UPDATE</a>).
2442 However, just because this routine returns a positive number does not
2443 mean that one or more rows of data will be returned. A SELECT statement
2444 will always have a positive sqlite3_column_count() but depending on the
2445 WHERE clause constraints and the table content, it might return no rows.</p>
2446
2447 <p>See also: <a href="#sqlite3_data_count">sqlite3_data_count()</a>
2448 </p><hr><a name="sqlite3_config"></a>
2449 <h2>Configuring The SQLite Library</h2>
2450 </div>
2451 <blockquote><pre>
2452 int sqlite3_config(int, ...);
2453 </pre></blockquote>
2454 <p>
2455 The sqlite3_config() interface is used to make global configuration
2456 changes to SQLite in order to tune SQLite to the specific needs of
2457 the application. The default configuration is recommended for most
2458 applications and so this routine is usually not necessary. It is
2459 provided to support rare applications with unusual needs.</p>
2460
2461 <p><b>The sqlite3_config() interface is not threadsafe. The application
2462 must ensure that no other SQLite interfaces are invoked by other
2463 threads while sqlite3_config() is running.</b></p>
2464
2465 <p>The first argument to sqlite3_config() is an integer
2466 <a href="#SQLITE_CONFIG_COVERING_INDEX_SCAN">configuration option</a> that determines
2467 what property of SQLite is to be configured. Subsequent arguments
2468 vary depending on the <a href="#SQLITE_CONFIG_COVERING_INDEX_SCAN">configuration option</a>
2469 in the first argument.</p>
2470
2471 <p>For most configuration options, the sqlite3_config() interface
2472 may only be invoked prior to library initialization using
2473 <a href="#sqlite3_initialize">sqlite3_initialize()</a> or after shutdown by <a href="#sqlite3_initialize">sqlite3_shutdown()</a>.
2474 The exceptional configuration options that may be invoked at any time
2475 are called "anytime configuration options".
2476 If sqlite3_config() is called after <a href="#sqlite3_initialize">sqlite3_initialize()</a> and before
2477 <a href="#sqlite3_initialize">sqlite3_shutdown()</a> with a first argument that is not an anytime
2478 configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
2479 Note, however, that sqlite3_config() can be called as part of the
2480 implementation of an application-defined <a href="#sqlite3_initialize">sqlite3_os_init()</a>.</p>
2481
2482 <p>When a configuration option is set, sqlite3_config() returns <a href="#SQLITE_ABORT">SQLITE_OK</a>.
2483 If the option is unknown or SQLite is unable to set the option
2484 then this routine returns a non-zero <a href="rescode.html">error code</a>.
2485 </p><hr><a name="sqlite3_context_db_handle"></a>
2486 <h2>Database Connection For Functions</h2>
2487 </div>
2488 <blockquote><pre>
2489 sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
2490 </pre></blockquote>
2491 <p>
2492 The sqlite3_context_db_handle() interface returns a copy of
2493 the pointer to the <a href="#sqlite3">database connection</a> (the 1st parameter)
2494 of the <a href="#sqlite3_create_function">sqlite3_create_function()</a>
2495 and <a href="#sqlite3_create_function">sqlite3_create_function16()</a> routines that originally
2496 registered the application defined function.
2497 </p><hr><a name="sqlite3_data_count"></a>
2498 <h2>Number of columns in a result set</h2>
2499 </div>
2500 <blockquote><pre>
2501 int sqlite3_data_count(sqlite3_stmt *pStmt);
2502 </pre></blockquote>
2503 <p>
2504 The sqlite3_data_count(P) interface returns the number of columns in the
2505 current row of the result set of <a href="#sqlite3_stmt">prepared statement</a> P.
2506 If prepared statement P does not have results ready to return
2507 (via calls to the <a href="#sqlite3_column_blob">sqlite3_column()</a> family of
2508 interfaces) then sqlite3_data_count(P) returns 0.
2509 The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
2510 The sqlite3_data_count(P) routine returns 0 if the previous call to
2511 <a href="#sqlite3_step">sqlite3_step</a>(P) returned <a href="#SQLITE_ABORT">SQLITE_DONE</a>. The sqlite3_data_count(P)
2512 will return non-zero if previous call to <a href="#sqlite3_step">sqlite3_step</a>(P) returned
2513 <a href="#SQLITE_ABORT">SQLITE_ROW</a>, except in the case of the <a href="pragma.html#pragma_incremental_vacuum">PRAGMA incremental_vacuum</a>
2514 where it always returns zero since each step of that multi-step
2515 pragma returns 0 columns of data.</p>
2516
2517 <p>See also: <a href="#sqlite3_column_count">sqlite3_column_count()</a>
2518 </p><hr><a name="sqlite3_database_file_object"></a>
2519 <h2>Database File Corresponding To A Journal</h2>
2520 </div>
2521 <blockquote><pre>
2522 sqlite3_file *sqlite3_database_file_object(const char*);
2523 </pre></blockquote>
2524 <p>
2525 If X is the name of a rollback or WAL-mode journal file that is
2526 passed into the xOpen method of <a href="#sqlite3_vfs">sqlite3_vfs</a>, then
2527 sqlite3_database_file_object(X) returns a pointer to the <a href="#sqlite3_file">sqlite3_file</a>
2528 object that represents the main database file.</p>
2529
2530 <p>This routine is intended for use in custom <a href="vfs.html">VFS</a> implementations
2531 only. It is not a general-purpose interface.
2532 The argument sqlite3_file_object(X) must be a filename pointer that
2533 has been passed into <a href="#sqlite3_vfs">sqlite3_vfs</a>.xOpen method where the
2534 flags parameter to xOpen contains one of the bits
2535 <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_MAIN_JOURNAL</a> or <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_WAL</a>. Any other use
2536 of this routine results in undefined and probably undesirable
2537 behavior.
2538 </p><hr><a name="sqlite3_db_cacheflush"></a>
2539 <h2>Flush caches to disk mid-transaction</h2>
2540 </div>
2541 <blockquote><pre>
2542 int sqlite3_db_cacheflush(sqlite3*);
2543 </pre></blockquote>
2544 <p>
2545 If a write-transaction is open on <a href="#sqlite3">database connection</a> D when the
2546 <a href="#sqlite3_db_cacheflush">sqlite3_db_cacheflush(D)</a> interface invoked, any dirty
2547 pages in the pager-cache that are not currently in use are written out
2548 to disk. A dirty page may be in use if a database cursor created by an
2549 active SQL statement is reading from it, or if it is page 1 of a database
2550 file (page 1 is always "in use"). The <a href="#sqlite3_db_cacheflush">sqlite3_db_cacheflush(D)</a>
2551 interface flushes caches for all schemas - "main", "temp", and
2552 any <a href="lang_attach.html">attached</a> databases.</p>
2553
2554 <p>If this function needs to obtain extra database locks before dirty pages
2555 can be flushed to disk, it does so. If those locks cannot be obtained
2556 immediately and there is a busy-handler callback configured, it is invoked
2557 in the usual manner. If the required lock still cannot be obtained, then
2558 the database is skipped and an attempt made to flush any dirty pages
2559 belonging to the next (if any) database. If any databases are skipped
2560 because locks cannot be obtained, but no other error occurs, this
2561 function returns SQLITE_BUSY.</p>
2562
2563 <p>If any other error occurs while flushing dirty pages to disk (for
2564 example an IO error or out-of-memory condition), then processing is
2565 abandoned and an SQLite <a href="rescode.html">error code</a> is returned to the caller immediately.</p>
2566
2567 <p>Otherwise, if no error occurs, <a href="#sqlite3_db_cacheflush">sqlite3_db_cacheflush()</a> returns SQLITE_OK.</p>
2568
2569 <p>This function does not set the database handle error code or message
2570 returned by the <a href="#sqlite3_errcode">sqlite3_errcode()</a> and <a href="#sqlite3_errcode">sqlite3_errmsg()</a> functions.
2571 </p><hr><a name="sqlite3_db_config"></a>
2572 <h2>Configure database connections</h2>
2573 </div>
2574 <blockquote><pre>
2575 int sqlite3_db_config(sqlite3*, int op, ...);
2576 </pre></blockquote>
2577 <p>
2578 The sqlite3_db_config() interface is used to make configuration
2579 changes to a <a href="#sqlite3">database connection</a>. The interface is similar to
2580 <a href="#sqlite3_config">sqlite3_config()</a> except that the changes apply to a single
2581 <a href="#sqlite3">database connection</a> (specified in the first argument).</p>
2582
2583 <p>The second argument to sqlite3_db_config(D,V,...) is the
2584 <a href="#sqlitedbconfiglookaside">configuration verb</a> - an integer code
2585 that indicates what aspect of the <a href="#sqlite3">database connection</a> is being configured.
2586 Subsequent arguments vary depending on the configuration verb.</p>
2587
2588 <p>Calls to sqlite3_db_config() return SQLITE_OK if and only if
2589 the call is considered successful.
2590 </p><hr><a name="sqlite3_db_filename"></a>
2591 <h2>Return The Filename For A Database Connection</h2>
2592 </div>
2593 <blockquote><pre>
2594 sqlite3_filename sqlite3_db_filename(sqlite3 *db, const char *zDbName);
2595 </pre></blockquote>
2596 <p>
2597 The sqlite3_db_filename(D,N) interface returns a pointer to the filename
2598 associated with database N of connection D.
2599 If there is no attached database N on the database
2600 connection D, or if database N is a temporary or in-memory database, then
2601 this function will return either a NULL pointer or an empty string.</p>
2602
2603 <p>The string value returned by this routine is owned and managed by
2604 the database connection. The value will be valid until the database N
2605 is <a href="lang_detach.html">DETACH</a>-ed or until the database connection closes.</p>
2606
2607 <p>The filename returned by this function is the output of the
2608 xFullPathname method of the <a href="vfs.html">VFS</a>. In other words, the filename
2609 will be an absolute pathname, even if the filename used
2610 to open the database originally was a URI or relative pathname.</p>
2611
2612 <p>If the filename pointer returned by this routine is not NULL, then it
2613 can be used as the filename input parameter to these routines:
2614 <ul>
2615 <li> <a href="#sqlite3_uri_boolean">sqlite3_uri_parameter()</a>
2616 <li> <a href="#sqlite3_uri_boolean">sqlite3_uri_boolean()</a>
2617 <li> <a href="#sqlite3_uri_boolean">sqlite3_uri_int64()</a>
2618 <li> <a href="#sqlite3_filename_database">sqlite3_filename_database()</a>
2619 <li> <a href="#sqlite3_filename_database">sqlite3_filename_journal()</a>
2620 <li> <a href="#sqlite3_filename_database">sqlite3_filename_wal()</a>
2621 </ul>
2622 </p><hr><a name="sqlite3_db_handle"></a>
2623 <h2>Find The Database Handle Of A Prepared Statement</h2>
2624 </div>
2625 <blockquote><pre>
2626 sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
2627 </pre></blockquote>
2628 <p>
2629 The sqlite3_db_handle interface returns the <a href="#sqlite3">database connection</a> handle
2630 to which a <a href="#sqlite3_stmt">prepared statement</a> belongs. The <a href="#sqlite3">database connection</a>
2631 returned by sqlite3_db_handle is the same <a href="#sqlite3">database connection</a>
2632 that was the first argument
2633 to the <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> call (or its variants) that was used to
2634 create the statement in the first place.
2635 </p><hr><a name="sqlite3_db_mutex"></a>
2636 <h2>Retrieve the mutex for a database connection</h2>
2637 </div>
2638 <blockquote><pre>
2639 sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
2640 </pre></blockquote>
2641 <p>
2642 This interface returns a pointer the <a href="#sqlite3_mutex">sqlite3_mutex</a> object that
2643 serializes access to the <a href="#sqlite3">database connection</a> given in the argument
2644 when the <a href="threadsafe.html">threading mode</a> is Serialized.
2645 If the <a href="threadsafe.html">threading mode</a> is Single-thread or Multi-thread then this
2646 routine returns a NULL pointer.
2647 </p><hr><a name="sqlite3_db_name"></a>
2648 <h2>Return The Schema Name For A Database Connection</h2>
2649 </div>
2650 <blockquote><pre>
2651 const char *sqlite3_db_name(sqlite3 *db, int N);
2652 </pre></blockquote>
2653 <p>
2654 The sqlite3_db_name(D,N) interface returns a pointer to the schema name
2655 for the N-th database on database connection D, or a NULL pointer of N is
2656 out of range. An N value of 0 means the main database file. An N of 1 is
2657 the "temp" schema. Larger values of N correspond to various ATTACH-ed
2658 databases.</p>
2659
2660 <p>Space to hold the string that is returned by sqlite3_db_name() is managed
2661 by SQLite itself. The string might be deallocated by any operation that
2662 changes the schema, including <a href="lang_attach.html">ATTACH</a> or <a href="lang_detach.html">DETACH</a> or calls to
2663 <a href="#sqlite3_serialize">sqlite3_serialize()</a> or <a href="#sqlite3_deserialize">sqlite3_deserialize()</a>, even operations that
2664 occur on a different thread. Applications that need to
2665 remember the string long-term should make their own copy. Applications that
2666 are accessing the same database connection simultaneously on multiple
2667 threads should mutex-protect calls to this API and should make their own
2668 private copy of the result prior to releasing the mutex.
2669 </p><hr><a name="sqlite3_db_readonly"></a>
2670 <h2>Determine if a database is read-only</h2>
2671 </div>
2672 <blockquote><pre>
2673 int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
2674 </pre></blockquote>
2675 <p>
2676 The sqlite3_db_readonly(D,N) interface returns 1 if the database N
2677 of connection D is read-only, 0 if it is read/write, or -1 if N is not
2678 the name of a database on connection D.
2679 </p><hr><a name="sqlite3_db_release_memory"></a>
2680 <h2>Free Memory Used By A Database Connection</h2>
2681 </div>
2682 <blockquote><pre>
2683 int sqlite3_db_release_memory(sqlite3*);
2684 </pre></blockquote>
2685 <p>
2686 The sqlite3_db_release_memory(D) interface attempts to free as much heap
2687 memory as possible from database connection D. Unlike the
2688 <a href="#sqlite3_release_memory">sqlite3_release_memory()</a> interface, this interface is in effect even
2689 when the <a href="compile.html#enable_memory_management">SQLITE_ENABLE_MEMORY_MANAGEMENT</a> compile-time option is
2690 omitted.</p>
2691
2692 <p>See also: <a href="#sqlite3_release_memory">sqlite3_release_memory()</a>
2693 </p><hr><a name="sqlite3_db_status"></a>
2694 <h2>Database Connection Status</h2>
2695 </div>
2696 <blockquote><pre>
2697 int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
2698 </pre></blockquote>
2699 <p>
2700 This interface is used to retrieve runtime status information
2701 about a single <a href="#sqlite3">database connection</a>. The first argument is the
2702 database connection object to be interrogated. The second argument
2703 is an integer constant, taken from the set of
2704 <a href="#SQLITE_DBSTATUS options">SQLITE_DBSTATUS options</a>, that
2705 determines the parameter to interrogate. The set of
2706 <a href="#SQLITE_DBSTATUS options">SQLITE_DBSTATUS options</a> is likely
2707 to grow in future releases of SQLite.</p>
2708
2709 <p>The current value of the requested parameter is written into *pCur
2710 and the highest instantaneous value is written into *pHiwtr. If
2711 the resetFlg is true, then the highest instantaneous value is
2712 reset back down to the current value.</p>
2713
2714 <p>The sqlite3_db_status() routine returns SQLITE_OK on success and a
2715 non-zero <a href="rescode.html">error code</a> on failure.</p>
2716
2717 <p>See also: <a href="#sqlite3_status">sqlite3_status()</a> and <a href="#sqlite3_stmt_status">sqlite3_stmt_status()</a>.
2718 </p><hr><a name="sqlite3_declare_vtab"></a>
2719 <h2>Declare The Schema Of A Virtual Table</h2>
2720 </div>
2721 <blockquote><pre>
2722 int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
2723 </pre></blockquote>
2724 <p>
2725 The <a href="vtab.html#xcreate">xCreate</a> and <a href="vtab.html#xconnect">xConnect</a> methods of a
2726 <a href="#sqlite3_module">virtual table module</a> call this interface
2727 to declare the format (the names and datatypes of the columns) of
2728 the virtual tables they implement.
2729 </p><hr><a name="sqlite3_deserialize"></a>
2730 <h2>Deserialize a database</h2>
2731 </div>
2732 <blockquote><pre>
2733 int sqlite3_deserialize(
2734 sqlite3 *db, /* The database connection */
2735 const char *zSchema, /* Which DB to reopen with the deserialization */
2736 unsigned char *pData, /* The serialized database content */
2737 sqlite3_int64 szDb, /* Number bytes in the deserialization */
2738 sqlite3_int64 szBuf, /* Total size of buffer pData[] */
2739 unsigned mFlags /* Zero or more SQLITE_DESERIALIZE_* flags */
2740 );
2741 </pre></blockquote>
2742 <p>
2743 The sqlite3_deserialize(D,S,P,N,M,F) interface causes the
2744 <a href="#sqlite3">database connection</a> D to disconnect from database S and then
2745 reopen S as an in-memory database based on the serialization contained
2746 in P. The serialized database P is N bytes in size. M is the size of
2747 the buffer P, which might be larger than N. If M is larger than N, and
2748 the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is
2749 permitted to add content to the in-memory database as long as the total
2750 size does not exceed M bytes.</p>
2751
2752 <p>If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will
2753 invoke sqlite3_free() on the serialization buffer when the database
2754 connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then
2755 SQLite will try to increase the buffer size using sqlite3_realloc64()
2756 if writes on the database cause it to grow larger than M bytes.</p>
2757
2758 <p>Applications must not modify the buffer P or invalidate it before
2759 the database connection D is closed.</p>
2760
2761 <p>The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
2762 database is currently in a read transaction or is involved in a backup
2763 operation.</p>
2764
2765 <p>It is not possible to deserialized into the TEMP database. If the
2766 S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
2767 function returns SQLITE_ERROR.</p>
2768
2769 <p>The deserialized database should not be in <a href="wal.html">WAL mode</a>. If the database
2770 is in WAL mode, then any attempt to use the database file will result
2771 in an <a href="#SQLITE_ABORT">SQLITE_CANTOPEN</a> error. The application can set the
2772 <a href="fileformat2.html#vnums">file format version numbers</a> (bytes 18 and 19) of the input database P
2773 to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the
2774 database file into rollback mode and work around this limitation.</p>
2775
2776 <p>If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
2777 SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
2778 <a href="#sqlite3_free">sqlite3_free()</a> is invoked on argument P prior to returning.</p>
2779
2780 <p>This interface is omitted if SQLite is compiled with the
2781 <a href="compile.html#omit_deserialize">SQLITE_OMIT_DESERIALIZE</a> option.
2782 </p><hr><a name="sqlite3_drop_modules"></a>
2783 <h2>Remove Unnecessary Virtual Table Implementations</h2>
2784 </div>
2785 <blockquote><pre>
2786 int sqlite3_drop_modules(
2787 sqlite3 *db, /* Remove modules from this connection */
2788 const char **azKeep /* Except, do not remove the ones named here */
2789 );
2790 </pre></blockquote>
2791 <p>
2792 The sqlite3_drop_modules(D,L) interface removes all virtual
2793 table modules from database connection D except those named on list L.
2794 The L parameter must be either NULL or a pointer to an array of pointers
2795 to strings where the array is terminated by a single NULL pointer.
2796 If the L parameter is NULL, then all virtual table modules are removed.</p>
2797
2798 <p>See also: <a href="#sqlite3_create_module">sqlite3_create_module()</a>
2799 </p><hr><a name="sqlite3_enable_load_extension"></a>
2800 <h2>Enable Or Disable Extension Loading</h2>
2801 </div>
2802 <blockquote><pre>
2803 int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
2804 </pre></blockquote>
2805 <p>
2806 So as not to open security holes in older applications that are
2807 unprepared to deal with <a href="loadext.html">extension loading</a>, and as a means of disabling
2808 <a href="loadext.html">extension loading</a> while evaluating user-entered SQL, the following API
2809 is provided to turn the <a href="#sqlite3_load_extension">sqlite3_load_extension()</a> mechanism on and off.</p>
2810
2811 <p>Extension loading is off by default.
2812 Call the sqlite3_enable_load_extension() routine with onoff==1
2813 to turn extension loading on and call it with onoff==0 to turn
2814 it back off again.</p>
2815
2816 <p>This interface enables or disables both the C-API
2817 <a href="#sqlite3_load_extension">sqlite3_load_extension()</a> and the SQL function <a href="lang_corefunc.html#load_extension">load_extension()</a>.
2818 Use <a href="#sqlite3_db_config">sqlite3_db_config</a>(db,<a href="#sqlitedbconfigenableloadextension">SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</a>,..)
2819 to enable or disable only the C-API.</p>
2820
2821 <p><b>Security warning:</b> It is recommended that extension loading
2822 be enabled using the <a href="#sqlitedbconfigenableloadextension">SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</a> method
2823 rather than this interface, so the <a href="lang_corefunc.html#load_extension">load_extension()</a> SQL function
2824 remains disabled. This will prevent SQL injections from giving attackers
2825 access to extension loading capabilities.
2826 </p><hr><a name="sqlite3_enable_shared_cache"></a>
2827 <h2>Enable Or Disable Shared Pager Cache</h2>
2828 </div>
2829 <blockquote><pre>
2830 int sqlite3_enable_shared_cache(int);
2831 </pre></blockquote>
2832 <p>
2833 This routine enables or disables the sharing of the database cache
2834 and schema data structures between <a href="#sqlite3">connections</a>
2835 to the same database. Sharing is enabled if the argument is true
2836 and disabled if the argument is false.</p>
2837
2838 <p>This interface is omitted if SQLite is compiled with
2839 <a href="compile.html#omit_shared_cache">-DSQLITE_OMIT_SHARED_CACHE</a>. The <a href="compile.html#omit_shared_cache">-DSQLITE_OMIT_SHARED_CACHE</a>
2840 compile-time option is recommended because the
2841 <a href="sharedcache.html#dontuse">use of shared cache mode is discouraged</a>.</p>
2842
2843 <p>Cache sharing is enabled and disabled for an entire process.
2844 This is a change as of SQLite <a href="releaselog/3_5_0.html">version 3.5.0</a> (2007-09-04).
2845 In prior versions of SQLite,
2846 sharing was enabled or disabled for each thread separately.</p>
2847
2848 <p>The cache sharing mode set by this interface effects all subsequent
2849 calls to <a href="#sqlite3_open">sqlite3_open()</a>, <a href="#sqlite3_open">sqlite3_open_v2()</a>, and <a href="#sqlite3_open">sqlite3_open16()</a>.
2850 Existing database connections continue to use the sharing mode
2851 that was in effect at the time they were opened.</p>
2852
2853 <p>This routine returns <a href="#SQLITE_ABORT">SQLITE_OK</a> if shared cache was enabled or disabled
2854 successfully. An <a href="rescode.html">error code</a> is returned otherwise.</p>
2855
2856 <p>Shared cache is disabled by default. It is recommended that it stay
2857 that way. In other words, do not use this routine. This interface
2858 continues to be provided for historical compatibility, but its use is
2859 discouraged. Any use of shared cache is discouraged. If shared cache
2860 must be used, it is recommended that shared cache only be enabled for
2861 individual database connections using the <a href="#sqlite3_open">sqlite3_open_v2()</a> interface
2862 with the <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_SHAREDCACHE</a> flag.</p>
2863
2864 <p>Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
2865 and will always return SQLITE_MISUSE. On those systems,
2866 shared cache mode should be enabled per-database connection via
2867 <a href="#sqlite3_open">sqlite3_open_v2()</a> with <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_SHAREDCACHE</a>.</p>
2868
2869 <p>This interface is threadsafe on processors where writing a
2870 32-bit integer is atomic.</p>
2871
2872 <p>See Also: <a href="sharedcache.html">SQLite Shared-Cache Mode</a>
2873 </p><hr><a name="sqlite3_exec"></a>
2874 <h2>One-Step Query Execution Interface</h2>
2875 </div>
2876 <blockquote><pre>
2877 int sqlite3_exec(
2878 sqlite3*, /* An open database */
2879 const char *sql, /* SQL to be evaluated */
2880 int (*callback)(void*,int,char**,char**), /* Callback function */
2881 void *, /* 1st argument to callback */
2882 char **errmsg /* Error msg written here */
2883 );
2884 </pre></blockquote>
2885 <p>
2886 The sqlite3_exec() interface is a convenience wrapper around
2887 <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>, <a href="#sqlite3_step">sqlite3_step()</a>, and <a href="#sqlite3_finalize">sqlite3_finalize()</a>,
2888 that allows an application to run multiple statements of SQL
2889 without having to use a lot of C code.</p>
2890
2891 <p>The sqlite3_exec() interface runs zero or more UTF-8 encoded,
2892 semicolon-separate SQL statements passed into its 2nd argument,
2893 in the context of the <a href="#sqlite3">database connection</a> passed in as its 1st
2894 argument. If the callback function of the 3rd argument to
2895 sqlite3_exec() is not NULL, then it is invoked for each result row
2896 coming out of the evaluated SQL statements. The 4th argument to
2897 sqlite3_exec() is relayed through to the 1st argument of each
2898 callback invocation. If the callback pointer to sqlite3_exec()
2899 is NULL, then no callback is ever invoked and result rows are
2900 ignored.</p>
2901
2902 <p>If an error occurs while evaluating the SQL statements passed into
2903 sqlite3_exec(), then execution of the current statement stops and
2904 subsequent statements are skipped. If the 5th parameter to sqlite3_exec()
2905 is not NULL then any error message is written into memory obtained
2906 from <a href="#sqlite3_free">sqlite3_malloc()</a> and passed back through the 5th parameter.
2907 To avoid memory leaks, the application should invoke <a href="#sqlite3_free">sqlite3_free()</a>
2908 on error message strings returned through the 5th parameter of
2909 sqlite3_exec() after the error message string is no longer needed.
2910 If the 5th parameter to sqlite3_exec() is not NULL and no errors
2911 occur, then sqlite3_exec() sets the pointer in its 5th parameter to
2912 NULL before returning.</p>
2913
2914 <p>If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
2915 routine returns SQLITE_ABORT without invoking the callback again and
2916 without running any subsequent SQL statements.</p>
2917
2918 <p>The 2nd argument to the sqlite3_exec() callback function is the
2919 number of columns in the result. The 3rd argument to the sqlite3_exec()
2920 callback is an array of pointers to strings obtained as if from
2921 <a href="#sqlite3_column_blob">sqlite3_column_text()</a>, one for each column. If an element of a
2922 result row is NULL then the corresponding string pointer for the
2923 sqlite3_exec() callback is a NULL pointer. The 4th argument to the
2924 sqlite3_exec() callback is an array of pointers to strings where each
2925 entry represents the name of corresponding result column as obtained
2926 from <a href="#sqlite3_column_name">sqlite3_column_name()</a>.</p>
2927
2928 <p>If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
2929 to an empty string, or a pointer that contains only whitespace and/or
2930 SQL comments, then no SQL statements are evaluated and the database
2931 is not changed.</p>
2932
2933 <p>Restrictions:</p>
2934
2935 <p><ul>
2936 <li> The application must ensure that the 1st parameter to sqlite3_exec()
2937 is a valid and open <a href="#sqlite3">database connection</a>.
2938 <li> The application must not close the <a href="#sqlite3">database connection</a> specified by
2939 the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
2940 <li> The application must not modify the SQL statement text passed into
2941 the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
2942 <li> The application must not dereference the arrays or string pointers
2943 passed as the 3rd and 4th callback parameters after it returns.
2944 </ul>
2945 </p><hr><a name="sqlite3_extended_result_codes"></a>
2946 <h2>Enable Or Disable Extended Result Codes</h2>
2947 </div>
2948 <blockquote><pre>
2949 int sqlite3_extended_result_codes(sqlite3*, int onoff);
2950 </pre></blockquote>
2951 <p>
2952 The sqlite3_extended_result_codes() routine enables or disables the
2953 <a href="rescode.html#extrc">extended result codes</a> feature of SQLite. The extended result
2954 codes are disabled by default for historical compatibility.
2955 </p><hr><a name="sqlite3_finalize"></a>
2956 <h2>Destroy A Prepared Statement Object</h2>
2957 </div>
2958 <blockquote><pre>
2959 int sqlite3_finalize(sqlite3_stmt *pStmt);
2960 </pre></blockquote>
2961 <p>
2962 The sqlite3_finalize() function is called to delete a <a href="#sqlite3_stmt">prepared statement</a>.
2963 If the most recent evaluation of the statement encountered no errors
2964 or if the statement is never been evaluated, then sqlite3_finalize() returns
2965 SQLITE_OK. If the most recent evaluation of statement S failed, then
2966 sqlite3_finalize(S) returns the appropriate <a href="rescode.html">error code</a> or
2967 <a href="rescode.html#extrc">extended error code</a>.</p>
2968
2969 <p>The sqlite3_finalize(S) routine can be called at any point during
2970 the life cycle of <a href="#sqlite3_stmt">prepared statement</a> S:
2971 before statement S is ever evaluated, after
2972 one or more calls to <a href="#sqlite3_reset">sqlite3_reset()</a>, or after any call
2973 to <a href="#sqlite3_step">sqlite3_step()</a> regardless of whether or not the statement has
2974 completed execution.</p>
2975
2976 <p>Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.</p>
2977
2978 <p>The application must finalize every <a href="#sqlite3_stmt">prepared statement</a> in order to avoid
2979 resource leaks. It is a grievous error for the application to try to use
2980 a prepared statement after it has been finalized. Any use of a prepared
2981 statement after it has been finalized can result in undefined and
2982 undesirable behavior such as segfaults and heap corruption.
2983 </p><hr><a name="sqlite3_last_insert_rowid"></a>
2984 <h2>Last Insert Rowid</h2>
2985 </div>
2986 <blockquote><pre>
2987 sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2988 </pre></blockquote>
2989 <p>
2990 Each entry in most SQLite tables (except for <a href="withoutrowid.html">WITHOUT ROWID</a> tables)
2991 has a unique 64-bit signed
2992 integer key called the <a href="lang_createtable.html#rowid">"rowid"</a>. The rowid is always available
2993 as an undeclared column named ROWID, OID, or _ROWID_ as long as those
2994 names are not also used by explicitly declared columns. If
2995 the table has a column of type <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> then that column
2996 is another alias for the rowid.</p>
2997
2998 <p>The sqlite3_last_insert_rowid(D) interface usually returns the <a href="lang_createtable.html#rowid">rowid</a> of
2999 the most recent successful <a href="lang_insert.html">INSERT</a> into a rowid table or <a href="vtab.html">virtual table</a>
3000 on database connection D. Inserts into <a href="withoutrowid.html">WITHOUT ROWID</a> tables are not
3001 recorded. If no successful <a href="lang_insert.html">INSERT</a>s into rowid tables have ever occurred
3002 on the database connection D, then sqlite3_last_insert_rowid(D) returns
3003 zero.</p>
3004
3005 <p>As well as being set automatically as rows are inserted into database
3006 tables, the value returned by this function may be set explicitly by
3007 <a href="#sqlite3_set_last_insert_rowid">sqlite3_set_last_insert_rowid()</a></p>
3008
3009 <p>Some virtual table implementations may INSERT rows into rowid tables as
3010 part of committing a transaction (e.g. to flush data accumulated in memory
3011 to disk). In this case subsequent calls to this function return the rowid
3012 associated with these internal INSERT operations, which leads to
3013 unintuitive results. Virtual table implementations that do write to rowid
3014 tables in this way can avoid this problem by restoring the original
3015 rowid value using <a href="#sqlite3_set_last_insert_rowid">sqlite3_set_last_insert_rowid()</a> before returning
3016 control to the user.</p>
3017
3018 <p>If an <a href="lang_insert.html">INSERT</a> occurs within a trigger then this routine will
3019 return the <a href="lang_createtable.html#rowid">rowid</a> of the inserted row as long as the trigger is
3020 running. Once the trigger program ends, the value returned
3021 by this routine reverts to what it was before the trigger was fired.</p>
3022
3023 <p>An <a href="lang_insert.html">INSERT</a> that fails due to a constraint violation is not a
3024 successful <a href="lang_insert.html">INSERT</a> and does not change the value returned by this
3025 routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
3026 and INSERT OR ABORT make no changes to the return value of this
3027 routine when their insertion fails. When INSERT OR REPLACE
3028 encounters a constraint violation, it does not fail. The
3029 INSERT continues to completion after deleting rows that caused
3030 the constraint problem so INSERT OR REPLACE will always change
3031 the return value of this interface.</p>
3032
3033 <p>For the purposes of this routine, an <a href="lang_insert.html">INSERT</a> is considered to
3034 be successful even if it is subsequently rolled back.</p>
3035
3036 <p>This function is accessible to SQL statements via the
3037 <a href="lang_corefunc.html#last_insert_rowid">last_insert_rowid() SQL function</a>.</p>
3038
3039 <p>If a separate thread performs a new <a href="lang_insert.html">INSERT</a> on the same
3040 database connection while the <a href="#sqlite3_last_insert_rowid">sqlite3_last_insert_rowid()</a>
3041 function is running and thus changes the last insert <a href="lang_createtable.html#rowid">rowid</a>,
3042 then the value returned by <a href="#sqlite3_last_insert_rowid">sqlite3_last_insert_rowid()</a> is
3043 unpredictable and might not equal either the old or the new
3044 last insert <a href="lang_createtable.html#rowid">rowid</a>.
3045 </p><hr><a name="sqlite3_limit"></a>
3046 <h2>Run-time Limits</h2>
3047 </div>
3048 <blockquote><pre>
3049 int sqlite3_limit(sqlite3*, int id, int newVal);
3050 </pre></blockquote>
3051 <p>
3052 This interface allows the size of various constructs to be limited
3053 on a connection by connection basis. The first parameter is the
3054 <a href="#sqlite3">database connection</a> whose limit is to be set or queried. The
3055 second parameter is one of the <a href="#SQLITE_LIMIT_ATTACHED">limit categories</a> that define a
3056 class of constructs to be size limited. The third parameter is the
3057 new limit for that construct.</p>
3058
3059 <p>If the new limit is a negative number, the limit is unchanged.
3060 For each limit category SQLITE_LIMIT_<i>NAME</i> there is a
3061 <a href="limits.html">hard upper bound</a>
3062 set at compile-time by a C preprocessor macro called
3063 <a href="limits.html">SQLITE_MAX_<i>NAME</i></a>.
3064 (The "_LIMIT_" in the name is changed to "_MAX_".)
3065 Attempts to increase a limit above its hard upper bound are
3066 silently truncated to the hard upper bound.</p>
3067
3068 <p>Regardless of whether or not the limit was changed, the
3069 <a href="#sqlite3_limit">sqlite3_limit()</a> interface returns the prior value of the limit.
3070 Hence, to find the current value of a limit without changing it,
3071 simply invoke this interface with the third parameter set to -1.</p>
3072
3073 <p>Run-time limits are intended for use in applications that manage
3074 both their own internal database and also databases that are controlled
3075 by untrusted external sources. An example application might be a
3076 web browser that has its own databases for storing history and
3077 separate databases controlled by JavaScript applications downloaded
3078 off the Internet. The internal databases can be given the
3079 large, default limits. Databases managed by external sources can
3080 be given much smaller limits designed to prevent a denial of service
3081 attack. Developers might also want to use the <a href="#sqlite3_set_authorizer">sqlite3_set_authorizer()</a>
3082 interface to further control untrusted SQL. The size of the database
3083 created by an untrusted script can be contained using the
3084 <a href="pragma.html#pragma_max_page_count">max_page_count</a> <a href="pragma.html#syntax">PRAGMA</a>.</p>
3085
3086 <p>New run-time limit categories may be added in future releases.
3087 </p><hr><a name="sqlite3_load_extension"></a>
3088 <h2>Load An Extension</h2>
3089 </div>
3090 <blockquote><pre>
3091 int sqlite3_load_extension(
3092 sqlite3 *db, /* Load the extension into this database connection */
3093 const char *zFile, /* Name of the shared library containing extension */
3094 const char *zProc, /* Entry point. Derived from zFile if 0 */
3095 char **pzErrMsg /* Put error message here if not 0 */
3096 );
3097 </pre></blockquote>
3098 <p>
3099 This interface loads an SQLite extension library from the named file.</p>
3100
3101 <p>The sqlite3_load_extension() interface attempts to load an
3102 <a href="loadext.html">SQLite extension</a> library contained in the file zFile. If
3103 the file cannot be loaded directly, attempts are made to load
3104 with various operating-system specific extensions added.
3105 So for example, if "samplelib" cannot be loaded, then names like
3106 "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
3107 be tried also.</p>
3108
3109 <p>The entry point is zProc.
3110 zProc may be 0, in which case SQLite will try to come up with an
3111 entry point name on its own. It first tries "sqlite3_extension_init".
3112 If that does not work, it constructs a name "sqlite3_X_init" where the
3113 X is consists of the lower-case equivalent of all ASCII alphabetic
3114 characters in the filename from the last "/" to the first following
3115 "." and omitting any initial "lib".
3116 The sqlite3_load_extension() interface returns
3117 <a href="#SQLITE_ABORT">SQLITE_OK</a> on success and <a href="#SQLITE_ABORT">SQLITE_ERROR</a> if something goes wrong.
3118 If an error occurs and pzErrMsg is not 0, then the
3119 <a href="#sqlite3_load_extension">sqlite3_load_extension()</a> interface shall attempt to
3120 fill *pzErrMsg with error message text stored in memory
3121 obtained from <a href="#sqlite3_free">sqlite3_malloc()</a>. The calling function
3122 should free this memory by calling <a href="#sqlite3_free">sqlite3_free()</a>.</p>
3123
3124 <p>Extension loading must be enabled using
3125 <a href="#sqlite3_enable_load_extension">sqlite3_enable_load_extension()</a> or
3126 <a href="#sqlite3_db_config">sqlite3_db_config</a>(db,<a href="#sqlitedbconfigenableloadextension">SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</a>,1,NULL)
3127 prior to calling this API,
3128 otherwise an error will be returned.</p>
3129
3130 <p><b>Security warning:</b> It is recommended that the
3131 <a href="#sqlitedbconfigenableloadextension">SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</a> method be used to enable only this
3132 interface. The use of the <a href="#sqlite3_enable_load_extension">sqlite3_enable_load_extension()</a> interface
3133 should be avoided. This will keep the SQL function <a href="lang_corefunc.html#load_extension">load_extension()</a>
3134 disabled and prevent SQL injections from giving attackers
3135 access to extension loading capabilities.</p>
3136
3137 <p>See also the <a href="lang_corefunc.html#load_extension">load_extension() SQL function</a>.
3138 </p><hr><a name="sqlite3_log"></a>
3139 <h2>Error Logging Interface</h2>
3140 </div>
3141 <blockquote><pre>
3142 void sqlite3_log(int iErrCode, const char *zFormat, ...);
3143 </pre></blockquote>
3144 <p>
3145 The <a href="#sqlite3_log">sqlite3_log()</a> interface writes a message into the <a href="errlog.html">error log</a>
3146 established by the <a href="#sqliteconfiglog">SQLITE_CONFIG_LOG</a> option to <a href="#sqlite3_config">sqlite3_config()</a>.
3147 If logging is enabled, the zFormat string and subsequent arguments are
3148 used with <a href="#sqlite3_mprintf">sqlite3_snprintf()</a> to generate the final output string.</p>
3149
3150 <p>The sqlite3_log() interface is intended for use by extensions such as
3151 virtual tables, collating functions, and SQL functions. While there is
3152 nothing to prevent an application from calling sqlite3_log(), doing so
3153 is considered bad form.</p>
3154
3155 <p>The zFormat string must not be NULL.</p>
3156
3157 <p>To avoid deadlocks and other threading problems, the sqlite3_log() routine
3158 will not use dynamically allocated memory. The log message is stored in
3159 a fixed-length buffer on the stack. If the log message is longer than
3160 a few hundred characters, it will be truncated to the length of the
3161 buffer.
3162 </p><hr><a name="sqlite3_next_stmt"></a>
3163 <h2>Find the next prepared statement</h2>
3164 </div>
3165 <blockquote><pre>
3166 sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
3167 </pre></blockquote>
3168 <p>
3169 This interface returns a pointer to the next <a href="#sqlite3_stmt">prepared statement</a> after
3170 pStmt associated with the <a href="#sqlite3">database connection</a> pDb. If pStmt is NULL
3171 then this interface returns a pointer to the first prepared statement
3172 associated with the database connection pDb. If no prepared statement
3173 satisfies the conditions of this routine, it returns NULL.</p>
3174
3175 <p>The <a href="#sqlite3">database connection</a> pointer D in a call to
3176 <a href="#sqlite3_next_stmt">sqlite3_next_stmt(D,S)</a> must refer to an open database
3177 connection and in particular must not be a NULL pointer.
3178 </p><hr><a name="sqlite3_overload_function"></a>
3179 <h2>Overload A Function For A Virtual Table</h2>
3180 </div>
3181 <blockquote><pre>
3182 int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
3183 </pre></blockquote>
3184 <p>
3185 Virtual tables can provide alternative implementations of functions
3186 using the <a href="vtab.html#xfindfunction">xFindFunction</a> method of the <a href="#sqlite3_module">virtual table module</a>.
3187 But global versions of those functions
3188 must exist in order to be overloaded.</p>
3189
3190 <p>This API makes sure a global version of a function with a particular
3191 name and number of parameters exists. If no such function exists
3192 before this API is called, a new function is created. The implementation
3193 of the new function always causes an exception to be thrown. So
3194 the new function is not good for anything by itself. Its only
3195 purpose is to be a placeholder function that can be overloaded
3196 by a <a href="vtab.html">virtual table</a>.
3197 </p><hr><a name="sqlite3_progress_handler"></a>
3198 <h2>Query Progress Callbacks</h2>
3199 </div>
3200 <blockquote><pre>
3201 void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3202 </pre></blockquote>
3203 <p>
3204 The sqlite3_progress_handler(D,N,X,P) interface causes the callback
3205 function X to be invoked periodically during long running calls to
3206 <a href="#sqlite3_step">sqlite3_step()</a> and <a href="#sqlite3_prepare">sqlite3_prepare()</a> and similar for
3207 database connection D. An example use for this
3208 interface is to keep a GUI updated during a large query.</p>
3209
3210 <p>The parameter P is passed through as the only parameter to the
3211 callback function X. The parameter N is the approximate number of
3212 <a href="opcode.html">virtual machine instructions</a> that are evaluated between successive
3213 invocations of the callback X. If N is less than one then the progress
3214 handler is disabled.</p>
3215
3216 <p>Only a single progress handler may be defined at one time per
3217 <a href="#sqlite3">database connection</a>; setting a new progress handler cancels the
3218 old one. Setting parameter X to NULL disables the progress handler.
3219 The progress handler is also disabled by setting N to a value less
3220 than 1.</p>
3221
3222 <p>If the progress callback returns non-zero, the operation is
3223 interrupted. This feature can be used to implement a
3224 "Cancel" button on a GUI progress dialog box.</p>
3225
3226 <p>The progress handler callback must not do anything that will modify
3227 the database connection that invoked the progress handler.
3228 Note that <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> and <a href="#sqlite3_step">sqlite3_step()</a> both modify their
3229 database connections for the meaning of "modify" in this paragraph.</p>
3230
3231 <p>The progress handler callback would originally only be invoked from the
3232 bytecode engine. It still might be invoked during <a href="#sqlite3_prepare">sqlite3_prepare()</a>
3233 and similar because those routines might force a reparse of the schema
3234 which involves running the bytecode engine. However, beginning with
3235 SQLite version 3.41.0, the progress handler callback might also be
3236 invoked directly from <a href="#sqlite3_prepare">sqlite3_prepare()</a> while analyzing and generating
3237 code for complex queries.
3238 </p><hr><a name="sqlite3_randomness"></a>
3239 <h2>Pseudo-Random Number Generator</h2>
3240 </div>
3241 <blockquote><pre>
3242 void sqlite3_randomness(int N, void *P);
3243 </pre></blockquote>
3244 <p>
3245 SQLite contains a high-quality pseudo-random number generator (PRNG) used to
3246 select random <a href="lang_createtable.html#rowid">ROWIDs</a> when inserting new records into a table that
3247 already uses the largest possible <a href="lang_createtable.html#rowid">ROWID</a>. The PRNG is also used for
3248 the built-in random() and randomblob() SQL functions. This interface allows
3249 applications to access the same PRNG for other purposes.</p>
3250
3251 <p>A call to this routine stores N bytes of randomness into buffer P.
3252 The P parameter can be a NULL pointer.</p>
3253
3254 <p>If this routine has not been previously called or if the previous
3255 call had N less than one or a NULL pointer for P, then the PRNG is
3256 seeded using randomness obtained from the xRandomness method of
3257 the default <a href="#sqlite3_vfs">sqlite3_vfs</a> object.
3258 If the previous call to this routine had an N of 1 or more and a
3259 non-NULL P then the pseudo-randomness is generated
3260 internally and without recourse to the <a href="#sqlite3_vfs">sqlite3_vfs</a> xRandomness
3261 method.
3262 </p><hr><a name="sqlite3_release_memory"></a>
3263 <h2>Attempt To Free Heap Memory</h2>
3264 </div>
3265 <blockquote><pre>
3266 int sqlite3_release_memory(int);
3267 </pre></blockquote>
3268 <p>
3269 The sqlite3_release_memory() interface attempts to free N bytes
3270 of heap memory by deallocating non-essential memory allocations
3271 held by the database library. Memory used to cache database
3272 pages to improve performance is an example of non-essential memory.
3273 sqlite3_release_memory() returns the number of bytes actually freed,
3274 which might be more or less than the amount requested.
3275 The sqlite3_release_memory() routine is a no-op returning zero
3276 if SQLite is not compiled with <a href="compile.html#enable_memory_management">SQLITE_ENABLE_MEMORY_MANAGEMENT</a>.</p>
3277
3278 <p>See also: <a href="#sqlite3_db_release_memory">sqlite3_db_release_memory()</a>
3279 </p><hr><a name="sqlite3_reset"></a>
3280 <h2>Reset A Prepared Statement Object</h2>
3281 </div>
3282 <blockquote><pre>
3283 int sqlite3_reset(sqlite3_stmt *pStmt);
3284 </pre></blockquote>
3285 <p>
3286 The sqlite3_reset() function is called to reset a <a href="#sqlite3_stmt">prepared statement</a>
3287 object back to its initial state, ready to be re-executed.
3288 Any SQL statement variables that had values bound to them using
3289 the <a href="#sqlite3_bind_blob">sqlite3_bind_*() API</a> retain their values.
3290 Use <a href="#sqlite3_clear_bindings">sqlite3_clear_bindings()</a> to reset the bindings.</p>
3291
3292 <p>The <a href="#sqlite3_reset">sqlite3_reset(S)</a> interface resets the <a href="#sqlite3_stmt">prepared statement</a> S
3293 back to the beginning of its program.</p>
3294
3295 <p>The return code from <a href="#sqlite3_reset">sqlite3_reset(S)</a> indicates whether or not
3296 the previous evaluation of prepared statement S completed successfully.
3297 If <a href="#sqlite3_step">sqlite3_step(S)</a> has never before been called on S or if
3298 <a href="#sqlite3_step">sqlite3_step(S)</a> has not been called since the previous call
3299 to <a href="#sqlite3_reset">sqlite3_reset(S)</a>, then <a href="#sqlite3_reset">sqlite3_reset(S)</a> will return
3300 <a href="#SQLITE_ABORT">SQLITE_OK</a>.</p>
3301
3302 <p>If the most recent call to <a href="#sqlite3_step">sqlite3_step(S)</a> for the
3303 <a href="#sqlite3_stmt">prepared statement</a> S indicated an error, then
3304 <a href="#sqlite3_reset">sqlite3_reset(S)</a> returns an appropriate <a href="rescode.html">error code</a>.
3305 The <a href="#sqlite3_reset">sqlite3_reset(S)</a> interface might also return an <a href="rescode.html">error code</a>
3306 if there were no prior errors but the process of resetting
3307 the prepared statement caused a new error. For example, if an
3308 <a href="lang_insert.html">INSERT</a> statement with a <a href="lang_returning.html">RETURNING</a> clause is only stepped one time,
3309 that one call to <a href="#sqlite3_step">sqlite3_step(S)</a> might return SQLITE_ROW but
3310 the overall statement might still fail and the <a href="#sqlite3_reset">sqlite3_reset(S)</a> call
3311 might return SQLITE_BUSY if locking constraints prevent the
3312 database change from committing. Therefore, it is important that
3313 applications check the return code from <a href="#sqlite3_reset">sqlite3_reset(S)</a> even if
3314 no prior call to <a href="#sqlite3_step">sqlite3_step(S)</a> indicated a problem.</p>
3315
3316 <p>The <a href="#sqlite3_reset">sqlite3_reset(S)</a> interface does not change the values
3317 of any <a href="#sqlite3_bind_blob">bindings</a> on the <a href="#sqlite3_stmt">prepared statement</a> S.
3318 </p><hr><a name="sqlite3_reset_auto_extension"></a>
3319 <h2>Reset Automatic Extension Loading</h2>
3320 </div>
3321 <blockquote><pre>
3322 void sqlite3_reset_auto_extension(void);
3323 </pre></blockquote>
3324 <p>
3325 This interface disables all automatic extensions previously
3326 registered using <a href="#sqlite3_auto_extension">sqlite3_auto_extension()</a>.
3327 </p><hr><a name="sqlite3_result_subtype"></a>
3328 <h2>Setting The Subtype Of An SQL Function</h2>
3329 </div>
3330 <blockquote><pre>
3331 void sqlite3_result_subtype(sqlite3_context*,unsigned int);
3332 </pre></blockquote>
3333 <p>
3334 The sqlite3_result_subtype(C,T) function causes the subtype of
3335 the result from the <a href="appfunc.html">application-defined SQL function</a> with
3336 <a href="#sqlite3_context">sqlite3_context</a> C to be the value T. Only the lower 8 bits
3337 of the subtype T are preserved in current versions of SQLite;
3338 higher order bits are discarded.
3339 The number of subtype bytes preserved by SQLite might increase
3340 in future releases of SQLite.</p>
3341
3342 <p>Every <a href="appfunc.html">application-defined SQL function</a> that invokes this interface
3343 should include the <a href="#sqliteresultsubtype">SQLITE_RESULT_SUBTYPE</a> property in its
3344 text encoding argument when the SQL function is
3345 <a href="#sqlite3_create_function">registered</a>. If the <a href="#sqliteresultsubtype">SQLITE_RESULT_SUBTYPE</a>
3346 property is omitted from the function that invokes sqlite3_result_subtype(),
3347 then in some cases the sqlite3_result_subtype() might fail to set
3348 the result subtype.</p>
3349
3350 <p>If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any
3351 SQL function that invokes the sqlite3_result_subtype() interface
3352 and that does not have the SQLITE_RESULT_SUBTYPE property will raise
3353 an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1
3354 by default.
3355 </p><hr><a name="sqlite3_serialize"></a>
3356 <h2>Serialize a database</h2>
3357 </div>
3358 <blockquote><pre>
3359 unsigned char *sqlite3_serialize(
3360 sqlite3 *db, /* The database connection */
3361 const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */
3362 sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */
3363 unsigned int mFlags /* Zero or more SQLITE_SERIALIZE_* flags */
3364 );
3365 </pre></blockquote>
3366 <p>
3367 The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
3368 that is a serialization of the S database on <a href="#sqlite3">database connection</a> D.
3369 If P is not a NULL pointer, then the size of the database in bytes
3370 is written into *P.</p>
3371
3372 <p>For an ordinary on-disk database file, the serialization is just a
3373 copy of the disk file. For an in-memory database or a "TEMP" database,
3374 the serialization is the same sequence of bytes which would be written
3375 to disk if that database where backed up to disk.</p>
3376
3377 <p>The usual case is that sqlite3_serialize() copies the serialization of
3378 the database into memory obtained from <a href="#sqlite3_free">sqlite3_malloc64()</a> and returns
3379 a pointer to that memory. The caller is responsible for freeing the
3380 returned value to avoid a memory leak. However, if the F argument
3381 contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations
3382 are made, and the sqlite3_serialize() function will return a pointer
3383 to the contiguous memory representation of the database that SQLite
3384 is currently using for that database, or NULL if the no such contiguous
3385 memory representation of the database exists. A contiguous memory
3386 representation of the database will usually only exist if there has
3387 been a prior call to <a href="#sqlite3_deserialize">sqlite3_deserialize(D,S,...)</a> with the same
3388 values of D and S.
3389 The size of the database is written into *P even if the
3390 SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
3391 of the database exists.</p>
3392
3393 <p>After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set,
3394 the returned buffer content will remain accessible and unchanged
3395 until either the next write operation on the connection or when
3396 the connection is closed, and applications must not modify the
3397 buffer. If the bit had been clear, the returned buffer will not
3398 be accessed by SQLite after the call.</p>
3399
3400 <p>A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
3401 SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
3402 allocation error occurs.</p>
3403
3404 <p>This interface is omitted if SQLite is compiled with the
3405 <a href="compile.html#omit_deserialize">SQLITE_OMIT_DESERIALIZE</a> option.
3406 </p><hr><a name="sqlite3_set_last_insert_rowid"></a>
3407 <h2>Set the Last Insert Rowid value.</h2>
3408 </div>
3409 <blockquote><pre>
3410 void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
3411 </pre></blockquote>
3412 <p>
3413 The sqlite3_set_last_insert_rowid(D, R) method allows the application to
3414 set the value returned by calling sqlite3_last_insert_rowid(D) to R
3415 without inserting a row into the database.
3416 </p><hr><a name="sqlite3_sleep"></a>
3417 <h2>Suspend Execution For A Short Time</h2>
3418 </div>
3419 <blockquote><pre>
3420 int sqlite3_sleep(int);
3421 </pre></blockquote>
3422 <p>
3423 The sqlite3_sleep() function causes the current thread to suspend execution
3424 for at least a number of milliseconds specified in its parameter.</p>
3425
3426 <p>If the operating system does not support sleep requests with
3427 millisecond time resolution, then the time will be rounded up to
3428 the nearest second. The number of milliseconds of sleep actually
3429 requested from the operating system is returned.</p>
3430
3431 <p>SQLite implements this interface by calling the xSleep()
3432 method of the default <a href="#sqlite3_vfs">sqlite3_vfs</a> object. If the xSleep() method
3433 of the default VFS is not implemented correctly, or not implemented at
3434 all, then the behavior of sqlite3_sleep() may deviate from the description
3435 in the previous paragraphs.</p>
3436
3437 <p>If a negative argument is passed to sqlite3_sleep() the results vary by
3438 VFS and operating system. Some system treat a negative argument as an
3439 instruction to sleep forever. Others understand it to mean do not sleep
3440 at all. In SQLite version 3.42.0 and later, a negative
3441 argument passed into sqlite3_sleep() is changed to zero before it is relayed
3442 down into the xSleep method of the VFS.
3443 </p><hr><a name="sqlite3_snapshot_cmp"></a>
3444 <h2>Compare the ages of two snapshot handles.</h2>
3445 </div>
3446 <blockquote><pre>
3447 int sqlite3_snapshot_cmp(
3448 sqlite3_snapshot *p1,
3449 sqlite3_snapshot *p2
3450 );
3451 </pre></blockquote>
3452 <p>
3453 The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
3454 of two valid snapshot handles.</p>
3455
3456 <p>If the two snapshot handles are not associated with the same database
3457 file, the result of the comparison is undefined.</p>
3458
3459 <p>Additionally, the result of the comparison is only valid if both of the
3460 snapshot handles were obtained by calling sqlite3_snapshot_get() since the
3461 last time the wal file was deleted. The wal file is deleted when the
3462 database is changed back to rollback mode or when the number of database
3463 clients drops to zero. If either snapshot handle was obtained before the
3464 wal file was last deleted, the value returned by this function
3465 is undefined.</p>
3466
3467 <p>Otherwise, this API returns a negative value if P1 refers to an older
3468 snapshot than P2, zero if the two handles refer to the same database
3469 snapshot, and a positive value if P1 is a newer snapshot than P2.</p>
3470
3471 <p>This interface is only available if SQLite is compiled with the
3472 <a href="compile.html#enable_snapshot">SQLITE_ENABLE_SNAPSHOT</a> option.
3473 </p><hr><a name="sqlite3_snapshot_free"></a>
3474 <h2>Destroy a snapshot</h2>
3475 </div>
3476 <blockquote><pre>
3477 void sqlite3_snapshot_free(sqlite3_snapshot*);
3478 </pre></blockquote>
3479 <p>
3480 The <a href="#sqlite3_snapshot_free">sqlite3_snapshot_free(P)</a> interface destroys <a href="#sqlite3_snapshot">sqlite3_snapshot</a> P.
3481 The application must eventually free every <a href="#sqlite3_snapshot">sqlite3_snapshot</a> object
3482 using this routine to avoid a memory leak.</p>
3483
3484 <p>The <a href="#sqlite3_snapshot_free">sqlite3_snapshot_free()</a> interface is only available when the
3485 <a href="compile.html#enable_snapshot">SQLITE_ENABLE_SNAPSHOT</a> compile-time option is used.
3486 </p><hr><a name="sqlite3_snapshot_get"></a>
3487 <h2>Record A Database Snapshot</h2>
3488 </div>
3489 <blockquote><pre>
3490 int sqlite3_snapshot_get(
3491 sqlite3 *db,
3492 const char *zSchema,
3493 sqlite3_snapshot **ppSnapshot
3494 );
3495 </pre></blockquote>
3496 <p>
3497 The <a href="#sqlite3_snapshot_get">sqlite3_snapshot_get(D,S,P)</a> interface attempts to make a
3498 new <a href="#sqlite3_snapshot">sqlite3_snapshot</a> object that records the current state of
3499 schema S in database connection D. On success, the
3500 <a href="#sqlite3_snapshot_get">sqlite3_snapshot_get(D,S,P)</a> interface writes a pointer to the newly
3501 created <a href="#sqlite3_snapshot">sqlite3_snapshot</a> object into *P and returns SQLITE_OK.
3502 If there is not already a read-transaction open on schema S when
3503 this function is called, one is opened automatically.</p>
3504
3505 <p>The following must be true for this function to succeed. If any of
3506 the following statements are false when sqlite3_snapshot_get() is
3507 called, SQLITE_ERROR is returned. The final value of *P is undefined
3508 in this case.</p>
3509
3510 <p><ul>
3511 <li> The database handle must not be in <a href="#sqlite3_get_autocommit">autocommit mode</a>.</p>
3512
3513 <p><li> Schema S of <a href="#sqlite3">database connection</a> D must be a <a href="wal.html">WAL mode</a> database.</p>
3514
3515 <p><li> There must not be a write transaction open on schema S of database
3516 connection D.</p>
3517
3518 <p><li> One or more transactions must have been written to the current wal
3519 file since it was created on disk (by any connection). This means
3520 that a snapshot cannot be taken on a wal mode database with no wal
3521 file immediately after it is first opened. At least one transaction
3522 must be written to it first.
3523 </ul></p>
3524
3525 <p>This function may also return SQLITE_NOMEM. If it is called with the
3526 database handle in autocommit mode but fails for some other reason,
3527 whether or not a read transaction is opened on schema S is undefined.</p>
3528
3529 <p>The <a href="#sqlite3_snapshot">sqlite3_snapshot</a> object returned from a successful call to
3530 <a href="#sqlite3_snapshot_get">sqlite3_snapshot_get()</a> must be freed using <a href="#sqlite3_snapshot_free">sqlite3_snapshot_free()</a>
3531 to avoid a memory leak.</p>
3532
3533 <p>The <a href="#sqlite3_snapshot_get">sqlite3_snapshot_get()</a> interface is only available when the
3534 <a href="compile.html#enable_snapshot">SQLITE_ENABLE_SNAPSHOT</a> compile-time option is used.
3535 </p><hr><a name="sqlite3_snapshot_open"></a>
3536 <h2>Start a read transaction on an historical snapshot</h2>
3537 </div>
3538 <blockquote><pre>
3539 int sqlite3_snapshot_open(
3540 sqlite3 *db,
3541 const char *zSchema,
3542 sqlite3_snapshot *pSnapshot
3543 );
3544 </pre></blockquote>
3545 <p>
3546 The <a href="#sqlite3_snapshot_open">sqlite3_snapshot_open(D,S,P)</a> interface either starts a new read
3547 transaction or upgrades an existing one for schema S of
3548 <a href="#sqlite3">database connection</a> D such that the read transaction refers to
3549 historical <a href="#sqlite3_snapshot">snapshot</a> P, rather than the most recent change to the
3550 database. The <a href="#sqlite3_snapshot_open">sqlite3_snapshot_open()</a> interface returns SQLITE_OK
3551 on success or an appropriate <a href="rescode.html">error code</a> if it fails.</p>
3552
3553 <p>In order to succeed, the database connection must not be in
3554 <a href="#sqlite3_get_autocommit">autocommit mode</a> when <a href="#sqlite3_snapshot_open">sqlite3_snapshot_open(D,S,P)</a> is called. If there
3555 is already a read transaction open on schema S, then the database handle
3556 must have no active statements (SELECT statements that have been passed
3557 to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()).
3558 SQLITE_ERROR is returned if either of these conditions is violated, or
3559 if schema S does not exist, or if the snapshot object is invalid.</p>
3560
3561 <p>A call to sqlite3_snapshot_open() will fail to open if the specified
3562 snapshot has been overwritten by a <a href="wal.html#ckpt">checkpoint</a>. In this case
3563 SQLITE_ERROR_SNAPSHOT is returned.</p>
3564
3565 <p>If there is already a read transaction open when this function is
3566 invoked, then the same read transaction remains open (on the same
3567 database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT
3568 is returned. If another error code - for example SQLITE_PROTOCOL or an
3569 SQLITE_IOERR error code - is returned, then the final state of the
3570 read transaction is undefined. If SQLITE_OK is returned, then the
3571 read transaction is now open on database snapshot P.</p>
3572
3573 <p>A call to <a href="#sqlite3_snapshot_open">sqlite3_snapshot_open(D,S,P)</a> will fail if the
3574 database connection D does not know that the database file for
3575 schema S is in <a href="wal.html">WAL mode</a>. A database connection might not know
3576 that the database file is in <a href="wal.html">WAL mode</a> if there has been no prior
3577 I/O on that database connection, or if the database entered <a href="wal.html">WAL mode</a>
3578 after the most recent I/O on the database connection.
3579 (Hint: Run "<a href="pragma.html#pragma_application_id">PRAGMA application_id</a>" against a newly opened
3580 database connection in order to make it ready to use snapshots.)</p>
3581
3582 <p>The <a href="#sqlite3_snapshot_open">sqlite3_snapshot_open()</a> interface is only available when the
3583 <a href="compile.html#enable_snapshot">SQLITE_ENABLE_SNAPSHOT</a> compile-time option is used.
3584 </p><hr><a name="sqlite3_snapshot_recover"></a>
3585 <h2>Recover snapshots from a wal file</h2>
3586 </div>
3587 <blockquote><pre>
3588 int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
3589 </pre></blockquote>
3590 <p>
3591 If a <a href="wal.html#walfile">WAL file</a> remains on disk after all database connections close
3592 (either through the use of the <a href="#sqlitefcntlpersistwal">SQLITE_FCNTL_PERSIST_WAL</a> <a href="#sqlite3_file_control">file control</a>
3593 or because the last process to have the database opened exited without
3594 calling <a href="#sqlite3_close">sqlite3_close()</a>) and a new connection is subsequently opened
3595 on that database and <a href="wal.html#walfile">WAL file</a>, the <a href="#sqlite3_snapshot_open">sqlite3_snapshot_open()</a> interface
3596 will only be able to open the last transaction added to the WAL file
3597 even though the WAL file contains other valid transactions.</p>
3598
3599 <p>This function attempts to scan the WAL file associated with database zDb
3600 of database handle db and make all valid snapshots available to
3601 sqlite3_snapshot_open(). It is an error if there is already a read
3602 transaction open on the database, or if the database is not a WAL mode
3603 database.</p>
3604
3605 <p>SQLITE_OK is returned if successful, or an SQLite error code otherwise.</p>
3606
3607 <p>This interface is only available if SQLite is compiled with the
3608 <a href="compile.html#enable_snapshot">SQLITE_ENABLE_SNAPSHOT</a> option.
3609 </p><hr><a name="sqlite3_soft_heap_limit"></a>
3610 <h2>Deprecated Soft Heap Limit Interface</h2>
3611 </div>
3612 <blockquote><pre>
3613 void sqlite3_soft_heap_limit(int N);
3614 </pre></blockquote>
3615 <p>
3616 This is a deprecated version of the <a href="#sqlite3_hard_heap_limit64">sqlite3_soft_heap_limit64()</a>
3617 interface. This routine is provided for historical compatibility
3618 only. All new applications should use the
3619 <a href="#sqlite3_hard_heap_limit64">sqlite3_soft_heap_limit64()</a> interface rather than this one.
3620 </p><hr><a name="sqlite3_step"></a>
3621 <h2>Evaluate An SQL Statement</h2>
3622 </div>
3623 <blockquote><pre>
3624 int sqlite3_step(sqlite3_stmt*);
3625 </pre></blockquote>
3626 <p>
3627 After a <a href="#sqlite3_stmt">prepared statement</a> has been prepared using any of
3628 <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>, <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a>, <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a>,
3629 or <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a> or one of the legacy
3630 interfaces <a href="#sqlite3_prepare">sqlite3_prepare()</a> or <a href="#sqlite3_prepare">sqlite3_prepare16()</a>, this function
3631 must be called one or more times to evaluate the statement.</p>
3632
3633 <p>The details of the behavior of the sqlite3_step() interface depend
3634 on whether the statement was prepared using the newer "vX" interfaces
3635 <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a>, <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>, <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a>,
3636 <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a> or the older legacy
3637 interfaces <a href="#sqlite3_prepare">sqlite3_prepare()</a> and <a href="#sqlite3_prepare">sqlite3_prepare16()</a>. The use of the
3638 new "vX" interface is recommended for new applications but the legacy
3639 interface will continue to be supported.</p>
3640
3641 <p>In the legacy interface, the return value will be either <a href="#SQLITE_ABORT">SQLITE_BUSY</a>,
3642 <a href="#SQLITE_ABORT">SQLITE_DONE</a>, <a href="#SQLITE_ABORT">SQLITE_ROW</a>, <a href="#SQLITE_ABORT">SQLITE_ERROR</a>, or <a href="#SQLITE_ABORT">SQLITE_MISUSE</a>.
3643 With the "v2" interface, any of the other <a href="rescode.html">result codes</a> or
3644 <a href="rescode.html#extrc">extended result codes</a> might be returned as well.</p>
3645
3646 <p><a href="#SQLITE_ABORT">SQLITE_BUSY</a> means that the database engine was unable to acquire the
3647 database locks it needs to do its job. If the statement is a <a href="lang_transaction.html">COMMIT</a>
3648 or occurs outside of an explicit transaction, then you can retry the
3649 statement. If the statement is not a <a href="lang_transaction.html">COMMIT</a> and occurs within an
3650 explicit transaction then you should rollback the transaction before
3651 continuing.</p>
3652
3653 <p><a href="#SQLITE_ABORT">SQLITE_DONE</a> means that the statement has finished executing
3654 successfully. sqlite3_step() should not be called again on this virtual
3655 machine without first calling <a href="#sqlite3_reset">sqlite3_reset()</a> to reset the virtual
3656 machine back to its initial state.</p>
3657
3658 <p>If the SQL statement being executed returns any data, then <a href="#SQLITE_ABORT">SQLITE_ROW</a>
3659 is returned each time a new row of data is ready for processing by the
3660 caller. The values may be accessed using the <a href="#sqlite3_column_blob">column access functions</a>.
3661 sqlite3_step() is called again to retrieve the next row of data.</p>
3662
3663 <p><a href="#SQLITE_ABORT">SQLITE_ERROR</a> means that a run-time error (such as a constraint
3664 violation) has occurred. sqlite3_step() should not be called again on
3665 the VM. More information may be found by calling <a href="#sqlite3_errcode">sqlite3_errmsg()</a>.
3666 With the legacy interface, a more specific error code (for example,
3667 <a href="#SQLITE_ABORT">SQLITE_INTERRUPT</a>, <a href="#SQLITE_ABORT">SQLITE_SCHEMA</a>, <a href="#SQLITE_ABORT">SQLITE_CORRUPT</a>, and so forth)
3668 can be obtained by calling <a href="#sqlite3_reset">sqlite3_reset()</a> on the
3669 <a href="#sqlite3_stmt">prepared statement</a>. In the "v2" interface,
3670 the more specific error code is returned directly by sqlite3_step().</p>
3671
3672 <p><a href="#SQLITE_ABORT">SQLITE_MISUSE</a> means that the this routine was called inappropriately.
3673 Perhaps it was called on a <a href="#sqlite3_stmt">prepared statement</a> that has
3674 already been <a href="#sqlite3_finalize">finalized</a> or on one that had
3675 previously returned <a href="#SQLITE_ABORT">SQLITE_ERROR</a> or <a href="#SQLITE_ABORT">SQLITE_DONE</a>. Or it could
3676 be the case that the same database connection is being used by two or
3677 more threads at the same moment in time.</p>
3678
3679 <p>For all versions of SQLite up to and including 3.6.23.1, a call to
3680 <a href="#sqlite3_reset">sqlite3_reset()</a> was required after sqlite3_step() returned anything
3681 other than <a href="#SQLITE_ABORT">SQLITE_ROW</a> before any subsequent invocation of
3682 sqlite3_step(). Failure to reset the prepared statement using
3683 <a href="#sqlite3_reset">sqlite3_reset()</a> would result in an <a href="#SQLITE_ABORT">SQLITE_MISUSE</a> return from
3684 sqlite3_step(). But after <a href="releaselog/3_6_23_1.html">version 3.6.23.1</a> (2010-03-26,
3685 sqlite3_step() began
3686 calling <a href="#sqlite3_reset">sqlite3_reset()</a> automatically in this circumstance rather
3687 than returning <a href="#SQLITE_ABORT">SQLITE_MISUSE</a>. This is not considered a compatibility
3688 break because any application that ever receives an SQLITE_MISUSE error
3689 is broken by definition. The <a href="compile.html#omit_autoreset">SQLITE_OMIT_AUTORESET</a> compile-time option
3690 can be used to restore the legacy behavior.</p>
3691
3692 <p><b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
3693 API always returns a generic error code, <a href="#SQLITE_ABORT">SQLITE_ERROR</a>, following any
3694 error other than <a href="#SQLITE_ABORT">SQLITE_BUSY</a> and <a href="#SQLITE_ABORT">SQLITE_MISUSE</a>. You must call
3695 <a href="#sqlite3_reset">sqlite3_reset()</a> or <a href="#sqlite3_finalize">sqlite3_finalize()</a> in order to find one of the
3696 specific <a href="rescode.html">error codes</a> that better describes the error.
3697 We admit that this is a goofy design. The problem has been fixed
3698 with the "v2" interface. If you prepare all of your SQL statements
3699 using <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a> or <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>
3700 or <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a> or <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a> instead
3701 of the legacy <a href="#sqlite3_prepare">sqlite3_prepare()</a> and <a href="#sqlite3_prepare">sqlite3_prepare16()</a> interfaces,
3702 then the more specific <a href="rescode.html">error codes</a> are returned directly
3703 by sqlite3_step(). The use of the "vX" interfaces is recommended.
3704 </p><hr><a name="sqlite3_stmt_busy"></a>
3705 <h2>Determine If A Prepared Statement Has Been Reset</h2>
3706 </div>
3707 <blockquote><pre>
3708 int sqlite3_stmt_busy(sqlite3_stmt*);
3709 </pre></blockquote>
3710 <p>
3711 The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3712 <a href="#sqlite3_stmt">prepared statement</a> S has been stepped at least once using
3713 <a href="#sqlite3_step">sqlite3_step(S)</a> but has neither run to completion (returned
3714 <a href="#SQLITE_ABORT">SQLITE_DONE</a> from <a href="#sqlite3_step">sqlite3_step(S)</a>) nor
3715 been reset using <a href="#sqlite3_reset">sqlite3_reset(S)</a>. The sqlite3_stmt_busy(S)
3716 interface returns false if S is a NULL pointer. If S is not a
3717 NULL pointer and is not a pointer to a valid <a href="#sqlite3_stmt">prepared statement</a>
3718 object, then the behavior is undefined and probably undesirable.</p>
3719
3720 <p>This interface can be used in combination <a href="#sqlite3_next_stmt">sqlite3_next_stmt()</a>
3721 to locate all prepared statements associated with a database
3722 connection that are in need of being reset. This can be used,
3723 for example, in diagnostic routines to search for prepared
3724 statements that are holding a transaction open.
3725 </p><hr><a name="sqlite3_stmt_explain"></a>
3726 <h2>Change The EXPLAIN Setting For A Prepared Statement</h2>
3727 </div>
3728 <blockquote><pre>
3729 int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode);
3730 </pre></blockquote>
3731 <p>
3732 The sqlite3_stmt_explain(S,E) interface changes the EXPLAIN
3733 setting for <a href="#sqlite3_stmt">prepared statement</a> S. If E is zero, then S becomes
3734 a normal prepared statement. If E is 1, then S behaves as if
3735 its SQL text began with "<a href="lang_explain.html">EXPLAIN</a>". If E is 2, then S behaves as if
3736 its SQL text began with "<a href="eqp.html">EXPLAIN QUERY PLAN</a>".</p>
3737
3738 <p>Calling sqlite3_stmt_explain(S,E) might cause S to be reprepared.
3739 SQLite tries to avoid a reprepare, but a reprepare might be necessary
3740 on the first transition into EXPLAIN or EXPLAIN QUERY PLAN mode.</p>
3741
3742 <p>Because of the potential need to reprepare, a call to
3743 sqlite3_stmt_explain(S,E) will fail with SQLITE_ERROR if S cannot be
3744 reprepared because it was created using <a href="#sqlite3_prepare">sqlite3_prepare()</a> instead of
3745 the newer <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> or <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a> interfaces and
3746 hence has no saved SQL text with which to reprepare.</p>
3747
3748 <p>Changing the explain setting for a prepared statement does not change
3749 the original SQL text for the statement. Hence, if the SQL text originally
3750 began with EXPLAIN or EXPLAIN QUERY PLAN, but sqlite3_stmt_explain(S,0)
3751 is called to convert the statement into an ordinary statement, the EXPLAIN
3752 or EXPLAIN QUERY PLAN keywords will still appear in the sqlite3_sql(S)
3753 output, even though the statement now acts like a normal SQL statement.</p>
3754
3755 <p>This routine returns SQLITE_OK if the explain mode is successfully
3756 changed, or an error code if the explain mode could not be changed.
3757 The explain mode cannot be changed while a statement is active.
3758 Hence, it is good practice to call <a href="#sqlite3_reset">sqlite3_reset(S)</a>
3759 immediately prior to calling sqlite3_stmt_explain(S,E).
3760 </p><hr><a name="sqlite3_stmt_isexplain"></a>
3761 <h2>Query The EXPLAIN Setting For A Prepared Statement</h2>
3762 </div>
3763 <blockquote><pre>
3764 int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt);
3765 </pre></blockquote>
3766 <p>
3767 The sqlite3_stmt_isexplain(S) interface returns 1 if the
3768 prepared statement S is an EXPLAIN statement, or 2 if the
3769 statement S is an EXPLAIN QUERY PLAN.
3770 The sqlite3_stmt_isexplain(S) interface returns 0 if S is
3771 an ordinary statement or a NULL pointer.
3772 </p><hr><a name="sqlite3_stmt_readonly"></a>
3773 <h2>Determine If An SQL Statement Writes The Database</h2>
3774 </div>
3775 <blockquote><pre>
3776 int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3777 </pre></blockquote>
3778 <p>
3779 The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
3780 and only if the <a href="#sqlite3_stmt">prepared statement</a> X makes no direct changes to
3781 the content of the database file.</p>
3782
3783 <p>Note that <a href="appfunc.html">application-defined SQL functions</a> or
3784 <a href="vtab.html">virtual tables</a> might change the database indirectly as a side effect.
3785 For example, if an application defines a function "eval()" that
3786 calls <a href="#sqlite3_exec">sqlite3_exec()</a>, then the following SQL statement would
3787 change the database file through side-effects:</p>
3788
3789 <p><blockquote><pre>
3790 SELECT eval('DELETE FROM t1') FROM t2;
3791 </pre></blockquote></p>
3792
3793 <p>But because the <a href="lang_select.html">SELECT</a> statement does not change the database file
3794 directly, sqlite3_stmt_readonly() would still return true.</p>
3795
3796 <p>Transaction control statements such as <a href="lang_transaction.html">BEGIN</a>, <a href="lang_transaction.html">COMMIT</a>, <a href="lang_transaction.html">ROLLBACK</a>,
3797 <a href="lang_savepoint.html">SAVEPOINT</a>, and <a href="lang_savepoint.html">RELEASE</a> cause sqlite3_stmt_readonly() to return true,
3798 since the statements themselves do not actually modify the database but
3799 rather they control the timing of when other statements modify the
3800 database. The <a href="lang_attach.html">ATTACH</a> and <a href="lang_detach.html">DETACH</a> statements also cause
3801 sqlite3_stmt_readonly() to return true since, while those statements
3802 change the configuration of a database connection, they do not make
3803 changes to the content of the database files on disk.
3804 The sqlite3_stmt_readonly() interface returns true for <a href="lang_transaction.html">BEGIN</a> since
3805 <a href="lang_transaction.html">BEGIN</a> merely sets internal flags, but the <a href="lang_transaction.html">BEGIN IMMEDIATE</a> and
3806 <a href="lang_transaction.html">BEGIN EXCLUSIVE</a> commands do touch the database and so
3807 sqlite3_stmt_readonly() returns false for those commands.</p>
3808
3809 <p>This routine returns false if there is any possibility that the
3810 statement might change the database file. A false return does
3811 not guarantee that the statement will change the database file.
3812 For example, an UPDATE statement might have a WHERE clause that
3813 makes it a no-op, but the sqlite3_stmt_readonly() result would still
3814 be false. Similarly, a CREATE TABLE IF NOT EXISTS statement is a
3815 read-only no-op if the table already exists, but
3816 sqlite3_stmt_readonly() still returns false for such a statement.</p>
3817
3818 <p>If prepared statement X is an <a href="lang_explain.html">EXPLAIN</a> or <a href="eqp.html">EXPLAIN QUERY PLAN</a>
3819 statement, then sqlite3_stmt_readonly(X) returns the same value as
3820 if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
3821 </p><hr><a name="sqlite3_stmt_scanstatus_reset"></a>
3822 <h2>Zero Scan-Status Counters</h2>
3823 </div>
3824 <blockquote><pre>
3825 void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
3826 </pre></blockquote>
3827 <p>
3828 Zero all <a href="#sqlite3_stmt_scanstatus">sqlite3_stmt_scanstatus()</a> related event counters.</p>
3829
3830 <p>This API is only available if the library is built with pre-processor
3831 symbol <a href="compile.html#enable_stmt_scanstatus">SQLITE_ENABLE_STMT_SCANSTATUS</a> defined.
3832 </p><hr><a name="sqlite3_stmt_status"></a>
3833 <h2>Prepared Statement Status</h2>
3834 </div>
3835 <blockquote><pre>
3836 int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
3837 </pre></blockquote>
3838 <p>
3839 Each prepared statement maintains various
3840 <a href="#SQLITE_STMTSTATUS counter">SQLITE_STMTSTATUS counters</a> that measure the number
3841 of times it has performed specific operations. These counters can
3842 be used to monitor the performance characteristics of the prepared
3843 statements. For example, if the number of table steps greatly exceeds
3844 the number of table searches or result rows, that would tend to indicate
3845 that the prepared statement is using a full table scan rather than
3846 an index.</p>
3847
3848 <p>This interface is used to retrieve and reset counter values from
3849 a <a href="#sqlite3_stmt">prepared statement</a>. The first argument is the prepared statement
3850 object to be interrogated. The second argument
3851 is an integer code for a specific <a href="#SQLITE_STMTSTATUS counter">SQLITE_STMTSTATUS counter</a>
3852 to be interrogated.
3853 The current value of the requested counter is returned.
3854 If the resetFlg is true, then the counter is reset to zero after this
3855 interface call returns.</p>
3856
3857 <p>See also: <a href="#sqlite3_status">sqlite3_status()</a> and <a href="#sqlite3_db_status">sqlite3_db_status()</a>.
3858 </p><hr><a name="sqlite3_str_finish"></a>
3859 <h2>Finalize A Dynamic String</h2>
3860 </div>
3861 <blockquote><pre>
3862 char *sqlite3_str_finish(sqlite3_str*);
3863 </pre></blockquote>
3864 <p>
3865 The <a href="#sqlite3_str_finish">sqlite3_str_finish(X)</a> interface destroys the sqlite3_str object X
3866 and returns a pointer to a memory buffer obtained from <a href="#sqlite3_free">sqlite3_malloc64()</a>
3867 that contains the constructed string. The calling application should
3868 pass the returned value to <a href="#sqlite3_free">sqlite3_free()</a> to avoid a memory leak.
3869 The <a href="#sqlite3_str_finish">sqlite3_str_finish(X)</a> interface may return a NULL pointer if any
3870 errors were encountered during construction of the string. The
3871 <a href="#sqlite3_str_finish">sqlite3_str_finish(X)</a> interface will also return a NULL pointer if the
3872 string in <a href="#sqlite3_str">sqlite3_str</a> object X is zero bytes long.
3873 </p><hr><a name="sqlite3_str_new"></a>
3874 <h2>Create A New Dynamic String Object</h2>
3875 </div>
3876 <blockquote><pre>
3877 sqlite3_str *sqlite3_str_new(sqlite3*);
3878 </pre></blockquote>
3879 <p>
3880 The <a href="#sqlite3_str_new">sqlite3_str_new(D)</a> interface allocates and initializes
3881 a new <a href="#sqlite3_str">sqlite3_str</a> object. To avoid memory leaks, the object returned by
3882 <a href="#sqlite3_str_new">sqlite3_str_new()</a> must be freed by a subsequent call to
3883 <a href="#sqlite3_str_finish">sqlite3_str_finish(X)</a>.</p>
3884
3885 <p>The <a href="#sqlite3_str_new">sqlite3_str_new(D)</a> interface always returns a pointer to a
3886 valid <a href="#sqlite3_str">sqlite3_str</a> object, though in the event of an out-of-memory
3887 error the returned object might be a special singleton that will
3888 silently reject new text, always return SQLITE_NOMEM from
3889 <a href="#sqlite3_str_errcode">sqlite3_str_errcode()</a>, always return 0 for
3890 <a href="#sqlite3_str_errcode">sqlite3_str_length()</a>, and always return NULL from
3891 <a href="#sqlite3_str_finish">sqlite3_str_finish(X)</a>. It is always safe to use the value
3892 returned by <a href="#sqlite3_str_new">sqlite3_str_new(D)</a> as the sqlite3_str parameter
3893 to any of the other <a href="#sqlite3_str">sqlite3_str</a> methods.</p>
3894
3895 <p>The D parameter to <a href="#sqlite3_str_new">sqlite3_str_new(D)</a> may be NULL. If the
3896 D parameter in <a href="#sqlite3_str_new">sqlite3_str_new(D)</a> is not NULL, then the maximum
3897 length of the string contained in the <a href="#sqlite3_str">sqlite3_str</a> object will be
3898 the value set for <a href="#sqlite3_limit">sqlite3_limit</a>(D,<a href="#sqlitelimitlength">SQLITE_LIMIT_LENGTH</a>) instead
3899 of <a href="limits.html#max_length">SQLITE_MAX_LENGTH</a>.
3900 </p><hr><a name="sqlite3_strglob"></a>
3901 <h2>String Globbing</h2>
3902 </div>
3903 <blockquote><pre>
3904 int sqlite3_strglob(const char *zGlob, const char *zStr);
3905 </pre></blockquote>
3906 <p>The <a href="#sqlite3_strglob">sqlite3_strglob(P,X)</a> interface returns zero if and only if
3907 string X matches the <a href="lang_expr.html#glob">GLOB</a> pattern P.
3908 The definition of <a href="lang_expr.html#glob">GLOB</a> pattern matching used in
3909 <a href="#sqlite3_strglob">sqlite3_strglob(P,X)</a> is the same as for the "X GLOB P" operator in the
3910 SQL dialect understood by SQLite. The <a href="#sqlite3_strglob">sqlite3_strglob(P,X)</a> function
3911 is case sensitive.</p>
3912
3913 <p>Note that this routine returns zero on a match and non-zero if the strings
3914 do not match, the same as <a href="#sqlite3_stricmp">sqlite3_stricmp()</a> and <a href="#sqlite3_stricmp">sqlite3_strnicmp()</a>.</p>
3915
3916 <p>See also: <a href="#sqlite3_strlike">sqlite3_strlike()</a>.
3917 </p><hr><a name="sqlite3_strlike"></a>
3918 <h2>String LIKE Matching</h2>
3919 </div>
3920 <blockquote><pre>
3921 int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
3922 </pre></blockquote>
3923 <p>The <a href="#sqlite3_strlike">sqlite3_strlike(P,X,E)</a> interface returns zero if and only if
3924 string X matches the <a href="lang_expr.html#like">LIKE</a> pattern P with escape character E.
3925 The definition of <a href="lang_expr.html#like">LIKE</a> pattern matching used in
3926 <a href="#sqlite3_strlike">sqlite3_strlike(P,X,E)</a> is the same as for the "X LIKE P ESCAPE E"
3927 operator in the SQL dialect understood by SQLite. For "X LIKE P" without
3928 the ESCAPE clause, set the E parameter of <a href="#sqlite3_strlike">sqlite3_strlike(P,X,E)</a> to 0.
3929 As with the LIKE operator, the <a href="#sqlite3_strlike">sqlite3_strlike(P,X,E)</a> function is case
3930 insensitive - equivalent upper and lower case ASCII characters match
3931 one another.</p>
3932
3933 <p>The <a href="#sqlite3_strlike">sqlite3_strlike(P,X,E)</a> function matches Unicode characters, though
3934 only ASCII characters are case folded.</p>
3935
3936 <p>Note that this routine returns zero on a match and non-zero if the strings
3937 do not match, the same as <a href="#sqlite3_stricmp">sqlite3_stricmp()</a> and <a href="#sqlite3_stricmp">sqlite3_strnicmp()</a>.</p>
3938
3939 <p>See also: <a href="#sqlite3_strglob">sqlite3_strglob()</a>.
3940 </p><hr><a name="sqlite3_system_errno"></a>
3941 <h2>Low-level system error code</h2>
3942 </div>
3943 <blockquote><pre>
3944 int sqlite3_system_errno(sqlite3*);
3945 </pre></blockquote>
3946 <p>
3947 Attempt to return the underlying operating system error code or error
3948 number that caused the most recent I/O error or failure to open a file.
3949 The return value is OS-dependent. For example, on unix systems, after
3950 <a href="#sqlite3_open">sqlite3_open_v2()</a> returns <a href="#SQLITE_ABORT">SQLITE_CANTOPEN</a>, this interface could be
3951 called to get back the underlying "errno" that caused the problem, such
3952 as ENOSPC, EAUTH, EISDIR, and so forth.
3953 </p><hr><a name="sqlite3_table_column_metadata"></a>
3954 <h2>Extract Metadata About A Column Of A Table</h2>
3955 </div>
3956 <blockquote><pre>
3957 int sqlite3_table_column_metadata(
3958 sqlite3 *db, /* Connection handle */
3959 const char *zDbName, /* Database name or NULL */
3960 const char *zTableName, /* Table name */
3961 const char *zColumnName, /* Column name */
3962 char const **pzDataType, /* OUTPUT: Declared data type */
3963 char const **pzCollSeq, /* OUTPUT: Collation sequence name */
3964 int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */
3965 int *pPrimaryKey, /* OUTPUT: True if column part of PK */
3966 int *pAutoinc /* OUTPUT: True if column is auto-increment */
3967 );
3968 </pre></blockquote>
3969 <p>
3970 The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
3971 information about column C of table T in database D
3972 on <a href="#sqlite3">database connection</a> X. The sqlite3_table_column_metadata()
3973 interface returns SQLITE_OK and fills in the non-NULL pointers in
3974 the final five arguments with appropriate values if the specified
3975 column exists. The sqlite3_table_column_metadata() interface returns
3976 SQLITE_ERROR if the specified column does not exist.
3977 If the column-name parameter to sqlite3_table_column_metadata() is a
3978 NULL pointer, then this routine simply checks for the existence of the
3979 table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
3980 does not. If the table name parameter T in a call to
3981 sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
3982 undefined behavior.</p>
3983
3984 <p>The column is identified by the second, third and fourth parameters to
3985 this function. The second parameter is either the name of the database
3986 (i.e. "main", "temp", or an attached database) containing the specified
3987 table or NULL. If it is NULL, then all attached databases are searched
3988 for the table using the same algorithm used by the database engine to
3989 resolve unqualified table references.</p>
3990
3991 <p>The third and fourth parameters to this function are the table and column
3992 name of the desired column, respectively.</p>
3993
3994 <p>Metadata is returned by writing to the memory locations passed as the 5th
3995 and subsequent parameters to this function. Any of these arguments may be
3996 NULL, in which case the corresponding element of metadata is omitted.</p>
3997
3998 <p><blockquote>
3999 <table border="1">
4000 <tr><th> Parameter <th> Output<br>Type <th> Description</p>
4001
4002 <p><tr><td> 5th <td> const char* <td> Data type
4003 <tr><td> 6th <td> const char* <td> Name of default collation sequence
4004 <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
4005 <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
4006 <tr><td> 9th <td> int <td> True if column is <a href="autoinc.html">AUTOINCREMENT</a>
4007 </table>
4008 </blockquote></p>
4009
4010 <p>The memory pointed to by the character pointers returned for the
4011 declaration type and collation sequence is valid until the next
4012 call to any SQLite API function.</p>
4013
4014 <p>If the specified table is actually a view, an <a href="rescode.html">error code</a> is returned.</p>
4015
4016 <p>If the specified column is "rowid", "oid" or "_rowid_" and the table
4017 is not a <a href="withoutrowid.html">WITHOUT ROWID</a> table and an
4018 <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> column has been explicitly declared, then the output
4019 parameters are set for the explicitly declared column. If there is no
4020 <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> column, then the outputs
4021 for the <a href="lang_createtable.html#rowid">rowid</a> are set as follows:</p>
4022
4023 <p><pre>
4024 data type: "INTEGER"
4025 collation sequence: "BINARY"
4026 not null: 0
4027 primary key: 1
4028 auto increment: 0
4029 </pre></p>
4030
4031 <p>This function causes all database schemas to be read from disk and
4032 parsed, if that has not already been done, and returns an error if
4033 any errors are encountered while loading the schema.
4034 </p><hr><a name="sqlite3_test_control"></a>
4035 <h2>Testing Interface</h2>
4036 </div>
4037 <blockquote><pre>
4038 int sqlite3_test_control(int op, ...);
4039 </pre></blockquote>
4040 <p>
4041 The sqlite3_test_control() interface is used to read out internal
4042 state of SQLite and to inject faults into SQLite for testing
4043 purposes. The first parameter is an operation code that determines
4044 the number, meaning, and operation of all subsequent parameters.</p>
4045
4046 <p>This interface is not for use by applications. It exists solely
4047 for verifying the correct operation of the SQLite library. Depending
4048 on how the SQLite library is compiled, this interface might not exist.</p>
4049
4050 <p>The details of the operation codes, their meanings, the parameters
4051 they take, and what they do are all subject to change without notice.
4052 Unlike most of the SQLite API, this function is not guaranteed to
4053 operate consistently from one release to the next.
4054 </p><hr><a name="sqlite3_threadsafe"></a>
4055 <h2>Test To See If The Library Is Threadsafe</h2>
4056 </div>
4057 <blockquote><pre>
4058 int sqlite3_threadsafe(void);
4059 </pre></blockquote>
4060 <p>
4061 The sqlite3_threadsafe() function returns zero if and only if
4062 SQLite was compiled with mutexing code omitted due to the
4063 <a href="compile.html#threadsafe">SQLITE_THREADSAFE</a> compile-time option being set to 0.</p>
4064
4065 <p>SQLite can be compiled with or without mutexes. When
4066 the <a href="compile.html#threadsafe">SQLITE_THREADSAFE</a> C preprocessor macro is 1 or 2, mutexes
4067 are enabled and SQLite is threadsafe. When the
4068 <a href="compile.html#threadsafe">SQLITE_THREADSAFE</a> macro is 0,
4069 the mutexes are omitted. Without the mutexes, it is not safe
4070 to use SQLite concurrently from more than one thread.</p>
4071
4072 <p>Enabling mutexes incurs a measurable performance penalty.
4073 So if speed is of utmost importance, it makes sense to disable
4074 the mutexes. But for maximum safety, mutexes should be enabled.
4075 The default behavior is for mutexes to be enabled.</p>
4076
4077 <p>This interface can be used by an application to make sure that the
4078 version of SQLite that it is linking against was compiled with
4079 the desired setting of the <a href="compile.html#threadsafe">SQLITE_THREADSAFE</a> macro.</p>
4080
4081 <p>This interface only reports on the compile-time mutex setting
4082 of the <a href="compile.html#threadsafe">SQLITE_THREADSAFE</a> flag. If SQLite is compiled with
4083 SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
4084 can be fully or partially disabled using a call to <a href="#sqlite3_config">sqlite3_config()</a>
4085 with the verbs <a href="#sqliteconfigsinglethread">SQLITE_CONFIG_SINGLETHREAD</a>, <a href="#sqliteconfigmultithread">SQLITE_CONFIG_MULTITHREAD</a>,
4086 or <a href="#sqliteconfigserialized">SQLITE_CONFIG_SERIALIZED</a>. The return value of the
4087 sqlite3_threadsafe() function shows only the compile-time setting of
4088 thread safety, not any run-time changes to that setting made by
4089 sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
4090 is unchanged by calls to sqlite3_config().</p>
4091
4092 <p>See the <a href="threadsafe.html">threading mode</a> documentation for additional information.
4093 </p><hr><a name="sqlite3_trace_v2"></a>
4094 <h2>SQL Trace Hook</h2>
4095 </div>
4096 <blockquote><pre>
4097 int sqlite3_trace_v2(
4098 sqlite3*,
4099 unsigned uMask,
4100 int(*xCallback)(unsigned,void*,void*,void*),
4101 void *pCtx
4102 );
4103 </pre></blockquote>
4104 <p>
4105 The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
4106 function X against <a href="#sqlite3">database connection</a> D, using property mask M
4107 and context pointer P. If the X callback is
4108 NULL or if the M mask is zero, then tracing is disabled. The
4109 M argument should be the bitwise OR-ed combination of
4110 zero or more <a href="#SQLITE_TRACE">SQLITE_TRACE</a> constants.</p>
4111
4112 <p>Each call to either sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P)
4113 overrides (cancels) all prior calls to sqlite3_trace(D,X,P) or
4114 sqlite3_trace_v2(D,M,X,P) for the <a href="#sqlite3">database connection</a> D. Each
4115 database connection may have at most one trace callback.</p>
4116
4117 <p>The X callback is invoked whenever any of the events identified by
4118 mask M occur. The integer return value from the callback is currently
4119 ignored, though this may change in future releases. Callback
4120 implementations should return zero to ensure future compatibility.</p>
4121
4122 <p>A trace callback is invoked with four arguments: callback(T,C,P,X).
4123 The T argument is one of the <a href="#SQLITE_TRACE">SQLITE_TRACE</a>
4124 constants to indicate why the callback was invoked.
4125 The C argument is a copy of the context pointer.
4126 The P and X arguments are pointers whose meanings depend on T.</p>
4127
4128 <p>The sqlite3_trace_v2() interface is intended to replace the legacy
4129 interfaces <a href="#sqlite3_profile">sqlite3_trace()</a> and <a href="#sqlite3_profile">sqlite3_profile()</a>, both of which
4130 are deprecated.
4131 </p><hr><a name="sqlite3_txn_state"></a>
4132 <h2>Determine the transaction state of a database</h2>
4133 </div>
4134 <blockquote><pre>
4135 int sqlite3_txn_state(sqlite3*,const char *zSchema);
4136 </pre></blockquote>
4137 <p>
4138 The sqlite3_txn_state(D,S) interface returns the current
4139 <a href="#SQLITE_TXN_NONE">transaction state</a> of schema S in database connection D. If S is NULL,
4140 then the highest transaction state of any schema on database connection D
4141 is returned. Transaction states are (in order of lowest to highest):
4142 <ol>
4143 <li value="0"> SQLITE_TXN_NONE
4144 <li value="1"> SQLITE_TXN_READ
4145 <li value="2"> SQLITE_TXN_WRITE
4146 </ol>
4147 If the S argument to sqlite3_txn_state(D,S) is not the name of
4148 a valid schema, then -1 is returned.
4149 </p><hr><a name="sqlite3_unlock_notify"></a>
4150 <h2>Unlock Notification</h2>
4151 </div>
4152 <blockquote><pre>
4153 int sqlite3_unlock_notify(
4154 sqlite3 *pBlocked, /* Waiting connection */
4155 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
4156 void *pNotifyArg /* Argument to pass to xNotify */
4157 );
4158 </pre></blockquote>
4159 <p>
4160 When running in shared-cache mode, a database operation may fail with
4161 an <a href="#SQLITE_ABORT">SQLITE_LOCKED</a> error if the required locks on the shared-cache or
4162 individual tables within the shared-cache cannot be obtained. See
4163 <a href="sharedcache.html">SQLite Shared-Cache Mode</a> for a description of shared-cache locking.
4164 This API may be used to register a callback that SQLite will invoke
4165 when the connection currently holding the required lock relinquishes it.
4166 This API is only available if the library was compiled with the
4167 <a href="compile.html#enable_unlock_notify">SQLITE_ENABLE_UNLOCK_NOTIFY</a> C-preprocessor symbol defined.</p>
4168
4169 <p>See Also: <a href="unlock_notify.html">Using the SQLite Unlock Notification Feature</a>.</p>
4170
4171 <p>Shared-cache locks are released when a database connection concludes
4172 its current transaction, either by committing it or rolling it back.</p>
4173
4174 <p>When a connection (known as the blocked connection) fails to obtain a
4175 shared-cache lock and SQLITE_LOCKED is returned to the caller, the
4176 identity of the database connection (the blocking connection) that
4177 has locked the required resource is stored internally. After an
4178 application receives an SQLITE_LOCKED error, it may call the
4179 sqlite3_unlock_notify() method with the blocked connection handle as
4180 the first argument to register for a callback that will be invoked
4181 when the blocking connections current transaction is concluded. The
4182 callback is invoked from within the <a href="#sqlite3_step">sqlite3_step</a> or <a href="#sqlite3_close">sqlite3_close</a>
4183 call that concludes the blocking connection's transaction.</p>
4184
4185 <p>If sqlite3_unlock_notify() is called in a multi-threaded application,
4186 there is a chance that the blocking connection will have already
4187 concluded its transaction by the time sqlite3_unlock_notify() is invoked.
4188 If this happens, then the specified callback is invoked immediately,
4189 from within the call to sqlite3_unlock_notify().</p>
4190
4191 <p>If the blocked connection is attempting to obtain a write-lock on a
4192 shared-cache table, and more than one other connection currently holds
4193 a read-lock on the same table, then SQLite arbitrarily selects one of
4194 the other connections to use as the blocking connection.</p>
4195
4196 <p>There may be at most one unlock-notify callback registered by a
4197 blocked connection. If sqlite3_unlock_notify() is called when the
4198 blocked connection already has a registered unlock-notify callback,
4199 then the new callback replaces the old. If sqlite3_unlock_notify() is
4200 called with a NULL pointer as its second argument, then any existing
4201 unlock-notify callback is canceled. The blocked connections
4202 unlock-notify callback may also be canceled by closing the blocked
4203 connection using <a href="#sqlite3_close">sqlite3_close()</a>.</p>
4204
4205 <p>The unlock-notify callback is not reentrant. If an application invokes
4206 any sqlite3_xxx API functions from within an unlock-notify callback, a
4207 crash or deadlock may be the result.</p>
4208
4209 <p>Unless deadlock is detected (see below), sqlite3_unlock_notify() always
4210 returns SQLITE_OK.</p>
4211
4212 <p><b>Callback Invocation Details</b></p>
4213
4214 <p>When an unlock-notify callback is registered, the application provides a
4215 single void* pointer that is passed to the callback when it is invoked.
4216 However, the signature of the callback function allows SQLite to pass
4217 it an array of void* context pointers. The first argument passed to
4218 an unlock-notify callback is a pointer to an array of void* pointers,
4219 and the second is the number of entries in the array.</p>
4220
4221 <p>When a blocking connection's transaction is concluded, there may be
4222 more than one blocked connection that has registered for an unlock-notify
4223 callback. If two or more such blocked connections have specified the
4224 same callback function, then instead of invoking the callback function
4225 multiple times, it is invoked once with the set of void* context pointers
4226 specified by the blocked connections bundled together into an array.
4227 This gives the application an opportunity to prioritize any actions
4228 related to the set of unblocked database connections.</p>
4229
4230 <p><b>Deadlock Detection</b></p>
4231
4232 <p>Assuming that after registering for an unlock-notify callback a
4233 database waits for the callback to be issued before taking any further
4234 action (a reasonable assumption), then using this API may cause the
4235 application to deadlock. For example, if connection X is waiting for
4236 connection Y's transaction to be concluded, and similarly connection
4237 Y is waiting on connection X's transaction, then neither connection
4238 will proceed and the system may remain deadlocked indefinitely.</p>
4239
4240 <p>To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
4241 detection. If a given call to sqlite3_unlock_notify() would put the
4242 system in a deadlocked state, then SQLITE_LOCKED is returned and no
4243 unlock-notify callback is registered. The system is said to be in
4244 a deadlocked state if connection A has registered for an unlock-notify
4245 callback on the conclusion of connection B's transaction, and connection
4246 B has itself registered for an unlock-notify callback when connection
4247 A's transaction is concluded. Indirect deadlock is also detected, so
4248 the system is also considered to be deadlocked if connection B has
4249 registered for an unlock-notify callback on the conclusion of connection
4250 C's transaction, where connection C is waiting on connection A. Any
4251 number of levels of indirection are allowed.</p>
4252
4253 <p><b>The "DROP TABLE" Exception</b></p>
4254
4255 <p>When a call to <a href="#sqlite3_step">sqlite3_step()</a> returns SQLITE_LOCKED, it is almost
4256 always appropriate to call sqlite3_unlock_notify(). There is however,
4257 one exception. When executing a "DROP TABLE" or "DROP INDEX" statement,
4258 SQLite checks if there are any currently executing SELECT statements
4259 that belong to the same connection. If there are, SQLITE_LOCKED is
4260 returned. In this case there is no "blocking connection", so invoking
4261 sqlite3_unlock_notify() results in the unlock-notify callback being
4262 invoked immediately. If the application then re-attempts the "DROP TABLE"
4263 or "DROP INDEX" query, an infinite loop might be the result.</p>
4264
4265 <p>One way around this problem is to check the extended error code returned
4266 by an sqlite3_step() call. If there is a blocking connection, then the
4267 extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
4268 the special "DROP TABLE/INDEX" case, the extended error code is just
4269 SQLITE_LOCKED.
4270 </p><hr><a name="sqlite3_update_hook"></a>
4271 <h2>Data Change Notification Callbacks</h2>
4272 </div>
4273 <blockquote><pre>
4274 void *sqlite3_update_hook(
4275 sqlite3*,
4276 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
4277 void*
4278 );
4279 </pre></blockquote>
4280 <p>
4281 The sqlite3_update_hook() interface registers a callback function
4282 with the <a href="#sqlite3">database connection</a> identified by the first argument
4283 to be invoked whenever a row is updated, inserted or deleted in
4284 a <a href="rowidtable.html">rowid table</a>.
4285 Any callback set by a previous call to this function
4286 for the same database connection is overridden.</p>
4287
4288 <p>The second argument is a pointer to the function to invoke when a
4289 row is updated, inserted or deleted in a rowid table.
4290 The first argument to the callback is a copy of the third argument
4291 to sqlite3_update_hook().
4292 The second callback argument is one of <a href="#SQLITE_ALTER_TABLE">SQLITE_INSERT</a>, <a href="#SQLITE_ALTER_TABLE">SQLITE_DELETE</a>,
4293 or <a href="#SQLITE_ALTER_TABLE">SQLITE_UPDATE</a>, depending on the operation that caused the callback
4294 to be invoked.
4295 The third and fourth arguments to the callback contain pointers to the
4296 database and table name containing the affected row.
4297 The final callback parameter is the <a href="lang_createtable.html#rowid">rowid</a> of the row.
4298 In the case of an update, this is the <a href="lang_createtable.html#rowid">rowid</a> after the update takes place.</p>
4299
4300 <p>The update hook is not invoked when internal system tables are
4301 modified (i.e. sqlite_sequence).
4302 The update hook is not invoked when <a href="withoutrowid.html">WITHOUT ROWID</a> tables are modified.</p>
4303
4304 <p>In the current implementation, the update hook
4305 is not invoked when conflicting rows are deleted because of an
4306 <a href="lang_conflict.html">ON CONFLICT REPLACE</a> clause. Nor is the update hook
4307 invoked when rows are deleted using the <a href="lang_delete.html#truncateopt">truncate optimization</a>.
4308 The exceptions defined in this paragraph might change in a future
4309 release of SQLite.</p>
4310
4311 <p>Whether the update hook is invoked before or after the
4312 corresponding change is currently unspecified and may differ
4313 depending on the type of change. Do not rely on the order of the
4314 hook call with regards to the final result of the operation which
4315 triggers the hook.</p>
4316
4317 <p>The update hook implementation must not do anything that will modify
4318 the database connection that invoked the update hook. Any actions
4319 to modify the database connection must be deferred until after the
4320 completion of the <a href="#sqlite3_step">sqlite3_step()</a> call that triggered the update hook.
4321 Note that <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> and <a href="#sqlite3_step">sqlite3_step()</a> both modify their
4322 database connections for the meaning of "modify" in this paragraph.</p>
4323
4324 <p>The sqlite3_update_hook(D,C,P) function
4325 returns the P argument from the previous call
4326 on the same <a href="#sqlite3">database connection</a> D, or NULL for
4327 the first call on D.</p>
4328
4329 <p>See also the <a href="#sqlite3_commit_hook">sqlite3_commit_hook()</a>, <a href="#sqlite3_commit_hook">sqlite3_rollback_hook()</a>,
4330 and <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_hook()</a> interfaces.
4331 </p><hr><a name="sqlite3_user_data"></a>
4332 <h2>User Data For Functions</h2>
4333 </div>
4334 <blockquote><pre>
4335 void *sqlite3_user_data(sqlite3_context*);
4336 </pre></blockquote>
4337 <p>
4338 The sqlite3_user_data() interface returns a copy of
4339 the pointer that was the pUserData parameter (the 5th parameter)
4340 of the <a href="#sqlite3_create_function">sqlite3_create_function()</a>
4341 and <a href="#sqlite3_create_function">sqlite3_create_function16()</a> routines that originally
4342 registered the application defined function.</p>
4343
4344 <p>This routine must be called from the same thread in which
4345 the application-defined function is running.
4346 </p><hr><a name="sqlite3_value_encoding"></a>
4347 <h2>Report the internal text encoding state of an sqlite3_value object</h2>
4348 </div>
4349 <blockquote><pre>
4350 int sqlite3_value_encoding(sqlite3_value*);
4351 </pre></blockquote>
4352 <p>
4353 The sqlite3_value_encoding(X) interface returns one of <a href="#SQLITE_ANY">SQLITE_UTF8</a>,
4354 <a href="#SQLITE_ANY">SQLITE_UTF16BE</a>, or <a href="#SQLITE_ANY">SQLITE_UTF16LE</a> according to the current text encoding
4355 of the value X, assuming that X has type TEXT. If sqlite3_value_type(X)
4356 returns something other than SQLITE_TEXT, then the return value from
4357 sqlite3_value_encoding(X) is meaningless. Calls to
4358 <a href="#sqlite3_value_blob">sqlite3_value_text(X)</a>, <a href="#sqlite3_value_blob">sqlite3_value_text16(X)</a>, <a href="#sqlite3_value_blob">sqlite3_value_text16be(X)</a>,
4359 <a href="#sqlite3_value_blob">sqlite3_value_text16le(X)</a>, <a href="#sqlite3_value_blob">sqlite3_value_bytes(X)</a>, or
4360 <a href="#sqlite3_value_blob">sqlite3_value_bytes16(X)</a> might change the encoding of the value X and
4361 thus change the return from subsequent calls to sqlite3_value_encoding(X).</p>
4362
4363 <p>This routine is intended for used by applications that test and validate
4364 the SQLite implementation. This routine is inquiring about the opaque
4365 internal state of an <a href="#sqlite3_value">sqlite3_value</a> object. Ordinary applications should
4366 not need to know what the internal state of an sqlite3_value object is and
4367 hence should not need to use this interface.
4368 </p><hr><a name="sqlite3_value_subtype"></a>
4369 <h2>Finding The Subtype Of SQL Values</h2>
4370 </div>
4371 <blockquote><pre>
4372 unsigned int sqlite3_value_subtype(sqlite3_value*);
4373 </pre></blockquote>
4374 <p>
4375 The sqlite3_value_subtype(V) function returns the subtype for
4376 an <a href="appfunc.html">application-defined SQL function</a> argument V. The subtype
4377 information can be used to pass a limited amount of context from
4378 one SQL function to another. Use the <a href="#sqlite3_result_subtype">sqlite3_result_subtype()</a>
4379 routine to set the subtype for the return value of an SQL function.</p>
4380
4381 <p>Every <a href="appfunc.html">application-defined SQL function</a> that invoke this interface
4382 should include the <a href="#sqlitesubtype">SQLITE_SUBTYPE</a> property in the text
4383 encoding argument when the function is <a href="#sqlite3_create_function">registered</a>.
4384 If the <a href="#sqlitesubtype">SQLITE_SUBTYPE</a> property is omitted, then sqlite3_value_subtype()
4385 might return zero instead of the upstream subtype in some corner cases.
4386 </p><hr><a name="sqlite3_vtab_collation"></a>
4387 <h2>Determine The Collation For a Virtual Table Constraint</h2>
4388 </div>
4389 <blockquote><pre>
4390 const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
4391 </pre></blockquote>
4392 <p>
4393 This function may only be called from within a call to the <a href="vtab.html#xbestindex">xBestIndex</a>
4394 method of a <a href="vtab.html">virtual table</a>. This function returns a pointer to a string
4395 that is the name of the appropriate collation sequence to use for text
4396 comparisons on the constraint identified by its arguments.</p>
4397
4398 <p>The first argument must be the pointer to the <a href="#sqlite3_index_info">sqlite3_index_info</a> object
4399 that is the first parameter to the xBestIndex() method. The second argument
4400 must be an index into the aConstraint[] array belonging to the
4401 sqlite3_index_info structure passed to xBestIndex.</p>
4402
4403 <p>Important:
4404 The first parameter must be the same pointer that is passed into the
4405 xBestMethod() method. The first parameter may not be a pointer to a
4406 different <a href="#sqlite3_index_info">sqlite3_index_info</a> object, even an exact copy.</p>
4407
4408 <p>The return value is computed as follows:</p>
4409
4410 <p><ol>
4411 <li><p> If the constraint comes from a WHERE clause expression that contains
4412 a <a href="lang_expr.html#collateop">COLLATE operator</a>, then the name of the collation specified by
4413 that COLLATE operator is returned.
4414 <li><p> If there is no COLLATE operator, but the column that is the subject
4415 of the constraint specifies an alternative collating sequence via
4416 a <a href="lang_createtable.html#collateclause">COLLATE clause</a> on the column definition within the CREATE TABLE
4417 statement that was passed into <a href="#sqlite3_declare_vtab">sqlite3_declare_vtab()</a>, then the
4418 name of that alternative collating sequence is returned.
4419 <li><p> Otherwise, "BINARY" is returned.
4420 </ol>
4421 </p><hr><a name="sqlite3_vtab_config"></a>
4422 <h2>Virtual Table Interface Configuration</h2>
4423 </div>
4424 <blockquote><pre>
4425 int sqlite3_vtab_config(sqlite3*, int op, ...);
4426 </pre></blockquote>
4427 <p>
4428 This function may be called by either the <a href="vtab.html#xconnect">xConnect</a> or <a href="vtab.html#xcreate">xCreate</a> method
4429 of a <a href="vtab.html">virtual table</a> implementation to configure
4430 various facets of the virtual table interface.</p>
4431
4432 <p>If this interface is invoked outside the context of an xConnect or
4433 xCreate virtual table method then the behavior is undefined.</p>
4434
4435 <p>In the call sqlite3_vtab_config(D,C,...) the D parameter is the
4436 <a href="#sqlite3">database connection</a> in which the virtual table is being created and
4437 which is passed in as the first argument to the <a href="vtab.html#xconnect">xConnect</a> or <a href="vtab.html#xcreate">xCreate</a>
4438 method that is invoking sqlite3_vtab_config(). The C parameter is one
4439 of the <a href="#SQLITE_VTAB_CONSTRAINT_SUPPORT">virtual table configuration options</a>. The presence and meaning
4440 of parameters after C depend on which <a href="#SQLITE_VTAB_CONSTRAINT_SUPPORT">virtual table configuration option</a>
4441 is used.
4442 </p><hr><a name="sqlite3_vtab_distinct"></a>
4443 <h2>Determine if a virtual table query is DISTINCT</h2>
4444 </div>
4445 <blockquote><pre>
4446 int sqlite3_vtab_distinct(sqlite3_index_info*);
4447 </pre></blockquote>
4448 <p>
4449 This API may only be used from within an <a href="vtab.html#xbestindex">xBestIndex method</a>
4450 of a <a href="vtab.html">virtual table</a> implementation. The result of calling this
4451 interface from outside of xBestIndex() is undefined and probably harmful.</p>
4452
4453 <p>The sqlite3_vtab_distinct() interface returns an integer between 0 and
4454 3. The integer returned by sqlite3_vtab_distinct()
4455 gives the virtual table additional information about how the query
4456 planner wants the output to be ordered. As long as the virtual table
4457 can meet the ordering requirements of the query planner, it may set
4458 the "orderByConsumed" flag.</p>
4459
4460 <p><ol><li value="0"><p>
4461 If the sqlite3_vtab_distinct() interface returns 0, that means
4462 that the query planner needs the virtual table to return all rows in the
4463 sort order defined by the "nOrderBy" and "aOrderBy" fields of the
4464 <a href="#sqlite3_index_info">sqlite3_index_info</a> object. This is the default expectation. If the
4465 virtual table outputs all rows in sorted order, then it is always safe for
4466 the xBestIndex method to set the "orderByConsumed" flag, regardless of
4467 the return value from sqlite3_vtab_distinct().
4468 <li value="1"><p>
4469 If the sqlite3_vtab_distinct() interface returns 1, that means
4470 that the query planner does not need the rows to be returned in sorted order
4471 as long as all rows with the same values in all columns identified by the
4472 "aOrderBy" field are adjacent. This mode is used when the query planner
4473 is doing a GROUP BY.
4474 <li value="2"><p>
4475 If the sqlite3_vtab_distinct() interface returns 2, that means
4476 that the query planner does not need the rows returned in any particular
4477 order, as long as rows with the same values in all columns identified
4478 by "aOrderBy" are adjacent. Furthermore, when two or more rows
4479 contain the same values for all columns identified by "colUsed", all but
4480 one such row may optionally be omitted from the result.
4481 The virtual table is not required to omit rows that are duplicates
4482 over the "colUsed" columns, but if the virtual table can do that without
4483 too much extra effort, it could potentially help the query to run faster.
4484 This mode is used for a DISTINCT query.
4485 <li value="3"><p>
4486 If the sqlite3_vtab_distinct() interface returns 3, that means the
4487 virtual table must return rows in the order defined by "aOrderBy" as
4488 if the sqlite3_vtab_distinct() interface had returned 0. However if
4489 two or more rows in the result have the same values for all columns
4490 identified by "colUsed", then all but one such row may optionally be
4491 omitted. Like when the return value is 2, the virtual table
4492 is not required to omit rows that are duplicates over the "colUsed"
4493 columns, but if the virtual table can do that without
4494 too much extra effort, it could potentially help the query to run faster.
4495 This mode is used for queries
4496 that have both DISTINCT and ORDER BY clauses.
4497 </ol></p>
4498
4499 <p><p>The following table summarizes the conditions under which the
4500 virtual table is allowed to set the "orderByConsumed" flag based on
4501 the value returned by sqlite3_vtab_distinct(). This table is a
4502 restatement of the previous four paragraphs:</p>
4503
4504 <p><table border=1 cellspacing=0 cellpadding=10 width="90%">
4505 <tr>
4506 <td valign="top">sqlite3_vtab_distinct() return value
4507 <td valign="top">Rows are returned in aOrderBy order
4508 <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
4509 <td valign="top">Duplicates over all colUsed columns may be omitted
4510 <tr><td>0<td>yes<td>yes<td>no
4511 <tr><td>1<td>no<td>yes<td>no
4512 <tr><td>2<td>no<td>yes<td>yes
4513 <tr><td>3<td>yes<td>yes<td>yes
4514 </table></p>
4515
4516 <p>For the purposes of comparing virtual table output values to see if the
4517 values are same value for sorting purposes, two NULL values are considered
4518 to be the same. In other words, the comparison operator is "IS"
4519 (or "IS NOT DISTINCT FROM") and not "==".</p>
4520
4521 <p>If a virtual table implementation is unable to meet the requirements
4522 specified above, then it must not set the "orderByConsumed" flag in the
4523 <a href="#sqlite3_index_info">sqlite3_index_info</a> object or an incorrect answer may result.</p>
4524
4525 <p>A virtual table implementation is always free to return rows in any order
4526 it wants, as long as the "orderByConsumed" flag is not set. When the
4527 the "orderByConsumed" flag is unset, the query planner will add extra
4528 <a href="opcode.html">bytecode</a> to ensure that the final results returned by the SQL query are
4529 ordered correctly. The use of the "orderByConsumed" flag and the
4530 sqlite3_vtab_distinct() interface is merely an optimization. Careful
4531 use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
4532 flag might help queries against a virtual table to run faster. Being
4533 overly aggressive and setting the "orderByConsumed" flag when it is not
4534 valid to do so, on the other hand, might cause SQLite to return incorrect
4535 results.
4536 </p><hr><a name="sqlite3_vtab_in"></a>
4537 <h2>Identify and handle IN constraints in xBestIndex</h2>
4538 </div>
4539 <blockquote><pre>
4540 int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
4541 </pre></blockquote>
4542 <p>
4543 This interface may only be used from within an
4544 <a href="vtab.html#xbestindex">xBestIndex() method</a> of a <a href="vtab.html">virtual table</a> implementation.
4545 The result of invoking this interface from any other context is
4546 undefined and probably harmful.</p>
4547
4548 <p>A constraint on a virtual table of the form
4549 "<a href="lang_expr.html#in_op">column IN (...)</a>" is
4550 communicated to the xBestIndex method as a
4551 <a href="#SQLITE_INDEX_CONSTRAINT_EQ">SQLITE_INDEX_CONSTRAINT_EQ</a> constraint. If xBestIndex wants to use
4552 this constraint, it must set the corresponding
4553 aConstraintUsage[].argvIndex to a positive integer. Then, under
4554 the usual mode of handling IN operators, SQLite generates <a href="opcode.html">bytecode</a>
4555 that invokes the <a href="vtab.html#xfilter">xFilter() method</a> once for each value
4556 on the right-hand side of the IN operator. Thus the virtual table
4557 only sees a single value from the right-hand side of the IN operator
4558 at a time.</p>
4559
4560 <p>In some cases, however, it would be advantageous for the virtual
4561 table to see all values on the right-hand of the IN operator all at
4562 once. The sqlite3_vtab_in() interfaces facilitates this in two ways:</p>
4563
4564 <p><ol>
4565 <li><p>
4566 A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
4567 if and only if the <a href="#sqlite3_index_info">P->aConstraint</a>[N] constraint
4568 is an <a href="lang_expr.html#in_op">IN operator</a> that can be processed all at once. In other words,
4569 sqlite3_vtab_in() with -1 in the third argument is a mechanism
4570 by which the virtual table can ask SQLite if all-at-once processing
4571 of the IN operator is even possible.</p>
4572
4573 <p><li><p>
4574 A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
4575 to SQLite that the virtual table does or does not want to process
4576 the IN operator all-at-once, respectively. Thus when the third
4577 parameter (F) is non-negative, this interface is the mechanism by
4578 which the virtual table tells SQLite how it wants to process the
4579 IN operator.
4580 </ol></p>
4581
4582 <p>The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
4583 within the same xBestIndex method call. For any given P,N pair,
4584 the return value from sqlite3_vtab_in(P,N,F) will always be the same
4585 within the same xBestIndex call. If the interface returns true
4586 (non-zero), that means that the constraint is an IN operator
4587 that can be processed all-at-once. If the constraint is not an IN
4588 operator or cannot be processed all-at-once, then the interface returns
4589 false.</p>
4590
4591 <p>All-at-once processing of the IN operator is selected if both of the
4592 following conditions are met:</p>
4593
4594 <p><ol>
4595 <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
4596 integer. This is how the virtual table tells SQLite that it wants to
4597 use the N-th constraint.</p>
4598
4599 <p><li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
4600 non-negative had F>=1.
4601 </ol></p>
4602
4603 <p>If either or both of the conditions above are false, then SQLite uses
4604 the traditional one-at-a-time processing strategy for the IN constraint.
4605 If both conditions are true, then the argvIndex-th parameter to the
4606 xFilter method will be an <a href="#sqlite3_value">sqlite3_value</a> that appears to be NULL,
4607 but which can be passed to <a href="#sqlite3_vtab_in_first">sqlite3_vtab_in_first()</a> and
4608 <a href="#sqlite3_vtab_in_first">sqlite3_vtab_in_next()</a> to find all values on the right-hand side
4609 of the IN constraint.
4610 </p><hr><a name="sqlite3_vtab_nochange"></a>
4611 <h2>Determine If Virtual Table Column Access Is For UPDATE</h2>
4612 </div>
4613 <blockquote><pre>
4614 int sqlite3_vtab_nochange(sqlite3_context*);
4615 </pre></blockquote>
4616 <p>
4617 If the sqlite3_vtab_nochange(X) routine is called within the <a href="vtab.html#xcolumn">xColumn</a>
4618 method of a <a href="vtab.html">virtual table</a>, then it might return true if the
4619 column is being fetched as part of an UPDATE operation during which the
4620 column value will not change. The virtual table implementation can use
4621 this hint as permission to substitute a return value that is less
4622 expensive to compute and that the corresponding
4623 <a href="vtab.html#xupdate">xUpdate</a> method understands as a "no-change" value.</p>
4624
4625 <p>If the <a href="vtab.html#xcolumn">xColumn</a> method calls sqlite3_vtab_nochange() and finds that
4626 the column is not changed by the UPDATE statement, then the xColumn
4627 method can optionally return without setting a result, without calling
4628 any of the <a href="#sqlite3_result_blob">sqlite3_result_xxxxx() interfaces</a>.
4629 In that case, <a href="#sqlite3_value_blob">sqlite3_value_nochange(X)</a> will return true for the
4630 same column in the <a href="vtab.html#xupdate">xUpdate</a> method.</p>
4631
4632 <p>The sqlite3_vtab_nochange() routine is an optimization. Virtual table
4633 implementations should continue to give a correct answer even if the
4634 sqlite3_vtab_nochange() interface were to always return false. In the
4635 current implementation, the sqlite3_vtab_nochange() interface does always
4636 returns false for the enhanced <a href="lang_update.html#upfrom">UPDATE FROM</a> statement.
4637 </p><hr><a name="sqlite3_vtab_on_conflict"></a>
4638 <h2>Determine The Virtual Table Conflict Policy</h2>
4639 </div>
4640 <blockquote><pre>
4641 int sqlite3_vtab_on_conflict(sqlite3 *);
4642 </pre></blockquote>
4643 <p>
4644 This function may only be called from within a call to the <a href="vtab.html#xupdate">xUpdate</a> method
4645 of a <a href="vtab.html">virtual table</a> implementation for an INSERT or UPDATE operation. The
4646 value returned is one of <a href="#SQLITE_FAIL">SQLITE_ROLLBACK</a>, <a href="#SQLITE_DENY">SQLITE_IGNORE</a>, <a href="#SQLITE_FAIL">SQLITE_FAIL</a>,
4647 <a href="#SQLITE_ABORT">SQLITE_ABORT</a>, or <a href="#SQLITE_FAIL">SQLITE_REPLACE</a>, according to the <a href="lang_conflict.html">ON CONFLICT</a> mode
4648 of the SQL statement that triggered the call to the <a href="vtab.html#xupdate">xUpdate</a> method of the
4649 <a href="vtab.html">virtual table</a>.
4650 </p><hr><a name="sqlite3_vtab_rhs_value"></a>
4651 <h2>Constraint values in xBestIndex()</h2>
4652 </div>
4653 <blockquote><pre>
4654 int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
4655 </pre></blockquote>
4656 <p>
4657 This API may only be used from within the <a href="vtab.html#xbestindex">xBestIndex method</a>
4658 of a <a href="vtab.html">virtual table</a> implementation. The result of calling this interface
4659 from outside of an xBestIndex method are undefined and probably harmful.</p>
4660
4661 <p>When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
4662 the <a href="vtab.html#xbestindex">xBestIndex</a> method of a <a href="vtab.html">virtual table</a> implementation, with P being
4663 a copy of the <a href="#sqlite3_index_info">sqlite3_index_info</a> object pointer passed into xBestIndex and
4664 J being a 0-based index into P->aConstraint[], then this routine
4665 attempts to set *V to the value of the right-hand operand of
4666 that constraint if the right-hand operand is known. If the
4667 right-hand operand is not known, then *V is set to a NULL pointer.
4668 The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
4669 and only if *V is set to a value. The sqlite3_vtab_rhs_value(P,J,V)
4670 inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
4671 constraint is not available. The sqlite3_vtab_rhs_value() interface
4672 can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
4673 something goes wrong.</p>
4674
4675 <p>The sqlite3_vtab_rhs_value() interface is usually only successful if
4676 the right-hand operand of a constraint is a literal value in the original
4677 SQL statement. If the right-hand operand is an expression or a reference
4678 to some other column or a <a href="#sqlite3_bind_blob">host parameter</a>, then sqlite3_vtab_rhs_value()
4679 will probably return <a href="#SQLITE_ABORT">SQLITE_NOTFOUND</a>.</p>
4680
4681 <p>Some constraints, such as <a href="#SQLITE_INDEX_CONSTRAINT_EQ">SQLITE_INDEX_CONSTRAINT_ISNULL</a> and
4682 <a href="#SQLITE_INDEX_CONSTRAINT_EQ">SQLITE_INDEX_CONSTRAINT_ISNOTNULL</a>, have no right-hand operand. For such
4683 constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.</p>
4684
4685 <p>The <a href="#sqlite3_value">sqlite3_value</a> object returned in *V is a protected sqlite3_value
4686 and remains valid for the duration of the xBestIndex method call.
4687 When xBestIndex returns, the sqlite3_value object returned by
4688 sqlite3_vtab_rhs_value() is automatically deallocated.</p>
4689
4690 <p>The "_rhs_" in the name of this routine is an abbreviation for
4691 "Right-Hand Side".
4692 </p><hr><a name="sqlite3_wal_autocheckpoint"></a>
4693 <h2>Configure an auto-checkpoint</h2>
4694 </div>
4695 <blockquote><pre>
4696 int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
4697 </pre></blockquote>
4698 <p>
4699 The <a href="#sqlite3_wal_autocheckpoint">sqlite3_wal_autocheckpoint(D,N)</a> is a wrapper around
4700 <a href="#sqlite3_wal_hook">sqlite3_wal_hook()</a> that causes any database on <a href="#sqlite3">database connection</a> D
4701 to automatically <a href="wal.html#ckpt">checkpoint</a>
4702 after committing a transaction if there are N or
4703 more frames in the <a href="wal.html">write-ahead log</a> file. Passing zero or
4704 a negative value as the nFrame parameter disables automatic
4705 checkpoints entirely.</p>
4706
4707 <p>The callback registered by this function replaces any existing callback
4708 registered using <a href="#sqlite3_wal_hook">sqlite3_wal_hook()</a>. Likewise, registering a callback
4709 using <a href="#sqlite3_wal_hook">sqlite3_wal_hook()</a> disables the automatic checkpoint mechanism
4710 configured by this function.</p>
4711
4712 <p>The <a href="pragma.html#pragma_wal_autocheckpoint">wal_autocheckpoint pragma</a> can be used to invoke this interface
4713 from SQL.</p>
4714
4715 <p>Checkpoints initiated by this mechanism are
4716 <a href="#sqlite3_wal_checkpoint_v2">PASSIVE</a>.</p>
4717
4718 <p>Every new <a href="#sqlite3">database connection</a> defaults to having the auto-checkpoint
4719 enabled with a threshold of 1000 or <a href="compile.html#default_wal_autocheckpoint">SQLITE_DEFAULT_WAL_AUTOCHECKPOINT</a>
4720 pages. The use of this interface
4721 is only necessary if the default setting is found to be suboptimal
4722 for a particular application.
4723 </p><hr><a name="sqlite3_wal_checkpoint"></a>
4724 <h2>Checkpoint a database</h2>
4725 </div>
4726 <blockquote><pre>
4727 int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
4728 </pre></blockquote>
4729 <p>
4730 The sqlite3_wal_checkpoint(D,X) is equivalent to
4731 <a href="#sqlite3_wal_checkpoint_v2">sqlite3_wal_checkpoint_v2</a>(D,X,<a href="#SQLITE_CHECKPOINT_FULL">SQLITE_CHECKPOINT_PASSIVE</a>,0,0).</p>
4732
4733 <p>In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
4734 <a href="wal.html">write-ahead log</a> for database X on <a href="#sqlite3">database connection</a> D to be
4735 transferred into the database file and for the write-ahead log to
4736 be reset. See the <a href="wal.html#ckpt">checkpointing</a> documentation for addition
4737 information.</p>
4738
4739 <p>This interface used to be the only way to cause a checkpoint to
4740 occur. But then the newer and more powerful <a href="#sqlite3_wal_checkpoint_v2">sqlite3_wal_checkpoint_v2()</a>
4741 interface was added. This interface is retained for backwards
4742 compatibility and as a convenience for applications that need to manually
4743 start a callback but which do not need the full power (and corresponding
4744 complication) of <a href="#sqlite3_wal_checkpoint_v2">sqlite3_wal_checkpoint_v2()</a>.
4745 </p><hr><a name="sqlite3_wal_checkpoint_v2"></a>
4746 <h2>Checkpoint a database</h2>
4747 </div>
4748 <blockquote><pre>
4749 int sqlite3_wal_checkpoint_v2(
4750 sqlite3 *db, /* Database handle */
4751 const char *zDb, /* Name of attached database (or NULL) */
4752 int eMode, /* SQLITE_CHECKPOINT_* value */
4753 int *pnLog, /* OUT: Size of WAL log in frames */
4754 int *pnCkpt /* OUT: Total number of frames checkpointed */
4755 );
4756 </pre></blockquote>
4757 <p>
4758 The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
4759 operation on database X of <a href="#sqlite3">database connection</a> D in mode M. Status
4760 information is written back into integers pointed to by L and C.
4761 The M parameter must be a valid <a href="#SQLITE_CHECKPOINT_FULL">checkpoint mode</a>:</p>
4762
4763 <p><dl>
4764 <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
4765 Checkpoint as many frames as possible without waiting for any database
4766 readers or writers to finish, then sync the database file if all frames
4767 in the log were checkpointed. The <a href="#sqlite3_busy_handler">busy-handler callback</a>
4768 is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.
4769 On the other hand, passive mode might leave the checkpoint unfinished
4770 if there are concurrent readers or writers.</p>
4771
4772 <p><dt>SQLITE_CHECKPOINT_FULL<dd>
4773 This mode blocks (it invokes the
4774 <a href="#sqlite3_busy_handler">busy-handler callback</a>) until there is no
4775 database writer and all readers are reading from the most recent database
4776 snapshot. It then checkpoints all frames in the log file and syncs the
4777 database file. This mode blocks new database writers while it is pending,
4778 but new database readers are allowed to continue unimpeded.</p>
4779
4780 <p><dt>SQLITE_CHECKPOINT_RESTART<dd>
4781 This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
4782 that after checkpointing the log file it blocks (calls the
4783 <a href="#sqlite3_busy_handler">busy-handler callback</a>)
4784 until all readers are reading from the database file only. This ensures
4785 that the next writer will restart the log file from the beginning.
4786 Like SQLITE_CHECKPOINT_FULL, this mode blocks new
4787 database writer attempts while it is pending, but does not impede readers.</p>
4788
4789 <p><dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
4790 This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
4791 addition that it also truncates the log file to zero bytes just prior
4792 to a successful return.
4793 </dl></p>
4794
4795 <p>If pnLog is not NULL, then *pnLog is set to the total number of frames in
4796 the log file or to -1 if the checkpoint could not run because
4797 of an error or because the database is not in <a href="wal.html">WAL mode</a>. If pnCkpt is not
4798 NULL,then *pnCkpt is set to the total number of checkpointed frames in the
4799 log file (including any that were already checkpointed before the function
4800 was called) or to -1 if the checkpoint could not run due to an error or
4801 because the database is not in WAL mode. Note that upon successful
4802 completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
4803 truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.</p>
4804
4805 <p>All calls obtain an exclusive "checkpoint" lock on the database file. If
4806 any other process is running a checkpoint operation at the same time, the
4807 lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a
4808 busy-handler configured, it will not be invoked in this case.</p>
4809
4810 <p>The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the
4811 exclusive "writer" lock on the database file. If the writer lock cannot be
4812 obtained immediately, and a busy-handler is configured, it is invoked and
4813 the writer lock retried until either the busy-handler returns 0 or the lock
4814 is successfully obtained. The busy-handler is also invoked while waiting for
4815 database readers as described above. If the busy-handler returns 0 before
4816 the writer lock is obtained or while waiting for database readers, the
4817 checkpoint operation proceeds from that point in the same way as
4818 SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
4819 without blocking any further. SQLITE_BUSY is returned in this case.</p>
4820
4821 <p>If parameter zDb is NULL or points to a zero length string, then the
4822 specified operation is attempted on all WAL databases <a href="lang_attach.html">attached</a> to
4823 <a href="#sqlite3">database connection</a> db. In this case the
4824 values written to output parameters *pnLog and *pnCkpt are undefined. If
4825 an SQLITE_BUSY error is encountered when processing one or more of the
4826 attached WAL databases, the operation is still attempted on any remaining
4827 attached databases and SQLITE_BUSY is returned at the end. If any other
4828 error occurs while processing an attached database, processing is abandoned
4829 and the error code is returned to the caller immediately. If no error
4830 (SQLITE_BUSY or otherwise) is encountered while processing the attached
4831 databases, SQLITE_OK is returned.</p>
4832
4833 <p>If database zDb is the name of an attached database that is not in WAL
4834 mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
4835 zDb is not NULL (or a zero length string) and is not the name of any
4836 attached database, SQLITE_ERROR is returned to the caller.</p>
4837
4838 <p>Unless it returns SQLITE_MISUSE,
4839 the sqlite3_wal_checkpoint_v2() interface
4840 sets the error information that is queried by
4841 <a href="#sqlite3_errcode">sqlite3_errcode()</a> and <a href="#sqlite3_errcode">sqlite3_errmsg()</a>.</p>
4842
4843 <p>The <a href="pragma.html#pragma_wal_checkpoint">PRAGMA wal_checkpoint</a> command can be used to invoke this interface
4844 from SQL.
4845 </p><hr><a name="sqlite3_wal_hook"></a>
4846 <h2>Write-Ahead Log Commit Hook</h2>
4847 </div>
4848 <blockquote><pre>
4849 void *sqlite3_wal_hook(
4850 sqlite3*,
4851 int(*)(void *,sqlite3*,const char*,int),
4852 void*
4853 );
4854 </pre></blockquote>
4855 <p>
4856 The <a href="#sqlite3_wal_hook">sqlite3_wal_hook()</a> function is used to register a callback that
4857 is invoked each time data is committed to a database in wal mode.</p>
4858
4859 <p>The callback is invoked by SQLite after the commit has taken place and
4860 the associated write-lock on the database released, so the implementation
4861 may read, write or <a href="wal.html#ckpt">checkpoint</a> the database as required.</p>
4862
4863 <p>The first parameter passed to the callback function when it is invoked
4864 is a copy of the third parameter passed to sqlite3_wal_hook() when
4865 registering the callback. The second is a copy of the database handle.
4866 The third parameter is the name of the database that was written to -
4867 either "main" or the name of an <a href="lang_attach.html">ATTACH</a>-ed database. The fourth parameter
4868 is the number of pages currently in the write-ahead log file,
4869 including those that were just committed.</p>
4870
4871 <p>The callback function should normally return <a href="#SQLITE_ABORT">SQLITE_OK</a>. If an error
4872 code is returned, that error will propagate back up through the
4873 SQLite code base to cause the statement that provoked the callback
4874 to report an error, though the commit will have still occurred. If the
4875 callback returns <a href="#SQLITE_ABORT">SQLITE_ROW</a> or <a href="#SQLITE_ABORT">SQLITE_DONE</a>, or if it returns a value
4876 that does not correspond to any valid SQLite error code, the results
4877 are undefined.</p>
4878
4879 <p>A single database handle may have at most a single write-ahead log callback
4880 registered at one time. Calling <a href="#sqlite3_wal_hook">sqlite3_wal_hook()</a> replaces any
4881 previously registered write-ahead log callback. The return value is
4882 a copy of the third parameter from the previous call, if any, or 0.
4883 Note that the <a href="#sqlite3_wal_autocheckpoint">sqlite3_wal_autocheckpoint()</a> interface and the
4884 <a href="pragma.html#pragma_wal_autocheckpoint">wal_autocheckpoint pragma</a> both invoke <a href="#sqlite3_wal_hook">sqlite3_wal_hook()</a> and will
4885 overwrite any prior <a href="#sqlite3_wal_hook">sqlite3_wal_hook()</a> settings.
4886 </p><hr><a name="SQLITE_ABORT"></a>
4887 <h2>Result Codes</h2>
4888 </div>
4889 <blockquote><pre>
4890 #define SQLITE_OK 0 /* Successful result */
4891 /* beginning-of-error-codes */
4892 #define SQLITE_ERROR 1 /* Generic error */
4893 #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
4894 #define SQLITE_PERM 3 /* Access permission denied */
4895 #define SQLITE_ABORT 4 /* Callback routine requested an abort */
4896 #define SQLITE_BUSY 5 /* The database file is locked */
4897 #define SQLITE_LOCKED 6 /* A table in the database is locked */
4898 #define SQLITE_NOMEM 7 /* A malloc() failed */
4899 #define SQLITE_READONLY 8 /* Attempt to write a readonly database */
4900 #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
4901 #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
4902 #define SQLITE_CORRUPT 11 /* The database disk image is malformed */
4903 #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
4904 #define SQLITE_FULL 13 /* Insertion failed because database is full */
4905 #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
4906 #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
4907 #define SQLITE_EMPTY 16 /* Internal use only */
4908 #define SQLITE_SCHEMA 17 /* The database schema changed */
4909 #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
4910 #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
4911 #define SQLITE_MISMATCH 20 /* Data type mismatch */
4912 #define SQLITE_MISUSE 21 /* Library used incorrectly */
4913 #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
4914 #define SQLITE_AUTH 23 /* Authorization denied */
4915 #define SQLITE_FORMAT 24 /* Not used */
4916 #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
4917 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
4918 #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
4919 #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
4920 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
4921 #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
4922 /* end-of-error-codes */
4923 </pre></blockquote>
4924 <p>
4925 Many SQLite functions return an integer result code from the set shown
4926 here in order to indicate success or failure.</p>
4927
4928 <p>New error codes may be added in future versions of SQLite.</p>
4929
4930 <p>See also: <a href="#SQLITE_ABORT_ROLLBACK">extended result code definitions</a>
4931 </p><hr><a name="SQLITE_ABORT_ROLLBACK"></a>
4932 <h2>Extended Result Codes</h2>
4933 </div>
4934 <blockquote><pre>
4935 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1&lt;&lt;8))
4936 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2&lt;&lt;8))
4937 #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3&lt;&lt;8))
4938 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1&lt;&lt;8))
4939 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2&lt;&lt;8))
4940 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3&lt;&lt;8))
4941 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4&lt;&lt;8))
4942 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5&lt;&lt;8))
4943 #define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6&lt;&lt;8))
4944 #define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7&lt;&lt;8))
4945 #define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8&lt;&lt;8))
4946 #define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9&lt;&lt;8))
4947 #define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10&lt;&lt;8))
4948 #define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11&lt;&lt;8))
4949 #define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12&lt;&lt;8))
4950 #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13&lt;&lt;8))
4951 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14&lt;&lt;8))
4952 #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15&lt;&lt;8))
4953 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16&lt;&lt;8))
4954 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17&lt;&lt;8))
4955 #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18&lt;&lt;8))
4956 #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19&lt;&lt;8))
4957 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20&lt;&lt;8))
4958 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21&lt;&lt;8))
4959 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22&lt;&lt;8))
4960 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23&lt;&lt;8))
4961 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24&lt;&lt;8))
4962 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25&lt;&lt;8))
4963 #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26&lt;&lt;8))
4964 #define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27&lt;&lt;8))
4965 #define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28&lt;&lt;8))
4966 #define SQLITE_IOERR_BEGIN_ATOMIC (SQLITE_IOERR | (29&lt;&lt;8))
4967 #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30&lt;&lt;8))
4968 #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31&lt;&lt;8))
4969 #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32&lt;&lt;8))
4970 #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33&lt;&lt;8))
4971 #define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34&lt;&lt;8))
4972 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1&lt;&lt;8))
4973 #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2&lt;&lt;8))
4974 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1&lt;&lt;8))
4975 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2&lt;&lt;8))
4976 #define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3&lt;&lt;8))
4977 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1&lt;&lt;8))
4978 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2&lt;&lt;8))
4979 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3&lt;&lt;8))
4980 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4&lt;&lt;8))
4981 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5&lt;&lt;8)) /* Not Used */
4982 #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6&lt;&lt;8))
4983 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1&lt;&lt;8))
4984 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2&lt;&lt;8))
4985 #define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3&lt;&lt;8))
4986 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1&lt;&lt;8))
4987 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2&lt;&lt;8))
4988 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3&lt;&lt;8))
4989 #define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4&lt;&lt;8))
4990 #define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5&lt;&lt;8))
4991 #define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6&lt;&lt;8))
4992 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2&lt;&lt;8))
4993 #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1&lt;&lt;8))
4994 #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2&lt;&lt;8))
4995 #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3&lt;&lt;8))
4996 #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4&lt;&lt;8))
4997 #define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5&lt;&lt;8))
4998 #define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6&lt;&lt;8))
4999 #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7&lt;&lt;8))
5000 #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8&lt;&lt;8))
5001 #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9&lt;&lt;8))
5002 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10&lt;&lt;8))
5003 #define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11&lt;&lt;8))
5004 #define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12&lt;&lt;8))
5005 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1&lt;&lt;8))
5006 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2&lt;&lt;8))
5007 #define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3&lt;&lt;8))
5008 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1&lt;&lt;8))
5009 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1&lt;&lt;8))
5010 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1&lt;&lt;8))
5011 #define SQLITE_OK_SYMLINK (SQLITE_OK | (2&lt;&lt;8)) /* internal use only */
5012 </pre></blockquote>
5013 <p>
5014 In its default configuration, SQLite API routines return one of 30 integer
5015 <a href="rescode.html">result codes</a>. However, experience has shown that many of
5016 these result codes are too coarse-grained. They do not provide as
5017 much information about problems as programmers might like. In an effort to
5018 address this, newer versions of SQLite (version 3.3.8 2006-10-09
5019 and later) include
5020 support for additional result codes that provide more detailed information
5021 about errors. These <a href="rescode.html#extrc">extended result codes</a> are enabled or disabled
5022 on a per database connection basis using the
5023 <a href="#sqlite3_extended_result_codes">sqlite3_extended_result_codes()</a> API. Or, the extended code for
5024 the most recent error can be obtained using
5025 <a href="#sqlite3_errcode">sqlite3_extended_errcode()</a>.
5026 </p><hr><a name="SQLITE_ACCESS_EXISTS"></a>
5027 <h2>Flags for the xAccess VFS method</h2>
5028 </div>
5029 <blockquote><pre>
5030 #define SQLITE_ACCESS_EXISTS 0
5031 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
5032 #define SQLITE_ACCESS_READ 2 /* Unused */
5033 </pre></blockquote>
5034 <p>
5035 These integer constants can be used as the third parameter to
5036 the xAccess method of an <a href="#sqlite3_vfs">sqlite3_vfs</a> object. They determine
5037 what kind of permissions the xAccess method is looking for.
5038 With SQLITE_ACCESS_EXISTS, the xAccess method
5039 simply checks whether the file exists.
5040 With SQLITE_ACCESS_READWRITE, the xAccess method
5041 checks whether the named directory is both readable and writable
5042 (in other words, if files can be added, removed, and renamed within
5043 the directory).
5044 The SQLITE_ACCESS_READWRITE constant is currently used only by the
5045 <a href="pragma.html#pragma_temp_store_directory">temp_store_directory pragma</a>, though this could change in a future
5046 release of SQLite.
5047 With SQLITE_ACCESS_READ, the xAccess method
5048 checks whether the file is readable. The SQLITE_ACCESS_READ constant is
5049 currently unused, though it might be used in a future release of
5050 SQLite.
5051 </p><hr><a name="SQLITE_ALTER_TABLE"></a>
5052 <h2>Authorizer Action Codes</h2>
5053 </div>
5054 <blockquote><pre>
5055 /******************************************* 3rd ************ 4th ***********/
5056 #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
5057 #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
5058 #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
5059 #define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
5060 #define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
5061 #define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */
5062 #define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
5063 #define SQLITE_CREATE_VIEW 8 /* View Name NULL */
5064 #define SQLITE_DELETE 9 /* Table Name NULL */
5065 #define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
5066 #define SQLITE_DROP_TABLE 11 /* Table Name NULL */
5067 #define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
5068 #define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
5069 #define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
5070 #define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */
5071 #define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
5072 #define SQLITE_DROP_VIEW 17 /* View Name NULL */
5073 #define SQLITE_INSERT 18 /* Table Name NULL */
5074 #define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */
5075 #define SQLITE_READ 20 /* Table Name Column Name */
5076 #define SQLITE_SELECT 21 /* NULL NULL */
5077 #define SQLITE_TRANSACTION 22 /* Operation NULL */
5078 #define SQLITE_UPDATE 23 /* Table Name Column Name */
5079 #define SQLITE_ATTACH 24 /* Filename NULL */
5080 #define SQLITE_DETACH 25 /* Database Name NULL */
5081 #define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
5082 #define SQLITE_REINDEX 27 /* Index Name NULL */
5083 #define SQLITE_ANALYZE 28 /* Table Name NULL */
5084 #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
5085 #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
5086 #define SQLITE_FUNCTION 31 /* NULL Function Name */
5087 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
5088 #define SQLITE_COPY 0 /* No longer used */
5089 #define SQLITE_RECURSIVE 33 /* NULL NULL */
5090 </pre></blockquote>
5091 <p>
5092 The <a href="#sqlite3_set_authorizer">sqlite3_set_authorizer()</a> interface registers a callback function
5093 that is invoked to authorize certain SQL statement actions. The
5094 second parameter to the callback is an integer code that specifies
5095 what action is being authorized. These are the integer action codes that
5096 the authorizer callback may be passed.</p>
5097
5098 <p>These action code values signify what kind of operation is to be
5099 authorized. The 3rd and 4th parameters to the authorization
5100 callback function will be parameters or NULL depending on which of these
5101 codes is used as the second parameter. The 5th parameter to the
5102 authorizer callback is the name of the database ("main", "temp",
5103 etc.) if applicable. The 6th parameter to the authorizer callback
5104 is the name of the inner-most trigger or view that is responsible for
5105 the access attempt or NULL if this access attempt is directly from
5106 top-level SQL code.
5107 </p><hr><a name="SQLITE_ANY"></a>
5108 <h2>Text Encodings</h2>
5109 </div>
5110 <blockquote><pre>
5111 #define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
5112 #define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
5113 #define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */
5114 #define SQLITE_UTF16 4 /* Use native byte order */
5115 #define SQLITE_ANY 5 /* Deprecated */
5116 #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
5117 </pre></blockquote>
5118 <p>
5119 These constant define integer codes that represent the various
5120 text encodings supported by SQLite.
5121 </p><hr><a name="SQLITE_BLOB"></a>
5122 <h2>Fundamental Datatypes</h2>
5123 </div>
5124 <blockquote><pre>
5125 #define SQLITE_INTEGER 1
5126 #define SQLITE_FLOAT 2
5127 #define SQLITE_BLOB 4
5128 #define SQLITE_NULL 5
5129 #ifdef SQLITE_TEXT
5130 # undef SQLITE_TEXT
5131 #else
5132 # define SQLITE_TEXT 3
5133 #endif
5134 #define SQLITE3_TEXT 3
5135 </pre></blockquote>
5136 <p>
5137 Every value in SQLite has one of five fundamental datatypes:</p>
5138
5139 <p><ul>
5140 <li> 64-bit signed integer
5141 <li> 64-bit IEEE floating point number
5142 <li> string
5143 <li> BLOB
5144 <li> NULL
5145 </ul></p>
5146
5147 <p>These constants are codes for each of those types.</p>
5148
5149 <p>Note that the SQLITE_TEXT constant was also used in SQLite version 2
5150 for a completely different meaning. Software that links against both
5151 SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not
5152 SQLITE_TEXT.
5153 </p><hr><a name="SQLITE_CHECKPOINT_FULL"></a>
5154 <h2>Checkpoint Mode Values</h2>
5155 </div>
5156 <blockquote><pre>
5157 #define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
5158 #define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
5159 #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */
5160 #define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
5161 </pre></blockquote>
5162 <p>
5163 These constants define all valid values for the "checkpoint mode" passed
5164 as the third parameter to the <a href="#sqlite3_wal_checkpoint_v2">sqlite3_wal_checkpoint_v2()</a> interface.
5165 See the <a href="#sqlite3_wal_checkpoint_v2">sqlite3_wal_checkpoint_v2()</a> documentation for details on the
5166 meaning of each of these checkpoint modes.
5167 </p><hr><a name="SQLITE_CONFIG_COVERING_INDEX_SCAN"></a>
5168 <h2>Configuration Options</h2>
5169 </div>
5170 <blockquote><pre>
5171 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
5172 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
5173 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */
5174 #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
5175 #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
5176 #define SQLITE_CONFIG_SCRATCH 6 /* No longer used */
5177 #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
5178 #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
5179 #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
5180 #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
5181 #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
5182 /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
5183 #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
5184 #define SQLITE_CONFIG_PCACHE 14 /* no-op */
5185 #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
5186 #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
5187 #define SQLITE_CONFIG_URI 17 /* int */
5188 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
5189 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
5190 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
5191 #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
5192 #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
5193 #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
5194 #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
5195 #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
5196 #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
5197 #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
5198 #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
5199 #define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */
5200 #define SQLITE_CONFIG_ROWID_IN_VIEW 30 /* int* */
5201 </pre></blockquote>
5202 <p>
5203 These constants are the available integer configuration options that
5204 can be passed as the first argument to the <a href="#sqlite3_config">sqlite3_config()</a> interface.</p>
5205
5206 <p>Most of the configuration options for sqlite3_config()
5207 will only work if invoked prior to <a href="#sqlite3_initialize">sqlite3_initialize()</a> or after
5208 <a href="#sqlite3_initialize">sqlite3_shutdown()</a>. The few exceptions to this rule are called
5209 "anytime configuration options".
5210 Calling <a href="#sqlite3_config">sqlite3_config()</a> with a first argument that is not an
5211 anytime configuration option in between calls to <a href="#sqlite3_initialize">sqlite3_initialize()</a> and
5212 <a href="#sqlite3_initialize">sqlite3_shutdown()</a> is a no-op that returns SQLITE_MISUSE.</p>
5213
5214 <p>The set of anytime configuration options can change (by insertions
5215 and/or deletions) from one release of SQLite to the next.
5216 As of SQLite version 3.42.0, the complete set of anytime configuration
5217 options is:
5218 <ul>
5219 <li> SQLITE_CONFIG_LOG
5220 <li> SQLITE_CONFIG_PCACHE_HDRSZ
5221 </ul></p>
5222
5223 <p>New configuration options may be added in future releases of SQLite.
5224 Existing configuration options might be discontinued. Applications
5225 should check the return code from <a href="#sqlite3_config">sqlite3_config()</a> to make sure that
5226 the call worked. The <a href="#sqlite3_config">sqlite3_config()</a> interface will return a
5227 non-zero <a href="rescode.html">error code</a> if a discontinued or unsupported configuration option
5228 is invoked.</p>
5229
5230 <p><dl>
5231 <a name="sqliteconfigsinglethread"></a>
5232 <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
5233 <dd>There are no arguments to this option. This option sets the
5234 <a href="threadsafe.html">threading mode</a> to Single-thread. In other words, it disables
5235 all mutexing and puts SQLite into a mode where it can only be used
5236 by a single thread. If SQLite is compiled with
5237 the <a href="compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
5238 it is not possible to change the <a href="threadsafe.html">threading mode</a> from its default
5239 value of Single-thread and so <a href="#sqlite3_config">sqlite3_config()</a> will return
5240 <a href="#SQLITE_ABORT">SQLITE_ERROR</a> if called with the SQLITE_CONFIG_SINGLETHREAD
5241 configuration option.</dd></p>
5242
5243 <p><a name="sqliteconfigmultithread"></a>
5244 <dt>SQLITE_CONFIG_MULTITHREAD</dt>
5245 <dd>There are no arguments to this option. This option sets the
5246 <a href="threadsafe.html">threading mode</a> to Multi-thread. In other words, it disables
5247 mutexing on <a href="#sqlite3">database connection</a> and <a href="#sqlite3_stmt">prepared statement</a> objects.
5248 The application is responsible for serializing access to
5249 <a href="#sqlite3">database connections</a> and <a href="#sqlite3_stmt">prepared statements</a>. But other mutexes
5250 are enabled so that SQLite will be safe to use in a multi-threaded
5251 environment as long as no two threads attempt to use the same
5252 <a href="#sqlite3">database connection</a> at the same time. If SQLite is compiled with
5253 the <a href="compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
5254 it is not possible to set the Multi-thread <a href="threadsafe.html">threading mode</a> and
5255 <a href="#sqlite3_config">sqlite3_config()</a> will return <a href="#SQLITE_ABORT">SQLITE_ERROR</a> if called with the
5256 SQLITE_CONFIG_MULTITHREAD configuration option.</dd></p>
5257
5258 <p><a name="sqliteconfigserialized"></a>
5259 <dt>SQLITE_CONFIG_SERIALIZED</dt>
5260 <dd>There are no arguments to this option. This option sets the
5261 <a href="threadsafe.html">threading mode</a> to Serialized. In other words, this option enables
5262 all mutexes including the recursive
5263 mutexes on <a href="#sqlite3">database connection</a> and <a href="#sqlite3_stmt">prepared statement</a> objects.
5264 In this mode (which is the default when SQLite is compiled with
5265 <a href="compile.html#threadsafe">SQLITE_THREADSAFE=1</a>) the SQLite library will itself serialize access
5266 to <a href="#sqlite3">database connections</a> and <a href="#sqlite3_stmt">prepared statements</a> so that the
5267 application is free to use the same <a href="#sqlite3">database connection</a> or the
5268 same <a href="#sqlite3_stmt">prepared statement</a> in different threads at the same time.
5269 If SQLite is compiled with
5270 the <a href="compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
5271 it is not possible to set the Serialized <a href="threadsafe.html">threading mode</a> and
5272 <a href="#sqlite3_config">sqlite3_config()</a> will return <a href="#SQLITE_ABORT">SQLITE_ERROR</a> if called with the
5273 SQLITE_CONFIG_SERIALIZED configuration option.</dd></p>
5274
5275 <p><a name="sqliteconfigmalloc"></a>
5276 <dt>SQLITE_CONFIG_MALLOC</dt>
5277 <dd> The SQLITE_CONFIG_MALLOC option takes a single argument which is
5278 a pointer to an instance of the <a href="#sqlite3_mem_methods">sqlite3_mem_methods</a> structure.
5279 The argument specifies
5280 alternative low-level memory allocation routines to be used in place of
5281 the memory allocation routines built into SQLite. SQLite makes
5282 its own private copy of the content of the <a href="#sqlite3_mem_methods">sqlite3_mem_methods</a> structure
5283 before the <a href="#sqlite3_config">sqlite3_config()</a> call returns.</dd></p>
5284
5285 <p><a name="sqliteconfiggetmalloc"></a>
5286 <dt>SQLITE_CONFIG_GETMALLOC</dt>
5287 <dd> The SQLITE_CONFIG_GETMALLOC option takes a single argument which
5288 is a pointer to an instance of the <a href="#sqlite3_mem_methods">sqlite3_mem_methods</a> structure.
5289 The <a href="#sqlite3_mem_methods">sqlite3_mem_methods</a>
5290 structure is filled with the currently defined memory allocation routines.
5291 This option can be used to overload the default memory allocation
5292 routines with a wrapper that simulations memory allocation failure or
5293 tracks memory usage, for example. </dd></p>
5294
5295 <p><a name="sqliteconfigsmallmalloc"></a>
5296 <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>
5297 <dd> The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of
5298 type int, interpreted as a boolean, which if true provides a hint to
5299 SQLite that it should avoid large memory allocations if possible.
5300 SQLite will run faster if it is free to make large memory allocations,
5301 but some application might prefer to run slower in exchange for
5302 guarantees about memory fragmentation that are possible if large
5303 allocations are avoided. This hint is normally off.
5304 </dd></p>
5305
5306 <p><a name="sqliteconfigmemstatus"></a>
5307 <dt>SQLITE_CONFIG_MEMSTATUS</dt>
5308 <dd> The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
5309 interpreted as a boolean, which enables or disables the collection of
5310 memory allocation statistics. When memory allocation statistics are
5311 disabled, the following SQLite interfaces become non-operational:
5312 <ul>
5313 <li> <a href="#sqlite3_hard_heap_limit64">sqlite3_hard_heap_limit64()</a>
5314 <li> <a href="#sqlite3_memory_highwater">sqlite3_memory_used()</a>
5315 <li> <a href="#sqlite3_memory_highwater">sqlite3_memory_highwater()</a>
5316 <li> <a href="#sqlite3_hard_heap_limit64">sqlite3_soft_heap_limit64()</a>
5317 <li> <a href="#sqlite3_status">sqlite3_status64()</a>
5318 </ul>
5319 Memory allocation statistics are enabled by default unless SQLite is
5320 compiled with <a href="compile.html#default_memstatus">SQLITE_DEFAULT_MEMSTATUS</a>=0 in which case memory
5321 allocation statistics are disabled by default.
5322 </dd></p>
5323
5324 <p><a name="sqliteconfigscratch"></a>
5325 <dt>SQLITE_CONFIG_SCRATCH</dt>
5326 <dd> The SQLITE_CONFIG_SCRATCH option is no longer used.
5327 </dd></p>
5328
5329 <p><a name="sqliteconfigpagecache"></a>
5330 <dt>SQLITE_CONFIG_PAGECACHE</dt>
5331 <dd> The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
5332 that SQLite can use for the database page cache with the default page
5333 cache implementation.
5334 This configuration option is a no-op if an application-defined page
5335 cache implementation is loaded using the <a href="#sqliteconfigpcache2">SQLITE_CONFIG_PCACHE2</a>.
5336 There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
5337 8-byte aligned memory (pMem), the size of each page cache line (sz),
5338 and the number of cache lines (N).
5339 The sz argument should be the size of the largest database page
5340 (a power of two between 512 and 65536) plus some extra bytes for each
5341 page header. The number of extra bytes needed by the page header
5342 can be determined using <a href="#sqliteconfigpcachehdrsz">SQLITE_CONFIG_PCACHE_HDRSZ</a>.
5343 It is harmless, apart from the wasted memory,
5344 for the sz parameter to be larger than necessary. The pMem
5345 argument must be either a NULL pointer or a pointer to an 8-byte
5346 aligned block of memory of at least sz*N bytes, otherwise
5347 subsequent behavior is undefined.
5348 When pMem is not NULL, SQLite will strive to use the memory provided
5349 to satisfy page cache needs, falling back to <a href="#sqlite3_free">sqlite3_malloc()</a> if
5350 a page cache line is larger than sz bytes or if all of the pMem buffer
5351 is exhausted.
5352 If pMem is NULL and N is non-zero, then each database connection
5353 does an initial bulk allocation for page cache memory
5354 from <a href="#sqlite3_free">sqlite3_malloc()</a> sufficient for N cache lines if N is positive or
5355 of -1024*N bytes if N is negative, . If additional
5356 page cache memory is needed beyond what is provided by the initial
5357 allocation, then SQLite goes to <a href="#sqlite3_free">sqlite3_malloc()</a> separately for each
5358 additional cache line. </dd></p>
5359
5360 <p><a name="sqliteconfigheap"></a>
5361 <dt>SQLITE_CONFIG_HEAP</dt>
5362 <dd> The SQLITE_CONFIG_HEAP option specifies a static memory buffer
5363 that SQLite will use for all of its dynamic memory allocation needs
5364 beyond those provided for by <a href="#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>.
5365 The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
5366 with either <a href="compile.html#enable_memsys3">SQLITE_ENABLE_MEMSYS3</a> or <a href="compile.html#enable_memsys5">SQLITE_ENABLE_MEMSYS5</a> and returns
5367 <a href="#SQLITE_ABORT">SQLITE_ERROR</a> if invoked otherwise.
5368 There are three arguments to SQLITE_CONFIG_HEAP:
5369 An 8-byte aligned pointer to the memory,
5370 the number of bytes in the memory buffer, and the minimum allocation size.
5371 If the first pointer (the memory pointer) is NULL, then SQLite reverts
5372 to using its default memory allocator (the system malloc() implementation),
5373 undoing any prior invocation of <a href="#sqliteconfigmalloc">SQLITE_CONFIG_MALLOC</a>. If the
5374 memory pointer is not NULL then the alternative memory
5375 allocator is engaged to handle all of SQLites memory allocation needs.
5376 The first pointer (the memory pointer) must be aligned to an 8-byte
5377 boundary or subsequent behavior of SQLite will be undefined.
5378 The minimum allocation size is capped at 2**12. Reasonable values
5379 for the minimum allocation size are 2**5 through 2**8.</dd></p>
5380
5381 <p><a name="sqliteconfigmutex"></a>
5382 <dt>SQLITE_CONFIG_MUTEX</dt>
5383 <dd> The SQLITE_CONFIG_MUTEX option takes a single argument which is a
5384 pointer to an instance of the <a href="#sqlite3_mutex_methods">sqlite3_mutex_methods</a> structure.
5385 The argument specifies alternative low-level mutex routines to be used
5386 in place the mutex routines built into SQLite. SQLite makes a copy of
5387 the content of the <a href="#sqlite3_mutex_methods">sqlite3_mutex_methods</a> structure before the call to
5388 <a href="#sqlite3_config">sqlite3_config()</a> returns. If SQLite is compiled with
5389 the <a href="compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
5390 the entire mutexing subsystem is omitted from the build and hence calls to
5391 <a href="#sqlite3_config">sqlite3_config()</a> with the SQLITE_CONFIG_MUTEX configuration option will
5392 return <a href="#SQLITE_ABORT">SQLITE_ERROR</a>.</dd></p>
5393
5394 <p><a name="sqliteconfiggetmutex"></a>
5395 <dt>SQLITE_CONFIG_GETMUTEX</dt>
5396 <dd> The SQLITE_CONFIG_GETMUTEX option takes a single argument which
5397 is a pointer to an instance of the <a href="#sqlite3_mutex_methods">sqlite3_mutex_methods</a> structure. The
5398 <a href="#sqlite3_mutex_methods">sqlite3_mutex_methods</a>
5399 structure is filled with the currently defined mutex routines.
5400 This option can be used to overload the default mutex allocation
5401 routines with a wrapper used to track mutex usage for performance
5402 profiling or testing, for example. If SQLite is compiled with
5403 the <a href="compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
5404 the entire mutexing subsystem is omitted from the build and hence calls to
5405 <a href="#sqlite3_config">sqlite3_config()</a> with the SQLITE_CONFIG_GETMUTEX configuration option will
5406 return <a href="#SQLITE_ABORT">SQLITE_ERROR</a>.</dd></p>
5407
5408 <p><a name="sqliteconfiglookaside"></a>
5409 <dt>SQLITE_CONFIG_LOOKASIDE</dt>
5410 <dd> The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
5411 the default size of lookaside memory on each <a href="#sqlite3">database connection</a>.
5412 The first argument is the
5413 size of each lookaside buffer slot and the second is the number of
5414 slots allocated to each database connection. SQLITE_CONFIG_LOOKASIDE
5415 sets the <i>default</i> lookaside size. The <a href="#sqlitedbconfiglookaside">SQLITE_DBCONFIG_LOOKASIDE</a>
5416 option to <a href="#sqlite3_db_config">sqlite3_db_config()</a> can be used to change the lookaside
5417 configuration on individual connections. </dd></p>
5418
5419 <p><a name="sqliteconfigpcache2"></a>
5420 <dt>SQLITE_CONFIG_PCACHE2</dt>
5421 <dd> The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
5422 a pointer to an <a href="#sqlite3_pcache_methods2">sqlite3_pcache_methods2</a> object. This object specifies
5423 the interface to a custom page cache implementation.
5424 SQLite makes a copy of the <a href="#sqlite3_pcache_methods2">sqlite3_pcache_methods2</a> object.</dd></p>
5425
5426 <p><a name="sqliteconfiggetpcache2"></a>
5427 <dt>SQLITE_CONFIG_GETPCACHE2</dt>
5428 <dd> The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
5429 is a pointer to an <a href="#sqlite3_pcache_methods2">sqlite3_pcache_methods2</a> object. SQLite copies of
5430 the current page cache implementation into that object. </dd></p>
5431
5432 <p><a name="sqliteconfiglog"></a>
5433 <dt>SQLITE_CONFIG_LOG</dt>
5434 <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
5435 global <a href="errlog.html">error log</a>.
5436 (The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
5437 function with a call signature of void(*)(void*,int,const char*),
5438 and a pointer to void. If the function pointer is not NULL, it is
5439 invoked by <a href="#sqlite3_log">sqlite3_log()</a> to process each logging event. If the
5440 function pointer is NULL, the <a href="#sqlite3_log">sqlite3_log()</a> interface becomes a no-op.
5441 The void pointer that is the second argument to SQLITE_CONFIG_LOG is
5442 passed through as the first parameter to the application-defined logger
5443 function whenever that function is invoked. The second parameter to
5444 the logger function is a copy of the first parameter to the corresponding
5445 <a href="#sqlite3_log">sqlite3_log()</a> call and is intended to be a <a href="rescode.html">result code</a> or an
5446 <a href="rescode.html#extrc">extended result code</a>. The third parameter passed to the logger is
5447 log message after formatting via <a href="#sqlite3_mprintf">sqlite3_snprintf()</a>.
5448 The SQLite logging interface is not reentrant; the logger function
5449 supplied by the application must not invoke any SQLite interface.
5450 In a multi-threaded application, the application-defined logger
5451 function must be threadsafe. </dd></p>
5452
5453 <p><a name="sqliteconfiguri"></a>
5454 <dt>SQLITE_CONFIG_URI
5455 <dd>The SQLITE_CONFIG_URI option takes a single argument of type int.
5456 If non-zero, then URI handling is globally enabled. If the parameter is zero,
5457 then URI handling is globally disabled. If URI handling is globally
5458 enabled, all filenames passed to <a href="#sqlite3_open">sqlite3_open()</a>, <a href="#sqlite3_open">sqlite3_open_v2()</a>,
5459 <a href="#sqlite3_open">sqlite3_open16()</a> or
5460 specified as part of <a href="lang_attach.html">ATTACH</a> commands are interpreted as URIs, regardless
5461 of whether or not the <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_URI</a> flag is set when the database
5462 connection is opened. If it is globally disabled, filenames are
5463 only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
5464 database connection is opened. By default, URI handling is globally
5465 disabled. The default value may be changed by compiling with the
5466 <a href="compile.html#use_uri">SQLITE_USE_URI</a> symbol defined.</p>
5467
5468 <p><a name="sqliteconfigcoveringindexscan"></a>
5469 <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
5470 <dd>The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
5471 argument which is interpreted as a boolean in order to enable or disable
5472 the use of covering indices for full table scans in the query optimizer.
5473 The default setting is determined
5474 by the <a href="compile.html#allow_covering_index_scan">SQLITE_ALLOW_COVERING_INDEX_SCAN</a> compile-time option, or is "on"
5475 if that compile-time option is omitted.
5476 The ability to disable the use of covering indices for full table scans
5477 is because some incorrectly coded legacy applications might malfunction
5478 when the optimization is enabled. Providing the ability to
5479 disable the optimization allows the older, buggy application code to work
5480 without change even with newer versions of SQLite.</p>
5481
5482 <p><a name="sqliteconfigpcache"></a>
5483 <a name="sqliteconfiggetpcache"></a>
5484
5485 <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
5486 <dd> These options are obsolete and should not be used by new code.
5487 They are retained for backwards compatibility but are now no-ops.
5488 </dd></p>
5489
5490 <p><a name="sqliteconfigsqllog"></a>
5491
5492 <dt>SQLITE_CONFIG_SQLLOG
5493 <dd>This option is only available if sqlite is compiled with the
5494 <a href="compile.html#enable_sqllog">SQLITE_ENABLE_SQLLOG</a> pre-processor macro defined. The first argument should
5495 be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
5496 The second should be of type (void*). The callback is invoked by the library
5497 in three separate circumstances, identified by the value passed as the
5498 fourth parameter. If the fourth parameter is 0, then the database connection
5499 passed as the second argument has just been opened. The third argument
5500 points to a buffer containing the name of the main database file. If the
5501 fourth parameter is 1, then the SQL statement that the third parameter
5502 points to has just been executed. Or, if the fourth parameter is 2, then
5503 the connection being passed as the second parameter is being closed. The
5504 third parameter is passed NULL In this case. An example of using this
5505 configuration option can be seen in the "test_sqllog.c" source file in
5506 the canonical SQLite source tree.</dd></p>
5507
5508 <p><a name="sqliteconfigmmapsize"></a>
5509
5510 <dt>SQLITE_CONFIG_MMAP_SIZE
5511 <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
5512 that are the default mmap size limit (the default setting for
5513 <a href="pragma.html#pragma_mmap_size">PRAGMA mmap_size</a>) and the maximum allowed mmap size limit.
5514 The default setting can be overridden by each database connection using
5515 either the <a href="pragma.html#pragma_mmap_size">PRAGMA mmap_size</a> command, or by using the
5516 <a href="#sqlitefcntlmmapsize">SQLITE_FCNTL_MMAP_SIZE</a> file control. The maximum allowed mmap size
5517 will be silently truncated if necessary so that it does not exceed the
5518 compile-time maximum mmap size set by the
5519 <a href="compile.html#max_mmap_size">SQLITE_MAX_MMAP_SIZE</a> compile-time option.
5520 If either argument to this option is negative, then that argument is
5521 changed to its compile-time default.</p>
5522
5523 <p><a name="sqliteconfigwin32heapsize"></a>
5524
5525 <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
5526 <dd>The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
5527 compiled for Windows with the <a href="compile.html#win32_malloc">SQLITE_WIN32_MALLOC</a> pre-processor macro
5528 defined. SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
5529 that specifies the maximum size of the created heap.</p>
5530
5531 <p><a name="sqliteconfigpcachehdrsz"></a>
5532
5533 <dt>SQLITE_CONFIG_PCACHE_HDRSZ
5534 <dd>The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
5535 is a pointer to an integer and writes into that integer the number of extra
5536 bytes per page required for each page in <a href="#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>.
5537 The amount of extra space required can change depending on the compiler,
5538 target platform, and SQLite version.</p>
5539
5540 <p><a name="sqliteconfigpmasz"></a>
5541
5542 <dt>SQLITE_CONFIG_PMASZ
5543 <dd>The SQLITE_CONFIG_PMASZ option takes a single parameter which
5544 is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
5545 sorter to that integer. The default minimum PMA Size is set by the
5546 <a href="compile.html#sorter_pmasz">SQLITE_SORTER_PMASZ</a> compile-time option. New threads are launched
5547 to help with sort operations when multithreaded sorting
5548 is enabled (using the <a href="pragma.html#pragma_threads">PRAGMA threads</a> command) and the amount of content
5549 to be sorted exceeds the page size times the minimum of the
5550 <a href="pragma.html#pragma_cache_size">PRAGMA cache_size</a> setting and this value.</p>
5551
5552 <p><a name="sqliteconfigstmtjrnlspill"></a>
5553
5554 <dt>SQLITE_CONFIG_STMTJRNL_SPILL
5555 <dd>The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which
5556 becomes the <a href="tempfiles.html#stmtjrnl">statement journal</a> spill-to-disk threshold.
5557 <a href="tempfiles.html#stmtjrnl">Statement journals</a> are held in memory until their size (in bytes)
5558 exceeds this threshold, at which point they are written to disk.
5559 Or if the threshold is -1, statement journals are always held
5560 exclusively in memory.
5561 Since many statement journals never become large, setting the spill
5562 threshold to a value such as 64KiB can greatly reduce the amount of
5563 I/O required to support statement rollback.
5564 The default value for this setting is controlled by the
5565 <a href="compile.html#stmtjrnl_spill">SQLITE_STMTJRNL_SPILL</a> compile-time option.</p>
5566
5567 <p><a name="sqliteconfigsorterrefsize"></a>
5568
5569 <dt>SQLITE_CONFIG_SORTERREF_SIZE
5570 <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
5571 of type (int) - the new value of the sorter-reference size threshold.
5572 Usually, when SQLite uses an external sort to order records according
5573 to an ORDER BY clause, all fields required by the caller are present in the
5574 sorted records. However, if SQLite determines based on the declared type
5575 of a table column that its values are likely to be very large - larger
5576 than the configured sorter-reference size threshold - then a reference
5577 is stored in each sorted record and the required column values loaded
5578 from the database as records are returned in sorted order. The default
5579 value for this option is to never use this optimization. Specifying a
5580 negative value for this option restores the default behavior.
5581 This option is only available if SQLite is compiled with the
5582 <a href="compile.html#enable_sorter_references">SQLITE_ENABLE_SORTER_REFERENCES</a> compile-time option.</p>
5583
5584 <p><a name="sqliteconfigmemdbmaxsize"></a>
5585
5586 <dt>SQLITE_CONFIG_MEMDB_MAXSIZE
5587 <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter
5588 <a href="#sqlite3_int64">sqlite3_int64</a> parameter which is the default maximum size for an in-memory
5589 database created using <a href="#sqlite3_deserialize">sqlite3_deserialize()</a>. This default maximum
5590 size can be adjusted up or down for individual databases using the
5591 <a href="#sqlitefcntlsizelimit">SQLITE_FCNTL_SIZE_LIMIT</a> <a href="#sqlite3_file_control">file-control</a>. If this
5592 configuration setting is never used, then the default maximum is determined
5593 by the <a href="compile.html#memdb_default_maxsize">SQLITE_MEMDB_DEFAULT_MAXSIZE</a> compile-time option. If that
5594 compile-time option is not set, then the default maximum is 1073741824.</p>
5595
5596 <p><a name="sqliteconfigrowidinview"></a>
5597
5598 <dt>SQLITE_CONFIG_ROWID_IN_VIEW
5599 <dd>The SQLITE_CONFIG_ROWID_IN_VIEW option enables or disables the ability
5600 for VIEWs to have a ROWID. The capability can only be enabled if SQLite is
5601 compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case the capability
5602 defaults to on. This configuration option queries the current setting or
5603 changes the setting to off or on. The argument is a pointer to an integer.
5604 If that integer initially holds a value of 1, then the ability for VIEWs to
5605 have ROWIDs is activated. If the integer initially holds zero, then the
5606 ability is deactivated. Any other initial value for the integer leaves the
5607 setting unchanged. After changes, if any, the integer is written with
5608 a 1 or 0, if the ability for VIEWs to have ROWIDs is on or off. If SQLite
5609 is compiled without -DSQLITE_ALLOW_ROWID_IN_VIEW (which is the usual and
5610 recommended case) then the integer is always filled with zero, regardless
5611 if its initial value.
5612 </dl>
5613 </p><hr><a name="SQLITE_DBCONFIG_DEFENSIVE"></a>
5614 <h2>Database Connection Configuration Options</h2>
5615 </div>
5616 <blockquote><pre>
5617 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
5618 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
5619 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
5620 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
5621 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
5622 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
5623 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
5624 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
5625 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
5626 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
5627 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
5628 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
5629 #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
5630 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
5631 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
5632 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
5633 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
5634 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
5635 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
5636 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
5637 #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
5638 </pre></blockquote>
5639 <p>
5640 These constants are the available integer configuration options that
5641 can be passed as the second argument to the <a href="#sqlite3_db_config">sqlite3_db_config()</a> interface.</p>
5642
5643 <p>New configuration options may be added in future releases of SQLite.
5644 Existing configuration options might be discontinued. Applications
5645 should check the return code from <a href="#sqlite3_db_config">sqlite3_db_config()</a> to make sure that
5646 the call worked. The <a href="#sqlite3_db_config">sqlite3_db_config()</a> interface will return a
5647 non-zero <a href="rescode.html">error code</a> if a discontinued or unsupported configuration option
5648 is invoked.</p>
5649
5650 <p><dl>
5651 <a name="sqlitedbconfiglookaside"></a>
5652
5653 <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
5654 <dd> This option takes three additional arguments that determine the
5655 <a href="malloc.html#lookaside">lookaside memory allocator</a> configuration for the <a href="#sqlite3">database connection</a>.
5656 The first argument (the third parameter to <a href="#sqlite3_db_config">sqlite3_db_config()</a> is a
5657 pointer to a memory buffer to use for lookaside memory.
5658 The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
5659 may be NULL in which case SQLite will allocate the
5660 lookaside buffer itself using <a href="#sqlite3_free">sqlite3_malloc()</a>. The second argument is the
5661 size of each lookaside buffer slot. The third argument is the number of
5662 slots. The size of the buffer in the first argument must be greater than
5663 or equal to the product of the second and third arguments. The buffer
5664 must be aligned to an 8-byte boundary. If the second argument to
5665 SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
5666 rounded down to the next smaller multiple of 8. The lookaside memory
5667 configuration for a database connection can only be changed when that
5668 connection is not currently using lookaside memory, or in other words
5669 when the "current value" returned by
5670 <a href="#sqlite3_db_status">sqlite3_db_status</a>(D,<a href="#sqlitedbstatuslookasideused">SQLITE_DBSTATUS_LOOKASIDE_USED</a>,...) is zero.
5671 Any attempt to change the lookaside memory configuration when lookaside
5672 memory is in use leaves the configuration unchanged and returns
5673 <a href="#SQLITE_ABORT">SQLITE_BUSY</a>.</dd></p>
5674
5675 <p><a name="sqlitedbconfigenablefkey"></a>
5676
5677 <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
5678 <dd> This option is used to enable or disable the enforcement of
5679 <a href="foreignkeys.html">foreign key constraints</a>. There should be two additional arguments.
5680 The first argument is an integer which is 0 to disable FK enforcement,
5681 positive to enable FK enforcement or negative to leave FK enforcement
5682 unchanged. The second parameter is a pointer to an integer into which
5683 is written 0 or 1 to indicate whether FK enforcement is off or on
5684 following this call. The second parameter may be a NULL pointer, in
5685 which case the FK enforcement setting is not reported back. </dd></p>
5686
5687 <p><a name="sqlitedbconfigenabletrigger"></a>
5688
5689 <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
5690 <dd> This option is used to enable or disable <a href="lang_createtrigger.html">triggers</a>.
5691 There should be two additional arguments.
5692 The first argument is an integer which is 0 to disable triggers,
5693 positive to enable triggers or negative to leave the setting unchanged.
5694 The second parameter is a pointer to an integer into which
5695 is written 0 or 1 to indicate whether triggers are disabled or enabled
5696 following this call. The second parameter may be a NULL pointer, in
5697 which case the trigger setting is not reported back.</p>
5698
5699 <p><p>Originally this option disabled all triggers. However, since
5700 SQLite version 3.35.0, TEMP triggers are still allowed even if
5701 this option is off. So, in other words, this option now only disables
5702 triggers in the main database schema or in the schemas of ATTACH-ed
5703 databases. </dd></p>
5704
5705 <p><a name="sqlitedbconfigenableview"></a>
5706
5707 <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
5708 <dd> This option is used to enable or disable <a href="lang_createview.html">views</a>.
5709 There should be two additional arguments.
5710 The first argument is an integer which is 0 to disable views,
5711 positive to enable views or negative to leave the setting unchanged.
5712 The second parameter is a pointer to an integer into which
5713 is written 0 or 1 to indicate whether views are disabled or enabled
5714 following this call. The second parameter may be a NULL pointer, in
5715 which case the view setting is not reported back.</p>
5716
5717 <p><p>Originally this option disabled all views. However, since
5718 SQLite version 3.35.0, TEMP views are still allowed even if
5719 this option is off. So, in other words, this option now only disables
5720 views in the main database schema or in the schemas of ATTACH-ed
5721 databases. </dd></p>
5722
5723 <p><a name="sqlitedbconfigenablefts3tokenizer"></a>
5724
5725 <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
5726 <dd> This option is used to enable or disable the
5727 <a href="fts3.html#f3tknzr">fts3_tokenizer()</a> function which is part of the
5728 <a href="fts3.html">FTS3</a> full-text search engine extension.
5729 There should be two additional arguments.
5730 The first argument is an integer which is 0 to disable fts3_tokenizer() or
5731 positive to enable fts3_tokenizer() or negative to leave the setting
5732 unchanged.
5733 The second parameter is a pointer to an integer into which
5734 is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
5735 following this call. The second parameter may be a NULL pointer, in
5736 which case the new setting is not reported back. </dd></p>
5737
5738 <p><a name="sqlitedbconfigenableloadextension"></a>
5739
5740 <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
5741 <dd> This option is used to enable or disable the <a href="#sqlite3_load_extension">sqlite3_load_extension()</a>
5742 interface independently of the <a href="lang_corefunc.html#load_extension">load_extension()</a> SQL function.
5743 The <a href="#sqlite3_enable_load_extension">sqlite3_enable_load_extension()</a> API enables or disables both the
5744 C-API <a href="#sqlite3_load_extension">sqlite3_load_extension()</a> and the SQL function <a href="lang_corefunc.html#load_extension">load_extension()</a>.
5745 There should be two additional arguments.
5746 When the first argument to this interface is 1, then only the C-API is
5747 enabled and the SQL function remains disabled. If the first argument to
5748 this interface is 0, then both the C-API and the SQL function are disabled.
5749 If the first argument is -1, then no changes are made to state of either the
5750 C-API or the SQL function.
5751 The second parameter is a pointer to an integer into which
5752 is written 0 or 1 to indicate whether <a href="#sqlite3_load_extension">sqlite3_load_extension()</a> interface
5753 is disabled or enabled following this call. The second parameter may
5754 be a NULL pointer, in which case the new setting is not reported back.
5755 </dd></p>
5756
5757 <p><a name="sqlitedbconfigmaindbname"></a>
5758 <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
5759 <dd> This option is used to change the name of the "main" database
5760 schema. The sole argument is a pointer to a constant UTF8 string
5761 which will become the new schema name in place of "main". SQLite
5762 does not make a copy of the new main schema name string, so the application
5763 must ensure that the argument passed into this DBCONFIG option is unchanged
5764 until after the database connection closes.
5765 </dd></p>
5766
5767 <p><a name="sqlitedbconfignockptonclose"></a>
5768
5769 <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
5770 <dd> Usually, when a database in wal mode is closed or detached from a
5771 database handle, SQLite checks if this will mean that there are now no
5772 connections at all to the database. If so, it performs a checkpoint
5773 operation before closing the connection. This option may be used to
5774 override this behavior. The first parameter passed to this operation
5775 is an integer - positive to disable checkpoints-on-close, or zero (the
5776 default) to enable them, and negative to leave the setting unchanged.
5777 The second parameter is a pointer to an integer
5778 into which is written 0 or 1 to indicate whether checkpoints-on-close
5779 have been disabled - 0 if they are not disabled, 1 if they are.
5780 </dd></p>
5781
5782 <p><a name="sqlitedbconfigenableqpsg"></a>
5783 <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
5784 <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
5785 the <a href="queryplanner-ng.html#qpstab">query planner stability guarantee</a> (QPSG). When the QPSG is active,
5786 a single SQL query statement will always use the same algorithm regardless
5787 of values of <a href="lang_expr.html#varparam">bound parameters</a>. The QPSG disables some query optimizations
5788 that look at the values of bound parameters, which can make some queries
5789 slower. But the QPSG has the advantage of more predictable behavior. With
5790 the QPSG active, SQLite will always use the same query plan in the field as
5791 was used during testing in the lab.
5792 The first argument to this setting is an integer which is 0 to disable
5793 the QPSG, positive to enable QPSG, or negative to leave the setting
5794 unchanged. The second parameter is a pointer to an integer into which
5795 is written 0 or 1 to indicate whether the QPSG is disabled or enabled
5796 following this call.
5797 </dd></p>
5798
5799 <p><a name="sqlitedbconfigtriggereqp"></a>
5800 <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
5801 <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
5802 include output for any operations performed by trigger programs. This
5803 option is used to set or clear (the default) a flag that governs this
5804 behavior. The first parameter passed to this operation is an integer -
5805 positive to enable output for trigger programs, or zero to disable it,
5806 or negative to leave the setting unchanged.
5807 The second parameter is a pointer to an integer into which is written
5808 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
5809 it is not disabled, 1 if it is.
5810 </dd></p>
5811
5812 <p><a name="sqlitedbconfigresetdatabase"></a>
5813 <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
5814 <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
5815 <a href="lang_vacuum.html">VACUUM</a> in order to reset a database back to an empty database
5816 with no schema and no content. The following process works even for
5817 a badly corrupted database file:
5818 <ol>
5819 <li> If the database connection is newly opened, make sure it has read the
5820 database schema by preparing then discarding some query against the
5821 database, or calling sqlite3_table_column_metadata(), ignoring any
5822 errors. This step is only necessary if the application desires to keep
5823 the database in WAL mode after the reset if it was in WAL mode before
5824 the reset.
5825 <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
5826 <li> <a href="#sqlite3_exec">sqlite3_exec</a>(db, "<a href="lang_vacuum.html">VACUUM</a>", 0, 0, 0);
5827 <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
5828 </ol>
5829 Because resetting a database is destructive and irreversible, the
5830 process requires the use of this obscure API and multiple steps to
5831 help ensure that it does not happen by accident. Because this
5832 feature must be capable of resetting corrupt databases, and
5833 shutting down virtual tables may require access to that corrupt
5834 storage, the library must abandon any installed virtual tables
5835 without calling their xDestroy() methods.</p>
5836
5837 <p><a name="sqlitedbconfigdefensive"></a>
5838 <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>
5839 <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the
5840 "defensive" flag for a database connection. When the defensive
5841 flag is enabled, language features that allow ordinary SQL to
5842 deliberately corrupt the database file are disabled. The disabled
5843 features include but are not limited to the following:
5844 <ul>
5845 <li> The <a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=ON</a> statement.
5846 <li> The <a href="pragma.html#pragma_journal_mode">PRAGMA journal_mode=OFF</a> statement.
5847 <li> The <a href="pragma.html#pragma_schema_version">PRAGMA schema_version=N</a> statement.
5848 <li> Writes to the <a href="dbpage.html">sqlite_dbpage</a> virtual table.
5849 <li> Direct writes to <a href="vtab.html#xshadowname">shadow tables</a>.
5850 </ul>
5851 </dd></p>
5852
5853 <p><a name="sqlitedbconfigwritableschema"></a>
5854 <dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt>
5855 <dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the
5856 "writable_schema" flag. This has the same effect and is logically equivalent
5857 to setting <a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=ON</a> or <a href="pragma.html#pragma_writable_schema">PRAGMA writable_schema=OFF</a>.
5858 The first argument to this setting is an integer which is 0 to disable
5859 the writable_schema, positive to enable writable_schema, or negative to
5860 leave the setting unchanged. The second parameter is a pointer to an
5861 integer into which is written 0 or 1 to indicate whether the writable_schema
5862 is enabled or disabled following this call.
5863 </dd></p>
5864
5865 <p><a name="sqlitedbconfiglegacyaltertable"></a>
5866
5867 <dt>SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</dt>
5868 <dd>The SQLITE_DBCONFIG_LEGACY_ALTER_TABLE option activates or deactivates
5869 the legacy behavior of the <a href="lang_altertable.html#altertabrename">ALTER TABLE RENAME</a> command such it
5870 behaves as it did prior to <a href="releaselog/3_24_0.html">version 3.24.0</a> (2018-06-04). See the
5871 "Compatibility Notice" on the <a href="lang_altertable.html#altertabrename">ALTER TABLE RENAME documentation</a> for
5872 additional information. This feature can also be turned on and off
5873 using the <a href="pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table</a> statement.
5874 </dd></p>
5875
5876 <p><a name="sqlitedbconfigdqsdml"></a>
5877
5878 <dt>SQLITE_DBCONFIG_DQS_DML</dt>
5879 <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
5880 the legacy <a href="quirks.html#dblquote">double-quoted string literal</a> misfeature for DML statements
5881 only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
5882 default value of this setting is determined by the <a href="compile.html#dqs">-DSQLITE_DQS</a>
5883 compile-time option.
5884 </dd></p>
5885
5886 <p><a name="sqlitedbconfigdqsddl"></a>
5887
5888 <dt>SQLITE_DBCONFIG_DQS_DDL</dt>
5889 <dd>The SQLITE_DBCONFIG_DQS option activates or deactivates
5890 the legacy <a href="quirks.html#dblquote">double-quoted string literal</a> misfeature for DDL statements,
5891 such as CREATE TABLE and CREATE INDEX. The
5892 default value of this setting is determined by the <a href="compile.html#dqs">-DSQLITE_DQS</a>
5893 compile-time option.
5894 </dd></p>
5895
5896 <p><a name="sqlitedbconfigtrustedschema"></a>
5897
5898 <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</dt>
5899 <dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to
5900 assume that database schemas are untainted by malicious content.
5901 When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite
5902 takes additional defensive steps to protect the application from harm
5903 including:
5904 <ul>
5905 <li> Prohibit the use of SQL functions inside triggers, views,
5906 CHECK constraints, DEFAULT clauses, expression indexes,
5907 partial indexes, or generated columns
5908 unless those functions are tagged with <a href="#sqliteinnocuous">SQLITE_INNOCUOUS</a>.
5909 <li> Prohibit the use of virtual tables inside of triggers or views
5910 unless those virtual tables are tagged with <a href="#sqlitevtabinnocuous">SQLITE_VTAB_INNOCUOUS</a>.
5911 </ul>
5912 This setting defaults to "on" for legacy compatibility, however
5913 all applications are advised to turn it off if possible. This setting
5914 can also be controlled using the <a href="pragma.html#pragma_trusted_schema">PRAGMA trusted_schema</a> statement.
5915 </dd></p>
5916
5917 <p><a name="sqlitedbconfiglegacyfileformat"></a>
5918
5919 <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</dt>
5920 <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
5921 the legacy file format flag. When activated, this flag causes all newly
5922 created database file to have a schema format version number (the 4-byte
5923 integer found at offset 44 into the database header) of 1. This in turn
5924 means that the resulting database file will be readable and writable by
5925 any SQLite version back to 3.0.0 (2004-06-18). Without this setting,
5926 newly created databases are generally not understandable by SQLite versions
5927 prior to 3.3.0 (2006-01-11). As these words are written, there
5928 is now scarcely any need to generate database files that are compatible
5929 all the way back to version 3.0.0, and so this setting is of little
5930 practical use, but is provided so that SQLite can continue to claim the
5931 ability to generate new database files that are compatible with version
5932 3.0.0.
5933 <p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on,
5934 the <a href="lang_vacuum.html">VACUUM</a> command will fail with an obscure error when attempting to
5935 process a table with generated columns and a descending index. This is
5936 not considered a bug since SQLite versions 3.3.0 and earlier do not support
5937 either generated columns or descending indexes.
5938 </dd></p>
5939
5940 <p><a name="sqlitedbconfigstmtscanstatus"></a>
5941
5942 <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</dt>
5943 <dd>The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in
5944 SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
5945 a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
5946 statistics. For statistics to be collected, the flag must be set on
5947 the database handle both when the SQL statement is prepared and when it
5948 is stepped. The flag is set (collection of statistics is enabled)
5949 by default. This option takes two arguments: an integer and a pointer to
5950 an integer.. The first argument is 1, 0, or -1 to enable, disable, or
5951 leave unchanged the statement scanstatus option. If the second argument
5952 is not NULL, then the value of the statement scanstatus setting after
5953 processing the first argument is written into the integer that the second
5954 argument points to.
5955 </dd></p>
5956
5957 <p><a name="sqlitedbconfigreversescanorder"></a>
5958
5959 <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
5960 <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
5961 in which tables and indexes are scanned so that the scans start at the end
5962 and work toward the beginning rather than starting at the beginning and
5963 working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
5964 same as setting <a href="pragma.html#pragma_reverse_unordered_selects">PRAGMA reverse_unordered_selects</a>. This option takes
5965 two arguments which are an integer and a pointer to an integer. The first
5966 argument is 1, 0, or -1 to enable, disable, or leave unchanged the
5967 reverse scan order flag, respectively. If the second argument is not NULL,
5968 then 0 or 1 is written into the integer that the second argument points to
5969 depending on if the reverse scan order flag is set after processing the
5970 first argument.
5971 </dd></p>
5972
5973 <p></dl>
5974 </p><hr><a name="SQLITE_DENY"></a>
5975 <h2>Authorizer Return Codes</h2>
5976 </div>
5977 <blockquote><pre>
5978 #define SQLITE_DENY 1 /* Abort the SQL statement with an error */
5979 #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
5980 </pre></blockquote>
5981 <p>
5982 The <a href="#sqlite3_set_authorizer">authorizer callback function</a> must
5983 return either <a href="#SQLITE_ABORT">SQLITE_OK</a> or one of these two constants in order
5984 to signal SQLite whether or not the action is permitted. See the
5985 <a href="#sqlite3_set_authorizer">authorizer documentation</a> for additional
5986 information.</p>
5987
5988 <p>Note that SQLITE_IGNORE is also used as a <a href="#SQLITE_FAIL">conflict resolution mode</a>
5989 returned from the <a href="#sqlite3_vtab_on_conflict">sqlite3_vtab_on_conflict()</a> interface.
5990 </p><hr><a name="SQLITE_DESERIALIZE_FREEONCLOSE"></a>
5991 <h2>Flags for sqlite3_deserialize()</h2>
5992 </div>
5993 <blockquote><pre>
5994 #define SQLITE_DESERIALIZE_FREEONCLOSE 1 /* Call sqlite3_free() on close */
5995 #define SQLITE_DESERIALIZE_RESIZEABLE 2 /* Resize using sqlite3_realloc64() */
5996 #define SQLITE_DESERIALIZE_READONLY 4 /* Database is read-only */
5997 </pre></blockquote>
5998 <p>
5999 The following are allowed values for 6th argument (the F argument) to
6000 the <a href="#sqlite3_deserialize">sqlite3_deserialize(D,S,P,N,M,F)</a> interface.</p>
6001
6002 <p>The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization
6003 in the P argument is held in memory obtained from <a href="#sqlite3_free">sqlite3_malloc64()</a>
6004 and that SQLite should take ownership of this memory and automatically
6005 free it when it has finished using it. Without this flag, the caller
6006 is responsible for freeing any dynamically allocated memory.</p>
6007
6008 <p>The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to
6009 grow the size of the database using calls to <a href="#sqlite3_free">sqlite3_realloc64()</a>. This
6010 flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used.
6011 Without this flag, the deserialized database cannot increase in size beyond
6012 the number of bytes specified by the M parameter.</p>
6013
6014 <p>The SQLITE_DESERIALIZE_READONLY flag means that the deserialized database
6015 should be treated as read-only.
6016 </p><hr><a name="SQLITE_DETERMINISTIC"></a>
6017 <h2>Function Flags</h2>
6018 </div>
6019 <blockquote><pre>
6020 #define SQLITE_DETERMINISTIC 0x000000800
6021 #define SQLITE_DIRECTONLY 0x000080000
6022 #define SQLITE_SUBTYPE 0x000100000
6023 #define SQLITE_INNOCUOUS 0x000200000
6024 #define SQLITE_RESULT_SUBTYPE 0x001000000
6025 </pre></blockquote>
6026 <p>
6027 These constants may be ORed together with the
6028 <a href="#SQLITE_ANY">preferred text encoding</a> as the fourth argument
6029 to <a href="#sqlite3_create_function">sqlite3_create_function()</a>, <a href="#sqlite3_create_function">sqlite3_create_function16()</a>, or
6030 <a href="#sqlite3_create_function">sqlite3_create_function_v2()</a>.</p>
6031
6032 <p><dl>
6033 <a name="sqlitedeterministic"></a>
6034 <dt>SQLITE_DETERMINISTIC</dt><dd>
6035 The SQLITE_DETERMINISTIC flag means that the new function always gives
6036 the same output when the input parameters are the same.
6037 The <a href="lang_corefunc.html#abs">abs() function</a> is deterministic, for example, but
6038 <a href="lang_corefunc.html#randomblob">randomblob()</a> is not. Functions must
6039 be deterministic in order to be used in certain contexts such as
6040 with the WHERE clause of <a href="partialindex.html">partial indexes</a> or in <a href="gencol.html">generated columns</a>.
6041 SQLite might also optimize deterministic functions by factoring them
6042 out of inner loops.
6043 </dd></p>
6044
6045 <p><a name="sqlitedirectonly"></a>
6046 <dt>SQLITE_DIRECTONLY</dt><dd>
6047 The SQLITE_DIRECTONLY flag means that the function may only be invoked
6048 from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in
6049 schema structures such as <a href="lang_createtable.html#ckconst">CHECK constraints</a>, <a href="lang_createtable.html#dfltval">DEFAULT clauses</a>,
6050 <a href="expridx.html">expression indexes</a>, <a href="partialindex.html">partial indexes</a>, or <a href="gencol.html">generated columns</a>.
6051 <p>
6052 The SQLITE_DIRECTONLY flag is recommended for any
6053 <a href="appfunc.html">application-defined SQL function</a>
6054 that has side-effects or that could potentially leak sensitive information.
6055 This will prevent attacks in which an application is tricked
6056 into using a database file that has had its schema surreptitiously
6057 modified to invoke the application-defined function in ways that are
6058 harmful.
6059 <p>
6060 Some people say it is good practice to set SQLITE_DIRECTONLY on all
6061 <a href="appfunc.html">application-defined SQL functions</a>, regardless of whether or not they
6062 are security sensitive, as doing so prevents those functions from being used
6063 inside of the database schema, and thus ensures that the database
6064 can be inspected and modified using generic tools (such as the <a href="cli.html">CLI</a>)
6065 that do not have access to the application-defined functions.
6066 </dd></p>
6067
6068 <p><a name="sqliteinnocuous"></a>
6069 <dt>SQLITE_INNOCUOUS</dt><dd>
6070 The SQLITE_INNOCUOUS flag means that the function is unlikely
6071 to cause problems even if misused. An innocuous function should have
6072 no side effects and should not depend on any values other than its
6073 input parameters. The <a href="lang_corefunc.html#abs">abs() function</a> is an example of an
6074 innocuous function.
6075 The <a href="lang_corefunc.html#load_extension">load_extension() SQL function</a> is not innocuous because of its
6076 side effects.
6077 <p> SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not
6078 exactly the same. The <a href="lang_corefunc.html#random">random() function</a> is an example of a
6079 function that is innocuous but not deterministic.
6080 <p>Some heightened security settings
6081 (<a href="#sqlitedbconfigtrustedschema">SQLITE_DBCONFIG_TRUSTED_SCHEMA</a> and <a href="pragma.html#pragma_trusted_schema">PRAGMA trusted_schema=OFF</a>)
6082 disable the use of SQL functions inside views and triggers and in
6083 schema structures such as <a href="lang_createtable.html#ckconst">CHECK constraints</a>, <a href="lang_createtable.html#dfltval">DEFAULT clauses</a>,
6084 <a href="expridx.html">expression indexes</a>, <a href="partialindex.html">partial indexes</a>, and <a href="gencol.html">generated columns</a> unless
6085 the function is tagged with SQLITE_INNOCUOUS. Most built-in functions
6086 are innocuous. Developers are advised to avoid using the
6087 SQLITE_INNOCUOUS flag for application-defined functions unless the
6088 function has been carefully audited and found to be free of potentially
6089 security-adverse side-effects and information-leaks.
6090 </dd></p>
6091
6092 <p><a name="sqlitesubtype"></a>
6093 <dt>SQLITE_SUBTYPE</dt><dd>
6094 The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
6095 <a href="#sqlite3_value_subtype">sqlite3_value_subtype()</a> to inspect the sub-types of its arguments.
6096 This flag instructs SQLite to omit some corner-case optimizations that
6097 might disrupt the operation of the <a href="#sqlite3_value_subtype">sqlite3_value_subtype()</a> function,
6098 causing it to return zero rather than the correct subtype().
6099 SQL functions that invokes <a href="#sqlite3_value_subtype">sqlite3_value_subtype()</a> should have this
6100 property. If the SQLITE_SUBTYPE property is omitted, then the return
6101 value from <a href="#sqlite3_value_subtype">sqlite3_value_subtype()</a> might sometimes be zero even though
6102 a non-zero subtype was specified by the function argument expression.</p>
6103
6104 <p><a name="sqliteresultsubtype"></a>
6105 <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
6106 The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call
6107 <a href="#sqlite3_result_subtype">sqlite3_result_subtype()</a> to cause a sub-type to be associated with its
6108 result.
6109 Every function that invokes <a href="#sqlite3_result_subtype">sqlite3_result_subtype()</a> should have this
6110 property. If it does not, then the call to <a href="#sqlite3_result_subtype">sqlite3_result_subtype()</a>
6111 might become a no-op if the function is used as term in an
6112 <a href="expridx.html">expression index</a>. On the other hand, SQL functions that never invoke
6113 <a href="#sqlite3_result_subtype">sqlite3_result_subtype()</a> should avoid setting this property, as the
6114 purpose of this property is to disable certain optimizations that are
6115 incompatible with subtypes.
6116 </dd>
6117 </dl>
6118 </p><hr><a name="SQLITE_FAIL"></a>
6119 <h2>Conflict resolution modes</h2>
6120 </div>
6121 <blockquote><pre>
6122 #define SQLITE_ROLLBACK 1
6123 /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */
6124 #define SQLITE_FAIL 3
6125 /* #define SQLITE_ABORT 4 // Also an error code */
6126 #define SQLITE_REPLACE 5
6127 </pre></blockquote>
6128 <p>
6129 These constants are returned by <a href="#sqlite3_vtab_on_conflict">sqlite3_vtab_on_conflict()</a> to
6130 inform a <a href="vtab.html">virtual table</a> implementation what the <a href="lang_conflict.html">ON CONFLICT</a> mode
6131 is for the SQL statement being evaluated.</p>
6132
6133 <p>Note that the <a href="#SQLITE_DENY">SQLITE_IGNORE</a> constant is also used as a potential
6134 return value from the <a href="#sqlite3_set_authorizer">sqlite3_set_authorizer()</a> callback and that
6135 <a href="#SQLITE_ABORT">SQLITE_ABORT</a> is also a <a href="rescode.html">result code</a>.
6136 </p><hr><a name="SQLITE_FCNTL_BEGIN_ATOMIC_WRITE"></a>
6137 <h2>Standard File Control Opcodes</h2>
6138 </div>
6139 <blockquote><pre>
6140 #define SQLITE_FCNTL_LOCKSTATE 1
6141 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
6142 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
6143 #define SQLITE_FCNTL_LAST_ERRNO 4
6144 #define SQLITE_FCNTL_SIZE_HINT 5
6145 #define SQLITE_FCNTL_CHUNK_SIZE 6
6146 #define SQLITE_FCNTL_FILE_POINTER 7
6147 #define SQLITE_FCNTL_SYNC_OMITTED 8
6148 #define SQLITE_FCNTL_WIN32_AV_RETRY 9
6149 #define SQLITE_FCNTL_PERSIST_WAL 10
6150 #define SQLITE_FCNTL_OVERWRITE 11
6151 #define SQLITE_FCNTL_VFSNAME 12
6152 #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
6153 #define SQLITE_FCNTL_PRAGMA 14
6154 #define SQLITE_FCNTL_BUSYHANDLER 15
6155 #define SQLITE_FCNTL_TEMPFILENAME 16
6156 #define SQLITE_FCNTL_MMAP_SIZE 18
6157 #define SQLITE_FCNTL_TRACE 19
6158 #define SQLITE_FCNTL_HAS_MOVED 20
6159 #define SQLITE_FCNTL_SYNC 21
6160 #define SQLITE_FCNTL_COMMIT_PHASETWO 22
6161 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23
6162 #define SQLITE_FCNTL_WAL_BLOCK 24
6163 #define SQLITE_FCNTL_ZIPVFS 25
6164 #define SQLITE_FCNTL_RBU 26
6165 #define SQLITE_FCNTL_VFS_POINTER 27
6166 #define SQLITE_FCNTL_JOURNAL_POINTER 28
6167 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29
6168 #define SQLITE_FCNTL_PDB 30
6169 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31
6170 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32
6171 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33
6172 #define SQLITE_FCNTL_LOCK_TIMEOUT 34
6173 #define SQLITE_FCNTL_DATA_VERSION 35
6174 #define SQLITE_FCNTL_SIZE_LIMIT 36
6175 #define SQLITE_FCNTL_CKPT_DONE 37
6176 #define SQLITE_FCNTL_RESERVE_BYTES 38
6177 #define SQLITE_FCNTL_CKPT_START 39
6178 #define SQLITE_FCNTL_EXTERNAL_READER 40
6179 #define SQLITE_FCNTL_CKSM_FILE 41
6180 #define SQLITE_FCNTL_RESET_CACHE 42
6181 </pre></blockquote>
6182 <p>
6183 These integer constants are opcodes for the xFileControl method
6184 of the <a href="#sqlite3_io_methods">sqlite3_io_methods</a> object and for the <a href="#sqlite3_file_control">sqlite3_file_control()</a>
6185 interface.</p>
6186
6187 <p><ul>
6188 <li><a name="sqlitefcntllockstate"></a>
6189
6190 The <a href="#sqlitefcntllockstate">SQLITE_FCNTL_LOCKSTATE</a> opcode is used for debugging. This
6191 opcode causes the xFileControl method to write the current state of
6192 the lock (one of <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_NONE</a>, <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_SHARED</a>,
6193 <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_RESERVED</a>, <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_PENDING</a>, or <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_EXCLUSIVE</a>)
6194 into an integer that the pArg argument points to.
6195 This capability is only available if SQLite is compiled with <a href="compile.html#debug">SQLITE_DEBUG</a>.</p>
6196
6197 <p><li><a name="sqlitefcntlsizehint"></a>
6198
6199 The <a href="#sqlitefcntlsizehint">SQLITE_FCNTL_SIZE_HINT</a> opcode is used by SQLite to give the VFS
6200 layer a hint of how large the database file will grow to be during the
6201 current transaction. This hint is not guaranteed to be accurate but it
6202 is often close. The underlying VFS might choose to preallocate database
6203 file space based on this hint in order to help writes to the database
6204 file run faster.</p>
6205
6206 <p><li><a name="sqlitefcntlsizelimit"></a>
6207
6208 The <a href="#sqlitefcntlsizelimit">SQLITE_FCNTL_SIZE_LIMIT</a> opcode is used by in-memory VFS that
6209 implements <a href="#sqlite3_deserialize">sqlite3_deserialize()</a> to set an upper bound on the size
6210 of the in-memory database. The argument is a pointer to a <a href="#sqlite3_int64">sqlite3_int64</a>.
6211 If the integer pointed to is negative, then it is filled in with the
6212 current limit. Otherwise the limit is set to the larger of the value
6213 of the integer pointed to and the current database size. The integer
6214 pointed to is set to the new limit.</p>
6215
6216 <p><li><a name="sqlitefcntlchunksize"></a>
6217
6218 The <a href="#sqlitefcntlchunksize">SQLITE_FCNTL_CHUNK_SIZE</a> opcode is used to request that the VFS
6219 extends and truncates the database file in chunks of a size specified
6220 by the user. The fourth argument to <a href="#sqlite3_file_control">sqlite3_file_control()</a> should
6221 point to an integer (type int) containing the new chunk-size to use
6222 for the nominated database. Allocating database file space in large
6223 chunks (say 1MB at a time), may reduce file-system fragmentation and
6224 improve performance on some systems.</p>
6225
6226 <p><li><a name="sqlitefcntlfilepointer"></a>
6227
6228 The <a href="#sqlitefcntlfilepointer">SQLITE_FCNTL_FILE_POINTER</a> opcode is used to obtain a pointer
6229 to the <a href="#sqlite3_file">sqlite3_file</a> object associated with a particular database
6230 connection. See also <a href="#sqlitefcntljournalpointer">SQLITE_FCNTL_JOURNAL_POINTER</a>.</p>
6231
6232 <p><li><a name="sqlitefcntljournalpointer"></a>
6233
6234 The <a href="#sqlitefcntljournalpointer">SQLITE_FCNTL_JOURNAL_POINTER</a> opcode is used to obtain a pointer
6235 to the <a href="#sqlite3_file">sqlite3_file</a> object associated with the journal file (either
6236 the <a href="lockingv3.html#rollback">rollback journal</a> or the <a href="wal.html">write-ahead log</a>) for a particular database
6237 connection. See also <a href="#sqlitefcntlfilepointer">SQLITE_FCNTL_FILE_POINTER</a>.</p>
6238
6239 <p><li><a name="sqlitefcntlsyncomitted"></a>
6240
6241 No longer in use.</p>
6242
6243 <p><li><a name="sqlitefcntlsync"></a>
6244
6245 The <a href="#sqlitefcntlsync">SQLITE_FCNTL_SYNC</a> opcode is generated internally by SQLite and
6246 sent to the VFS immediately before the xSync method is invoked on a
6247 database file descriptor. Or, if the xSync method is not invoked
6248 because the user has configured SQLite with
6249 <a href="pragma.html#pragma_synchronous">PRAGMA synchronous=OFF</a> it is invoked in place
6250 of the xSync method. In most cases, the pointer argument passed with
6251 this file-control is NULL. However, if the database file is being synced
6252 as part of a multi-database commit, the argument points to a nul-terminated
6253 string containing the transactions super-journal file name. VFSes that
6254 do not need this signal should silently ignore this opcode. Applications
6255 should not call <a href="#sqlite3_file_control">sqlite3_file_control()</a> with this opcode as doing so may
6256 disrupt the operation of the specialized VFSes that do require it.</p>
6257
6258 <p><li><a name="sqlitefcntlcommitphasetwo"></a>
6259
6260 The <a href="#sqlitefcntlcommitphasetwo">SQLITE_FCNTL_COMMIT_PHASETWO</a> opcode is generated internally by SQLite
6261 and sent to the VFS after a transaction has been committed immediately
6262 but before the database is unlocked. VFSes that do not need this signal
6263 should silently ignore this opcode. Applications should not call
6264 <a href="#sqlite3_file_control">sqlite3_file_control()</a> with this opcode as doing so may disrupt the
6265 operation of the specialized VFSes that do require it.</p>
6266
6267 <p><li><a name="sqlitefcntlwin32avretry"></a>
6268
6269 The <a href="#sqlitefcntlwin32avretry">SQLITE_FCNTL_WIN32_AV_RETRY</a> opcode is used to configure automatic
6270 retry counts and intervals for certain disk I/O operations for the
6271 windows <a href="vfs.html">VFS</a> in order to provide robustness in the presence of
6272 anti-virus programs. By default, the windows VFS will retry file read,
6273 file write, and file delete operations up to 10 times, with a delay
6274 of 25 milliseconds before the first retry and with the delay increasing
6275 by an additional 25 milliseconds with each subsequent retry. This
6276 opcode allows these two values (10 retries and 25 milliseconds of delay)
6277 to be adjusted. The values are changed for all database connections
6278 within the same process. The argument is a pointer to an array of two
6279 integers where the first integer is the new retry count and the second
6280 integer is the delay. If either integer is negative, then the setting
6281 is not changed but instead the prior value of that setting is written
6282 into the array entry, allowing the current retry settings to be
6283 interrogated. The zDbName parameter is ignored.</p>
6284
6285 <p><li><a name="sqlitefcntlpersistwal"></a>
6286
6287 The <a href="#sqlitefcntlpersistwal">SQLITE_FCNTL_PERSIST_WAL</a> opcode is used to set or query the
6288 persistent <a href="wal.html">Write Ahead Log</a> setting. By default, the auxiliary
6289 write ahead log (<a href="wal.html#walfile">WAL file</a>) and shared memory
6290 files used for transaction control
6291 are automatically deleted when the latest connection to the database
6292 closes. Setting persistent WAL mode causes those files to persist after
6293 close. Persisting the files is useful when other processes that do not
6294 have write permission on the directory containing the database file want
6295 to read the database file, as the WAL and shared memory files must exist
6296 in order for the database to be readable. The fourth parameter to
6297 <a href="#sqlite3_file_control">sqlite3_file_control()</a> for this opcode should be a pointer to an integer.
6298 That integer is 0 to disable persistent WAL mode or 1 to enable persistent
6299 WAL mode. If the integer is -1, then it is overwritten with the current
6300 WAL persistence setting.</p>
6301
6302 <p><li><a name="sqlitefcntlpowersafeoverwrite"></a>
6303
6304 The <a href="#sqlitefcntlpowersafeoverwrite">SQLITE_FCNTL_POWERSAFE_OVERWRITE</a> opcode is used to set or query the
6305 persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting
6306 determines the <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_POWERSAFE_OVERWRITE</a> bit of the
6307 xDeviceCharacteristics methods. The fourth parameter to
6308 <a href="#sqlite3_file_control">sqlite3_file_control()</a> for this opcode should be a pointer to an integer.
6309 That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
6310 mode. If the integer is -1, then it is overwritten with the current
6311 zero-damage mode setting.</p>
6312
6313 <p><li><a name="sqlitefcntloverwrite"></a>
6314
6315 The <a href="#sqlitefcntloverwrite">SQLITE_FCNTL_OVERWRITE</a> opcode is invoked by SQLite after opening
6316 a write transaction to indicate that, unless it is rolled back for some
6317 reason, the entire database file will be overwritten by the current
6318 transaction. This is used by VACUUM operations.</p>
6319
6320 <p><li><a name="sqlitefcntlvfsname"></a>
6321
6322 The <a href="#sqlitefcntlvfsname">SQLITE_FCNTL_VFSNAME</a> opcode can be used to obtain the names of
6323 all <a href="vfs.html">VFSes</a> in the VFS stack. The names are of all VFS shims and the
6324 final bottom-level VFS are written into memory obtained from
6325 <a href="#sqlite3_free">sqlite3_malloc()</a> and the result is stored in the char* variable
6326 that the fourth parameter of <a href="#sqlite3_file_control">sqlite3_file_control()</a> points to.
6327 The caller is responsible for freeing the memory when done. As with
6328 all file-control actions, there is no guarantee that this will actually
6329 do anything. Callers should initialize the char* variable to a NULL
6330 pointer in case this file-control is not implemented. This file-control
6331 is intended for diagnostic use only.</p>
6332
6333 <p><li><a name="sqlitefcntlvfspointer"></a>
6334
6335 The <a href="#sqlitefcntlvfspointer">SQLITE_FCNTL_VFS_POINTER</a> opcode finds a pointer to the top-level
6336 <a href="vfs.html">VFSes</a> currently in use. The argument X in
6337 sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
6338 of type "<a href="#sqlite3_vfs">sqlite3_vfs</a> **". This opcodes will set *X
6339 to a pointer to the top-level VFS.
6340 When there are multiple VFS shims in the stack, this opcode finds the
6341 upper-most shim only.</p>
6342
6343 <p><li><a name="sqlitefcntlpragma"></a>
6344
6345 Whenever a <a href="pragma.html#syntax">PRAGMA</a> statement is parsed, an <a href="#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a>
6346 file control is sent to the open <a href="#sqlite3_file">sqlite3_file</a> object corresponding
6347 to the database file to which the pragma statement refers. The argument
6348 to the <a href="#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control is an array of
6349 pointers to strings (char**) in which the second element of the array
6350 is the name of the pragma and the third element is the argument to the
6351 pragma or NULL if the pragma has no argument. The handler for an
6352 <a href="#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control can optionally make the first element
6353 of the char** argument point to a string obtained from <a href="#sqlite3_mprintf">sqlite3_mprintf()</a>
6354 or the equivalent and that string will become the result of the pragma or
6355 the error message if the pragma fails. If the
6356 <a href="#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control returns <a href="#SQLITE_ABORT">SQLITE_NOTFOUND</a>, then normal
6357 <a href="pragma.html#syntax">PRAGMA</a> processing continues. If the <a href="#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a>
6358 file control returns <a href="#SQLITE_ABORT">SQLITE_OK</a>, then the parser assumes that the
6359 VFS has handled the PRAGMA itself and the parser generates a no-op
6360 prepared statement if result string is NULL, or that returns a copy
6361 of the result string if the string is non-NULL.
6362 If the <a href="#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control returns
6363 any result code other than <a href="#SQLITE_ABORT">SQLITE_OK</a> or <a href="#SQLITE_ABORT">SQLITE_NOTFOUND</a>, that means
6364 that the VFS encountered an error while handling the <a href="pragma.html#syntax">PRAGMA</a> and the
6365 compilation of the PRAGMA fails with an error. The <a href="#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a>
6366 file control occurs at the beginning of pragma statement analysis and so
6367 it is able to override built-in <a href="pragma.html#syntax">PRAGMA</a> statements.</p>
6368
6369 <p><li><a name="sqlitefcntlbusyhandler"></a>
6370
6371 The <a href="#sqlitefcntlbusyhandler">SQLITE_FCNTL_BUSYHANDLER</a>
6372 file-control may be invoked by SQLite on the database file handle
6373 shortly after it is opened in order to provide a custom VFS with access
6374 to the connection's busy-handler callback. The argument is of type (void**)
6375 - an array of two (void *) values. The first (void *) actually points
6376 to a function of type (int (*)(void *)). In order to invoke the connection's
6377 busy-handler, this function should be invoked with the second (void *) in
6378 the array as the only argument. If it returns non-zero, then the operation
6379 should be retried. If it returns zero, the custom VFS should abandon the
6380 current operation.</p>
6381
6382 <p><li><a name="sqlitefcntltempfilename"></a>
6383
6384 Applications can invoke the <a href="#sqlitefcntltempfilename">SQLITE_FCNTL_TEMPFILENAME</a> file-control
6385 to have SQLite generate a
6386 temporary filename using the same algorithm that is followed to generate
6387 temporary filenames for TEMP tables and other internal uses. The
6388 argument should be a char** which will be filled with the filename
6389 written into memory obtained from <a href="#sqlite3_free">sqlite3_malloc()</a>. The caller should
6390 invoke <a href="#sqlite3_free">sqlite3_free()</a> on the result to avoid a memory leak.</p>
6391
6392 <p><li><a name="sqlitefcntlmmapsize"></a>
6393
6394 The <a href="#sqlitefcntlmmapsize">SQLITE_FCNTL_MMAP_SIZE</a> file control is used to query or set the
6395 maximum number of bytes that will be used for memory-mapped I/O.
6396 The argument is a pointer to a value of type sqlite3_int64 that
6397 is an advisory maximum number of bytes in the file to memory map. The
6398 pointer is overwritten with the old value. The limit is not changed if
6399 the value originally pointed to is negative, and so the current limit
6400 can be queried by passing in a pointer to a negative number. This
6401 file-control is used internally to implement <a href="pragma.html#pragma_mmap_size">PRAGMA mmap_size</a>.</p>
6402
6403 <p><li><a name="sqlitefcntltrace"></a>
6404
6405 The <a href="#sqlitefcntltrace">SQLITE_FCNTL_TRACE</a> file control provides advisory information
6406 to the VFS about what the higher layers of the SQLite stack are doing.
6407 This file control is used by some VFS activity tracing <a href="vfs.html#shim">shims</a>.
6408 The argument is a zero-terminated string. Higher layers in the
6409 SQLite stack may generate instances of this file control if
6410 the <a href="compile.html#use_fcntl_trace">SQLITE_USE_FCNTL_TRACE</a> compile-time option is enabled.</p>
6411
6412 <p><li><a name="sqlitefcntlhasmoved"></a>
6413
6414 The <a href="#sqlitefcntlhasmoved">SQLITE_FCNTL_HAS_MOVED</a> file control interprets its argument as a
6415 pointer to an integer and it writes a boolean into that integer depending
6416 on whether or not the file has been renamed, moved, or deleted since it
6417 was first opened.</p>
6418
6419 <p><li><a name="sqlitefcntlwin32gethandle"></a>
6420
6421 The <a href="#sqlitefcntlwin32gethandle">SQLITE_FCNTL_WIN32_GET_HANDLE</a> opcode can be used to obtain the
6422 underlying native file handle associated with a file handle. This file
6423 control interprets its argument as a pointer to a native file handle and
6424 writes the resulting value there.</p>
6425
6426 <p><li><a name="sqlitefcntlwin32sethandle"></a>
6427
6428 The <a href="#sqlitefcntlwin32sethandle">SQLITE_FCNTL_WIN32_SET_HANDLE</a> opcode is used for debugging. This
6429 opcode causes the xFileControl method to swap the file handle with the one
6430 pointed to by the pArg argument. This capability is used during testing
6431 and only needs to be supported when SQLITE_TEST is defined.</p>
6432
6433 <p><li><a name="sqlitefcntlwalblock"></a>
6434
6435 The <a href="#sqlitefcntlwalblock">SQLITE_FCNTL_WAL_BLOCK</a> is a signal to the VFS layer that it might
6436 be advantageous to block on the next WAL lock if the lock is not immediately
6437 available. The WAL subsystem issues this signal during rare
6438 circumstances in order to fix a problem with priority inversion.
6439 Applications should <em>not</em> use this file-control.</p>
6440
6441 <p><li><a name="sqlitefcntlzipvfs"></a>
6442
6443 The <a href="#sqlitefcntlzipvfs">SQLITE_FCNTL_ZIPVFS</a> opcode is implemented by zipvfs only. All other
6444 VFS should return SQLITE_NOTFOUND for this opcode.</p>
6445
6446 <p><li><a name="sqlitefcntlrbu"></a>
6447
6448 The <a href="#sqlitefcntlrbu">SQLITE_FCNTL_RBU</a> opcode is implemented by the special VFS used by
6449 the RBU extension only. All other VFS should return SQLITE_NOTFOUND for
6450 this opcode.</p>
6451
6452 <p><li><a name="sqlitefcntlbeginatomicwrite"></a>
6453
6454 If the <a href="#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> opcode returns SQLITE_OK, then
6455 the file descriptor is placed in "batch write mode", which
6456 means all subsequent write operations will be deferred and done
6457 atomically at the next <a href="#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a>. Systems
6458 that do not support batch atomic writes will return SQLITE_NOTFOUND.
6459 Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to
6460 the closing <a href="#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a> or
6461 <a href="#sqlitefcntlrollbackatomicwrite">SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE</a>, SQLite will make
6462 no VFS interface calls on the same <a href="#sqlite3_file">sqlite3_file</a> file descriptor
6463 except for calls to the xWrite method and the xFileControl method
6464 with <a href="#sqlitefcntlsizehint">SQLITE_FCNTL_SIZE_HINT</a>.</p>
6465
6466 <p><li><a name="sqlitefcntlcommitatomicwrite"></a>
6467
6468 The <a href="#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a> opcode causes all write
6469 operations since the previous successful call to
6470 <a href="#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> to be performed atomically.
6471 This file control returns <a href="#SQLITE_ABORT">SQLITE_OK</a> if and only if the writes were
6472 all performed successfully and have been committed to persistent storage.
6473 Regardless of whether or not it is successful, this file control takes
6474 the file descriptor out of batch write mode so that all subsequent
6475 write operations are independent.
6476 SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without
6477 a prior successful call to <a href="#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a>.</p>
6478
6479 <p><li><a name="sqlitefcntlrollbackatomicwrite"></a>
6480
6481 The <a href="#sqlitefcntlrollbackatomicwrite">SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE</a> opcode causes all write
6482 operations since the previous successful call to
6483 <a href="#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> to be rolled back.
6484 This file control takes the file descriptor out of batch write mode
6485 so that all subsequent write operations are independent.
6486 SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
6487 a prior successful call to <a href="#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a>.</p>
6488
6489 <p><li><a name="sqlitefcntllocktimeout"></a>
6490
6491 The <a href="#sqlitefcntllocktimeout">SQLITE_FCNTL_LOCK_TIMEOUT</a> opcode is used to configure a VFS
6492 to block for up to M milliseconds before failing when attempting to
6493 obtain a file lock using the xLock or xShmLock methods of the VFS.
6494 The parameter is a pointer to a 32-bit signed integer that contains
6495 the value that M is to be set to. Before returning, the 32-bit signed
6496 integer is overwritten with the previous value of M.</p>
6497
6498 <p><li><a name="sqlitefcntldataversion"></a>
6499
6500 The <a href="#sqlitefcntldataversion">SQLITE_FCNTL_DATA_VERSION</a> opcode is used to detect changes to
6501 a database file. The argument is a pointer to a 32-bit unsigned integer.
6502 The "data version" for the pager is written into the pointer. The
6503 "data version" changes whenever any change occurs to the corresponding
6504 database file, either through SQL statements on the same database
6505 connection or through transactions committed by separate database
6506 connections possibly in other processes. The <a href="#sqlite3_total_changes">sqlite3_total_changes()</a>
6507 interface can be used to find if any database on the connection has changed,
6508 but that interface responds to changes on TEMP as well as MAIN and does
6509 not provide a mechanism to detect changes to MAIN only. Also, the
6510 <a href="#sqlite3_total_changes">sqlite3_total_changes()</a> interface responds to internal changes only and
6511 omits changes made by other database connections. The
6512 <a href="pragma.html#pragma_data_version">PRAGMA data_version</a> command provides a mechanism to detect changes to
6513 a single attached database that occur due to other database connections,
6514 but omits changes implemented by the database connection on which it is
6515 called. This file control is the only mechanism to detect changes that
6516 happen either internally or externally and that are associated with
6517 a particular attached database.</p>
6518
6519 <p><li><a name="sqlitefcntlckptstart"></a>
6520
6521 The <a href="#sqlitefcntlckptstart">SQLITE_FCNTL_CKPT_START</a> opcode is invoked from within a checkpoint
6522 in wal mode before the client starts to copy pages from the wal
6523 file to the database file.</p>
6524
6525 <p><li><a name="sqlitefcntlckptdone"></a>
6526
6527 The <a href="#sqlitefcntlckptdone">SQLITE_FCNTL_CKPT_DONE</a> opcode is invoked from within a checkpoint
6528 in wal mode after the client has finished copying pages from the wal
6529 file to the database file, but before the *-shm file is updated to
6530 record the fact that the pages have been checkpointed.</p>
6531
6532 <p><li><a name="sqlitefcntlexternalreader"></a>
6533
6534 The EXPERIMENTAL <a href="#sqlitefcntlexternalreader">SQLITE_FCNTL_EXTERNAL_READER</a> opcode is used to detect
6535 whether or not there is a database client in another process with a wal-mode
6536 transaction open on the database or not. It is only available on unix.The
6537 (void*) argument passed with this file-control should be a pointer to a
6538 value of type (int). The integer value is set to 1 if the database is a wal
6539 mode database and there exists at least one client in another process that
6540 currently has an SQL transaction open on the database. It is set to 0 if
6541 the database is not a wal-mode db, or if there is no such connection in any
6542 other process. This opcode cannot be used to detect transactions opened
6543 by clients within the current process, only within other processes.</p>
6544
6545 <p><li><a name="sqlitefcntlcksmfile"></a>
6546
6547 The <a href="#sqlitefcntlcksmfile">SQLITE_FCNTL_CKSM_FILE</a> opcode is for use internally by the
6548 <a href="cksumvfs.html">checksum VFS shim</a> only.</p>
6549
6550 <p><li><a name="sqlitefcntlresetcache"></a>
6551
6552 If there is currently no transaction open on the database, and the
6553 database is not a temp db, then the <a href="#sqlitefcntlresetcache">SQLITE_FCNTL_RESET_CACHE</a> file-control
6554 purges the contents of the in-memory page cache. If there is an open
6555 transaction, or if the db is a temp-db, this opcode is a no-op, not an error.
6556 </ul>
6557 </p><hr><a name="SQLITE_INDEX_CONSTRAINT_EQ"></a>
6558 <h2>Virtual Table Constraint Operator Codes</h2>
6559 </div>
6560 <blockquote><pre>
6561 #define SQLITE_INDEX_CONSTRAINT_EQ 2
6562 #define SQLITE_INDEX_CONSTRAINT_GT 4
6563 #define SQLITE_INDEX_CONSTRAINT_LE 8
6564 #define SQLITE_INDEX_CONSTRAINT_LT 16
6565 #define SQLITE_INDEX_CONSTRAINT_GE 32
6566 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
6567 #define SQLITE_INDEX_CONSTRAINT_LIKE 65
6568 #define SQLITE_INDEX_CONSTRAINT_GLOB 66
6569 #define SQLITE_INDEX_CONSTRAINT_REGEXP 67
6570 #define SQLITE_INDEX_CONSTRAINT_NE 68
6571 #define SQLITE_INDEX_CONSTRAINT_ISNOT 69
6572 #define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
6573 #define SQLITE_INDEX_CONSTRAINT_ISNULL 71
6574 #define SQLITE_INDEX_CONSTRAINT_IS 72
6575 #define SQLITE_INDEX_CONSTRAINT_LIMIT 73
6576 #define SQLITE_INDEX_CONSTRAINT_OFFSET 74
6577 #define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
6578 </pre></blockquote>
6579 <p>
6580 These macros define the allowed values for the
6581 <a href="#sqlite3_index_info">sqlite3_index_info</a>.aConstraint[].op field. Each value represents
6582 an operator that is part of a constraint term in the WHERE clause of
6583 a query that uses a <a href="vtab.html">virtual table</a>.</p>
6584
6585 <p>The left-hand operand of the operator is given by the corresponding
6586 aConstraint[].iColumn field. An iColumn of -1 indicates the left-hand
6587 operand is the rowid.
6588 The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
6589 operators have no left-hand operand, and so for those operators the
6590 corresponding aConstraint[].iColumn is meaningless and should not be
6591 used.</p>
6592
6593 <p>All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
6594 value 255 are reserved to represent functions that are overloaded
6595 by the <a href="vtab.html#xfindfunction">xFindFunction method</a> of the virtual table
6596 implementation.</p>
6597
6598 <p>The right-hand operands for each constraint might be accessible using
6599 the <a href="#sqlite3_vtab_rhs_value">sqlite3_vtab_rhs_value()</a> interface. Usually the right-hand
6600 operand is only available if it appears as a single constant literal
6601 in the input SQL. If the right-hand operand is another column or an
6602 expression (even a constant expression) or a parameter, then the
6603 sqlite3_vtab_rhs_value() probably will not be able to extract it.
6604 The SQLITE_INDEX_CONSTRAINT_ISNULL and
6605 SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
6606 and hence calls to sqlite3_vtab_rhs_value() for those operators will
6607 always return SQLITE_NOTFOUND.</p>
6608
6609 <p>The collating sequence to be used for comparison can be found using
6610 the <a href="#sqlite3_vtab_collation">sqlite3_vtab_collation()</a> interface. For most real-world virtual
6611 tables, the collating sequence of constraints does not matter (for example
6612 because the constraints are numeric) and so the sqlite3_vtab_collation()
6613 interface is not commonly needed.
6614 </p><hr><a name="SQLITE_IOCAP_ATOMIC"></a>
6615 <h2>Device Characteristics</h2>
6616 </div>
6617 <blockquote><pre>
6618 #define SQLITE_IOCAP_ATOMIC 0x00000001
6619 #define SQLITE_IOCAP_ATOMIC512 0x00000002
6620 #define SQLITE_IOCAP_ATOMIC1K 0x00000004
6621 #define SQLITE_IOCAP_ATOMIC2K 0x00000008
6622 #define SQLITE_IOCAP_ATOMIC4K 0x00000010
6623 #define SQLITE_IOCAP_ATOMIC8K 0x00000020
6624 #define SQLITE_IOCAP_ATOMIC16K 0x00000040
6625 #define SQLITE_IOCAP_ATOMIC32K 0x00000080
6626 #define SQLITE_IOCAP_ATOMIC64K 0x00000100
6627 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200
6628 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400
6629 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
6630 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
6631 #define SQLITE_IOCAP_IMMUTABLE 0x00002000
6632 #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
6633 </pre></blockquote>
6634 <p>
6635 The xDeviceCharacteristics method of the <a href="#sqlite3_io_methods">sqlite3_io_methods</a>
6636 object returns an integer which is a vector of these
6637 bit values expressing I/O characteristics of the mass storage
6638 device that holds the file that the <a href="#sqlite3_io_methods">sqlite3_io_methods</a>
6639 refers to.</p>
6640
6641 <p>The SQLITE_IOCAP_ATOMIC property means that all writes of
6642 any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
6643 mean that writes of blocks that are nnn bytes in size and
6644 are aligned to an address which is an integer multiple of
6645 nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
6646 that when data is appended to a file, the data is appended
6647 first then the size of the file is extended, never the other
6648 way around. The SQLITE_IOCAP_SEQUENTIAL property means that
6649 information is written to disk in the same order as calls
6650 to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
6651 after reboot following a crash or power loss, the only bytes in a
6652 file that were written at the application level might have changed
6653 and that adjacent bytes, even bytes within the same sector are
6654 guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
6655 flag indicates that a file cannot be deleted when open. The
6656 SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
6657 read-only media and cannot be changed even by processes with
6658 elevated privileges.</p>
6659
6660 <p>The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying
6661 filesystem supports doing multiple write operations atomically when those
6662 write operations are bracketed by <a href="#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> and
6663 <a href="#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a>.
6664 </p><hr><a name="SQLITE_LOCK_EXCLUSIVE"></a>
6665 <h2>File Locking Levels</h2>
6666 </div>
6667 <blockquote><pre>
6668 #define SQLITE_LOCK_NONE 0 /* xUnlock() only */
6669 #define SQLITE_LOCK_SHARED 1 /* xLock() or xUnlock() */
6670 #define SQLITE_LOCK_RESERVED 2 /* xLock() only */
6671 #define SQLITE_LOCK_PENDING 3 /* xLock() only */
6672 #define SQLITE_LOCK_EXCLUSIVE 4 /* xLock() only */
6673 </pre></blockquote>
6674 <p>
6675 SQLite uses one of these integer values as the second
6676 argument to calls it makes to the xLock() and xUnlock() methods
6677 of an <a href="#sqlite3_io_methods">sqlite3_io_methods</a> object. These values are ordered from
6678 lest restrictive to most restrictive.</p>
6679
6680 <p>The argument to xLock() is always SHARED or higher. The argument to
6681 xUnlock is either SHARED or NONE.
6682 </p><hr><a name="SQLITE_MUTEX_FAST"></a>
6683 <h2>Mutex Types</h2>
6684 </div>
6685 <blockquote><pre>
6686 #define SQLITE_MUTEX_FAST 0
6687 #define SQLITE_MUTEX_RECURSIVE 1
6688 #define SQLITE_MUTEX_STATIC_MAIN 2
6689 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */
6690 #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */
6691 #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */
6692 #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_randomness() */
6693 #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
6694 #define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */
6695 #define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */
6696 #define SQLITE_MUTEX_STATIC_APP1 8 /* For use by application */
6697 #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
6698 #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
6699 #define SQLITE_MUTEX_STATIC_VFS1 11 /* For use by built-in VFS */
6700 #define SQLITE_MUTEX_STATIC_VFS2 12 /* For use by extension VFS */
6701 #define SQLITE_MUTEX_STATIC_VFS3 13 /* For use by application VFS */
6702 </pre></blockquote>
6703 <p>
6704 The <a href="#sqlite3_mutex_alloc">sqlite3_mutex_alloc()</a> interface takes a single argument
6705 which is one of these integer constants.</p>
6706
6707 <p>The set of static mutexes may change from one SQLite release to the
6708 next. Applications that override the built-in mutex logic must be
6709 prepared to accommodate additional static mutexes.
6710 </p><hr><a name="SQLITE_OPEN_AUTOPROXY"></a>
6711 <h2>Flags For File Open Operations</h2>
6712 </div>
6713 <blockquote><pre>
6714 #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
6715 #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
6716 #define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
6717 #define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
6718 #define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
6719 #define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
6720 #define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */
6721 #define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */
6722 #define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
6723 #define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
6724 #define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */
6725 #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */
6726 #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */
6727 #define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */
6728 #define SQLITE_OPEN_SUPER_JOURNAL 0x00004000 /* VFS only */
6729 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
6730 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
6731 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
6732 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
6733 #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
6734 #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
6735 #define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */
6736 </pre></blockquote>
6737 <p>
6738 These bit values are intended for use in the
6739 3rd parameter to the <a href="#sqlite3_open">sqlite3_open_v2()</a> interface and
6740 in the 4th parameter to the <a href="#sqlite3vfsxopen">sqlite3_vfs.xOpen</a> method.</p>
6741
6742 <p>Only those flags marked as "Ok for sqlite3_open_v2()" may be
6743 used as the third argument to the <a href="#sqlite3_open">sqlite3_open_v2()</a> interface.
6744 The other flags have historically been ignored by sqlite3_open_v2(),
6745 though future versions of SQLite might change so that an error is
6746 raised if any of the disallowed bits are passed into sqlite3_open_v2().
6747 Applications should not depend on the historical behavior.</p>
6748
6749 <p>Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into
6750 <a href="#sqlite3_open">sqlite3_open_v2()</a> does *not* cause the underlying database file
6751 to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into
6752 <a href="#sqlite3_open">sqlite3_open_v2()</a> has historically be a no-op and might become an
6753 error in future versions of SQLite.
6754 </p><hr><a name="SQLITE_PREPARE_NORMALIZE"></a>
6755 <h2>Prepare Flags</h2>
6756 </div>
6757 <blockquote><pre>
6758 #define SQLITE_PREPARE_PERSISTENT 0x01
6759 #define SQLITE_PREPARE_NORMALIZE 0x02
6760 #define SQLITE_PREPARE_NO_VTAB 0x04
6761 </pre></blockquote>
6762 <p>
6763 These constants define various flags that can be passed into
6764 "prepFlags" parameter of the <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a> and
6765 <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a> interfaces.</p>
6766
6767 <p>New flags may be added in future releases of SQLite.</p>
6768
6769 <p><dl>
6770 <a name="sqlitepreparepersistent"></a>
6771 <dt>SQLITE_PREPARE_PERSISTENT</dt>
6772 <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
6773 that the prepared statement will be retained for a long time and
6774 probably reused many times. Without this flag, <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a>
6775 and <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a> assume that the prepared statement will
6776 be used just once or at most a few times and then destroyed using
6777 <a href="#sqlite3_finalize">sqlite3_finalize()</a> relatively soon. The current implementation acts
6778 on this hint by avoiding the use of <a href="malloc.html#lookaside">lookaside memory</a> so as not to
6779 deplete the limited store of lookaside memory. Future versions of
6780 SQLite may act on this hint differently.</p>
6781
6782 <p><a name="sqlitepreparenormalize"></a>
6783 <dt>SQLITE_PREPARE_NORMALIZE</dt>
6784 <dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used
6785 to be required for any prepared statement that wanted to use the
6786 <a href="#sqlite3_expanded_sql">sqlite3_normalized_sql()</a> interface. However, the
6787 <a href="#sqlite3_expanded_sql">sqlite3_normalized_sql()</a> interface is now available to all
6788 prepared statements, regardless of whether or not they use this
6789 flag.</p>
6790
6791 <p><a name="sqlitepreparenovtab"></a>
6792 <dt>SQLITE_PREPARE_NO_VTAB</dt>
6793 <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
6794 to return an error (error code SQLITE_ERROR) if the statement uses
6795 any virtual tables.
6796 </dl>
6797 </p><hr><a name="SQLITE_SCANSTAT_COMPLEX"></a>
6798 <h2>Prepared Statement Scan Status</h2>
6799 </div>
6800 <blockquote><pre>
6801 #define SQLITE_SCANSTAT_COMPLEX 0x0001
6802 </pre></blockquote>
6803 <p></p><hr><a name="SQLITE_SCANSTAT_EST"></a>
6804 <h2>Prepared Statement Scan Status Opcodes</h2>
6805 </div>
6806 <blockquote><pre>
6807 #define SQLITE_SCANSTAT_NLOOP 0
6808 #define SQLITE_SCANSTAT_NVISIT 1
6809 #define SQLITE_SCANSTAT_EST 2
6810 #define SQLITE_SCANSTAT_NAME 3
6811 #define SQLITE_SCANSTAT_EXPLAIN 4
6812 #define SQLITE_SCANSTAT_SELECTID 5
6813 #define SQLITE_SCANSTAT_PARENTID 6
6814 #define SQLITE_SCANSTAT_NCYCLE 7
6815 </pre></blockquote>
6816 <p>
6817 The following constants can be used for the T parameter to the
6818 <a href="#sqlite3_stmt_scanstatus">sqlite3_stmt_scanstatus(S,X,T,V)</a> interface. Each constant designates a
6819 different metric for sqlite3_stmt_scanstatus() to return.</p>
6820
6821 <p>When the value returned to V is a string, space to hold that string is
6822 managed by the prepared statement S and will be automatically freed when
6823 S is finalized.</p>
6824
6825 <p>Not all values are available for all query elements. When a value is
6826 not available, the output variable is set to -1 if the value is numeric,
6827 or to NULL if it is a string (SQLITE_SCANSTAT_NAME).</p>
6828
6829 <p><dl>
6830 <a name="sqlitescanstatnloop"></a>
6831 <dt>SQLITE_SCANSTAT_NLOOP</dt>
6832 <dd>The <a href="#sqlite3_int64">sqlite3_int64</a> variable pointed to by the V parameter will be
6833 set to the total number of times that the X-th loop has run.</dd></p>
6834
6835 <p><a name="sqlitescanstatnvisit"></a>
6836 <dt>SQLITE_SCANSTAT_NVISIT</dt>
6837 <dd>The <a href="#sqlite3_int64">sqlite3_int64</a> variable pointed to by the V parameter will be set
6838 to the total number of rows examined by all iterations of the X-th loop.</dd></p>
6839
6840 <p><a name="sqlitescanstatest"></a>
6841 <dt>SQLITE_SCANSTAT_EST</dt>
6842 <dd>The "double" variable pointed to by the V parameter will be set to the
6843 query planner's estimate for the average number of rows output from each
6844 iteration of the X-th loop. If the query planner's estimates was accurate,
6845 then this value will approximate the quotient NVISIT/NLOOP and the
6846 product of this value for all prior loops with the same SELECTID will
6847 be the NLOOP value for the current loop.</p>
6848
6849 <p><a name="sqlitescanstatname"></a>
6850 <dt>SQLITE_SCANSTAT_NAME</dt>
6851 <dd>The "const char *" variable pointed to by the V parameter will be set
6852 to a zero-terminated UTF-8 string containing the name of the index or table
6853 used for the X-th loop.</p>
6854
6855 <p><a name="sqlitescanstatexplain"></a>
6856 <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
6857 <dd>The "const char *" variable pointed to by the V parameter will be set
6858 to a zero-terminated UTF-8 string containing the <a href="eqp.html">EXPLAIN QUERY PLAN</a>
6859 description for the X-th loop.</p>
6860
6861 <p><a name="sqlitescanstatselectid"></a>
6862 <dt>SQLITE_SCANSTAT_SELECTID</dt>
6863 <dd>The "int" variable pointed to by the V parameter will be set to the
6864 id for the X-th query plan element. The id value is unique within the
6865 statement. The select-id is the same value as is output in the first
6866 column of an <a href="eqp.html">EXPLAIN QUERY PLAN</a> query.</p>
6867
6868 <p><a name="sqlitescanstatparentid"></a>
6869 <dt>SQLITE_SCANSTAT_PARENTID</dt>
6870 <dd>The "int" variable pointed to by the V parameter will be set to the
6871 the id of the parent of the current query element, if applicable, or
6872 to zero if the query element has no parent. This is the same value as
6873 returned in the second column of an <a href="eqp.html">EXPLAIN QUERY PLAN</a> query.</p>
6874
6875 <p><a name="sqlitescanstatncycle"></a>
6876 <dt>SQLITE_SCANSTAT_NCYCLE</dt>
6877 <dd>The sqlite3_int64 output value is set to the number of cycles,
6878 according to the processor time-stamp counter, that elapsed while the
6879 query element was being processed. This value is not available for
6880 all query elements - if it is unavailable the output variable is
6881 set to -1.
6882 </dl>
6883 </p><hr><a name="SQLITE_SHM_EXCLUSIVE"></a>
6884 <h2>Flags for the xShmLock VFS method</h2>
6885 </div>
6886 <blockquote><pre>
6887 #define SQLITE_SHM_UNLOCK 1
6888 #define SQLITE_SHM_LOCK 2
6889 #define SQLITE_SHM_SHARED 4
6890 #define SQLITE_SHM_EXCLUSIVE 8
6891 </pre></blockquote>
6892 <p>
6893 These integer constants define the various locking operations
6894 allowed by the xShmLock method of <a href="#sqlite3_io_methods">sqlite3_io_methods</a>. The
6895 following are the only legal combinations of flags to the
6896 xShmLock method:</p>
6897
6898 <p><ul>
6899 <li> SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
6900 <li> SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
6901 <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
6902 <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
6903 </ul></p>
6904
6905 <p>When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
6906 was given on the corresponding lock.</p>
6907
6908 <p>The xShmLock method can transition between unlocked and SHARED or
6909 between unlocked and EXCLUSIVE. It cannot transition between SHARED
6910 and EXCLUSIVE.
6911 </p><hr><a name="SQLITE_SOURCE_ID"></a>
6912 <h2>Compile-Time Library Version Numbers</h2>
6913 </div>
6914 <blockquote><pre>
6915 #define SQLITE_VERSION "3.46.1"
6916 #define SQLITE_VERSION_NUMBER 3046001
6917 #define SQLITE_SOURCE_ID "2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33"
6918 </pre></blockquote>
6919 <p>
6920 The <a href="#SQLITE_SOURCE_ID">SQLITE_VERSION</a> C preprocessor macro in the sqlite3.h header
6921 evaluates to a string literal that is the SQLite version in the
6922 format "X.Y.Z" where X is the major version number (always 3 for
6923 SQLite3) and Y is the minor version number and Z is the release number.
6924 The <a href="#SQLITE_SOURCE_ID">SQLITE_VERSION_NUMBER</a> C preprocessor macro resolves to an integer
6925 with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
6926 numbers used in <a href="#SQLITE_SOURCE_ID">SQLITE_VERSION</a>.
6927 The SQLITE_VERSION_NUMBER for any given release of SQLite will also
6928 be larger than the release from which it is derived. Either Y will
6929 be held constant and Z will be incremented or else Y will be incremented
6930 and Z will be reset to zero.</p>
6931
6932 <p>Since <a href="releaselog/3_6_18.html">version 3.6.18</a> (2009-09-11),
6933 SQLite source code has been stored in the
6934 <a href="http://www.fossil-scm.org/">Fossil configuration management
6935 system</a>. The SQLITE_SOURCE_ID macro evaluates to
6936 a string which identifies a particular check-in of SQLite
6937 within its configuration management system. The SQLITE_SOURCE_ID
6938 string contains the date and time of the check-in (UTC) and a SHA1
6939 or SHA3-256 hash of the entire source tree. If the source code has
6940 been edited in any way since it was last checked in, then the last
6941 four hexadecimal digits of the hash may be modified.</p>
6942
6943 <p>See also: <a href="#sqlite3_libversion">sqlite3_libversion()</a>,
6944 <a href="#sqlite3_libversion">sqlite3_libversion_number()</a>, <a href="#sqlite3_libversion">sqlite3_sourceid()</a>,
6945 <a href="lang_corefunc.html#sqlite_version">sqlite_version()</a> and <a href="lang_corefunc.html#sqlite_source_id">sqlite_source_id()</a>.
6946 </p><hr><a name="SQLITE_STATIC"></a>
6947 <h2>Constants Defining Special Destructor Behavior</h2>
6948 </div>
6949 <blockquote><pre>
6950 typedef void (*sqlite3_destructor_type)(void*);
6951 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
6952 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
6953 </pre></blockquote>
6954 <p>
6955 These are special values for the destructor that is passed in as the
6956 final argument to routines like <a href="#sqlite3_result_blob">sqlite3_result_blob()</a>. If the destructor
6957 argument is SQLITE_STATIC, it means that the content pointer is constant
6958 and will never change. It does not need to be destroyed. The
6959 SQLITE_TRANSIENT value means that the content will likely change in
6960 the near future and that SQLite should make its own private copy of
6961 the content before returning.</p>
6962
6963 <p>The typedef is necessary to work around problems in certain
6964 C++ compilers.
6965 </p><hr><a name="SQLITE_STATUS_MALLOC_COUNT"></a>
6966 <h2>Status Parameters</h2>
6967 </div>
6968 <blockquote><pre>
6969 #define SQLITE_STATUS_MEMORY_USED 0
6970 #define SQLITE_STATUS_PAGECACHE_USED 1
6971 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2
6972 #define SQLITE_STATUS_SCRATCH_USED 3 /* NOT USED */
6973 #define SQLITE_STATUS_SCRATCH_OVERFLOW 4 /* NOT USED */
6974 #define SQLITE_STATUS_MALLOC_SIZE 5
6975 #define SQLITE_STATUS_PARSER_STACK 6
6976 #define SQLITE_STATUS_PAGECACHE_SIZE 7
6977 #define SQLITE_STATUS_SCRATCH_SIZE 8 /* NOT USED */
6978 #define SQLITE_STATUS_MALLOC_COUNT 9
6979 </pre></blockquote>
6980 <p>
6981 These integer constants designate various run-time status parameters
6982 that can be returned by <a href="#sqlite3_status">sqlite3_status()</a>.</p>
6983
6984 <p><dl>
6985 <a name="sqlitestatusmemoryused"></a>
6986 <dt>SQLITE_STATUS_MEMORY_USED</dt>
6987 <dd>This parameter is the current amount of memory checked out
6988 using <a href="#sqlite3_free">sqlite3_malloc()</a>, either directly or indirectly. The
6989 figure includes calls made to <a href="#sqlite3_free">sqlite3_malloc()</a> by the application
6990 and internal memory usage by the SQLite library. Auxiliary page-cache
6991 memory controlled by <a href="#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a> is not included in
6992 this parameter. The amount returned is the sum of the allocation
6993 sizes as reported by the xSize method in <a href="#sqlite3_mem_methods">sqlite3_mem_methods</a>.</dd></p>
6994
6995 <p><a name="sqlitestatusmallocsize"></a>
6996 <dt>SQLITE_STATUS_MALLOC_SIZE</dt>
6997 <dd>This parameter records the largest memory allocation request
6998 handed to <a href="#sqlite3_free">sqlite3_malloc()</a> or <a href="#sqlite3_free">sqlite3_realloc()</a> (or their
6999 internal equivalents). Only the value returned in the
7000 *pHighwater parameter to <a href="#sqlite3_status">sqlite3_status()</a> is of interest.
7001 The value written into the *pCurrent parameter is undefined.</dd></p>
7002
7003 <p><a name="sqlitestatusmalloccount"></a>
7004 <dt>SQLITE_STATUS_MALLOC_COUNT</dt>
7005 <dd>This parameter records the number of separate memory allocations
7006 currently checked out.</dd></p>
7007
7008 <p><a name="sqlitestatuspagecacheused"></a>
7009 <dt>SQLITE_STATUS_PAGECACHE_USED</dt>
7010 <dd>This parameter returns the number of pages used out of the
7011 <a href="malloc.html#pagecache">pagecache memory allocator</a> that was configured using
7012 <a href="#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>. The
7013 value returned is in pages, not in bytes.</dd></p>
7014
7015 <p><a name="sqlitestatuspagecacheoverflow"></a>
7016
7017 <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
7018 <dd>This parameter returns the number of bytes of page cache
7019 allocation which could not be satisfied by the <a href="#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>
7020 buffer and where forced to overflow to <a href="#sqlite3_free">sqlite3_malloc()</a>. The
7021 returned value includes allocations that overflowed because they
7022 where too large (they were larger than the "sz" parameter to
7023 <a href="#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>) and allocations that overflowed because
7024 no space was left in the page cache.</dd></p>
7025
7026 <p><a name="sqlitestatuspagecachesize"></a>
7027 <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
7028 <dd>This parameter records the largest memory allocation request
7029 handed to the <a href="malloc.html#pagecache">pagecache memory allocator</a>. Only the value returned in the
7030 *pHighwater parameter to <a href="#sqlite3_status">sqlite3_status()</a> is of interest.
7031 The value written into the *pCurrent parameter is undefined.</dd></p>
7032
7033 <p><a name="sqlitestatusscratchused"></a>
7034 <dt>SQLITE_STATUS_SCRATCH_USED</dt>
7035 <dd>No longer used.</dd></p>
7036
7037 <p><a name="sqlitestatusscratchoverflow"></a>
7038 <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
7039 <dd>No longer used.</dd></p>
7040
7041 <p><a name="sqlitestatusscratchsize"></a>
7042 <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
7043 <dd>No longer used.</dd></p>
7044
7045 <p><a name="sqlitestatusparserstack"></a>
7046 <dt>SQLITE_STATUS_PARSER_STACK</dt>
7047 <dd>The *pHighwater parameter records the deepest parser stack.
7048 The *pCurrent value is undefined. The *pHighwater value is only
7049 meaningful if SQLite is compiled with <a href="compile.html#yytrackmaxstackdepth">YYTRACKMAXSTACKDEPTH</a>.</dd>
7050 </dl></p>
7051
7052 <p>New status parameters may be added from time to time.
7053 </p><hr><a name="SQLITE_SYNC_DATAONLY"></a>
7054 <h2>Synchronization Type Flags</h2>
7055 </div>
7056 <blockquote><pre>
7057 #define SQLITE_SYNC_NORMAL 0x00002
7058 #define SQLITE_SYNC_FULL 0x00003
7059 #define SQLITE_SYNC_DATAONLY 0x00010
7060 </pre></blockquote>
7061 <p>
7062 When SQLite invokes the xSync() method of an
7063 <a href="#sqlite3_io_methods">sqlite3_io_methods</a> object it uses a combination of
7064 these integer values as the second argument.</p>
7065
7066 <p>When the SQLITE_SYNC_DATAONLY flag is used, it means that the
7067 sync operation only needs to flush data to mass storage. Inode
7068 information need not be flushed. If the lower four bits of the flag
7069 equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
7070 If the lower four bits equal SQLITE_SYNC_FULL, that means
7071 to use Mac OS X style fullsync instead of fsync().</p>
7072
7073 <p>Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
7074 with the <a href="pragma.html#pragma_synchronous">PRAGMA synchronous</a>=NORMAL and <a href="pragma.html#pragma_synchronous">PRAGMA synchronous</a>=FULL
7075 settings. The <a href="pragma.html#pragma_synchronous">synchronous pragma</a> determines when calls to the
7076 xSync VFS method occur and applies uniformly across all platforms.
7077 The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
7078 energetic or rigorous or forceful the sync operations are and
7079 only make a difference on Mac OSX for the default SQLite code.
7080 (Third-party VFS implementations might also make the distinction
7081 between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
7082 operating systems natively supported by SQLite, only Mac OSX
7083 cares about the difference.)
7084 </p><hr><a name="SQLITE_TESTCTRL_ALWAYS"></a>
7085 <h2>Testing Interface Operation Codes</h2>
7086 </div>
7087 <blockquote><pre>
7088 #define SQLITE_TESTCTRL_FIRST 5
7089 #define SQLITE_TESTCTRL_PRNG_SAVE 5
7090 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
7091 #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
7092 #define SQLITE_TESTCTRL_FK_NO_ACTION 7
7093 #define SQLITE_TESTCTRL_BITVEC_TEST 8
7094 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
7095 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
7096 #define SQLITE_TESTCTRL_PENDING_BYTE 11
7097 #define SQLITE_TESTCTRL_ASSERT 12
7098 #define SQLITE_TESTCTRL_ALWAYS 13
7099 #define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */
7100 #define SQLITE_TESTCTRL_JSON_SELFCHECK 14
7101 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
7102 #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
7103 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
7104 #define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17
7105 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
7106 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
7107 #define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19
7108 #define SQLITE_TESTCTRL_NEVER_CORRUPT 20
7109 #define SQLITE_TESTCTRL_VDBE_COVERAGE 21
7110 #define SQLITE_TESTCTRL_BYTEORDER 22
7111 #define SQLITE_TESTCTRL_ISINIT 23
7112 #define SQLITE_TESTCTRL_SORTER_MMAP 24
7113 #define SQLITE_TESTCTRL_IMPOSTER 25
7114 #define SQLITE_TESTCTRL_PARSER_COVERAGE 26
7115 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
7116 #define SQLITE_TESTCTRL_PRNG_SEED 28
7117 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
7118 #define SQLITE_TESTCTRL_SEEK_COUNT 30
7119 #define SQLITE_TESTCTRL_TRACEFLAGS 31
7120 #define SQLITE_TESTCTRL_TUNE 32
7121 #define SQLITE_TESTCTRL_LOGEST 33
7122 #define SQLITE_TESTCTRL_USELONGDOUBLE 34
7123 #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
7124 </pre></blockquote>
7125 <p>
7126 These constants are the valid operation code parameters used
7127 as the first argument to <a href="#sqlite3_test_control">sqlite3_test_control()</a>.</p>
7128
7129 <p>These parameters and their meanings are subject to change
7130 without notice. These values are for testing purposes only.
7131 Applications should not use any of these parameters or the
7132 <a href="#sqlite3_test_control">sqlite3_test_control()</a> interface.
7133 </p><hr><a name="SQLITE_TRACE"></a>
7134 <h2>SQL Trace Event Codes</h2>
7135 </div>
7136 <blockquote><pre>
7137 #define SQLITE_TRACE_STMT 0x01
7138 #define SQLITE_TRACE_PROFILE 0x02
7139 #define SQLITE_TRACE_ROW 0x04
7140 #define SQLITE_TRACE_CLOSE 0x08
7141 </pre></blockquote>
7142 <p>
7143 These constants identify classes of events that can be monitored
7144 using the <a href="#sqlite3_trace_v2">sqlite3_trace_v2()</a> tracing logic. The M argument
7145 to <a href="#sqlite3_trace_v2">sqlite3_trace_v2(D,M,X,P)</a> is an OR-ed combination of one or more of
7146 the following constants. The first argument to the trace callback
7147 is one of the following constants.</p>
7148
7149 <p>New tracing constants may be added in future releases.</p>
7150
7151 <p>A trace callback has four arguments: xCallback(T,C,P,X).
7152 The T argument is one of the integer type codes above.
7153 The C argument is a copy of the context pointer passed in as the
7154 fourth argument to <a href="#sqlite3_trace_v2">sqlite3_trace_v2()</a>.
7155 The P and X arguments are pointers whose meanings depend on T.</p>
7156
7157 <p><dl>
7158 <a name="sqlitetracestmt"></a>
7159 <dt>SQLITE_TRACE_STMT</dt>
7160 <dd>An SQLITE_TRACE_STMT callback is invoked when a prepared statement
7161 first begins running and possibly at other times during the
7162 execution of the prepared statement, such as at the start of each
7163 trigger subprogram. The P argument is a pointer to the
7164 <a href="#sqlite3_stmt">prepared statement</a>. The X argument is a pointer to a string which
7165 is the unexpanded SQL text of the prepared statement or an SQL comment
7166 that indicates the invocation of a trigger. The callback can compute
7167 the same text that would have been returned by the legacy <a href="#sqlite3_profile">sqlite3_trace()</a>
7168 interface by using the X argument when X begins with "--" and invoking
7169 <a href="#sqlite3_expanded_sql">sqlite3_expanded_sql(P)</a> otherwise.</p>
7170
7171 <p><a name="sqlitetraceprofile"></a>
7172 <dt>SQLITE_TRACE_PROFILE</dt>
7173 <dd>An SQLITE_TRACE_PROFILE callback provides approximately the same
7174 information as is provided by the <a href="#sqlite3_profile">sqlite3_profile()</a> callback.
7175 The P argument is a pointer to the <a href="#sqlite3_stmt">prepared statement</a> and the
7176 X argument points to a 64-bit integer which is approximately
7177 the number of nanoseconds that the prepared statement took to run.
7178 The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.</p>
7179
7180 <p><a name="sqlitetracerow"></a>
7181 <dt>SQLITE_TRACE_ROW</dt>
7182 <dd>An SQLITE_TRACE_ROW callback is invoked whenever a prepared
7183 statement generates a single row of result.
7184 The P argument is a pointer to the <a href="#sqlite3_stmt">prepared statement</a> and the
7185 X argument is unused.</p>
7186
7187 <p><a name="sqlitetraceclose"></a>
7188 <dt>SQLITE_TRACE_CLOSE</dt>
7189 <dd>An SQLITE_TRACE_CLOSE callback is invoked when a database
7190 connection closes.
7191 The P argument is a pointer to the <a href="#sqlite3">database connection</a> object
7192 and the X argument is unused.
7193 </dl>
7194 </p><hr><a name="SQLITE_TXN_NONE"></a>
7195 <h2>Allowed return values from sqlite3_txn_state()</h2>
7196 </div>
7197 <blockquote><pre>
7198 #define SQLITE_TXN_NONE 0
7199 #define SQLITE_TXN_READ 1
7200 #define SQLITE_TXN_WRITE 2
7201 </pre></blockquote>
7202 <p>
7203 These constants define the current transaction state of a database file.
7204 The <a href="#sqlite3_txn_state">sqlite3_txn_state(D,S)</a> interface returns one of these
7205 constants in order to describe the transaction state of schema S
7206 in <a href="#sqlite3">database connection</a> D.</p>
7207
7208 <p><dl>
7209 <a name="sqlitetxnnone"></a>
7210 <dt>SQLITE_TXN_NONE</dt>
7211 <dd>The SQLITE_TXN_NONE state means that no transaction is currently
7212 pending.</dd></p>
7213
7214 <p><a name="sqlitetxnread"></a>
7215 <dt>SQLITE_TXN_READ</dt>
7216 <dd>The SQLITE_TXN_READ state means that the database is currently
7217 in a read transaction. Content has been read from the database file
7218 but nothing in the database file has changed. The transaction state
7219 will advanced to SQLITE_TXN_WRITE if any changes occur and there are
7220 no other conflicting concurrent write transactions. The transaction
7221 state will revert to SQLITE_TXN_NONE following a <a href="lang_transaction.html">ROLLBACK</a> or
7222 <a href="lang_transaction.html">COMMIT</a>.</dd></p>
7223
7224 <p><a name="sqlitetxnwrite"></a>
7225 <dt>SQLITE_TXN_WRITE</dt>
7226 <dd>The SQLITE_TXN_WRITE state means that the database is currently
7227 in a write transaction. Content has been written to the database file
7228 but has not yet committed. The transaction state will change to
7229 to SQLITE_TXN_NONE at the next <a href="lang_transaction.html">ROLLBACK</a> or <a href="lang_transaction.html">COMMIT</a>.</dd>
7230 </p><hr><a name="SQLITE_VTAB_CONSTRAINT_SUPPORT"></a>
7231 <h2>Virtual Table Configuration Options</h2>
7232 </div>
7233 <blockquote><pre>
7234 #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
7235 #define SQLITE_VTAB_INNOCUOUS 2
7236 #define SQLITE_VTAB_DIRECTONLY 3
7237 #define SQLITE_VTAB_USES_ALL_SCHEMAS 4
7238 </pre></blockquote>
7239 <p>
7240 These macros define the various options to the
7241 <a href="#sqlite3_vtab_config">sqlite3_vtab_config()</a> interface that <a href="vtab.html">virtual table</a> implementations
7242 can use to customize and optimize their behavior.</p>
7243
7244 <p><dl>
7245 <a name="sqlitevtabconstraintsupport"></a>
7246
7247 <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT</dt>
7248 <dd>Calls of the form
7249 <a href="#sqlite3_vtab_config">sqlite3_vtab_config</a>(db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
7250 where X is an integer. If X is zero, then the <a href="vtab.html">virtual table</a> whose
7251 <a href="vtab.html#xcreate">xCreate</a> or <a href="vtab.html#xconnect">xConnect</a> method invoked <a href="#sqlite3_vtab_config">sqlite3_vtab_config()</a> does not
7252 support constraints. In this configuration (which is the default) if
7253 a call to the <a href="vtab.html#xupdate">xUpdate</a> method returns <a href="#SQLITE_ABORT">SQLITE_CONSTRAINT</a>, then the entire
7254 statement is rolled back as if <a href="lang_conflict.html">OR ABORT</a> had been
7255 specified as part of the users SQL statement, regardless of the actual
7256 ON CONFLICT mode specified.</p>
7257
7258 <p>If X is non-zero, then the virtual table implementation guarantees
7259 that if <a href="vtab.html#xupdate">xUpdate</a> returns <a href="#SQLITE_ABORT">SQLITE_CONSTRAINT</a>, it will do so before
7260 any modifications to internal or persistent data structures have been made.
7261 If the <a href="lang_conflict.html">ON CONFLICT</a> mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite
7262 is able to roll back a statement or database transaction, and abandon
7263 or continue processing the current SQL statement as appropriate.
7264 If the ON CONFLICT mode is REPLACE and the <a href="vtab.html#xupdate">xUpdate</a> method returns
7265 <a href="#SQLITE_ABORT">SQLITE_CONSTRAINT</a>, SQLite handles this as if the ON CONFLICT mode
7266 had been ABORT.</p>
7267
7268 <p>Virtual table implementations that are required to handle OR REPLACE
7269 must do so within the <a href="vtab.html#xupdate">xUpdate</a> method. If a call to the
7270 <a href="#sqlite3_vtab_on_conflict">sqlite3_vtab_on_conflict()</a> function indicates that the current ON
7271 CONFLICT policy is REPLACE, the virtual table implementation should
7272 silently replace the appropriate rows within the xUpdate callback and
7273 return SQLITE_OK. Or, if this is not possible, it may return
7274 SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT
7275 constraint handling.
7276 </dd></p>
7277
7278 <p><a name="sqlitevtabdirectonly"></a>
7279 <dt>SQLITE_VTAB_DIRECTONLY</dt>
7280 <dd>Calls of the form
7281 <a href="#sqlite3_vtab_config">sqlite3_vtab_config</a>(db,SQLITE_VTAB_DIRECTONLY) from within the
7282 the <a href="vtab.html#xconnect">xConnect</a> or <a href="vtab.html#xcreate">xCreate</a> methods of a <a href="vtab.html">virtual table</a> implementation
7283 prohibits that virtual table from being used from within triggers and
7284 views.
7285 </dd></p>
7286
7287 <p><a name="sqlitevtabinnocuous"></a>
7288 <dt>SQLITE_VTAB_INNOCUOUS</dt>
7289 <dd>Calls of the form
7290 <a href="#sqlite3_vtab_config">sqlite3_vtab_config</a>(db,SQLITE_VTAB_INNOCUOUS) from within the
7291 the <a href="vtab.html#xconnect">xConnect</a> or <a href="vtab.html#xcreate">xCreate</a> methods of a <a href="vtab.html">virtual table</a> implementation
7292 identify that virtual table as being safe to use from within triggers
7293 and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
7294 virtual table can do no serious harm even if it is controlled by a
7295 malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
7296 flag unless absolutely necessary.
7297 </dd></p>
7298
7299 <p><a name="sqlitevtabusesallschemas"></a>
7300 <dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
7301 <dd>Calls of the form
7302 <a href="#sqlite3_vtab_config">sqlite3_vtab_config</a>(db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
7303 the <a href="vtab.html#xconnect">xConnect</a> or <a href="vtab.html#xcreate">xCreate</a> methods of a <a href="vtab.html">virtual table</a> implementation
7304 instruct the query planner to begin at least a read transaction on
7305 all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
7306 virtual table is used.
7307 </dd>
7308 </dl>
7309 </p><hr><a name="SQLITE_WIN32_DATA_DIRECTORY_TYPE"></a>
7310 <h2>Win32 Directory Types</h2>
7311 </div>
7312 <blockquote><pre>
7313 #define SQLITE_WIN32_DATA_DIRECTORY_TYPE 1
7314 #define SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2
7315 </pre></blockquote>
7316 <p>
7317 These macros are only available on Windows. They define the allowed values
7318 for the type argument to the <a href="#sqlite3_win32_set_directory">sqlite3_win32_set_directory</a> interface.
7319 </p><hr><a name="SQLITE_LIMIT_ATTACHED"></a>
7320 <h2>Run-Time Limit Categories</h2>
7321 </div>
7322 <blockquote><pre>
7323 #define SQLITE_LIMIT_LENGTH 0
7324 #define SQLITE_LIMIT_SQL_LENGTH 1
7325 #define SQLITE_LIMIT_COLUMN 2
7326 #define SQLITE_LIMIT_EXPR_DEPTH 3
7327 #define SQLITE_LIMIT_COMPOUND_SELECT 4
7328 #define SQLITE_LIMIT_VDBE_OP 5
7329 #define SQLITE_LIMIT_FUNCTION_ARG 6
7330 #define SQLITE_LIMIT_ATTACHED 7
7331 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
7332 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
7333 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
7334 #define SQLITE_LIMIT_WORKER_THREADS 11
7335 </pre></blockquote>
7336 <p>
7337 These constants define various performance limits
7338 that can be lowered at run-time using <a href="#sqlite3_limit">sqlite3_limit()</a>.
7339 The synopsis of the meanings of the various limits is shown below.
7340 Additional information is available at <a href="limits.html">Limits in SQLite</a>.</p>
7341
7342 <p><dl>
7343 <a name="sqlitelimitlength"></a>
7344 <dt>SQLITE_LIMIT_LENGTH</dt>
7345 <dd>The maximum size of any string or BLOB or table row, in bytes.<dd></p>
7346
7347 <p><a name="sqlitelimitsqllength"></a>
7348 <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
7349 <dd>The maximum length of an SQL statement, in bytes.</dd></p>
7350
7351 <p><a name="sqlitelimitcolumn"></a>
7352 <dt>SQLITE_LIMIT_COLUMN</dt>
7353 <dd>The maximum number of columns in a table definition or in the
7354 result set of a <a href="lang_select.html">SELECT</a> or the maximum number of columns in an index
7355 or in an ORDER BY or GROUP BY clause.</dd></p>
7356
7357 <p><a name="sqlitelimitexprdepth"></a>
7358 <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
7359 <dd>The maximum depth of the parse tree on any expression.</dd></p>
7360
7361 <p><a name="sqlitelimitcompoundselect"></a>
7362 <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
7363 <dd>The maximum number of terms in a compound SELECT statement.</dd></p>
7364
7365 <p><a name="sqlitelimitvdbeop"></a>
7366 <dt>SQLITE_LIMIT_VDBE_OP</dt>
7367 <dd>The maximum number of instructions in a virtual machine program
7368 used to implement an SQL statement. If <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> or
7369 the equivalent tries to allocate space for more than this many opcodes
7370 in a single prepared statement, an SQLITE_NOMEM error is returned.</dd></p>
7371
7372 <p><a name="sqlitelimitfunctionarg"></a>
7373 <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
7374 <dd>The maximum number of arguments on a function.</dd></p>
7375
7376 <p><a name="sqlitelimitattached"></a>
7377 <dt>SQLITE_LIMIT_ATTACHED</dt>
7378 <dd>The maximum number of <a href="lang_attach.html">attached databases</a>.</dd></p>
7379
7380 <p><a name="sqlitelimitlikepatternlength"></a>
7381
7382 <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
7383 <dd>The maximum length of the pattern argument to the <a href="lang_expr.html#like">LIKE</a> or
7384 <a href="lang_expr.html#glob">GLOB</a> operators.</dd></p>
7385
7386 <p><a name="sqlitelimitvariablenumber"></a>
7387
7388 <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
7389 <dd>The maximum index number of any <a href="lang_expr.html#varparam">parameter</a> in an SQL statement.</p>
7390
7391 <p><a name="sqlitelimittriggerdepth"></a>
7392 <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
7393 <dd>The maximum depth of recursion for triggers.</dd></p>
7394
7395 <p><a name="sqlitelimitworkerthreads"></a>
7396 <dt>SQLITE_LIMIT_WORKER_THREADS</dt>
7397 <dd>The maximum number of auxiliary worker threads that a single
7398 <a href="#sqlite3_stmt">prepared statement</a> may start.</dd>
7399 </dl>
7400 </p><hr><a name="SQLITE_DBSTATUS options"></a>
7401 <h2>Status Parameters for database connections</h2>
7402 </div>
7403 <blockquote><pre>
7404 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
7405 #define SQLITE_DBSTATUS_CACHE_USED 1
7406 #define SQLITE_DBSTATUS_SCHEMA_USED 2
7407 #define SQLITE_DBSTATUS_STMT_USED 3
7408 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
7409 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
7410 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
7411 #define SQLITE_DBSTATUS_CACHE_HIT 7
7412 #define SQLITE_DBSTATUS_CACHE_MISS 8
7413 #define SQLITE_DBSTATUS_CACHE_WRITE 9
7414 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
7415 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
7416 #define SQLITE_DBSTATUS_CACHE_SPILL 12
7417 #define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */
7418 </pre></blockquote>
7419 <p>
7420 These constants are the available integer "verbs" that can be passed as
7421 the second argument to the <a href="#sqlite3_db_status">sqlite3_db_status()</a> interface.</p>
7422
7423 <p>New verbs may be added in future releases of SQLite. Existing verbs
7424 might be discontinued. Applications should check the return code from
7425 <a href="#sqlite3_db_status">sqlite3_db_status()</a> to make sure that the call worked.
7426 The <a href="#sqlite3_db_status">sqlite3_db_status()</a> interface will return a non-zero error code
7427 if a discontinued or unsupported verb is invoked.</p>
7428
7429 <p><dl>
7430 <a name="sqlitedbstatuslookasideused"></a>
7431 <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
7432 <dd>This parameter returns the number of lookaside memory slots currently
7433 checked out.</dd></p>
7434
7435 <p><a name="sqlitedbstatuslookasidehit"></a>
7436 <dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
7437 <dd>This parameter returns the number of malloc attempts that were
7438 satisfied using lookaside memory. Only the high-water value is meaningful;
7439 the current value is always zero.</p>
7440
7441 <p><a name="sqlitedbstatuslookasidemisssize"></a>
7442
7443 <dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
7444 <dd>This parameter returns the number malloc attempts that might have
7445 been satisfied using lookaside memory but failed due to the amount of
7446 memory requested being larger than the lookaside slot size.
7447 Only the high-water value is meaningful;
7448 the current value is always zero.</p>
7449
7450 <p><a name="sqlitedbstatuslookasidemissfull"></a>
7451
7452 <dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
7453 <dd>This parameter returns the number malloc attempts that might have
7454 been satisfied using lookaside memory but failed due to all lookaside
7455 memory already being in use.
7456 Only the high-water value is meaningful;
7457 the current value is always zero.</p>
7458
7459 <p><a name="sqlitedbstatuscacheused"></a>
7460 <dt>SQLITE_DBSTATUS_CACHE_USED</dt>
7461 <dd>This parameter returns the approximate number of bytes of heap
7462 memory used by all pager caches associated with the database connection.
7463 The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.</p>
7464
7465 <p><a name="sqlitedbstatuscacheusedshared"></a>
7466
7467 <dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
7468 <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
7469 pager cache is shared between two or more connections the bytes of heap
7470 memory used by that pager cache is divided evenly between the attached
7471 connections. In other words, if none of the pager caches associated
7472 with the database connection are shared, this request returns the same
7473 value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
7474 shared, the value returned by this call will be smaller than that returned
7475 by DBSTATUS_CACHE_USED. The highwater mark associated with
7476 SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.</p>
7477
7478 <p><a name="sqlitedbstatusschemaused"></a>
7479 <dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
7480 <dd>This parameter returns the approximate number of bytes of heap
7481 memory used to store the schema for all databases associated
7482 with the connection - main, temp, and any <a href="lang_attach.html">ATTACH</a>-ed databases.
7483 The full amount of memory used by the schemas is reported, even if the
7484 schema memory is shared with other database connections due to
7485 <a href="sharedcache.html">shared cache mode</a> being enabled.
7486 The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.</p>
7487
7488 <p><a name="sqlitedbstatusstmtused"></a>
7489 <dt>SQLITE_DBSTATUS_STMT_USED</dt>
7490 <dd>This parameter returns the approximate number of bytes of heap
7491 and lookaside memory used by all prepared statements associated with
7492 the database connection.
7493 The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
7494 </dd></p>
7495
7496 <p><a name="sqlitedbstatuscachehit"></a>
7497 <dt>SQLITE_DBSTATUS_CACHE_HIT</dt>
7498 <dd>This parameter returns the number of pager cache hits that have
7499 occurred. The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT
7500 is always 0.
7501 </dd></p>
7502
7503 <p><a name="sqlitedbstatuscachemiss"></a>
7504 <dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
7505 <dd>This parameter returns the number of pager cache misses that have
7506 occurred. The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
7507 is always 0.
7508 </dd></p>
7509
7510 <p><a name="sqlitedbstatuscachewrite"></a>
7511 <dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
7512 <dd>This parameter returns the number of dirty cache entries that have
7513 been written to disk. Specifically, the number of pages written to the
7514 wal file in wal mode databases, or the number of pages written to the
7515 database file in rollback mode databases. Any pages written as part of
7516 transaction rollback or database recovery operations are not included.
7517 If an IO or other error occurs while writing a page to disk, the effect
7518 on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined. The
7519 highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
7520 </dd></p>
7521
7522 <p><a name="sqlitedbstatuscachespill"></a>
7523 <dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
7524 <dd>This parameter returns the number of dirty cache entries that have
7525 been written to disk in the middle of a transaction due to the page
7526 cache overflowing. Transactions are more efficient if they are written
7527 to disk all at once. When pages spill mid-transaction, that introduces
7528 additional overhead. This parameter can be used help identify
7529 inefficiencies that can be resolved by increasing the cache size.
7530 </dd></p>
7531
7532 <p><a name="sqlitedbstatusdeferredfks"></a>
7533 <dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
7534 <dd>This parameter returns zero for the current value if and only if
7535 all foreign key constraints (deferred or immediate) have been
7536 resolved. The highwater mark is always 0.
7537 </dd>
7538 </dl>
7539 </p><hr><a name="SQLITE_STMTSTATUS counter"></a>
7540 <h2>Status Parameters for prepared statements</h2>
7541 </div>
7542 <blockquote><pre>
7543 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
7544 #define SQLITE_STMTSTATUS_SORT 2
7545 #define SQLITE_STMTSTATUS_AUTOINDEX 3
7546 #define SQLITE_STMTSTATUS_VM_STEP 4
7547 #define SQLITE_STMTSTATUS_REPREPARE 5
7548 #define SQLITE_STMTSTATUS_RUN 6
7549 #define SQLITE_STMTSTATUS_FILTER_MISS 7
7550 #define SQLITE_STMTSTATUS_FILTER_HIT 8
7551 #define SQLITE_STMTSTATUS_MEMUSED 99
7552 </pre></blockquote>
7553 <p>
7554 These preprocessor macros define integer codes that name counter
7555 values associated with the <a href="#sqlite3_stmt_status">sqlite3_stmt_status()</a> interface.
7556 The meanings of the various counters are as follows:</p>
7557
7558 <p><dl>
7559 <a name="sqlitestmtstatusfullscanstep"></a>
7560 <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
7561 <dd>This is the number of times that SQLite has stepped forward in
7562 a table as part of a full table scan. Large numbers for this counter
7563 may indicate opportunities for performance improvement through
7564 careful use of indices.</dd></p>
7565
7566 <p><a name="sqlitestmtstatussort"></a>
7567 <dt>SQLITE_STMTSTATUS_SORT</dt>
7568 <dd>This is the number of sort operations that have occurred.
7569 A non-zero value in this counter may indicate an opportunity to
7570 improvement performance through careful use of indices.</dd></p>
7571
7572 <p><a name="sqlitestmtstatusautoindex"></a>
7573 <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
7574 <dd>This is the number of rows inserted into transient indices that
7575 were created automatically in order to help joins run faster.
7576 A non-zero value in this counter may indicate an opportunity to
7577 improvement performance by adding permanent indices that do not
7578 need to be reinitialized each time the statement is run.</dd></p>
7579
7580 <p><a name="sqlitestmtstatusvmstep"></a>
7581 <dt>SQLITE_STMTSTATUS_VM_STEP</dt>
7582 <dd>This is the number of virtual machine operations executed
7583 by the prepared statement if that number is less than or equal
7584 to 2147483647. The number of virtual machine operations can be
7585 used as a proxy for the total work done by the prepared statement.
7586 If the number of virtual machine operations exceeds 2147483647
7587 then the value returned by this statement status code is undefined.</p>
7588
7589 <p><a name="sqlitestmtstatusreprepare"></a>
7590 <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
7591 <dd>This is the number of times that the prepare statement has been
7592 automatically regenerated due to schema changes or changes to
7593 <a href="lang_expr.html#varparam">bound parameters</a> that might affect the query plan.</p>
7594
7595 <p><a name="sqlitestmtstatusrun"></a>
7596 <dt>SQLITE_STMTSTATUS_RUN</dt>
7597 <dd>This is the number of times that the prepared statement has
7598 been run. A single "run" for the purposes of this counter is one
7599 or more calls to <a href="#sqlite3_step">sqlite3_step()</a> followed by a call to <a href="#sqlite3_reset">sqlite3_reset()</a>.
7600 The counter is incremented on the first <a href="#sqlite3_step">sqlite3_step()</a> call of each
7601 cycle.</p>
7602
7603 <p><a name="sqlitestmtstatusfiltermiss"></a>
7604
7605 <a name="sqlitestmtstatusfilterhit"></a>
7606
7607 <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
7608 SQLITE_STMTSTATUS_FILTER_MISS</dt>
7609 <dd>SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
7610 step was bypassed because a Bloom filter returned not-found. The
7611 corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
7612 times that the Bloom filter returned a find, and thus the join step
7613 had to be processed as normal.</p>
7614
7615 <p><a name="sqlitestmtstatusmemused"></a>
7616 <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
7617 <dd>This is the approximate number of bytes of heap memory
7618 used to store the prepared statement. This value is not actually
7619 a counter, and so the resetFlg parameter to sqlite3_stmt_status()
7620 is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.
7621 </dd>
7622 </dl>
7623 </p><hr><a name="sqlite3_snapshot"></a>
7624 <h2>Database Snapshot</h2>
7625 </div>
7626 <blockquote><pre>
7627 typedef struct sqlite3_snapshot {
7628 unsigned char hidden[48];
7629 } sqlite3_snapshot;
7630 </pre></blockquote>
7631 <p>
7632 An instance of the snapshot object records the state of a <a href="wal.html">WAL mode</a>
7633 database for some specific point in history.</p>
7634
7635 <p>In <a href="wal.html">WAL mode</a>, multiple <a href="#sqlite3">database connections</a> that are open on the
7636 same database file can each be reading a different historical version
7637 of the database file. When a <a href="#sqlite3">database connection</a> begins a read
7638 transaction, that connection sees an unchanging copy of the database
7639 as it existed for the point in time when the transaction first started.
7640 Subsequent changes to the database from other connections are not seen
7641 by the reader until a new read transaction is started.</p>
7642
7643 <p>The sqlite3_snapshot object records state information about an historical
7644 version of the database file so that it is possible to later open a new read
7645 transaction that sees that historical version of the database rather than
7646 the most recent version.
7647 </p><p>1 Constructor using this object: <a href="#sqlite3_snapshot_get">sqlite3_snapshot_get()</a></p>
7648 <p>1 Destructor using this object: <a href="#sqlite3_snapshot_free">sqlite3_snapshot_free()</a></p>
7649 <p>3 Methods using this object:
7650 <a href="#sqlite3_snapshot_cmp">sqlite3_snapshot_cmp()</a>,
7651 <a href="#sqlite3_snapshot_open">sqlite3_snapshot_open()</a>,
7652 <a href="#sqlite3_snapshot_recover">sqlite3_snapshot_recover()</a></p>
7653 <hr><a name="sqlite3_int64"></a>
7654 <h2>64-Bit Integer Types</h2>
7655 </div>
7656 <blockquote><pre>
7657 #ifdef SQLITE_INT64_TYPE
7658 typedef SQLITE_INT64_TYPE sqlite_int64;
7659 # ifdef SQLITE_UINT64_TYPE
7660 typedef SQLITE_UINT64_TYPE sqlite_uint64;
7661 # else
7662 typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
7663 # endif
7664 #elif defined(_MSC_VER) || defined(__BORLANDC__)
7665 typedef __int64 sqlite_int64;
7666 typedef unsigned __int64 sqlite_uint64;
7667 #else
7668 typedef long long int sqlite_int64;
7669 typedef unsigned long long int sqlite_uint64;
7670 #endif
7671 typedef sqlite_int64 sqlite3_int64;
7672 typedef sqlite_uint64 sqlite3_uint64;
7673 </pre></blockquote>
7674 <p>
7675 Because there is no cross-platform way to specify 64-bit integer types
7676 SQLite includes typedefs for 64-bit signed and unsigned integers.</p>
7677
7678 <p>The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
7679 The sqlite_int64 and sqlite_uint64 types are supported for backwards
7680 compatibility only.</p>
7681
7682 <p>The sqlite3_int64 and sqlite_int64 types can store integer values
7683 between -9223372036854775808 and +9223372036854775807 inclusive. The
7684 sqlite3_uint64 and sqlite_uint64 types can store integer values
7685 between 0 and +18446744073709551615 inclusive.
7686 </p><hr><a name="sqlite3_module"></a>
7687 <h2>Virtual Table Object</h2>
7688 </div>
7689 <blockquote><pre>
7690 struct sqlite3_module {
7691 int iVersion;
7692 int (*xCreate)(sqlite3*, void *pAux,
7693 int argc, const char *const*argv,
7694 sqlite3_vtab **ppVTab, char**);
7695 int (*xConnect)(sqlite3*, void *pAux,
7696 int argc, const char *const*argv,
7697 sqlite3_vtab **ppVTab, char**);
7698 int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
7699 int (*xDisconnect)(sqlite3_vtab *pVTab);
7700 int (*xDestroy)(sqlite3_vtab *pVTab);
7701 int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
7702 int (*xClose)(sqlite3_vtab_cursor*);
7703 int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
7704 int argc, sqlite3_value **argv);
7705 int (*xNext)(sqlite3_vtab_cursor*);
7706 int (*xEof)(sqlite3_vtab_cursor*);
7707 int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
7708 int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
7709 int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
7710 int (*xBegin)(sqlite3_vtab *pVTab);
7711 int (*xSync)(sqlite3_vtab *pVTab);
7712 int (*xCommit)(sqlite3_vtab *pVTab);
7713 int (*xRollback)(sqlite3_vtab *pVTab);
7714 int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
7715 void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
7716 void **ppArg);
7717 int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
7718 /* The methods above are in version 1 of the sqlite_module object. Those
7719 ** below are for version 2 and greater. */
7720 int (*xSavepoint)(sqlite3_vtab *pVTab, int);
7721 int (*xRelease)(sqlite3_vtab *pVTab, int);
7722 int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
7723 /* The methods above are in versions 1 and 2 of the sqlite_module object.
7724 ** Those below are for version 3 and greater. */
7725 int (*xShadowName)(const char*);
7726 /* The methods above are in versions 1 through 3 of the sqlite_module object.
7727 ** Those below are for version 4 and greater. */
7728 int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema,
7729 const char *zTabName, int mFlags, char **pzErr);
7730 };
7731 </pre></blockquote>
7732 <p>
7733 This structure, sometimes called a "virtual table module",
7734 defines the implementation of a <a href="vtab.html">virtual table</a>.
7735 This structure consists mostly of methods for the module.</p>
7736
7737 <p>A virtual table module is created by filling in a persistent
7738 instance of this structure and passing a pointer to that instance
7739 to <a href="#sqlite3_create_module">sqlite3_create_module()</a> or <a href="#sqlite3_create_module">sqlite3_create_module_v2()</a>.
7740 The registration remains valid until it is replaced by a different
7741 module or until the <a href="#sqlite3">database connection</a> closes. The content
7742 of this structure must not change while it is registered with
7743 any database connection.
7744 </p><hr><a name="sqlite3_vtab_cursor"></a>
7745 <h2>Virtual Table Cursor Object</h2>
7746 </div>
7747 <blockquote><pre>
7748 struct sqlite3_vtab_cursor {
7749 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
7750 /* Virtual table implementations will typically add additional fields */
7751 };
7752 </pre></blockquote>
7753 <p>
7754 Every <a href="#sqlite3_module">virtual table module</a> implementation uses a subclass of the
7755 following structure to describe cursors that point into the
7756 <a href="vtab.html">virtual table</a> and are used
7757 to loop through the virtual table. Cursors are created using the
7758 <a href="vtab.html#xopen">xOpen</a> method of the module and are destroyed
7759 by the <a href="vtab.html#xclose">xClose</a> method. Cursors are used
7760 by the <a href="vtab.html#xfilter">xFilter</a>, <a href="vtab.html#xnext">xNext</a>, <a href="vtab.html#xeof">xEof</a>, <a href="vtab.html#xcolumn">xColumn</a>, and <a href="vtab.html#xrowid">xRowid</a> methods
7761 of the module. Each module implementation will define
7762 the content of a cursor structure to suit its own needs.</p>
7763
7764 <p>This superclass exists in order to define fields of the cursor that
7765 are common to all implementations.
7766 </p><hr><a name="sqlite3_blob"></a>
7767 <h2>A Handle To An Open BLOB</h2>
7768 </div>
7769 <blockquote><pre>
7770 typedef struct sqlite3_blob sqlite3_blob;
7771 </pre></blockquote>
7772 <p>
7773 An instance of this object represents an open BLOB on which
7774 <a href="#sqlite3_blob_open">incremental BLOB I/O</a> can be performed.
7775 Objects of this type are created by <a href="#sqlite3_blob_open">sqlite3_blob_open()</a>
7776 and destroyed by <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>.
7777 The <a href="#sqlite3_blob_read">sqlite3_blob_read()</a> and <a href="#sqlite3_blob_write">sqlite3_blob_write()</a> interfaces
7778 can be used to read or write small subsections of the BLOB.
7779 The <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a> interface returns the size of the BLOB in bytes.
7780 </p><p>1 Constructor using this object: <a href="#sqlite3_blob_open">sqlite3_blob_open()</a></p>
7781 <p>1 Destructor using this object: <a href="#sqlite3_blob_close">sqlite3_blob_close()</a></p>
7782 <p>4 Methods using this object:
7783 <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a>,
7784 <a href="#sqlite3_blob_read">sqlite3_blob_read()</a>,
7785 <a href="#sqlite3_blob_reopen">sqlite3_blob_reopen()</a>,
7786 <a href="#sqlite3_blob_write">sqlite3_blob_write()</a></p>
7787 <hr><a name="sqlite3"></a>
7788 <h2>Database Connection Handle</h2>
7789 </div>
7790 <blockquote><pre>
7791 typedef struct sqlite3 sqlite3;
7792 </pre></blockquote>
7793 <p>
7794 Each open SQLite database is represented by a pointer to an instance of
7795 the opaque structure named "sqlite3". It is useful to think of an sqlite3
7796 pointer as an object. The <a href="#sqlite3_open">sqlite3_open()</a>, <a href="#sqlite3_open">sqlite3_open16()</a>, and
7797 <a href="#sqlite3_open">sqlite3_open_v2()</a> interfaces are its constructors, and <a href="#sqlite3_close">sqlite3_close()</a>
7798 and <a href="#sqlite3_close">sqlite3_close_v2()</a> are its destructors. There are many other
7799 interfaces (such as
7800 <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>, <a href="#sqlite3_create_function">sqlite3_create_function()</a>, and
7801 <a href="#sqlite3_busy_timeout">sqlite3_busy_timeout()</a> to name but three) that are methods on an
7802 sqlite3 object.
7803 </p><p>3 Constructors using this object:
7804 <a href="#sqlite3_open">sqlite3_open()</a>,
7805 <a href="#sqlite3_open">sqlite3_open16()</a>,
7806 <a href="#sqlite3_open">sqlite3_open_v2()</a></p>
7807 <p>2 Destructors using this object:
7808 <a href="#sqlite3_close">sqlite3_close()</a>,
7809 <a href="#sqlite3_close">sqlite3_close_v2()</a></p>
7810 <p>77 Methods using this object:
7811 <div class='columns' style='columns: 17em auto;'>
7812 <ul style='padding-top:0;'>
7813 <li><a href='#sqlite3_autovacuum_pages'>sqlite3_autovacuum_pages</a></li>
7814 <li><a href='#sqlite3_blob_open'>sqlite3_blob_open</a></li>
7815 <li><a href='#sqlite3_busy_handler'>sqlite3_busy_handler</a></li>
7816 <li><a href='#sqlite3_busy_timeout'>sqlite3_busy_timeout</a></li>
7817 <li><a href='#sqlite3_changes'>sqlite3_changes</a></li>
7818 <li><a href='#sqlite3_changes'>sqlite3_changes64</a></li>
7819 <li><a href='#sqlite3_collation_needed'>sqlite3_collation_needed</a></li>
7820 <li><a href='#sqlite3_collation_needed'>sqlite3_collation_needed16</a></li>
7821 <li><a href='#sqlite3_commit_hook'>sqlite3_commit_hook</a></li>
7822 <li><a href='#sqlite3_create_collation'>sqlite3_create_collation</a></li>
7823 <li><a href='#sqlite3_create_collation'>sqlite3_create_collation16</a></li>
7824 <li><a href='#sqlite3_create_collation'>sqlite3_create_collation_v2</a></li>
7825 <li><a href='#sqlite3_create_function'>sqlite3_create_function</a></li>
7826 <li><a href='#sqlite3_create_function'>sqlite3_create_function16</a></li>
7827 <li><a href='#sqlite3_create_function'>sqlite3_create_function_v2</a></li>
7828 <li><a href='#sqlite3_create_module'>sqlite3_create_module</a></li>
7829 <li><a href='#sqlite3_create_module'>sqlite3_create_module_v2</a></li>
7830 <li><a href='#sqlite3_create_function'>sqlite3_create_window_function</a></li>
7831 <li><a href='#sqlite3_db_cacheflush'>sqlite3_db_cacheflush</a></li>
7832 <li><a href='#sqlite3_db_config'>sqlite3_db_config</a></li>
7833 <li><a href='#sqlite3_db_filename'>sqlite3_db_filename</a></li>
7834 <li><a href='#sqlite3_db_mutex'>sqlite3_db_mutex</a></li>
7835 <li><a href='#sqlite3_db_name'>sqlite3_db_name</a></li>
7836 <li><a href='#sqlite3_db_readonly'>sqlite3_db_readonly</a></li>
7837 <li><a href='#sqlite3_db_release_memory'>sqlite3_db_release_memory</a></li>
7838 <li><a href='#sqlite3_db_status'>sqlite3_db_status</a></li>
7839 <li><a href='#sqlite3_drop_modules'>sqlite3_drop_modules</a></li>
7840 <li><a href='#sqlite3_enable_load_extension'>sqlite3_enable_load_extension</a></li>
7841 <li><a href='#sqlite3_errcode'>sqlite3_errcode</a></li>
7842 <li><a href='#sqlite3_errcode'>sqlite3_errmsg</a></li>
7843 <li><a href='#sqlite3_errcode'>sqlite3_errmsg16</a></li>
7844 <li><a href='#sqlite3_errcode'>sqlite3_error_offset</a></li>
7845 <li><a href='#sqlite3_errcode'>sqlite3_errstr</a></li>
7846 <li><a href='#sqlite3_exec'>sqlite3_exec</a></li>
7847 <li><a href='#sqlite3_errcode'>sqlite3_extended_errcode</a></li>
7848 <li><a href='#sqlite3_extended_result_codes'>sqlite3_extended_result_codes</a></li>
7849 <li><a href='#sqlite3_file_control'>sqlite3_file_control</a></li>
7850 <li><a href='#sqlite3_free_table'>sqlite3_free_table</a></li>
7851 <li><a href='#sqlite3_get_autocommit'>sqlite3_get_autocommit</a></li>
7852 <li><a href='#sqlite3_get_clientdata'>sqlite3_get_clientdata</a></li>
7853 <li><a href='#sqlite3_free_table'>sqlite3_get_table</a></li>
7854 <li><a href='#sqlite3_interrupt'>sqlite3_interrupt</a></li>
7855 <li><a href='#sqlite3_interrupt'>sqlite3_is_interrupted</a></li>
7856 <li><a href='#sqlite3_last_insert_rowid'>sqlite3_last_insert_rowid</a></li>
7857 <li><a href='#sqlite3_limit'>sqlite3_limit</a></li>
7858 <li><a href='#sqlite3_load_extension'>sqlite3_load_extension</a></li>
7859 <li><a href='#sqlite3_next_stmt'>sqlite3_next_stmt</a></li>
7860 <li><a href='#sqlite3_overload_function'>sqlite3_overload_function</a></li>
7861 <li><a href='#sqlite3_prepare'>sqlite3_prepare</a></li>
7862 <li><a href='#sqlite3_prepare'>sqlite3_prepare16</a></li>
7863 <li><a href='#sqlite3_prepare'>sqlite3_prepare16_v2</a></li>
7864 <li><a href='#sqlite3_prepare'>sqlite3_prepare16_v3</a></li>
7865 <li><a href='#sqlite3_prepare'>sqlite3_prepare_v2</a></li>
7866 <li><a href='#sqlite3_prepare'>sqlite3_prepare_v3</a></li>
7867 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_blobwrite</a></li>
7868 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_count</a></li>
7869 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_depth</a></li>
7870 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_hook</a></li>
7871 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_new</a></li>
7872 <li><a href='#sqlite3_preupdate_blobwrite'>sqlite3_preupdate_old</a></li>
7873 <li><a href='#sqlite3_progress_handler'>sqlite3_progress_handler</a></li>
7874 <li><a href='#sqlite3_commit_hook'>sqlite3_rollback_hook</a></li>
7875 <li><a href='#sqlite3_set_authorizer'>sqlite3_set_authorizer</a></li>
7876 <li><a href='#sqlite3_get_clientdata'>sqlite3_set_clientdata</a></li>
7877 <li><a href='#sqlite3_set_last_insert_rowid'>sqlite3_set_last_insert_rowid</a></li>
7878 <li><a href='#sqlite3_system_errno'>sqlite3_system_errno</a></li>
7879 <li><a href='#sqlite3_table_column_metadata'>sqlite3_table_column_metadata</a></li>
7880 <li><a href='#sqlite3_total_changes'>sqlite3_total_changes</a></li>
7881 <li><a href='#sqlite3_total_changes'>sqlite3_total_changes64</a></li>
7882 <li><a href='#sqlite3_trace_v2'>sqlite3_trace_v2</a></li>
7883 <li><a href='#sqlite3_txn_state'>sqlite3_txn_state</a></li>
7884 <li><a href='#sqlite3_unlock_notify'>sqlite3_unlock_notify</a></li>
7885 <li><a href='#sqlite3_update_hook'>sqlite3_update_hook</a></li>
7886 <li><a href='#sqlite3_wal_autocheckpoint'>sqlite3_wal_autocheckpoint</a></li>
7887 <li><a href='#sqlite3_wal_checkpoint'>sqlite3_wal_checkpoint</a></li>
7888 <li><a href='#sqlite3_wal_checkpoint_v2'>sqlite3_wal_checkpoint_v2</a></li>
7889 <li><a href='#sqlite3_wal_hook'>sqlite3_wal_hook</a></li>
7890 </ul>
7891 </div>
7892 </p>
7893 <hr><a name="sqlite3_str"></a>
7894 <h2>Dynamic String Object</h2>
7895 </div>
7896 <blockquote><pre>
7897 typedef struct sqlite3_str sqlite3_str;
7898 </pre></blockquote>
7899 <p>
7900 An instance of the sqlite3_str object contains a dynamically-sized
7901 string under construction.</p>
7902
7903 <p>The lifecycle of an sqlite3_str object is as follows:
7904 <ol>
7905 <li> The sqlite3_str object is created using <a href="#sqlite3_str_new">sqlite3_str_new()</a>.
7906 <li> Text is appended to the sqlite3_str object using various
7907 methods, such as <a href="#sqlite3_str_append">sqlite3_str_appendf()</a>.
7908 <li> The sqlite3_str object is destroyed and the string it created
7909 is returned using the <a href="#sqlite3_str_finish">sqlite3_str_finish()</a> interface.
7910 </ol>
7911 </p><p>1 Constructor using this object: <a href="#sqlite3_str_new">sqlite3_str_new()</a></p>
7912 <p>1 Destructor using this object: <a href="#sqlite3_str_finish">sqlite3_str_finish()</a></p>
7913 <p>9 Methods using this object:
7914 <div class='columns' style='columns: 17em auto;'>
7915 <ul style='padding-top:0;'>
7916 <li><a href='#sqlite3_str_append'>sqlite3_str_append</a></li>
7917 <li><a href='#sqlite3_str_append'>sqlite3_str_appendall</a></li>
7918 <li><a href='#sqlite3_str_append'>sqlite3_str_appendchar</a></li>
7919 <li><a href='#sqlite3_str_append'>sqlite3_str_appendf</a></li>
7920 <li><a href='#sqlite3_str_errcode'>sqlite3_str_errcode</a></li>
7921 <li><a href='#sqlite3_str_errcode'>sqlite3_str_length</a></li>
7922 <li><a href='#sqlite3_str_append'>sqlite3_str_reset</a></li>
7923 <li><a href='#sqlite3_str_errcode'>sqlite3_str_value</a></li>
7924 <li><a href='#sqlite3_str_append'>sqlite3_str_vappendf</a></li>
7925 </ul>
7926 </div>
7927 </p>
7928 <hr><a name="sqlite3_pcache_methods2"></a>
7929 <h2>Application Defined Page Cache.</h2>
7930 </div>
7931 <blockquote><pre>
7932 typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;
7933 struct sqlite3_pcache_methods2 {
7934 int iVersion;
7935 void *pArg;
7936 int (*xInit)(void*);
7937 void (*xShutdown)(void*);
7938 sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);
7939 void (*xCachesize)(sqlite3_pcache*, int nCachesize);
7940 int (*xPagecount)(sqlite3_pcache*);
7941 sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
7942 void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);
7943 void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*,
7944 unsigned oldKey, unsigned newKey);
7945 void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
7946 void (*xDestroy)(sqlite3_pcache*);
7947 void (*xShrink)(sqlite3_pcache*);
7948 };
7949 </pre></blockquote>
7950 <p>
7951 The <a href="#sqlite3_config">sqlite3_config</a>(<a href="#sqliteconfigpcache2">SQLITE_CONFIG_PCACHE2</a>, ...) interface can
7952 register an alternative page cache implementation by passing in an
7953 instance of the sqlite3_pcache_methods2 structure.
7954 In many applications, most of the heap memory allocated by
7955 SQLite is used for the page cache.
7956 By implementing a
7957 custom page cache using this API, an application can better control
7958 the amount of memory consumed by SQLite, the way in which
7959 that memory is allocated and released, and the policies used to
7960 determine exactly which parts of a database file are cached and for
7961 how long.</p>
7962
7963 <p>The alternative page cache mechanism is an
7964 extreme measure that is only needed by the most demanding applications.
7965 The built-in page cache is recommended for most uses.</p>
7966
7967 <p>The contents of the sqlite3_pcache_methods2 structure are copied to an
7968 internal buffer by SQLite within the call to <a href="#sqlite3_config">sqlite3_config</a>. Hence
7969 the application may discard the parameter after the call to
7970 <a href="#sqlite3_config">sqlite3_config()</a> returns.</p>
7971
7972 <p><a name="thexinitpagecachemethod"></a>
7973
7974 The xInit() method is called once for each effective
7975 call to <a href="#sqlite3_initialize">sqlite3_initialize()</a>
7976 (usually only once during the lifetime of the process). The xInit()
7977 method is passed a copy of the sqlite3_pcache_methods2.pArg value.
7978 The intent of the xInit() method is to set up global data structures
7979 required by the custom page cache implementation.
7980 If the xInit() method is NULL, then the
7981 built-in default page cache is used instead of the application defined
7982 page cache.</p>
7983
7984 <p><a name="thexshutdownpagecachemethod"></a>
7985
7986 The xShutdown() method is called by <a href="#sqlite3_initialize">sqlite3_shutdown()</a>.
7987 It can be used to clean up
7988 any outstanding resources before process shutdown, if required.
7989 The xShutdown() method may be NULL.</p>
7990
7991 <p>SQLite automatically serializes calls to the xInit method,
7992 so the xInit method need not be threadsafe. The
7993 xShutdown method is only called from <a href="#sqlite3_initialize">sqlite3_shutdown()</a> so it does
7994 not need to be threadsafe either. All other methods must be threadsafe
7995 in multithreaded applications.</p>
7996
7997 <p>SQLite will never invoke xInit() more than once without an intervening
7998 call to xShutdown().</p>
7999
8000 <p><a name="thexcreatepagecachemethods"></a>
8001
8002 SQLite invokes the xCreate() method to construct a new cache instance.
8003 SQLite will typically create one cache instance for each open database file,
8004 though this is not guaranteed. The
8005 first parameter, szPage, is the size in bytes of the pages that must
8006 be allocated by the cache. szPage will always a power of two. The
8007 second parameter szExtra is a number of bytes of extra storage
8008 associated with each page cache entry. The szExtra parameter will
8009 a number less than 250. SQLite will use the
8010 extra szExtra bytes on each page to store metadata about the underlying
8011 database page on disk. The value passed into szExtra depends
8012 on the SQLite version, the target platform, and how SQLite was compiled.
8013 The third argument to xCreate(), bPurgeable, is true if the cache being
8014 created will be used to cache database pages of a file stored on disk, or
8015 false if it is used for an in-memory database. The cache implementation
8016 does not have to do anything special based with the value of bPurgeable;
8017 it is purely advisory. On a cache where bPurgeable is false, SQLite will
8018 never invoke xUnpin() except to deliberately delete a page.
8019 In other words, calls to xUnpin() on a cache with bPurgeable set to
8020 false will always have the "discard" flag set to true.
8021 Hence, a cache created with bPurgeable false will
8022 never contain any unpinned pages.</p>
8023
8024 <p><a name="thexcachesizepagecachemethod"></a>
8025
8026 The xCachesize() method may be called at any time by SQLite to set the
8027 suggested maximum cache-size (number of pages stored by) the cache
8028 instance passed as the first argument. This is the value configured using
8029 the SQLite "<a href="pragma.html#pragma_cache_size">PRAGMA cache_size</a>" command. As with the bPurgeable
8030 parameter, the implementation is not required to do anything with this
8031 value; it is advisory only.</p>
8032
8033 <p><a name="thexpagecountpagecachemethods"></a>
8034
8035 The xPagecount() method must return the number of pages currently
8036 stored in the cache, both pinned and unpinned.</p>
8037
8038 <p><a name="thexfetchpagecachemethods"></a>
8039
8040 The xFetch() method locates a page in the cache and returns a pointer to
8041 an sqlite3_pcache_page object associated with that page, or a NULL pointer.
8042 The pBuf element of the returned sqlite3_pcache_page object will be a
8043 pointer to a buffer of szPage bytes used to store the content of a
8044 single database page. The pExtra element of sqlite3_pcache_page will be
8045 a pointer to the szExtra bytes of extra storage that SQLite has requested
8046 for each entry in the page cache.</p>
8047
8048 <p>The page to be fetched is determined by the key. The minimum key value
8049 is 1. After it has been retrieved using xFetch, the page is considered
8050 to be "pinned".</p>
8051
8052 <p>If the requested page is already in the page cache, then the page cache
8053 implementation must return a pointer to the page buffer with its content
8054 intact. If the requested page is not already in the cache, then the
8055 cache implementation should use the value of the createFlag
8056 parameter to help it determined what action to take:</p>
8057
8058 <p><table border=1 width=85% align=center>
8059 <tr><th> createFlag <th> Behavior when page is not already in cache
8060 <tr><td> 0 <td> Do not allocate a new page. Return NULL.
8061 <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
8062 Otherwise return NULL.
8063 <tr><td> 2 <td> Make every effort to allocate a new page. Only return
8064 NULL if allocating a new page is effectively impossible.
8065 </table></p>
8066
8067 <p>SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
8068 will only use a createFlag of 2 after a prior call with a createFlag of 1
8069 failed. In between the xFetch() calls, SQLite may
8070 attempt to unpin one or more cache pages by spilling the content of
8071 pinned pages to disk and synching the operating system disk cache.</p>
8072
8073 <p><a name="thexunpinpagecachemethod"></a>
8074
8075 xUnpin() is called by SQLite with a pointer to a currently pinned page
8076 as its second argument. If the third parameter, discard, is non-zero,
8077 then the page must be evicted from the cache.
8078 If the discard parameter is
8079 zero, then the page may be discarded or retained at the discretion of
8080 page cache implementation. The page cache implementation
8081 may choose to evict unpinned pages at any time.</p>
8082
8083 <p>The cache must not perform any reference counting. A single
8084 call to xUnpin() unpins the page regardless of the number of prior calls
8085 to xFetch().</p>
8086
8087 <p><a name="thexrekeypagecachemethods"></a>
8088
8089 The xRekey() method is used to change the key value associated with the
8090 page passed as the second argument. If the cache
8091 previously contains an entry associated with newKey, it must be
8092 discarded. Any prior cache entry associated with newKey is guaranteed not
8093 to be pinned.</p>
8094
8095 <p>When SQLite calls the xTruncate() method, the cache must discard all
8096 existing cache entries with page numbers (keys) greater than or equal
8097 to the value of the iLimit parameter passed to xTruncate(). If any
8098 of these pages are pinned, they are implicitly unpinned, meaning that
8099 they can be safely discarded.</p>
8100
8101 <p><a name="thexdestroypagecachemethod"></a>
8102
8103 The xDestroy() method is used to delete a cache allocated by xCreate().
8104 All resources associated with the specified cache should be freed. After
8105 calling the xDestroy() method, SQLite considers the <a href="#sqlite3_pcache">sqlite3_pcache*</a>
8106 handle invalid, and will not use it with any other sqlite3_pcache_methods2
8107 functions.</p>
8108
8109 <p><a name="thexshrinkpagecachemethod"></a>
8110
8111 SQLite invokes the xShrink() method when it wants the page cache to
8112 free up as much of heap memory as possible. The page cache implementation
8113 is not obligated to free any memory, but well-behaved implementations should
8114 do their best.
8115 </p><hr><a name="sqlite3_stmt"></a>
8116 <h2>Prepared Statement Object</h2>
8117 </div>
8118 <blockquote><pre>
8119 typedef struct sqlite3_stmt sqlite3_stmt;
8120 </pre></blockquote>
8121 <p>
8122 An instance of this object represents a single SQL statement that
8123 has been compiled into binary form and is ready to be evaluated.</p>
8124
8125 <p>Think of each SQL statement as a separate computer program. The
8126 original SQL text is source code. A prepared statement object
8127 is the compiled object code. All SQL must be converted into a
8128 prepared statement before it can be run.</p>
8129
8130 <p>The life-cycle of a prepared statement object usually goes like this:</p>
8131
8132 <p><ol>
8133 <li> Create the prepared statement object using <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>.
8134 <li> Bind values to <a href="lang_expr.html#varparam">parameters</a> using the sqlite3_bind_*()
8135 interfaces.
8136 <li> Run the SQL by calling <a href="#sqlite3_step">sqlite3_step()</a> one or more times.
8137 <li> Reset the prepared statement using <a href="#sqlite3_reset">sqlite3_reset()</a> then go back
8138 to step 2. Do this zero or more times.
8139 <li> Destroy the object using <a href="#sqlite3_finalize">sqlite3_finalize()</a>.
8140 </ol>
8141 </p><p>6 Constructors using this object:
8142 <div class='columns' style='columns: 17em auto;'>
8143 <ul style='padding-top:0;'>
8144 <li><a href='#sqlite3_prepare'>sqlite3_prepare</a></li>
8145 <li><a href='#sqlite3_prepare'>sqlite3_prepare16</a></li>
8146 <li><a href='#sqlite3_prepare'>sqlite3_prepare16_v2</a></li>
8147 <li><a href='#sqlite3_prepare'>sqlite3_prepare16_v3</a></li>
8148 <li><a href='#sqlite3_prepare'>sqlite3_prepare_v2</a></li>
8149 <li><a href='#sqlite3_prepare'>sqlite3_prepare_v3</a></li>
8150 </ul>
8151 </div>
8152 </p>
8153 <p>1 Destructor using this object: <a href="#sqlite3_finalize">sqlite3_finalize()</a></p>
8154 <p>53 Methods using this object:
8155 <div class='columns' style='columns: 17em auto;'>
8156 <ul style='padding-top:0;'>
8157 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_blob</a></li>
8158 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_blob64</a></li>
8159 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_double</a></li>
8160 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_int</a></li>
8161 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_int64</a></li>
8162 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_null</a></li>
8163 <li><a href='#sqlite3_bind_parameter_count'>sqlite3_bind_parameter_count</a></li>
8164 <li><a href='#sqlite3_bind_parameter_index'>sqlite3_bind_parameter_index</a></li>
8165 <li><a href='#sqlite3_bind_parameter_name'>sqlite3_bind_parameter_name</a></li>
8166 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_pointer</a></li>
8167 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_text</a></li>
8168 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_text16</a></li>
8169 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_text64</a></li>
8170 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_value</a></li>
8171 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_zeroblob</a></li>
8172 <li><a href='#sqlite3_bind_blob'>sqlite3_bind_zeroblob64</a></li>
8173 <li><a href='#sqlite3_clear_bindings'>sqlite3_clear_bindings</a></li>
8174 <li><a href='#sqlite3_column_blob'>sqlite3_column_blob</a></li>
8175 <li><a href='#sqlite3_column_blob'>sqlite3_column_bytes</a></li>
8176 <li><a href='#sqlite3_column_blob'>sqlite3_column_bytes16</a></li>
8177 <li><a href='#sqlite3_column_count'>sqlite3_column_count</a></li>
8178 <li><a href='#sqlite3_column_database_name'>sqlite3_column_database_name</a></li>
8179 <li><a href='#sqlite3_column_database_name'>sqlite3_column_database_name16</a></li>
8180 <li><a href='#sqlite3_column_decltype'>sqlite3_column_decltype</a></li>
8181 <li><a href='#sqlite3_column_decltype'>sqlite3_column_decltype16</a></li>
8182 <li><a href='#sqlite3_column_blob'>sqlite3_column_double</a></li>
8183 <li><a href='#sqlite3_column_blob'>sqlite3_column_int</a></li>
8184 <li><a href='#sqlite3_column_blob'>sqlite3_column_int64</a></li>
8185 <li><a href='#sqlite3_column_name'>sqlite3_column_name</a></li>
8186 <li><a href='#sqlite3_column_name'>sqlite3_column_name16</a></li>
8187 <li><a href='#sqlite3_column_database_name'>sqlite3_column_origin_name</a></li>
8188 <li><a href='#sqlite3_column_database_name'>sqlite3_column_origin_name16</a></li>
8189 <li><a href='#sqlite3_column_database_name'>sqlite3_column_table_name</a></li>
8190 <li><a href='#sqlite3_column_database_name'>sqlite3_column_table_name16</a></li>
8191 <li><a href='#sqlite3_column_blob'>sqlite3_column_text</a></li>
8192 <li><a href='#sqlite3_column_blob'>sqlite3_column_text16</a></li>
8193 <li><a href='#sqlite3_column_blob'>sqlite3_column_type</a></li>
8194 <li><a href='#sqlite3_column_blob'>sqlite3_column_value</a></li>
8195 <li><a href='#sqlite3_data_count'>sqlite3_data_count</a></li>
8196 <li><a href='#sqlite3_db_handle'>sqlite3_db_handle</a></li>
8197 <li><a href='#sqlite3_expanded_sql'>sqlite3_expanded_sql</a></li>
8198 <li><a href='#sqlite3_expanded_sql'>sqlite3_normalized_sql</a></li>
8199 <li><a href='#sqlite3_reset'>sqlite3_reset</a></li>
8200 <li><a href='#sqlite3_expanded_sql'>sqlite3_sql</a></li>
8201 <li><a href='#sqlite3_step'>sqlite3_step</a></li>
8202 <li><a href='#sqlite3_stmt_busy'>sqlite3_stmt_busy</a></li>
8203 <li><a href='#sqlite3_stmt_explain'>sqlite3_stmt_explain</a></li>
8204 <li><a href='#sqlite3_stmt_isexplain'>sqlite3_stmt_isexplain</a></li>
8205 <li><a href='#sqlite3_stmt_readonly'>sqlite3_stmt_readonly</a></li>
8206 <li><a href='#sqlite3_stmt_scanstatus'>sqlite3_stmt_scanstatus</a></li>
8207 <li><a href='#sqlite3_stmt_scanstatus_reset'>sqlite3_stmt_scanstatus_reset</a></li>
8208 <li><a href='#sqlite3_stmt_scanstatus'>sqlite3_stmt_scanstatus_v2</a></li>
8209 <li><a href='#sqlite3_stmt_status'>sqlite3_stmt_status</a></li>
8210 </ul>
8211 </div>
8212 </p>
8213 <hr><a name="sqlite3_value"></a>
8214 <h2>Dynamically Typed Value Object</h2>
8215 </div>
8216 <blockquote><pre>
8217 typedef struct sqlite3_value sqlite3_value;
8218 </pre></blockquote>
8219 <p>
8220 SQLite uses the sqlite3_value object to represent all values
8221 that can be stored in a database table. SQLite uses dynamic typing
8222 for the values it stores. Values stored in sqlite3_value objects
8223 can be integers, floating point values, strings, BLOBs, or NULL.</p>
8224
8225 <p>An sqlite3_value object may be either "protected" or "unprotected".
8226 Some interfaces require a protected sqlite3_value. Other interfaces
8227 will accept either a protected or an unprotected sqlite3_value.
8228 Every interface that accepts sqlite3_value arguments specifies
8229 whether or not it requires a protected sqlite3_value. The
8230 <a href="#sqlite3_value_dup">sqlite3_value_dup()</a> interface can be used to construct a new
8231 protected sqlite3_value from an unprotected sqlite3_value.</p>
8232
8233 <p>The terms "protected" and "unprotected" refer to whether or not
8234 a mutex is held. An internal mutex is held for a protected
8235 sqlite3_value object but no mutex is held for an unprotected
8236 sqlite3_value object. If SQLite is compiled to be single-threaded
8237 (with <a href="compile.html#threadsafe">SQLITE_THREADSAFE=0</a> and with <a href="#sqlite3_threadsafe">sqlite3_threadsafe()</a> returning 0)
8238 or if SQLite is run in one of reduced mutex modes
8239 <a href="#sqliteconfigsinglethread">SQLITE_CONFIG_SINGLETHREAD</a> or <a href="#sqliteconfigmultithread">SQLITE_CONFIG_MULTITHREAD</a>
8240 then there is no distinction between protected and unprotected
8241 sqlite3_value objects and they can be used interchangeably. However,
8242 for maximum code portability it is recommended that applications
8243 still make the distinction between protected and unprotected
8244 sqlite3_value objects even when not strictly required.</p>
8245
8246 <p>The sqlite3_value objects that are passed as parameters into the
8247 implementation of <a href="appfunc.html">application-defined SQL functions</a> are protected.
8248 The sqlite3_value objects returned by <a href="#sqlite3_vtab_rhs_value">sqlite3_vtab_rhs_value()</a>
8249 are protected.
8250 The sqlite3_value object returned by
8251 <a href="#sqlite3_column_blob">sqlite3_column_value()</a> is unprotected.
8252 Unprotected sqlite3_value objects may only be used as arguments
8253 to <a href="#sqlite3_result_blob">sqlite3_result_value()</a>, <a href="#sqlite3_bind_blob">sqlite3_bind_value()</a>, and
8254 <a href="#sqlite3_value_dup">sqlite3_value_dup()</a>.
8255 The <a href="#sqlite3_value_blob">sqlite3_value_type()</a> family of
8256 interfaces require protected sqlite3_value objects.
8257 </p><p>19 Methods using this object:
8258 <div class='columns' style='columns: 17em auto;'>
8259 <ul style='padding-top:0;'>
8260 <li><a href='#sqlite3_value_blob'>sqlite3_value_blob</a></li>
8261 <li><a href='#sqlite3_value_blob'>sqlite3_value_bytes</a></li>
8262 <li><a href='#sqlite3_value_blob'>sqlite3_value_bytes16</a></li>
8263 <li><a href='#sqlite3_value_blob'>sqlite3_value_double</a></li>
8264 <li><a href='#sqlite3_value_dup'>sqlite3_value_dup</a></li>
8265 <li><a href='#sqlite3_value_encoding'>sqlite3_value_encoding</a></li>
8266 <li><a href='#sqlite3_value_dup'>sqlite3_value_free</a></li>
8267 <li><a href='#sqlite3_value_blob'>sqlite3_value_frombind</a></li>
8268 <li><a href='#sqlite3_value_blob'>sqlite3_value_int</a></li>
8269 <li><a href='#sqlite3_value_blob'>sqlite3_value_int64</a></li>
8270 <li><a href='#sqlite3_value_blob'>sqlite3_value_nochange</a></li>
8271 <li><a href='#sqlite3_value_blob'>sqlite3_value_numeric_type</a></li>
8272 <li><a href='#sqlite3_value_blob'>sqlite3_value_pointer</a></li>
8273 <li><a href='#sqlite3_value_subtype'>sqlite3_value_subtype</a></li>
8274 <li><a href='#sqlite3_value_blob'>sqlite3_value_text</a></li>
8275 <li><a href='#sqlite3_value_blob'>sqlite3_value_text16</a></li>
8276 <li><a href='#sqlite3_value_blob'>sqlite3_value_text16be</a></li>
8277 <li><a href='#sqlite3_value_blob'>sqlite3_value_text16le</a></li>
8278 <li><a href='#sqlite3_value_blob'>sqlite3_value_type</a></li>
8279 </ul>
8280 </div>
8281 </p>
8282 <hr><a name="sqlite3_aggregate_count"></a>
8283 <h2>Deprecated Functions</h2>
8284 </div>
8285 <blockquote><pre>
8286 #ifndef SQLITE_OMIT_DEPRECATED
8287 int sqlite3_aggregate_count(sqlite3_context*);
8288 int sqlite3_expired(sqlite3_stmt*);
8289 int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
8290 int sqlite3_global_recover(void);
8291 void sqlite3_thread_cleanup(void);
8292 int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
8293 void*,sqlite3_int64);
8294 #endif
8295 </pre></blockquote>
8296 <p>
8297 These functions are <a href="capi3ref.html">deprecated</a>. In order to maintain
8298 backwards compatibility with older code, these functions continue
8299 to be supported. However, new applications should avoid
8300 the use of these functions. To encourage programmers to avoid
8301 these functions, we will not explain what they do.
8302 </p><hr><a name="sqlite3_backup_finish"></a>
8303 <h2>Online Backup API.</h2>
8304 </div>
8305 <blockquote><pre>
8306 sqlite3_backup *sqlite3_backup_init(
8307 sqlite3 *pDest, /* Destination database handle */
8308 const char *zDestName, /* Destination database name */
8309 sqlite3 *pSource, /* Source database handle */
8310 const char *zSourceName /* Source database name */
8311 );
8312 int sqlite3_backup_step(sqlite3_backup *p, int nPage);
8313 int sqlite3_backup_finish(sqlite3_backup *p);
8314 int sqlite3_backup_remaining(sqlite3_backup *p);
8315 int sqlite3_backup_pagecount(sqlite3_backup *p);
8316 </pre></blockquote>
8317 <p>
8318 The backup API copies the content of one database into another.
8319 It is useful either for creating backups of databases or
8320 for copying in-memory databases to or from persistent files.</p>
8321
8322 <p>See Also: <a href="backup.html">Using the SQLite Online Backup API</a></p>
8323
8324 <p>SQLite holds a write transaction open on the destination database file
8325 for the duration of the backup operation.
8326 The source database is read-locked only while it is being read;
8327 it is not locked continuously for the entire backup operation.
8328 Thus, the backup may be performed on a live source database without
8329 preventing other database connections from
8330 reading or writing to the source database while the backup is underway.</p>
8331
8332 <p>To perform a backup operation:
8333 <ol>
8334 <li><b>sqlite3_backup_init()</b> is called once to initialize the
8335 backup,
8336 <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
8337 the data between the two databases, and finally
8338 <li><b>sqlite3_backup_finish()</b> is called to release all resources
8339 associated with the backup operation.
8340 </ol>
8341 There should be exactly one call to sqlite3_backup_finish() for each
8342 successful call to sqlite3_backup_init().</p>
8343
8344 <p><a name="sqlite3backupinit"></a>
8345 <b>sqlite3_backup_init()</b></p>
8346
8347 <p>The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
8348 <a href="#sqlite3">database connection</a> associated with the destination database
8349 and the database name, respectively.
8350 The database name is "main" for the main database, "temp" for the
8351 temporary database, or the name specified after the AS keyword in
8352 an <a href="lang_attach.html">ATTACH</a> statement for an attached database.
8353 The S and M arguments passed to
8354 sqlite3_backup_init(D,N,S,M) identify the <a href="#sqlite3">database connection</a>
8355 and database name of the source database, respectively.
8356 The source and destination <a href="#sqlite3">database connections</a> (parameters S and D)
8357 must be different or else sqlite3_backup_init(D,N,S,M) will fail with
8358 an error.</p>
8359
8360 <p>A call to sqlite3_backup_init() will fail, returning NULL, if
8361 there is already a read or read-write transaction open on the
8362 destination database.</p>
8363
8364 <p>If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
8365 returned and an error code and error message are stored in the
8366 destination <a href="#sqlite3">database connection</a> D.
8367 The error code and message for the failed call to sqlite3_backup_init()
8368 can be retrieved using the <a href="#sqlite3_errcode">sqlite3_errcode()</a>, <a href="#sqlite3_errcode">sqlite3_errmsg()</a>, and/or
8369 <a href="#sqlite3_errcode">sqlite3_errmsg16()</a> functions.
8370 A successful call to sqlite3_backup_init() returns a pointer to an
8371 <a href="#sqlite3_backup">sqlite3_backup</a> object.
8372 The <a href="#sqlite3_backup">sqlite3_backup</a> object may be used with the sqlite3_backup_step() and
8373 sqlite3_backup_finish() functions to perform the specified backup
8374 operation.</p>
8375
8376 <p><a name="sqlite3backupstep"></a>
8377 <b>sqlite3_backup_step()</b></p>
8378
8379 <p>Function sqlite3_backup_step(B,N) will copy up to N pages between
8380 the source and destination databases specified by <a href="#sqlite3_backup">sqlite3_backup</a> object B.
8381 If N is negative, all remaining source pages are copied.
8382 If sqlite3_backup_step(B,N) successfully copies N pages and there
8383 are still more pages to be copied, then the function returns <a href="#SQLITE_ABORT">SQLITE_OK</a>.
8384 If sqlite3_backup_step(B,N) successfully finishes copying all pages
8385 from source to destination, then it returns <a href="#SQLITE_ABORT">SQLITE_DONE</a>.
8386 If an error occurs while running sqlite3_backup_step(B,N),
8387 then an <a href="rescode.html">error code</a> is returned. As well as <a href="#SQLITE_ABORT">SQLITE_OK</a> and
8388 <a href="#SQLITE_ABORT">SQLITE_DONE</a>, a call to sqlite3_backup_step() may return <a href="#SQLITE_ABORT">SQLITE_READONLY</a>,
8389 <a href="#SQLITE_ABORT">SQLITE_NOMEM</a>, <a href="#SQLITE_ABORT">SQLITE_BUSY</a>, <a href="#SQLITE_ABORT">SQLITE_LOCKED</a>, or an
8390 <a href="#SQLITE_ABORT_ROLLBACK">SQLITE_IOERR_XXX</a> extended error code.</p>
8391
8392 <p>The sqlite3_backup_step() might return <a href="#SQLITE_ABORT">SQLITE_READONLY</a> if
8393 <ol>
8394 <li> the destination database was opened read-only, or
8395 <li> the destination database is using write-ahead-log journaling
8396 and the destination and source page sizes differ, or
8397 <li> the destination database is an in-memory database and the
8398 destination and source page sizes differ.
8399 </ol></p>
8400
8401 <p>If sqlite3_backup_step() cannot obtain a required file-system lock, then
8402 the <a href="#sqlite3_busy_handler">busy-handler function</a>
8403 is invoked (if one is specified). If the
8404 busy-handler returns non-zero before the lock is available, then
8405 <a href="#SQLITE_ABORT">SQLITE_BUSY</a> is returned to the caller. In this case the call to
8406 sqlite3_backup_step() can be retried later. If the source
8407 <a href="#sqlite3">database connection</a>
8408 is being used to write to the source database when sqlite3_backup_step()
8409 is called, then <a href="#SQLITE_ABORT">SQLITE_LOCKED</a> is returned immediately. Again, in this
8410 case the call to sqlite3_backup_step() can be retried later on. If
8411 <a href="#SQLITE_ABORT_ROLLBACK">SQLITE_IOERR_XXX</a>, <a href="#SQLITE_ABORT">SQLITE_NOMEM</a>, or
8412 <a href="#SQLITE_ABORT">SQLITE_READONLY</a> is returned, then
8413 there is no point in retrying the call to sqlite3_backup_step(). These
8414 errors are considered fatal. The application must accept
8415 that the backup operation has failed and pass the backup operation handle
8416 to the sqlite3_backup_finish() to release associated resources.</p>
8417
8418 <p>The first call to sqlite3_backup_step() obtains an exclusive lock
8419 on the destination file. The exclusive lock is not released until either
8420 sqlite3_backup_finish() is called or the backup operation is complete
8421 and sqlite3_backup_step() returns <a href="#SQLITE_ABORT">SQLITE_DONE</a>. Every call to
8422 sqlite3_backup_step() obtains a <a href="lockingv3.html#shared_lock">shared lock</a> on the source database that
8423 lasts for the duration of the sqlite3_backup_step() call.
8424 Because the source database is not locked between calls to
8425 sqlite3_backup_step(), the source database may be modified mid-way
8426 through the backup process. If the source database is modified by an
8427 external process or via a database connection other than the one being
8428 used by the backup operation, then the backup will be automatically
8429 restarted by the next call to sqlite3_backup_step(). If the source
8430 database is modified by the using the same database connection as is used
8431 by the backup operation, then the backup database is automatically
8432 updated at the same time.</p>
8433
8434 <p><a name="sqlite3backupfinish"></a>
8435 <b>sqlite3_backup_finish()</b></p>
8436
8437 <p>When sqlite3_backup_step() has returned <a href="#SQLITE_ABORT">SQLITE_DONE</a>, or when the
8438 application wishes to abandon the backup operation, the application
8439 should destroy the <a href="#sqlite3_backup">sqlite3_backup</a> by passing it to sqlite3_backup_finish().
8440 The sqlite3_backup_finish() interfaces releases all
8441 resources associated with the <a href="#sqlite3_backup">sqlite3_backup</a> object.
8442 If sqlite3_backup_step() has not yet returned <a href="#SQLITE_ABORT">SQLITE_DONE</a>, then any
8443 active write-transaction on the destination database is rolled back.
8444 The <a href="#sqlite3_backup">sqlite3_backup</a> object is invalid
8445 and may not be used following a call to sqlite3_backup_finish().</p>
8446
8447 <p>The value returned by sqlite3_backup_finish is <a href="#SQLITE_ABORT">SQLITE_OK</a> if no
8448 sqlite3_backup_step() errors occurred, regardless or whether or not
8449 sqlite3_backup_step() completed.
8450 If an out-of-memory condition or IO error occurred during any prior
8451 sqlite3_backup_step() call on the same <a href="#sqlite3_backup">sqlite3_backup</a> object, then
8452 sqlite3_backup_finish() returns the corresponding <a href="rescode.html">error code</a>.</p>
8453
8454 <p>A return of <a href="#SQLITE_ABORT">SQLITE_BUSY</a> or <a href="#SQLITE_ABORT">SQLITE_LOCKED</a> from sqlite3_backup_step()
8455 is not a permanent error and does not affect the return value of
8456 sqlite3_backup_finish().</p>
8457
8458 <p><a name="sqlite3backupremaining"></a>
8459 <a name="sqlite3backuppagecount"></a>
8460
8461 <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b></p>
8462
8463 <p>The sqlite3_backup_remaining() routine returns the number of pages still
8464 to be backed up at the conclusion of the most recent sqlite3_backup_step().
8465 The sqlite3_backup_pagecount() routine returns the total number of pages
8466 in the source database at the conclusion of the most recent
8467 sqlite3_backup_step().
8468 The values returned by these functions are only updated by
8469 sqlite3_backup_step(). If the source database is modified in a way that
8470 changes the size of the source database or the number of pages remaining,
8471 those changes are not reflected in the output of sqlite3_backup_pagecount()
8472 and sqlite3_backup_remaining() until after the next
8473 sqlite3_backup_step().</p>
8474
8475 <p><b>Concurrent Usage of Database Handles</b></p>
8476
8477 <p>The source <a href="#sqlite3">database connection</a> may be used by the application for other
8478 purposes while a backup operation is underway or being initialized.
8479 If SQLite is compiled and configured to support threadsafe database
8480 connections, then the source database connection may be used concurrently
8481 from within other threads.</p>
8482
8483 <p>However, the application must guarantee that the destination
8484 <a href="#sqlite3">database connection</a> is not passed to any other API (by any thread) after
8485 sqlite3_backup_init() is called and before the corresponding call to
8486 sqlite3_backup_finish(). SQLite does not currently check to see
8487 if the application incorrectly accesses the destination <a href="#sqlite3">database connection</a>
8488 and so no error code is reported, but the operations may malfunction
8489 nevertheless. Use of the destination database connection while a
8490 backup is in progress might also cause a mutex deadlock.</p>
8491
8492 <p>If running in <a href="sharedcache.html">shared cache mode</a>, the application must
8493 guarantee that the shared cache used by the destination database
8494 is not accessed while the backup is running. In practice this means
8495 that the application must guarantee that the disk file being
8496 backed up to is not accessed by any connection within the process,
8497 not just the specific connection that was passed to sqlite3_backup_init().</p>
8498
8499 <p>The <a href="#sqlite3_backup">sqlite3_backup</a> object itself is partially threadsafe. Multiple
8500 threads may safely make multiple concurrent calls to sqlite3_backup_step().
8501 However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
8502 APIs are not strictly speaking threadsafe. If they are invoked at the
8503 same time as another thread is invoking sqlite3_backup_step() it is
8504 possible that they return invalid values.
8505 </p><hr><a name="sqlite3_changes"></a>
8506 <h2>Count The Number Of Rows Modified</h2>
8507 </div>
8508 <blockquote><pre>
8509 int sqlite3_changes(sqlite3*);
8510 sqlite3_int64 sqlite3_changes64(sqlite3*);
8511 </pre></blockquote>
8512 <p>
8513 These functions return the number of rows modified, inserted or
8514 deleted by the most recently completed INSERT, UPDATE or DELETE
8515 statement on the database connection specified by the only parameter.
8516 The two functions are identical except for the type of the return value
8517 and that if the number of rows modified by the most recent INSERT, UPDATE
8518 or DELETE is greater than the maximum value supported by type "int", then
8519 the return value of sqlite3_changes() is undefined. Executing any other
8520 type of SQL statement does not modify the value returned by these functions.</p>
8521
8522 <p>Only changes made directly by the INSERT, UPDATE or DELETE statement are
8523 considered - auxiliary changes caused by <a href="lang_createtrigger.html">triggers</a>,
8524 <a href="foreignkeys.html#fk_actions">foreign key actions</a> or <a href="lang_replace.html">REPLACE</a> constraint resolution are not counted.</p>
8525
8526 <p>Changes to a view that are intercepted by
8527 <a href="lang_createtrigger.html#instead_of_trigger">INSTEAD OF triggers</a> are not counted. The value
8528 returned by sqlite3_changes() immediately after an INSERT, UPDATE or
8529 DELETE statement run on a view is always zero. Only changes made to real
8530 tables are counted.</p>
8531
8532 <p>Things are more complicated if the sqlite3_changes() function is
8533 executed while a trigger program is running. This may happen if the
8534 program uses the <a href="lang_corefunc.html#changes">changes() SQL function</a>, or if some other callback
8535 function invokes sqlite3_changes() directly. Essentially:</p>
8536
8537 <p><ul>
8538 <li> Before entering a trigger program the value returned by
8539 sqlite3_changes() function is saved. After the trigger program
8540 has finished, the original value is restored.</p>
8541
8542 <p><li> Within a trigger program each INSERT, UPDATE and DELETE
8543 statement sets the value returned by sqlite3_changes()
8544 upon completion as normal. Of course, this value will not include
8545 any changes performed by sub-triggers, as the sqlite3_changes()
8546 value will be saved and restored after each sub-trigger has run.
8547 </ul></p>
8548
8549 <p>This means that if the changes() SQL function (or similar) is used
8550 by the first INSERT, UPDATE or DELETE statement within a trigger, it
8551 returns the value as set when the calling statement began executing.
8552 If it is used by the second or subsequent such statement within a trigger
8553 program, the value returned reflects the number of rows modified by the
8554 previous INSERT, UPDATE or DELETE statement within the same trigger.</p>
8555
8556 <p>If a separate thread makes changes on the same database connection
8557 while <a href="#sqlite3_changes">sqlite3_changes()</a> is running then the value returned
8558 is unpredictable and not meaningful.</p>
8559
8560 <p>See also:
8561 <ul>
8562 <li> the <a href="#sqlite3_total_changes">sqlite3_total_changes()</a> interface
8563 <li> the <a href="pragma.html#pragma_count_changes">count_changes pragma</a>
8564 <li> the <a href="lang_corefunc.html#changes">changes() SQL function</a>
8565 <li> the <a href="pragma.html#pragma_data_version">data_version pragma</a>
8566 </ul>
8567 </p><hr><a name="sqlite3_close"></a>
8568 <h2>Closing A Database Connection</h2>
8569 </div>
8570 <blockquote><pre>
8571 int sqlite3_close(sqlite3*);
8572 int sqlite3_close_v2(sqlite3*);
8573 </pre></blockquote>
8574 <p>
8575 The sqlite3_close() and sqlite3_close_v2() routines are destructors
8576 for the <a href="#sqlite3">sqlite3</a> object.
8577 Calls to sqlite3_close() and sqlite3_close_v2() return <a href="#SQLITE_ABORT">SQLITE_OK</a> if
8578 the <a href="#sqlite3">sqlite3</a> object is successfully destroyed and all associated
8579 resources are deallocated.</p>
8580
8581 <p>Ideally, applications should <a href="#sqlite3_finalize">finalize</a> all
8582 <a href="#sqlite3_stmt">prepared statements</a>, <a href="#sqlite3_blob_close">close</a> all <a href="#sqlite3_blob">BLOB handles</a>, and
8583 <a href="#sqlite3backupfinish">finish</a> all <a href="#sqlite3_backup">sqlite3_backup</a> objects associated
8584 with the <a href="#sqlite3">sqlite3</a> object prior to attempting to close the object.
8585 If the database connection is associated with unfinalized prepared
8586 statements, BLOB handlers, and/or unfinished sqlite3_backup objects then
8587 sqlite3_close() will leave the database connection open and return
8588 <a href="#SQLITE_ABORT">SQLITE_BUSY</a>. If sqlite3_close_v2() is called with unfinalized prepared
8589 statements, unclosed BLOB handlers, and/or unfinished sqlite3_backups,
8590 it returns <a href="#SQLITE_ABORT">SQLITE_OK</a> regardless, but instead of deallocating the database
8591 connection immediately, it marks the database connection as an unusable
8592 "zombie" and makes arrangements to automatically deallocate the database
8593 connection after all prepared statements are finalized, all BLOB handles
8594 are closed, and all backups have finished. The sqlite3_close_v2() interface
8595 is intended for use with host languages that are garbage collected, and
8596 where the order in which destructors are called is arbitrary.</p>
8597
8598 <p>If an <a href="#sqlite3">sqlite3</a> object is destroyed while a transaction is open,
8599 the transaction is automatically rolled back.</p>
8600
8601 <p>The C parameter to <a href="#sqlite3_close">sqlite3_close(C)</a> and <a href="#sqlite3_close">sqlite3_close_v2(C)</a>
8602 must be either a NULL
8603 pointer or an <a href="#sqlite3">sqlite3</a> object pointer obtained
8604 from <a href="#sqlite3_open">sqlite3_open()</a>, <a href="#sqlite3_open">sqlite3_open16()</a>, or
8605 <a href="#sqlite3_open">sqlite3_open_v2()</a>, and not previously closed.
8606 Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
8607 argument is a harmless no-op.
8608 </p><hr><a name="sqlite3_collation_needed"></a>
8609 <h2>Collation Needed Callbacks</h2>
8610 </div>
8611 <blockquote><pre>
8612 int sqlite3_collation_needed(
8613 sqlite3*,
8614 void*,
8615 void(*)(void*,sqlite3*,int eTextRep,const char*)
8616 );
8617 int sqlite3_collation_needed16(
8618 sqlite3*,
8619 void*,
8620 void(*)(void*,sqlite3*,int eTextRep,const void*)
8621 );
8622 </pre></blockquote>
8623 <p>
8624 To avoid having to register all collation sequences before a database
8625 can be used, a single callback function may be registered with the
8626 <a href="#sqlite3">database connection</a> to be invoked whenever an undefined collation
8627 sequence is required.</p>
8628
8629 <p>If the function is registered using the sqlite3_collation_needed() API,
8630 then it is passed the names of undefined collation sequences as strings
8631 encoded in UTF-8. If sqlite3_collation_needed16() is used,
8632 the names are passed as UTF-16 in machine native byte order.
8633 A call to either function replaces the existing collation-needed callback.</p>
8634
8635 <p>When the callback is invoked, the first argument passed is a copy
8636 of the second argument to sqlite3_collation_needed() or
8637 sqlite3_collation_needed16(). The second argument is the database
8638 connection. The third argument is one of <a href="#SQLITE_ANY">SQLITE_UTF8</a>, <a href="#SQLITE_ANY">SQLITE_UTF16BE</a>,
8639 or <a href="#SQLITE_ANY">SQLITE_UTF16LE</a>, indicating the most desirable form of the collation
8640 sequence function required. The fourth parameter is the name of the
8641 required collation sequence.</p>
8642
8643 <p>The callback function should register the desired collation using
8644 <a href="#sqlite3_create_collation">sqlite3_create_collation()</a>, <a href="#sqlite3_create_collation">sqlite3_create_collation16()</a>, or
8645 <a href="#sqlite3_create_collation">sqlite3_create_collation_v2()</a>.
8646 </p><hr><a name="sqlite3_column_database_name"></a>
8647 <h2>Source Of Data In A Query Result</h2>
8648 </div>
8649 <blockquote><pre>
8650 const char *sqlite3_column_database_name(sqlite3_stmt*,int);
8651 const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
8652 const char *sqlite3_column_table_name(sqlite3_stmt*,int);
8653 const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
8654 const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
8655 const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
8656 </pre></blockquote>
8657 <p>
8658 These routines provide a means to determine the database, table, and
8659 table column that is the origin of a particular result column in
8660 <a href="lang_select.html">SELECT</a> statement.
8661 The name of the database or table or column can be returned as
8662 either a UTF-8 or UTF-16 string. The _database_ routines return
8663 the database name, the _table_ routines return the table name, and
8664 the origin_ routines return the column name.
8665 The returned string is valid until the <a href="#sqlite3_stmt">prepared statement</a> is destroyed
8666 using <a href="#sqlite3_finalize">sqlite3_finalize()</a> or until the statement is automatically
8667 reprepared by the first call to <a href="#sqlite3_step">sqlite3_step()</a> for a particular run
8668 or until the same information is requested
8669 again in a different encoding.</p>
8670
8671 <p>The names returned are the original un-aliased names of the
8672 database, table, and column.</p>
8673
8674 <p>The first argument to these interfaces is a <a href="#sqlite3_stmt">prepared statement</a>.
8675 These functions return information about the Nth result column returned by
8676 the statement, where N is the second function argument.
8677 The left-most column is column 0 for these routines.</p>
8678
8679 <p>If the Nth column returned by the statement is an expression or
8680 subquery and is not a column value, then all of these functions return
8681 NULL. These routines might also return NULL if a memory allocation error
8682 occurs. Otherwise, they return the name of the attached database, table,
8683 or column that query result column was extracted from.</p>
8684
8685 <p>As with all other SQLite APIs, those whose names end with "16" return
8686 UTF-16 encoded strings and the other functions return UTF-8.</p>
8687
8688 <p>These APIs are only available if the library was compiled with the
8689 <a href="compile.html#enable_column_metadata">SQLITE_ENABLE_COLUMN_METADATA</a> C-preprocessor symbol.</p>
8690
8691 <p>If two or more threads call one or more
8692 <a href="#sqlite3_column_database_name">column metadata interfaces</a>
8693 for the same <a href="#sqlite3_stmt">prepared statement</a> and result column
8694 at the same time then the results are undefined.
8695 </p><hr><a name="sqlite3_column_decltype"></a>
8696 <h2>Declared Datatype Of A Query Result</h2>
8697 </div>
8698 <blockquote><pre>
8699 const char *sqlite3_column_decltype(sqlite3_stmt*,int);
8700 const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
8701 </pre></blockquote>
8702 <p>
8703 The first parameter is a <a href="#sqlite3_stmt">prepared statement</a>.
8704 If this statement is a <a href="lang_select.html">SELECT</a> statement and the Nth column of the
8705 returned result set of that <a href="lang_select.html">SELECT</a> is a table column (not an
8706 expression or subquery) then the declared type of the table
8707 column is returned. If the Nth column of the result set is an
8708 expression or subquery, then a NULL pointer is returned.
8709 The returned string is always UTF-8 encoded.</p>
8710
8711 <p>For example, given the database schema:</p>
8712
8713 <p>CREATE TABLE t1(c1 VARIANT);</p>
8714
8715 <p>and the following statement to be compiled:</p>
8716
8717 <p>SELECT c1 + 1, c1 FROM t1;</p>
8718
8719 <p>this routine would return the string "VARIANT" for the second result
8720 column (i==1), and a NULL pointer for the first result column (i==0).</p>
8721
8722 <p>SQLite uses dynamic run-time typing. So just because a column
8723 is declared to contain a particular type does not mean that the
8724 data stored in that column is of the declared type. SQLite is
8725 strongly typed, but the typing is dynamic not static. Type
8726 is associated with individual values, not with the containers
8727 used to hold those values.
8728 </p><hr><a name="sqlite3_column_name"></a>
8729 <h2>Column Names In A Result Set</h2>
8730 </div>
8731 <blockquote><pre>
8732 const char *sqlite3_column_name(sqlite3_stmt*, int N);
8733 const void *sqlite3_column_name16(sqlite3_stmt*, int N);
8734 </pre></blockquote>
8735 <p>
8736 These routines return the name assigned to a particular column
8737 in the result set of a <a href="lang_select.html">SELECT</a> statement. The sqlite3_column_name()
8738 interface returns a pointer to a zero-terminated UTF-8 string
8739 and sqlite3_column_name16() returns a pointer to a zero-terminated
8740 UTF-16 string. The first parameter is the <a href="#sqlite3_stmt">prepared statement</a>
8741 that implements the <a href="lang_select.html">SELECT</a> statement. The second parameter is the
8742 column number. The leftmost column is number 0.</p>
8743
8744 <p>The returned string pointer is valid until either the <a href="#sqlite3_stmt">prepared statement</a>
8745 is destroyed by <a href="#sqlite3_finalize">sqlite3_finalize()</a> or until the statement is automatically
8746 reprepared by the first call to <a href="#sqlite3_step">sqlite3_step()</a> for a particular run
8747 or until the next call to
8748 sqlite3_column_name() or sqlite3_column_name16() on the same column.</p>
8749
8750 <p>If sqlite3_malloc() fails during the processing of either routine
8751 (for example during a conversion from UTF-8 to UTF-16) then a
8752 NULL pointer is returned.</p>
8753
8754 <p>The name of a result column is the value of the "AS" clause for
8755 that column, if there is an AS clause. If there is no AS clause
8756 then the name of the column is unspecified and may change from
8757 one release of SQLite to the next.
8758 </p><hr><a name="sqlite3_commit_hook"></a>
8759 <h2>Commit And Rollback Notification Callbacks</h2>
8760 </div>
8761 <blockquote><pre>
8762 void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
8763 void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
8764 </pre></blockquote>
8765 <p>
8766 The sqlite3_commit_hook() interface registers a callback
8767 function to be invoked whenever a transaction is <a href="lang_transaction.html">committed</a>.
8768 Any callback set by a previous call to sqlite3_commit_hook()
8769 for the same database connection is overridden.
8770 The sqlite3_rollback_hook() interface registers a callback
8771 function to be invoked whenever a transaction is <a href="lang_transaction.html">rolled back</a>.
8772 Any callback set by a previous call to sqlite3_rollback_hook()
8773 for the same database connection is overridden.
8774 The pArg argument is passed through to the callback.
8775 If the callback on a commit hook function returns non-zero,
8776 then the commit is converted into a rollback.</p>
8777
8778 <p>The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
8779 return the P argument from the previous call of the same function
8780 on the same <a href="#sqlite3">database connection</a> D, or NULL for
8781 the first call for each function on D.</p>
8782
8783 <p>The commit and rollback hook callbacks are not reentrant.
8784 The callback implementation must not do anything that will modify
8785 the database connection that invoked the callback. Any actions
8786 to modify the database connection must be deferred until after the
8787 completion of the <a href="#sqlite3_step">sqlite3_step()</a> call that triggered the commit
8788 or rollback hook in the first place.
8789 Note that running any other SQL statements, including SELECT statements,
8790 or merely calling <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> and <a href="#sqlite3_step">sqlite3_step()</a> will modify
8791 the database connections for the meaning of "modify" in this paragraph.</p>
8792
8793 <p>Registering a NULL function disables the callback.</p>
8794
8795 <p>When the commit hook callback routine returns zero, the <a href="lang_transaction.html">COMMIT</a>
8796 operation is allowed to continue normally. If the commit hook
8797 returns non-zero, then the <a href="lang_transaction.html">COMMIT</a> is converted into a <a href="lang_transaction.html">ROLLBACK</a>.
8798 The rollback hook is invoked on a rollback that results from a commit
8799 hook returning non-zero, just as it would be with any other rollback.</p>
8800
8801 <p>For the purposes of this API, a transaction is said to have been
8802 rolled back if an explicit "ROLLBACK" statement is executed, or
8803 an error or constraint causes an implicit rollback to occur.
8804 The rollback callback is not invoked if a transaction is
8805 automatically rolled back because the database connection is closed.</p>
8806
8807 <p>See also the <a href="#sqlite3_update_hook">sqlite3_update_hook()</a> interface.
8808 </p><hr><a name="sqlite3_compileoption_get"></a>
8809 <h2>Run-Time Library Compilation Options Diagnostics</h2>
8810 </div>
8811 <blockquote><pre>
8812 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
8813 int sqlite3_compileoption_used(const char *zOptName);
8814 const char *sqlite3_compileoption_get(int N);
8815 #else
8816 # define sqlite3_compileoption_used(X) 0
8817 # define sqlite3_compileoption_get(X) ((void*)0)
8818 #endif
8819 </pre></blockquote>
8820 <p>
8821 The sqlite3_compileoption_used() function returns 0 or 1
8822 indicating whether the specified option was defined at
8823 compile time. The SQLITE_ prefix may be omitted from the
8824 option name passed to sqlite3_compileoption_used().</p>
8825
8826 <p>The sqlite3_compileoption_get() function allows iterating
8827 over the list of options that were defined at compile time by
8828 returning the N-th compile time option string. If N is out of range,
8829 sqlite3_compileoption_get() returns a NULL pointer. The SQLITE_
8830 prefix is omitted from any strings returned by
8831 sqlite3_compileoption_get().</p>
8832
8833 <p>Support for the diagnostic functions sqlite3_compileoption_used()
8834 and sqlite3_compileoption_get() may be omitted by specifying the
8835 <a href="compile.html#omit_compileoption_diags">SQLITE_OMIT_COMPILEOPTION_DIAGS</a> option at compile time.</p>
8836
8837 <p>See also: SQL functions <a href="lang_corefunc.html#sqlite_compileoption_used">sqlite_compileoption_used()</a> and
8838 <a href="lang_corefunc.html#sqlite_compileoption_get">sqlite_compileoption_get()</a> and the <a href="pragma.html#pragma_compile_options">compile_options pragma</a>.
8839 </p><hr><a name="sqlite3_complete"></a>
8840 <h2>Determine If An SQL Statement Is Complete</h2>
8841 </div>
8842 <blockquote><pre>
8843 int sqlite3_complete(const char *sql);
8844 int sqlite3_complete16(const void *sql);
8845 </pre></blockquote>
8846 <p>
8847 These routines are useful during command-line input to determine if the
8848 currently entered text seems to form a complete SQL statement or
8849 if additional input is needed before sending the text into
8850 SQLite for parsing. These routines return 1 if the input string
8851 appears to be a complete SQL statement. A statement is judged to be
8852 complete if it ends with a semicolon token and is not a prefix of a
8853 well-formed CREATE TRIGGER statement. Semicolons that are embedded within
8854 string literals or quoted identifier names or comments are not
8855 independent tokens (they are part of the token in which they are
8856 embedded) and thus do not count as a statement terminator. Whitespace
8857 and comments that follow the final semicolon are ignored.</p>
8858
8859 <p>These routines return 0 if the statement is incomplete. If a
8860 memory allocation fails, then SQLITE_NOMEM is returned.</p>
8861
8862 <p>These routines do not parse the SQL statements thus
8863 will not detect syntactically incorrect SQL.</p>
8864
8865 <p>If SQLite has not been initialized using <a href="#sqlite3_initialize">sqlite3_initialize()</a> prior
8866 to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
8867 automatically by sqlite3_complete16(). If that initialization fails,
8868 then the return value from sqlite3_complete16() will be non-zero
8869 regardless of whether or not the input SQL is complete.</p>
8870
8871 <p>The input to <a href="#sqlite3_complete">sqlite3_complete()</a> must be a zero-terminated
8872 UTF-8 string.</p>
8873
8874 <p>The input to <a href="#sqlite3_complete">sqlite3_complete16()</a> must be a zero-terminated
8875 UTF-16 string in native byte order.
8876 </p><hr><a name="sqlite3_create_collation"></a>
8877 <h2>Define New Collating Sequences</h2>
8878 </div>
8879 <blockquote><pre>
8880 int sqlite3_create_collation(
8881 sqlite3*,
8882 const char *zName,
8883 int eTextRep,
8884 void *pArg,
8885 int(*xCompare)(void*,int,const void*,int,const void*)
8886 );
8887 int sqlite3_create_collation_v2(
8888 sqlite3*,
8889 const char *zName,
8890 int eTextRep,
8891 void *pArg,
8892 int(*xCompare)(void*,int,const void*,int,const void*),
8893 void(*xDestroy)(void*)
8894 );
8895 int sqlite3_create_collation16(
8896 sqlite3*,
8897 const void *zName,
8898 int eTextRep,
8899 void *pArg,
8900 int(*xCompare)(void*,int,const void*,int,const void*)
8901 );
8902 </pre></blockquote>
8903 <p>
8904 These functions add, remove, or modify a <a href="datatype3.html#collation">collation</a> associated
8905 with the <a href="#sqlite3">database connection</a> specified as the first argument.</p>
8906
8907 <p>The name of the collation is a UTF-8 string
8908 for sqlite3_create_collation() and sqlite3_create_collation_v2()
8909 and a UTF-16 string in native byte order for sqlite3_create_collation16().
8910 Collation names that compare equal according to <a href="#sqlite3_stricmp">sqlite3_strnicmp()</a> are
8911 considered to be the same name.</p>
8912
8913 <p>The third argument (eTextRep) must be one of the constants:
8914 <ul>
8915 <li> <a href="#SQLITE_ANY">SQLITE_UTF8</a>,
8916 <li> <a href="#SQLITE_ANY">SQLITE_UTF16LE</a>,
8917 <li> <a href="#SQLITE_ANY">SQLITE_UTF16BE</a>,
8918 <li> <a href="#SQLITE_ANY">SQLITE_UTF16</a>, or
8919 <li> <a href="#SQLITE_ANY">SQLITE_UTF16_ALIGNED</a>.
8920 </ul>
8921 The eTextRep argument determines the encoding of strings passed
8922 to the collating function callback, xCompare.
8923 The <a href="#SQLITE_ANY">SQLITE_UTF16</a> and <a href="#SQLITE_ANY">SQLITE_UTF16_ALIGNED</a> values for eTextRep
8924 force strings to be UTF16 with native byte order.
8925 The <a href="#SQLITE_ANY">SQLITE_UTF16_ALIGNED</a> value for eTextRep forces strings to begin
8926 on an even byte address.</p>
8927
8928 <p>The fourth argument, pArg, is an application data pointer that is passed
8929 through as the first argument to the collating function callback.</p>
8930
8931 <p>The fifth argument, xCompare, is a pointer to the collating function.
8932 Multiple collating functions can be registered using the same name but
8933 with different eTextRep parameters and SQLite will use whichever
8934 function requires the least amount of data transformation.
8935 If the xCompare argument is NULL then the collating function is
8936 deleted. When all collating functions having the same name are deleted,
8937 that collation is no longer usable.</p>
8938
8939 <p>The collating function callback is invoked with a copy of the pArg
8940 application data pointer and with two strings in the encoding specified
8941 by the eTextRep argument. The two integer parameters to the collating
8942 function callback are the length of the two strings, in bytes. The collating
8943 function must return an integer that is negative, zero, or positive
8944 if the first string is less than, equal to, or greater than the second,
8945 respectively. A collating function must always return the same answer
8946 given the same inputs. If two or more collating functions are registered
8947 to the same collation name (using different eTextRep values) then all
8948 must give an equivalent answer when invoked with equivalent strings.
8949 The collating function must obey the following properties for all
8950 strings A, B, and C:</p>
8951
8952 <p><ol>
8953 <li> If A==B then B==A.
8954 <li> If A==B and B==C then A==C.
8955 <li> If A&lt;B THEN B&gt;A.
8956 <li> If A&lt;B and B&lt;C then A&lt;C.
8957 </ol></p>
8958
8959 <p>If a collating function fails any of the above constraints and that
8960 collating function is registered and used, then the behavior of SQLite
8961 is undefined.</p>
8962
8963 <p>The sqlite3_create_collation_v2() works like sqlite3_create_collation()
8964 with the addition that the xDestroy callback is invoked on pArg when
8965 the collating function is deleted.
8966 Collating functions are deleted when they are overridden by later
8967 calls to the collation creation functions or when the
8968 <a href="#sqlite3">database connection</a> is closed using <a href="#sqlite3_close">sqlite3_close()</a>.</p>
8969
8970 <p>The xDestroy callback is <u>not</u> called if the
8971 sqlite3_create_collation_v2() function fails. Applications that invoke
8972 sqlite3_create_collation_v2() with a non-NULL xDestroy argument should
8973 check the return code and dispose of the application data pointer
8974 themselves rather than expecting SQLite to deal with it for them.
8975 This is different from every other SQLite interface. The inconsistency
8976 is unfortunate but cannot be changed without breaking backwards
8977 compatibility.</p>
8978
8979 <p>See also: <a href="#sqlite3_collation_needed">sqlite3_collation_needed()</a> and <a href="#sqlite3_collation_needed">sqlite3_collation_needed16()</a>.
8980 </p><hr><a name="sqlite3_create_filename"></a>
8981 <h2>Create and Destroy VFS Filenames</h2>
8982 </div>
8983 <blockquote><pre>
8984 sqlite3_filename sqlite3_create_filename(
8985 const char *zDatabase,
8986 const char *zJournal,
8987 const char *zWal,
8988 int nParam,
8989 const char **azParam
8990 );
8991 void sqlite3_free_filename(sqlite3_filename);
8992 </pre></blockquote>
8993 <p>
8994 These interfaces are provided for use by <a href="vfs.html#shim">VFS shim</a> implementations and
8995 are not useful outside of that context.</p>
8996
8997 <p>The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of
8998 database filename D with corresponding journal file J and WAL file W and
8999 with N URI parameters key/values pairs in the array P. The result from
9000 sqlite3_create_filename(D,J,W,N,P) is a pointer to a database filename that
9001 is safe to pass to routines like:
9002 <ul>
9003 <li> <a href="#sqlite3_uri_boolean">sqlite3_uri_parameter()</a>,
9004 <li> <a href="#sqlite3_uri_boolean">sqlite3_uri_boolean()</a>,
9005 <li> <a href="#sqlite3_uri_boolean">sqlite3_uri_int64()</a>,
9006 <li> <a href="#sqlite3_uri_boolean">sqlite3_uri_key()</a>,
9007 <li> <a href="#sqlite3_filename_database">sqlite3_filename_database()</a>,
9008 <li> <a href="#sqlite3_filename_database">sqlite3_filename_journal()</a>, or
9009 <li> <a href="#sqlite3_filename_database">sqlite3_filename_wal()</a>.
9010 </ul>
9011 If a memory allocation error occurs, sqlite3_create_filename() might
9012 return a NULL pointer. The memory obtained from sqlite3_create_filename(X)
9013 must be released by a corresponding call to sqlite3_free_filename(Y).</p>
9014
9015 <p>The P parameter in sqlite3_create_filename(D,J,W,N,P) should be an array
9016 of 2*N pointers to strings. Each pair of pointers in this array corresponds
9017 to a key and value for a query parameter. The P parameter may be a NULL
9018 pointer if N is zero. None of the 2*N pointers in the P array may be
9019 NULL pointers and key pointers should not be empty strings.
9020 None of the D, J, or W parameters to sqlite3_create_filename(D,J,W,N,P) may
9021 be NULL pointers, though they can be empty strings.</p>
9022
9023 <p>The sqlite3_free_filename(Y) routine releases a memory allocation
9024 previously obtained from sqlite3_create_filename(). Invoking
9025 sqlite3_free_filename(Y) where Y is a NULL pointer is a harmless no-op.</p>
9026
9027 <p>If the Y parameter to sqlite3_free_filename(Y) is anything other
9028 than a NULL pointer or a pointer previously acquired from
9029 sqlite3_create_filename(), then bad things such as heap
9030 corruption or segfaults may occur. The value Y should not be
9031 used again after sqlite3_free_filename(Y) has been called. This means
9032 that if the <a href="#sqlite3vfsxopen">sqlite3_vfs.xOpen()</a> method of a VFS has been called using Y,
9033 then the corresponding [sqlite3_module.xClose() method should also be
9034 invoked prior to calling sqlite3_free_filename(Y).
9035 </p><hr><a name="sqlite3_create_module"></a>
9036 <h2>Register A Virtual Table Implementation</h2>
9037 </div>
9038 <blockquote><pre>
9039 int sqlite3_create_module(
9040 sqlite3 *db, /* SQLite connection to register module with */
9041 const char *zName, /* Name of the module */
9042 const sqlite3_module *p, /* Methods for the module */
9043 void *pClientData /* Client data for xCreate/xConnect */
9044 );
9045 int sqlite3_create_module_v2(
9046 sqlite3 *db, /* SQLite connection to register module with */
9047 const char *zName, /* Name of the module */
9048 const sqlite3_module *p, /* Methods for the module */
9049 void *pClientData, /* Client data for xCreate/xConnect */
9050 void(*xDestroy)(void*) /* Module destructor function */
9051 );
9052 </pre></blockquote>
9053 <p>
9054 These routines are used to register a new <a href="#sqlite3_module">virtual table module</a> name.
9055 Module names must be registered before
9056 creating a new <a href="vtab.html">virtual table</a> using the module and before using a
9057 preexisting <a href="vtab.html">virtual table</a> for the module.</p>
9058
9059 <p>The module name is registered on the <a href="#sqlite3">database connection</a> specified
9060 by the first parameter. The name of the module is given by the
9061 second parameter. The third parameter is a pointer to
9062 the implementation of the <a href="#sqlite3_module">virtual table module</a>. The fourth
9063 parameter is an arbitrary client data pointer that is passed through
9064 into the <a href="vtab.html#xcreate">xCreate</a> and <a href="vtab.html#xconnect">xConnect</a> methods of the virtual table module
9065 when a new virtual table is be being created or reinitialized.</p>
9066
9067 <p>The sqlite3_create_module_v2() interface has a fifth parameter which
9068 is a pointer to a destructor for the pClientData. SQLite will
9069 invoke the destructor function (if it is not NULL) when SQLite
9070 no longer needs the pClientData pointer. The destructor will also
9071 be invoked if the call to sqlite3_create_module_v2() fails.
9072 The sqlite3_create_module()
9073 interface is equivalent to sqlite3_create_module_v2() with a NULL
9074 destructor.</p>
9075
9076 <p>If the third parameter (the pointer to the sqlite3_module object) is
9077 NULL then no new module is created and any existing modules with the
9078 same name are dropped.</p>
9079
9080 <p>See also: <a href="#sqlite3_drop_modules">sqlite3_drop_modules()</a>
9081 </p><hr><a name="sqlite3_errcode"></a>
9082 <h2>Error Codes And Messages</h2>
9083 </div>
9084 <blockquote><pre>
9085 int sqlite3_errcode(sqlite3 *db);
9086 int sqlite3_extended_errcode(sqlite3 *db);
9087 const char *sqlite3_errmsg(sqlite3*);
9088 const void *sqlite3_errmsg16(sqlite3*);
9089 const char *sqlite3_errstr(int);
9090 int sqlite3_error_offset(sqlite3 *db);
9091 </pre></blockquote>
9092 <p>
9093 If the most recent sqlite3_* API call associated with
9094 <a href="#sqlite3">database connection</a> D failed, then the sqlite3_errcode(D) interface
9095 returns the numeric <a href="rescode.html">result code</a> or <a href="rescode.html#extrc">extended result code</a> for that
9096 API call.
9097 The sqlite3_extended_errcode()
9098 interface is the same except that it always returns the
9099 <a href="rescode.html#extrc">extended result code</a> even when extended result codes are
9100 disabled.</p>
9101
9102 <p>The values returned by sqlite3_errcode() and/or
9103 sqlite3_extended_errcode() might change with each API call.
9104 Except, there are some interfaces that are guaranteed to never
9105 change the value of the error code. The error-code preserving
9106 interfaces include the following:</p>
9107
9108 <p><ul>
9109 <li> sqlite3_errcode()
9110 <li> sqlite3_extended_errcode()
9111 <li> sqlite3_errmsg()
9112 <li> sqlite3_errmsg16()
9113 <li> sqlite3_error_offset()
9114 </ul></p>
9115
9116 <p>The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
9117 text that describes the error, as either UTF-8 or UTF-16 respectively,
9118 or NULL if no error message is available.
9119 (See how SQLite handles <a href="invalidutf.html">invalid UTF</a> for exceptions to this rule.)
9120 Memory to hold the error message string is managed internally.
9121 The application does not need to worry about freeing the result.
9122 However, the error string might be overwritten or deallocated by
9123 subsequent calls to other SQLite interface functions.</p>
9124
9125 <p>The sqlite3_errstr(E) interface returns the English-language text
9126 that describes the <a href="rescode.html">result code</a> E, as UTF-8, or NULL if E is not an
9127 result code for which a text error message is available.
9128 Memory to hold the error message string is managed internally
9129 and must not be freed by the application.</p>
9130
9131 <p>If the most recent error references a specific token in the input
9132 SQL, the sqlite3_error_offset() interface returns the byte offset
9133 of the start of that token. The byte offset returned by
9134 sqlite3_error_offset() assumes that the input SQL is UTF8.
9135 If the most recent error does not reference a specific token in the input
9136 SQL, then the sqlite3_error_offset() function returns -1.</p>
9137
9138 <p>When the serialized <a href="threadsafe.html">threading mode</a> is in use, it might be the
9139 case that a second error occurs on a separate thread in between
9140 the time of the first error and the call to these interfaces.
9141 When that happens, the second error will be reported since these
9142 interfaces always report the most recent result. To avoid
9143 this, each thread can obtain exclusive use of the <a href="#sqlite3">database connection</a> D
9144 by invoking <a href="#sqlite3_mutex_alloc">sqlite3_mutex_enter</a>(<a href="#sqlite3_db_mutex">sqlite3_db_mutex</a>(D)) before beginning
9145 to use D and invoking <a href="#sqlite3_mutex_alloc">sqlite3_mutex_leave</a>(<a href="#sqlite3_db_mutex">sqlite3_db_mutex</a>(D)) after
9146 all calls to the interfaces listed here are completed.</p>
9147
9148 <p>If an interface fails with SQLITE_MISUSE, that means the interface
9149 was invoked incorrectly by the application. In that case, the
9150 error code and message may or may not be set.
9151 </p><hr><a name="sqlite3_expanded_sql"></a>
9152 <h2>Retrieving Statement SQL</h2>
9153 </div>
9154 <blockquote><pre>
9155 const char *sqlite3_sql(sqlite3_stmt *pStmt);
9156 char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
9157 #ifdef SQLITE_ENABLE_NORMALIZE
9158 const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
9159 #endif
9160 </pre></blockquote>
9161 <p>
9162 The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
9163 SQL text used to create <a href="#sqlite3_stmt">prepared statement</a> P if P was
9164 created by <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>, <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a>,
9165 <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a>, or <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a>.
9166 The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
9167 string containing the SQL text of prepared statement P with
9168 <a href="lang_expr.html#varparam">bound parameters</a> expanded.
9169 The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8
9170 string containing the normalized SQL text of prepared statement P. The
9171 semantics used to normalize a SQL statement are unspecified and subject
9172 to change. At a minimum, literal values will be replaced with suitable
9173 placeholders.</p>
9174
9175 <p>For example, if a prepared statement is created using the SQL
9176 text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
9177 and parameter :xyz is unbound, then sqlite3_sql() will return
9178 the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
9179 will return "SELECT 2345,NULL".</p>
9180
9181 <p>The sqlite3_expanded_sql() interface returns NULL if insufficient memory
9182 is available to hold the result, or if the result would exceed the
9183 the maximum string length determined by the <a href="#sqlitelimitlength">SQLITE_LIMIT_LENGTH</a>.</p>
9184
9185 <p>The <a href="compile.html#trace_size_limit">SQLITE_TRACE_SIZE_LIMIT</a> compile-time option limits the size of
9186 bound parameter expansions. The <a href="compile.html#omit_trace">SQLITE_OMIT_TRACE</a> compile-time
9187 option causes sqlite3_expanded_sql() to always return NULL.</p>
9188
9189 <p>The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
9190 are managed by SQLite and are automatically freed when the prepared
9191 statement is finalized.
9192 The string returned by sqlite3_expanded_sql(P), on the other hand,
9193 is obtained from <a href="#sqlite3_free">sqlite3_malloc()</a> and must be freed by the application
9194 by passing it to <a href="#sqlite3_free">sqlite3_free()</a>.</p>
9195
9196 <p>The sqlite3_normalized_sql() interface is only available if
9197 the <a href="compile.html#enable_normalize">SQLITE_ENABLE_NORMALIZE</a> compile-time option is defined.
9198 </p><hr><a name="sqlite3_filename_database"></a>
9199 <h2>Translate filenames</h2>
9200 </div>
9201 <blockquote><pre>
9202 const char *sqlite3_filename_database(sqlite3_filename);
9203 const char *sqlite3_filename_journal(sqlite3_filename);
9204 const char *sqlite3_filename_wal(sqlite3_filename);
9205 </pre></blockquote>
9206 <p>
9207 These routines are available to <a href="vfs.html">custom VFS implementations</a> for
9208 translating filenames between the main database file, the journal file,
9209 and the WAL file.</p>
9210
9211 <p>If F is the name of an sqlite database file, journal file, or WAL file
9212 passed by the SQLite core into the VFS, then sqlite3_filename_database(F)
9213 returns the name of the corresponding database file.</p>
9214
9215 <p>If F is the name of an sqlite database file, journal file, or WAL file
9216 passed by the SQLite core into the VFS, or if F is a database filename
9217 obtained from <a href="#sqlite3_db_filename">sqlite3_db_filename()</a>, then sqlite3_filename_journal(F)
9218 returns the name of the corresponding rollback journal file.</p>
9219
9220 <p>If F is the name of an sqlite database file, journal file, or WAL file
9221 that was passed by the SQLite core into the VFS, or if F is a database
9222 filename obtained from <a href="#sqlite3_db_filename">sqlite3_db_filename()</a>, then
9223 sqlite3_filename_wal(F) returns the name of the corresponding
9224 WAL file.</p>
9225
9226 <p>In all of the above, if F is not the name of a database, journal or WAL
9227 filename passed into the VFS from the SQLite core and F is not the
9228 return value from <a href="#sqlite3_db_filename">sqlite3_db_filename()</a>, then the result is
9229 undefined and is likely a memory access violation.
9230 </p><hr><a name="sqlite3_free"></a>
9231 <h2>Memory Allocation Subsystem</h2>
9232 </div>
9233 <blockquote><pre>
9234 void *sqlite3_malloc(int);
9235 void *sqlite3_malloc64(sqlite3_uint64);
9236 void *sqlite3_realloc(void*, int);
9237 void *sqlite3_realloc64(void*, sqlite3_uint64);
9238 void sqlite3_free(void*);
9239 sqlite3_uint64 sqlite3_msize(void*);
9240 </pre></blockquote>
9241 <p>
9242 The SQLite core uses these three routines for all of its own
9243 internal memory allocation needs. "Core" in the previous sentence
9244 does not include operating-system specific <a href="vfs.html">VFS</a> implementation. The
9245 Windows VFS uses native malloc() and free() for some operations.</p>
9246
9247 <p>The sqlite3_malloc() routine returns a pointer to a block
9248 of memory at least N bytes in length, where N is the parameter.
9249 If sqlite3_malloc() is unable to obtain sufficient free
9250 memory, it returns a NULL pointer. If the parameter N to
9251 sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
9252 a NULL pointer.</p>
9253
9254 <p>The sqlite3_malloc64(N) routine works just like
9255 sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead
9256 of a signed 32-bit integer.</p>
9257
9258 <p>Calling sqlite3_free() with a pointer previously returned
9259 by sqlite3_malloc() or sqlite3_realloc() releases that memory so
9260 that it might be reused. The sqlite3_free() routine is
9261 a no-op if is called with a NULL pointer. Passing a NULL pointer
9262 to sqlite3_free() is harmless. After being freed, memory
9263 should neither be read nor written. Even reading previously freed
9264 memory might result in a segmentation fault or other severe error.
9265 Memory corruption, a segmentation fault, or other severe error
9266 might result if sqlite3_free() is called with a non-NULL pointer that
9267 was not obtained from sqlite3_malloc() or sqlite3_realloc().</p>
9268
9269 <p>The sqlite3_realloc(X,N) interface attempts to resize a
9270 prior memory allocation X to be at least N bytes.
9271 If the X parameter to sqlite3_realloc(X,N)
9272 is a NULL pointer then its behavior is identical to calling
9273 sqlite3_malloc(N).
9274 If the N parameter to sqlite3_realloc(X,N) is zero or
9275 negative then the behavior is exactly the same as calling
9276 sqlite3_free(X).
9277 sqlite3_realloc(X,N) returns a pointer to a memory allocation
9278 of at least N bytes in size or NULL if insufficient memory is available.
9279 If M is the size of the prior allocation, then min(N,M) bytes
9280 of the prior allocation are copied into the beginning of buffer returned
9281 by sqlite3_realloc(X,N) and the prior allocation is freed.
9282 If sqlite3_realloc(X,N) returns NULL and N is positive, then the
9283 prior allocation is not freed.</p>
9284
9285 <p>The sqlite3_realloc64(X,N) interfaces works the same as
9286 sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
9287 of a 32-bit signed integer.</p>
9288
9289 <p>If X is a memory allocation previously obtained from sqlite3_malloc(),
9290 sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then
9291 sqlite3_msize(X) returns the size of that memory allocation in bytes.
9292 The value returned by sqlite3_msize(X) might be larger than the number
9293 of bytes requested when X was allocated. If X is a NULL pointer then
9294 sqlite3_msize(X) returns zero. If X points to something that is not
9295 the beginning of memory allocation, or if it points to a formerly
9296 valid memory allocation that has now been freed, then the behavior
9297 of sqlite3_msize(X) is undefined and possibly harmful.</p>
9298
9299 <p>The memory returned by sqlite3_malloc(), sqlite3_realloc(),
9300 sqlite3_malloc64(), and sqlite3_realloc64()
9301 is always aligned to at least an 8 byte boundary, or to a
9302 4 byte boundary if the <a href="compile.html#4_byte_aligned_malloc">SQLITE_4_BYTE_ALIGNED_MALLOC</a> compile-time
9303 option is used.</p>
9304
9305 <p>The pointer arguments to <a href="#sqlite3_free">sqlite3_free()</a> and <a href="#sqlite3_free">sqlite3_realloc()</a>
9306 must be either NULL or else pointers obtained from a prior
9307 invocation of <a href="#sqlite3_free">sqlite3_malloc()</a> or <a href="#sqlite3_free">sqlite3_realloc()</a> that have
9308 not yet been released.</p>
9309
9310 <p>The application must not read or write any part of
9311 a block of memory after it has been released using
9312 <a href="#sqlite3_free">sqlite3_free()</a> or <a href="#sqlite3_free">sqlite3_realloc()</a>.
9313 </p><hr><a name="sqlite3_free_table"></a>
9314 <h2>Convenience Routines For Running Queries</h2>
9315 </div>
9316 <blockquote><pre>
9317 int sqlite3_get_table(
9318 sqlite3 *db, /* An open database */
9319 const char *zSql, /* SQL to be evaluated */
9320 char ***pazResult, /* Results of the query */
9321 int *pnRow, /* Number of result rows written here */
9322 int *pnColumn, /* Number of result columns written here */
9323 char **pzErrmsg /* Error msg written here */
9324 );
9325 void sqlite3_free_table(char **result);
9326 </pre></blockquote>
9327 <p>
9328 This is a legacy interface that is preserved for backwards compatibility.
9329 Use of this interface is not recommended.</p>
9330
9331 <p>Definition: A <b>result table</b> is memory data structure created by the
9332 <a href="#sqlite3_free_table">sqlite3_get_table()</a> interface. A result table records the
9333 complete query results from one or more queries.</p>
9334
9335 <p>The table conceptually has a number of rows and columns. But
9336 these numbers are not part of the result table itself. These
9337 numbers are obtained separately. Let N be the number of rows
9338 and M be the number of columns.</p>
9339
9340 <p>A result table is an array of pointers to zero-terminated UTF-8 strings.
9341 There are (N+1)*M elements in the array. The first M pointers point
9342 to zero-terminated strings that contain the names of the columns.
9343 The remaining entries all point to query results. NULL values result
9344 in NULL pointers. All other values are in their UTF-8 zero-terminated
9345 string representation as returned by <a href="#sqlite3_column_blob">sqlite3_column_text()</a>.</p>
9346
9347 <p>A result table might consist of one or more memory allocations.
9348 It is not safe to pass a result table directly to <a href="#sqlite3_free">sqlite3_free()</a>.
9349 A result table should be deallocated using <a href="#sqlite3_free_table">sqlite3_free_table()</a>.</p>
9350
9351 <p>As an example of the result table format, suppose a query result
9352 is as follows:</p>
9353
9354 <p><blockquote><pre>
9355 Name | Age
9356 -----------------------
9357 Alice | 43
9358 Bob | 28
9359 Cindy | 21
9360 </pre></blockquote></p>
9361
9362 <p>There are two columns (M==2) and three rows (N==3). Thus the
9363 result table has 8 entries. Suppose the result table is stored
9364 in an array named azResult. Then azResult holds this content:</p>
9365
9366 <p><blockquote><pre>
9367 azResult&#91;0] = "Name";
9368 azResult&#91;1] = "Age";
9369 azResult&#91;2] = "Alice";
9370 azResult&#91;3] = "43";
9371 azResult&#91;4] = "Bob";
9372 azResult&#91;5] = "28";
9373 azResult&#91;6] = "Cindy";
9374 azResult&#91;7] = "21";
9375 </pre></blockquote></p>
9376
9377 <p>The sqlite3_get_table() function evaluates one or more
9378 semicolon-separated SQL statements in the zero-terminated UTF-8
9379 string of its 2nd parameter and returns a result table to the
9380 pointer given in its 3rd parameter.</p>
9381
9382 <p>After the application has finished with the result from sqlite3_get_table(),
9383 it must pass the result table pointer to sqlite3_free_table() in order to
9384 release the memory that was malloced. Because of the way the
9385 <a href="#sqlite3_free">sqlite3_malloc()</a> happens within sqlite3_get_table(), the calling
9386 function must not try to call <a href="#sqlite3_free">sqlite3_free()</a> directly. Only
9387 <a href="#sqlite3_free_table">sqlite3_free_table()</a> is able to release the memory properly and safely.</p>
9388
9389 <p>The sqlite3_get_table() interface is implemented as a wrapper around
9390 <a href="#sqlite3_exec">sqlite3_exec()</a>. The sqlite3_get_table() routine does not have access
9391 to any internal data structures of SQLite. It uses only the public
9392 interface defined here. As a consequence, errors that occur in the
9393 wrapper layer outside of the internal <a href="#sqlite3_exec">sqlite3_exec()</a> call are not
9394 reflected in subsequent calls to <a href="#sqlite3_errcode">sqlite3_errcode()</a> or
9395 <a href="#sqlite3_errcode">sqlite3_errmsg()</a>.
9396 </p><hr><a name="sqlite3_get_auxdata"></a>
9397 <h2>Function Auxiliary Data</h2>
9398 </div>
9399 <blockquote><pre>
9400 void *sqlite3_get_auxdata(sqlite3_context*, int N);
9401 void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
9402 </pre></blockquote>
9403 <p>
9404 These functions may be used by (non-aggregate) SQL functions to
9405 associate auxiliary data with argument values. If the same argument
9406 value is passed to multiple invocations of the same SQL function during
9407 query execution, under some circumstances the associated auxiliary data
9408 might be preserved. An example of where this might be useful is in a
9409 regular-expression matching function. The compiled version of the regular
9410 expression can be stored as auxiliary data associated with the pattern string.
9411 Then as long as the pattern string remains the same,
9412 the compiled regular expression can be reused on multiple
9413 invocations of the same function.</p>
9414
9415 <p>The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
9416 associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
9417 value to the application-defined function. N is zero for the left-most
9418 function argument. If there is no auxiliary data
9419 associated with the function argument, the sqlite3_get_auxdata(C,N) interface
9420 returns a NULL pointer.</p>
9421
9422 <p>The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
9423 N-th argument of the application-defined function. Subsequent
9424 calls to sqlite3_get_auxdata(C,N) return P from the most recent
9425 sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
9426 NULL if the auxiliary data has been discarded.
9427 After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
9428 SQLite will invoke the destructor function X with parameter P exactly
9429 once, when the auxiliary data is discarded.
9430 SQLite is free to discard the auxiliary data at any time, including: <ul>
9431 <li> when the corresponding function parameter changes, or
9432 <li> when <a href="#sqlite3_reset">sqlite3_reset()</a> or <a href="#sqlite3_finalize">sqlite3_finalize()</a> is called for the
9433 SQL statement, or
9434 <li> when sqlite3_set_auxdata() is invoked again on the same
9435 parameter, or
9436 <li> during the original sqlite3_set_auxdata() call when a memory
9437 allocation error occurs.
9438 <li> during the original sqlite3_set_auxdata() call if the function
9439 is evaluated during query planning instead of during query execution,
9440 as sometimes happens with <a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a>. </ul></p>
9441
9442 <p>Note the last two bullets in particular. The destructor X in
9443 sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
9444 sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
9445 should be called near the end of the function implementation and the
9446 function implementation should not make any use of P after
9447 sqlite3_set_auxdata() has been called. Furthermore, a call to
9448 sqlite3_get_auxdata() that occurs immediately after a corresponding call
9449 to sqlite3_set_auxdata() might still return NULL if an out-of-memory
9450 condition occurred during the sqlite3_set_auxdata() call or if the
9451 function is being evaluated during query planning rather than during
9452 query execution.</p>
9453
9454 <p>In practice, auxiliary data is preserved between function calls for
9455 function parameters that are compile-time constants, including literal
9456 values and <a href="lang_expr.html#varparam">parameters</a> and expressions composed from the same.</p>
9457
9458 <p>The value of the N parameter to these interfaces should be non-negative.
9459 Future enhancements may make use of negative N values to define new
9460 kinds of function caching behavior.</p>
9461
9462 <p>These routines must be called from the same thread in which
9463 the SQL function is running.</p>
9464
9465 <p>See also: <a href="#sqlite3_get_clientdata">sqlite3_get_clientdata()</a> and <a href="#sqlite3_get_clientdata">sqlite3_set_clientdata()</a>.
9466 </p><hr><a name="sqlite3_get_clientdata"></a>
9467 <h2>Database Connection Client Data</h2>
9468 </div>
9469 <blockquote><pre>
9470 void *sqlite3_get_clientdata(sqlite3*,const char*);
9471 int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*));
9472 </pre></blockquote>
9473 <p>
9474 These functions are used to associate one or more named pointers
9475 with a <a href="#sqlite3">database connection</a>.
9476 A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P
9477 to be attached to <a href="#sqlite3">database connection</a> D using name N. Subsequent
9478 calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P
9479 or a NULL pointer if there were no prior calls to
9480 sqlite3_set_clientdata() with the same values of D and N.
9481 Names are compared using strcmp() and are thus case sensitive.</p>
9482
9483 <p>If P and X are both non-NULL, then the destructor X is invoked with
9484 argument P on the first of the following occurrences:
9485 <ul>
9486 <li> An out-of-memory error occurs during the call to
9487 sqlite3_set_clientdata() which attempts to register pointer P.
9488 <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made
9489 with the same D and N parameters.
9490 <li> The database connection closes. SQLite does not make any guarantees
9491 about the order in which destructors are called, only that all
9492 destructors will be called exactly once at some point during the
9493 database connection closing process.
9494 </ul></p>
9495
9496 <p>SQLite does not do anything with client data other than invoke
9497 destructors on the client data at the appropriate time. The intended
9498 use for client data is to provide a mechanism for wrapper libraries
9499 to store additional information about an SQLite database connection.</p>
9500
9501 <p>There is no limit (other than available memory) on the number of different
9502 client data pointers (with different names) that can be attached to a
9503 single database connection. However, the implementation is optimized
9504 for the case of having only one or two different client data names.
9505 Applications and wrapper libraries are discouraged from using more than
9506 one client data name each.</p>
9507
9508 <p>There is no way to enumerate the client data pointers
9509 associated with a database connection. The N parameter can be thought
9510 of as a secret key such that only code that knows the secret key is able
9511 to access the associated data.</p>
9512
9513 <p>Security Warning: These interfaces should not be exposed in scripting
9514 languages or in other circumstances where it might be possible for an
9515 an attacker to invoke them. Any agent that can invoke these interfaces
9516 can probably also take control of the process.</p>
9517
9518 <p>Database connection client data is only available for SQLite
9519 version 3.44.0 (2023-11-01) and later.</p>
9520
9521 <p>See also: <a href="#sqlite3_get_auxdata">sqlite3_set_auxdata()</a> and <a href="#sqlite3_get_auxdata">sqlite3_get_auxdata()</a>.
9522 </p><hr><a name="sqlite3_hard_heap_limit64"></a>
9523 <h2>Impose A Limit On Heap Size</h2>
9524 </div>
9525 <blockquote><pre>
9526 sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
9527 sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
9528 </pre></blockquote>
9529 <p>
9530 These interfaces impose limits on the amount of heap memory that will be
9531 by all database connections within a single process.</p>
9532
9533 <p>The sqlite3_soft_heap_limit64() interface sets and/or queries the
9534 soft limit on the amount of heap memory that may be allocated by SQLite.
9535 SQLite strives to keep heap memory utilization below the soft heap
9536 limit by reducing the number of pages held in the page cache
9537 as heap memory usages approaches the limit.
9538 The soft heap limit is "soft" because even though SQLite strives to stay
9539 below the limit, it will exceed the limit rather than generate
9540 an <a href="#SQLITE_ABORT">SQLITE_NOMEM</a> error. In other words, the soft heap limit
9541 is advisory only.</p>
9542
9543 <p>The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of
9544 N bytes on the amount of memory that will be allocated. The
9545 sqlite3_hard_heap_limit64(N) interface is similar to
9546 sqlite3_soft_heap_limit64(N) except that memory allocations will fail
9547 when the hard heap limit is reached.</p>
9548
9549 <p>The return value from both sqlite3_soft_heap_limit64() and
9550 sqlite3_hard_heap_limit64() is the size of
9551 the heap limit prior to the call, or negative in the case of an
9552 error. If the argument N is negative
9553 then no change is made to the heap limit. Hence, the current
9554 size of heap limits can be determined by invoking
9555 sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1).</p>
9556
9557 <p>Setting the heap limits to zero disables the heap limiter mechanism.</p>
9558
9559 <p>The soft heap limit may not be greater than the hard heap limit.
9560 If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
9561 is invoked with a value of N that is greater than the hard heap limit,
9562 the soft heap limit is set to the value of the hard heap limit.
9563 The soft heap limit is automatically enabled whenever the hard heap
9564 limit is enabled. When sqlite3_hard_heap_limit64(N) is invoked and
9565 the soft heap limit is outside the range of 1..N, then the soft heap
9566 limit is set to N. Invoking sqlite3_soft_heap_limit64(0) when the
9567 hard heap limit is enabled makes the soft heap limit equal to the
9568 hard heap limit.</p>
9569
9570 <p>The memory allocation limits can also be adjusted using
9571 <a href="pragma.html#pragma_soft_heap_limit">PRAGMA soft_heap_limit</a> and <a href="pragma.html#pragma_hard_heap_limit">PRAGMA hard_heap_limit</a>.</p>
9572
9573 <p>The heap limits are not enforced in the current implementation
9574 if one or more of following conditions are true:</p>
9575
9576 <p><ul>
9577 <li> The limit value is set to zero.
9578 <li> Memory accounting is disabled using a combination of the
9579 <a href="#sqlite3_config">sqlite3_config</a>(<a href="#sqliteconfigmemstatus">SQLITE_CONFIG_MEMSTATUS</a>,...) start-time option and
9580 the <a href="compile.html#default_memstatus">SQLITE_DEFAULT_MEMSTATUS</a> compile-time option.
9581 <li> An alternative page cache implementation is specified using
9582 <a href="#sqlite3_config">sqlite3_config</a>(<a href="#sqliteconfigpcache2">SQLITE_CONFIG_PCACHE2</a>,...).
9583 <li> The page cache allocates from its own memory pool supplied
9584 by <a href="#sqlite3_config">sqlite3_config</a>(<a href="#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>,...) rather than
9585 from the heap.
9586 </ul></p>
9587
9588 <p>The circumstances under which SQLite will enforce the heap limits may
9589 changes in future releases of SQLite.
9590 </p><hr><a name="sqlite3_initialize"></a>
9591 <h2>Initialize The SQLite Library</h2>
9592 </div>
9593 <blockquote><pre>
9594 int sqlite3_initialize(void);
9595 int sqlite3_shutdown(void);
9596 int sqlite3_os_init(void);
9597 int sqlite3_os_end(void);
9598 </pre></blockquote>
9599 <p>
9600 The sqlite3_initialize() routine initializes the
9601 SQLite library. The sqlite3_shutdown() routine
9602 deallocates any resources that were allocated by sqlite3_initialize().
9603 These routines are designed to aid in process initialization and
9604 shutdown on embedded systems. Workstation applications using
9605 SQLite normally do not need to invoke either of these routines.</p>
9606
9607 <p>A call to sqlite3_initialize() is an "effective" call if it is
9608 the first time sqlite3_initialize() is invoked during the lifetime of
9609 the process, or if it is the first time sqlite3_initialize() is invoked
9610 following a call to sqlite3_shutdown(). Only an effective call
9611 of sqlite3_initialize() does any initialization. All other calls
9612 are harmless no-ops.</p>
9613
9614 <p>A call to sqlite3_shutdown() is an "effective" call if it is the first
9615 call to sqlite3_shutdown() since the last sqlite3_initialize(). Only
9616 an effective call to sqlite3_shutdown() does any deinitialization.
9617 All other valid calls to sqlite3_shutdown() are harmless no-ops.</p>
9618
9619 <p>The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
9620 is not. The sqlite3_shutdown() interface must only be called from a
9621 single thread. All open <a href="#sqlite3">database connections</a> must be closed and all
9622 other SQLite resources must be deallocated prior to invoking
9623 sqlite3_shutdown().</p>
9624
9625 <p>Among other things, sqlite3_initialize() will invoke
9626 sqlite3_os_init(). Similarly, sqlite3_shutdown()
9627 will invoke sqlite3_os_end().</p>
9628
9629 <p>The sqlite3_initialize() routine returns <a href="#SQLITE_ABORT">SQLITE_OK</a> on success.
9630 If for some reason, sqlite3_initialize() is unable to initialize
9631 the library (perhaps it is unable to allocate a needed resource such
9632 as a mutex) it returns an <a href="rescode.html">error code</a> other than <a href="#SQLITE_ABORT">SQLITE_OK</a>.</p>
9633
9634 <p>The sqlite3_initialize() routine is called internally by many other
9635 SQLite interfaces so that an application usually does not need to
9636 invoke sqlite3_initialize() directly. For example, <a href="#sqlite3_open">sqlite3_open()</a>
9637 calls sqlite3_initialize() so the SQLite library will be automatically
9638 initialized when <a href="#sqlite3_open">sqlite3_open()</a> is called if it has not be initialized
9639 already. However, if SQLite is compiled with the <a href="compile.html#omit_autoinit">SQLITE_OMIT_AUTOINIT</a>
9640 compile-time option, then the automatic calls to sqlite3_initialize()
9641 are omitted and the application must call sqlite3_initialize() directly
9642 prior to using any other SQLite interface. For maximum portability,
9643 it is recommended that applications always invoke sqlite3_initialize()
9644 directly prior to using any other SQLite interface. Future releases
9645 of SQLite may require this. In other words, the behavior exhibited
9646 when SQLite is compiled with <a href="compile.html#omit_autoinit">SQLITE_OMIT_AUTOINIT</a> might become the
9647 default behavior in some future release of SQLite.</p>
9648
9649 <p>The sqlite3_os_init() routine does operating-system specific
9650 initialization of the SQLite library. The sqlite3_os_end()
9651 routine undoes the effect of sqlite3_os_init(). Typical tasks
9652 performed by these routines include allocation or deallocation
9653 of static resources, initialization of global variables,
9654 setting up a default <a href="#sqlite3_vfs">sqlite3_vfs</a> module, or setting up
9655 a default configuration using <a href="#sqlite3_config">sqlite3_config()</a>.</p>
9656
9657 <p>The application should never invoke either sqlite3_os_init()
9658 or sqlite3_os_end() directly. The application should only invoke
9659 sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init()
9660 interface is called automatically by sqlite3_initialize() and
9661 sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate
9662 implementations for sqlite3_os_init() and sqlite3_os_end()
9663 are built into SQLite when it is compiled for Unix, Windows, or OS/2.
9664 When <a href="custombuild.html">built for other platforms</a>
9665 (using the <a href="compile.html#os_other">SQLITE_OS_OTHER=1</a> compile-time
9666 option) the application must supply a suitable implementation for
9667 sqlite3_os_init() and sqlite3_os_end(). An application-supplied
9668 implementation of sqlite3_os_init() or sqlite3_os_end()
9669 must return <a href="#SQLITE_ABORT">SQLITE_OK</a> on success and some other <a href="rescode.html">error code</a> upon
9670 failure.
9671 </p><hr><a name="sqlite3_interrupt"></a>
9672 <h2>Interrupt A Long-Running Query</h2>
9673 </div>
9674 <blockquote><pre>
9675 void sqlite3_interrupt(sqlite3*);
9676 int sqlite3_is_interrupted(sqlite3*);
9677 </pre></blockquote>
9678 <p>
9679 This function causes any pending database operation to abort and
9680 return at its earliest opportunity. This routine is typically
9681 called in response to a user action such as pressing "Cancel"
9682 or Ctrl-C where the user wants a long query operation to halt
9683 immediately.</p>
9684
9685 <p>It is safe to call this routine from a thread different from the
9686 thread that is currently running the database operation. But it
9687 is not safe to call this routine with a <a href="#sqlite3">database connection</a> that
9688 is closed or might close before sqlite3_interrupt() returns.</p>
9689
9690 <p>If an SQL operation is very nearly finished at the time when
9691 sqlite3_interrupt() is called, then it might not have an opportunity
9692 to be interrupted and might continue to completion.</p>
9693
9694 <p>An SQL operation that is interrupted will return <a href="#SQLITE_ABORT">SQLITE_INTERRUPT</a>.
9695 If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
9696 that is inside an explicit transaction, then the entire transaction
9697 will be rolled back automatically.</p>
9698
9699 <p>The sqlite3_interrupt(D) call is in effect until all currently running
9700 SQL statements on <a href="#sqlite3">database connection</a> D complete. Any new SQL statements
9701 that are started after the sqlite3_interrupt() call and before the
9702 running statement count reaches zero are interrupted as if they had been
9703 running prior to the sqlite3_interrupt() call. New SQL statements
9704 that are started after the running statement count reaches zero are
9705 not effected by the sqlite3_interrupt().
9706 A call to sqlite3_interrupt(D) that occurs when there are no running
9707 SQL statements is a no-op and has no effect on SQL statements
9708 that are started after the sqlite3_interrupt() call returns.</p>
9709
9710 <p>The <a href="#sqlite3_interrupt">sqlite3_is_interrupted(D)</a> interface can be used to determine whether
9711 or not an interrupt is currently in effect for <a href="#sqlite3">database connection</a> D.
9712 It returns 1 if an interrupt is currently in effect, or 0 otherwise.
9713 </p><hr><a name="sqlite3_keyword_check"></a>
9714 <h2>SQL Keyword Checking</h2>
9715 </div>
9716 <blockquote><pre>
9717 int sqlite3_keyword_count(void);
9718 int sqlite3_keyword_name(int,const char**,int*);
9719 int sqlite3_keyword_check(const char*,int);
9720 </pre></blockquote>
9721 <p>
9722 These routines provide access to the set of SQL language keywords
9723 recognized by SQLite. Applications can uses these routines to determine
9724 whether or not a specific identifier needs to be escaped (for example,
9725 by enclosing in double-quotes) so as not to confuse the parser.</p>
9726
9727 <p>The sqlite3_keyword_count() interface returns the number of distinct
9728 keywords understood by SQLite.</p>
9729
9730 <p>The sqlite3_keyword_name(N,Z,L) interface finds the 0-based N-th keyword and
9731 makes *Z point to that keyword expressed as UTF8 and writes the number
9732 of bytes in the keyword into *L. The string that *Z points to is not
9733 zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns
9734 SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z
9735 or L are NULL or invalid pointers then calls to
9736 sqlite3_keyword_name(N,Z,L) result in undefined behavior.</p>
9737
9738 <p>The sqlite3_keyword_check(Z,L) interface checks to see whether or not
9739 the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero
9740 if it is and zero if not.</p>
9741
9742 <p>The parser used by SQLite is forgiving. It is often possible to use
9743 a keyword as an identifier as long as such use does not result in a
9744 parsing ambiguity. For example, the statement
9745 "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and
9746 creates a new table named "BEGIN" with three columns named
9747 "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid
9748 using keywords as identifiers. Common techniques used to avoid keyword
9749 name collisions include:
9750 <ul>
9751 <li> Put all identifier names inside double-quotes. This is the official
9752 SQL way to escape identifier names.
9753 <li> Put identifier names inside &#91;...&#93;. This is not standard SQL,
9754 but it is what SQL Server does and so lots of programmers use this
9755 technique.
9756 <li> Begin every identifier with the letter "Z" as no SQL keywords start
9757 with "Z".
9758 <li> Include a digit somewhere in every identifier name.
9759 </ul></p>
9760
9761 <p>Note that the number of keywords understood by SQLite can depend on
9762 compile-time options. For example, "VACUUM" is not a keyword if
9763 SQLite is compiled with the <a href="compile.html#omit_vacuum">-DSQLITE_OMIT_VACUUM</a> option. Also,
9764 new keywords may be added to future releases of SQLite.
9765 </p><hr><a name="sqlite3_libversion"></a>
9766 <h2>Run-Time Library Version Numbers</h2>
9767 </div>
9768 <blockquote><pre>
9769 SQLITE_EXTERN const char sqlite3_version[];
9770 const char *sqlite3_libversion(void);
9771 const char *sqlite3_sourceid(void);
9772 int sqlite3_libversion_number(void);
9773 </pre></blockquote>
9774 <p>
9775 These interfaces provide the same information as the <a href="#SQLITE_SOURCE_ID">SQLITE_VERSION</a>,
9776 <a href="#SQLITE_SOURCE_ID">SQLITE_VERSION_NUMBER</a>, and <a href="#SQLITE_SOURCE_ID">SQLITE_SOURCE_ID</a> C preprocessor macros
9777 but are associated with the library instead of the header file. Cautious
9778 programmers might include assert() statements in their application to
9779 verify that values returned by these interfaces match the macros in
9780 the header, and thus ensure that the application is
9781 compiled with matching library and header files.</p>
9782
9783 <p><blockquote><pre>
9784 assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
9785 assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
9786 assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
9787 </pre></blockquote></p>
9788
9789 <p>The sqlite3_version[] string constant contains the text of <a href="#SQLITE_SOURCE_ID">SQLITE_VERSION</a>
9790 macro. The sqlite3_libversion() function returns a pointer to the
9791 to the sqlite3_version[] string constant. The sqlite3_libversion()
9792 function is provided for use in DLLs since DLL users usually do not have
9793 direct access to string constants within the DLL. The
9794 sqlite3_libversion_number() function returns an integer equal to
9795 <a href="#SQLITE_SOURCE_ID">SQLITE_VERSION_NUMBER</a>. The sqlite3_sourceid() function returns
9796 a pointer to a string constant whose value is the same as the
9797 <a href="#SQLITE_SOURCE_ID">SQLITE_SOURCE_ID</a> C preprocessor macro. Except if SQLite is built
9798 using an edited copy of <a href="amalgamation.html">the amalgamation</a>, then the last four characters
9799 of the hash might be different from <a href="#SQLITE_SOURCE_ID">SQLITE_SOURCE_ID</a>.</p>
9800
9801 <p>See also: <a href="lang_corefunc.html#sqlite_version">sqlite_version()</a> and <a href="lang_corefunc.html#sqlite_source_id">sqlite_source_id()</a>.
9802 </p><hr><a name="sqlite3_memory_highwater"></a>
9803 <h2>Memory Allocator Statistics</h2>
9804 </div>
9805 <blockquote><pre>
9806 sqlite3_int64 sqlite3_memory_used(void);
9807 sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
9808 </pre></blockquote>
9809 <p>
9810 SQLite provides these two interfaces for reporting on the status
9811 of the <a href="#sqlite3_free">sqlite3_malloc()</a>, <a href="#sqlite3_free">sqlite3_free()</a>, and <a href="#sqlite3_free">sqlite3_realloc()</a>
9812 routines, which form the built-in memory allocation subsystem.</p>
9813
9814 <p>The <a href="#sqlite3_memory_highwater">sqlite3_memory_used()</a> routine returns the number of bytes
9815 of memory currently outstanding (malloced but not freed).
9816 The <a href="#sqlite3_memory_highwater">sqlite3_memory_highwater()</a> routine returns the maximum
9817 value of <a href="#sqlite3_memory_highwater">sqlite3_memory_used()</a> since the high-water mark
9818 was last reset. The values returned by <a href="#sqlite3_memory_highwater">sqlite3_memory_used()</a> and
9819 <a href="#sqlite3_memory_highwater">sqlite3_memory_highwater()</a> include any overhead
9820 added by SQLite in its implementation of <a href="#sqlite3_free">sqlite3_malloc()</a>,
9821 but not overhead added by the any underlying system library
9822 routines that <a href="#sqlite3_free">sqlite3_malloc()</a> may call.</p>
9823
9824 <p>The memory high-water mark is reset to the current value of
9825 <a href="#sqlite3_memory_highwater">sqlite3_memory_used()</a> if and only if the parameter to
9826 <a href="#sqlite3_memory_highwater">sqlite3_memory_highwater()</a> is true. The value returned
9827 by <a href="#sqlite3_memory_highwater">sqlite3_memory_highwater(1)</a> is the high-water mark
9828 prior to the reset.
9829 </p><hr><a name="sqlite3_mprintf"></a>
9830 <h2>Formatted String Printing Functions</h2>
9831 </div>
9832 <blockquote><pre>
9833 char *sqlite3_mprintf(const char*,...);
9834 char *sqlite3_vmprintf(const char*, va_list);
9835 char *sqlite3_snprintf(int,char*,const char*, ...);
9836 char *sqlite3_vsnprintf(int,char*,const char*, va_list);
9837 </pre></blockquote>
9838 <p>
9839 These routines are work-alikes of the "printf()" family of functions
9840 from the standard C library.
9841 These routines understand most of the common formatting options from
9842 the standard library printf()
9843 plus some additional non-standard formats (<a href="printf.html#percentq">%q</a>, <a href="printf.html#percentq">%Q</a>, <a href="printf.html#percentw">%w</a>, and <a href="printf.html#percentz">%z</a>).
9844 See the <a href="printf.html">built-in printf()</a> documentation for details.</p>
9845
9846 <p>The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
9847 results into memory obtained from <a href="#sqlite3_free">sqlite3_malloc64()</a>.
9848 The strings returned by these two routines should be
9849 released by <a href="#sqlite3_free">sqlite3_free()</a>. Both routines return a
9850 NULL pointer if <a href="#sqlite3_free">sqlite3_malloc64()</a> is unable to allocate enough
9851 memory to hold the resulting string.</p>
9852
9853 <p>The sqlite3_snprintf() routine is similar to "snprintf()" from
9854 the standard C library. The result is written into the
9855 buffer supplied as the second parameter whose size is given by
9856 the first parameter. Note that the order of the
9857 first two parameters is reversed from snprintf(). This is an
9858 historical accident that cannot be fixed without breaking
9859 backwards compatibility. Note also that sqlite3_snprintf()
9860 returns a pointer to its buffer instead of the number of
9861 characters actually written into the buffer. We admit that
9862 the number of characters written would be a more useful return
9863 value but we cannot change the implementation of sqlite3_snprintf()
9864 now without breaking compatibility.</p>
9865
9866 <p>As long as the buffer size is greater than zero, sqlite3_snprintf()
9867 guarantees that the buffer is always zero-terminated. The first
9868 parameter "n" is the total size of the buffer, including space for
9869 the zero terminator. So the longest string that can be completely
9870 written will be n-1 characters.</p>
9871
9872 <p>The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().</p>
9873
9874 <p>See also: <a href="printf.html">built-in printf()</a>, <a href="lang_corefunc.html#printf">printf() SQL function</a>
9875 </p><hr><a name="sqlite3_mutex_alloc"></a>
9876 <h2>Mutexes</h2>
9877 </div>
9878 <blockquote><pre>
9879 sqlite3_mutex *sqlite3_mutex_alloc(int);
9880 void sqlite3_mutex_free(sqlite3_mutex*);
9881 void sqlite3_mutex_enter(sqlite3_mutex*);
9882 int sqlite3_mutex_try(sqlite3_mutex*);
9883 void sqlite3_mutex_leave(sqlite3_mutex*);
9884 </pre></blockquote>
9885 <p>
9886 The SQLite core uses these routines for thread
9887 synchronization. Though they are intended for internal
9888 use by SQLite, code that links against SQLite is
9889 permitted to use any of these routines.</p>
9890
9891 <p>The SQLite source code contains multiple implementations
9892 of these mutex routines. An appropriate implementation
9893 is selected automatically at compile-time. The following
9894 implementations are available in the SQLite core:</p>
9895
9896 <p><ul>
9897 <li> SQLITE_MUTEX_PTHREADS
9898 <li> SQLITE_MUTEX_W32
9899 <li> SQLITE_MUTEX_NOOP
9900 </ul></p>
9901
9902 <p>The SQLITE_MUTEX_NOOP implementation is a set of routines
9903 that does no real locking and is appropriate for use in
9904 a single-threaded application. The SQLITE_MUTEX_PTHREADS and
9905 SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
9906 and Windows.</p>
9907
9908 <p>If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
9909 macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
9910 implementation is included with the library. In this case the
9911 application must supply a custom mutex implementation using the
9912 <a href="#sqliteconfigmutex">SQLITE_CONFIG_MUTEX</a> option of the sqlite3_config() function
9913 before calling sqlite3_initialize() or any other public sqlite3_
9914 function that calls sqlite3_initialize().</p>
9915
9916 <p>The sqlite3_mutex_alloc() routine allocates a new
9917 mutex and returns a pointer to it. The sqlite3_mutex_alloc()
9918 routine returns NULL if it is unable to allocate the requested
9919 mutex. The argument to sqlite3_mutex_alloc() must one of these
9920 integer constants:</p>
9921
9922 <p><ul>
9923 <li> SQLITE_MUTEX_FAST
9924 <li> SQLITE_MUTEX_RECURSIVE
9925 <li> SQLITE_MUTEX_STATIC_MAIN
9926 <li> SQLITE_MUTEX_STATIC_MEM
9927 <li> SQLITE_MUTEX_STATIC_OPEN
9928 <li> SQLITE_MUTEX_STATIC_PRNG
9929 <li> SQLITE_MUTEX_STATIC_LRU
9930 <li> SQLITE_MUTEX_STATIC_PMEM
9931 <li> SQLITE_MUTEX_STATIC_APP1
9932 <li> SQLITE_MUTEX_STATIC_APP2
9933 <li> SQLITE_MUTEX_STATIC_APP3
9934 <li> SQLITE_MUTEX_STATIC_VFS1
9935 <li> SQLITE_MUTEX_STATIC_VFS2
9936 <li> SQLITE_MUTEX_STATIC_VFS3
9937 </ul></p>
9938
9939 <p>The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
9940 cause sqlite3_mutex_alloc() to create
9941 a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
9942 is used but not necessarily so when SQLITE_MUTEX_FAST is used.
9943 The mutex implementation does not need to make a distinction
9944 between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
9945 not want to. SQLite will only request a recursive mutex in
9946 cases where it really needs one. If a faster non-recursive mutex
9947 implementation is available on the host platform, the mutex subsystem
9948 might return such a mutex in response to SQLITE_MUTEX_FAST.</p>
9949
9950 <p>The other allowed parameters to sqlite3_mutex_alloc() (anything other
9951 than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
9952 a pointer to a static preexisting mutex. Nine static mutexes are
9953 used by the current version of SQLite. Future versions of SQLite
9954 may add additional static mutexes. Static mutexes are for internal
9955 use by SQLite only. Applications that use SQLite mutexes should
9956 use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
9957 SQLITE_MUTEX_RECURSIVE.</p>
9958
9959 <p>Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
9960 or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
9961 returns a different mutex on every call. For the static
9962 mutex types, the same mutex is returned on every call that has
9963 the same type number.</p>
9964
9965 <p>The sqlite3_mutex_free() routine deallocates a previously
9966 allocated dynamic mutex. Attempting to deallocate a static
9967 mutex results in undefined behavior.</p>
9968
9969 <p>The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
9970 to enter a mutex. If another thread is already within the mutex,
9971 sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
9972 SQLITE_BUSY. The sqlite3_mutex_try() interface returns <a href="#SQLITE_ABORT">SQLITE_OK</a>
9973 upon successful entry. Mutexes created using
9974 SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
9975 In such cases, the
9976 mutex must be exited an equal number of times before another thread
9977 can enter. If the same thread tries to enter any mutex other
9978 than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.</p>
9979
9980 <p>Some systems (for example, Windows 95) do not support the operation
9981 implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
9982 will always return SQLITE_BUSY. In most cases the SQLite core only uses
9983 sqlite3_mutex_try() as an optimization, so this is acceptable
9984 behavior. The exceptions are unix builds that set the
9985 SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working
9986 sqlite3_mutex_try() is required.</p>
9987
9988 <p>The sqlite3_mutex_leave() routine exits a mutex that was
9989 previously entered by the same thread. The behavior
9990 is undefined if the mutex is not currently entered by the
9991 calling thread or is not currently allocated.</p>
9992
9993 <p>If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(),
9994 sqlite3_mutex_leave(), or sqlite3_mutex_free() is a NULL pointer,
9995 then any of the four routines behaves as a no-op.</p>
9996
9997 <p>See also: <a href="#sqlite3_mutex_held">sqlite3_mutex_held()</a> and <a href="#sqlite3_mutex_held">sqlite3_mutex_notheld()</a>.
9998 </p><hr><a name="sqlite3_mutex_held"></a>
9999 <h2>Mutex Verification Routines</h2>
10000 </div>
10001 <blockquote><pre>
10002 #ifndef NDEBUG
10003 int sqlite3_mutex_held(sqlite3_mutex*);
10004 int sqlite3_mutex_notheld(sqlite3_mutex*);
10005 #endif
10006 </pre></blockquote>
10007 <p>
10008 The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
10009 are intended for use inside assert() statements. The SQLite core
10010 never uses these routines except inside an assert() and applications
10011 are advised to follow the lead of the core. The SQLite core only
10012 provides implementations for these routines when it is compiled
10013 with the SQLITE_DEBUG flag. External mutex implementations
10014 are only required to provide these routines if SQLITE_DEBUG is
10015 defined and if NDEBUG is not defined.</p>
10016
10017 <p>These routines should return true if the mutex in their argument
10018 is held or not held, respectively, by the calling thread.</p>
10019
10020 <p>The implementation is not required to provide versions of these
10021 routines that actually work. If the implementation does not provide working
10022 versions of these routines, it should at least provide stubs that always
10023 return true so that one does not get spurious assertion failures.</p>
10024
10025 <p>If the argument to sqlite3_mutex_held() is a NULL pointer then
10026 the routine should return 1. This seems counter-intuitive since
10027 clearly the mutex cannot be held if it does not exist. But
10028 the reason the mutex does not exist is because the build is not
10029 using mutexes. And we do not want the assert() containing the
10030 call to sqlite3_mutex_held() to fail, so a non-zero return is
10031 the appropriate thing to do. The sqlite3_mutex_notheld()
10032 interface should also return 1 when given a NULL pointer.
10033 </p><hr><a name="sqlite3_open"></a>
10034 <h2>Opening A New Database Connection</h2>
10035 </div>
10036 <blockquote><pre>
10037 int sqlite3_open(
10038 const char *filename, /* Database filename (UTF-8) */
10039 sqlite3 **ppDb /* OUT: SQLite db handle */
10040 );
10041 int sqlite3_open16(
10042 const void *filename, /* Database filename (UTF-16) */
10043 sqlite3 **ppDb /* OUT: SQLite db handle */
10044 );
10045 int sqlite3_open_v2(
10046 const char *filename, /* Database filename (UTF-8) */
10047 sqlite3 **ppDb, /* OUT: SQLite db handle */
10048 int flags, /* Flags */
10049 const char *zVfs /* Name of VFS module to use */
10050 );
10051 </pre></blockquote>
10052 <p>
10053 These routines open an SQLite database file as specified by the
10054 filename argument. The filename argument is interpreted as UTF-8 for
10055 sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
10056 order for sqlite3_open16(). A <a href="#sqlite3">database connection</a> handle is usually
10057 returned in *ppDb, even if an error occurs. The only exception is that
10058 if SQLite is unable to allocate memory to hold the <a href="#sqlite3">sqlite3</a> object,
10059 a NULL will be written into *ppDb instead of a pointer to the <a href="#sqlite3">sqlite3</a>
10060 object. If the database is opened (and/or created) successfully, then
10061 <a href="#SQLITE_ABORT">SQLITE_OK</a> is returned. Otherwise an <a href="rescode.html">error code</a> is returned. The
10062 <a href="#sqlite3_errcode">sqlite3_errmsg()</a> or <a href="#sqlite3_errcode">sqlite3_errmsg16()</a> routines can be used to obtain
10063 an English language description of the error following a failure of any
10064 of the sqlite3_open() routines.</p>
10065
10066 <p>The default encoding will be UTF-8 for databases created using
10067 sqlite3_open() or sqlite3_open_v2(). The default encoding for databases
10068 created using sqlite3_open16() will be UTF-16 in the native byte order.</p>
10069
10070 <p>Whether or not an error occurs when it is opened, resources
10071 associated with the <a href="#sqlite3">database connection</a> handle should be released by
10072 passing it to <a href="#sqlite3_close">sqlite3_close()</a> when it is no longer required.</p>
10073
10074 <p>The sqlite3_open_v2() interface works like sqlite3_open()
10075 except that it accepts two additional parameters for additional control
10076 over the new database connection. The flags parameter to
10077 sqlite3_open_v2() must include, at a minimum, one of the following
10078 three flag combinations:</p>
10079
10080 <p><dl>
10081 <dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_READONLY</a></dt>
10082 <dd>The database is opened in read-only mode. If the database does
10083 not already exist, an error is returned.</dd></p>
10084
10085 <p><dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_READWRITE</a></dt>
10086 <dd>The database is opened for reading and writing if possible, or
10087 reading only if the file is write protected by the operating
10088 system. In either case the database must already exist, otherwise
10089 an error is returned. For historical reasons, if opening in
10090 read-write mode fails due to OS-level permissions, an attempt is
10091 made to open it in read-only mode. <a href="#sqlite3_db_readonly">sqlite3_db_readonly()</a> can be
10092 used to determine whether the database is actually
10093 read-write.</dd></p>
10094
10095 <p><dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_READWRITE</a> | <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_CREATE</a></dt>
10096 <dd>The database is opened for reading and writing, and is created if
10097 it does not already exist. This is the behavior that is always used for
10098 sqlite3_open() and sqlite3_open16().</dd>
10099 </dl></p>
10100
10101 <p>In addition to the required flags, the following optional flags are
10102 also supported:</p>
10103
10104 <p><dl>
10105 <dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_URI</a></dt>
10106 <dd>The filename can be interpreted as a URI if this flag is set.</dd></p>
10107
10108 <p><dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_MEMORY</a></dt>
10109 <dd>The database will be opened as an in-memory database. The database
10110 is named by the "filename" argument for the purposes of cache-sharing,
10111 if shared cache mode is enabled, but the "filename" is otherwise ignored.
10112 </dd></p>
10113
10114 <p><dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_NOMUTEX</a></dt>
10115 <dd>The new database connection will use the "multi-thread"
10116 <a href="threadsafe.html">threading mode</a>. This means that separate threads are allowed
10117 to use SQLite at the same time, as long as each thread is using
10118 a different <a href="#sqlite3">database connection</a>.</p>
10119
10120 <p><dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_FULLMUTEX</a></dt>
10121 <dd>The new database connection will use the "serialized"
10122 <a href="threadsafe.html">threading mode</a>. This means the multiple threads can safely
10123 attempt to use the same database connection at the same time.
10124 (Mutexes will block any actual concurrency, but in this mode
10125 there is no harm in trying.)</p>
10126
10127 <p><dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_SHAREDCACHE</a></dt>
10128 <dd>The database is opened <a href="sharedcache.html">shared cache</a> enabled, overriding
10129 the default shared cache setting provided by
10130 <a href="#sqlite3_enable_shared_cache">sqlite3_enable_shared_cache()</a>.
10131 The <a href="sharedcache.html#dontuse">use of shared cache mode is discouraged</a> and hence shared cache
10132 capabilities may be omitted from many builds of SQLite. In such cases,
10133 this option is a no-op.</p>
10134
10135 <p><dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_PRIVATECACHE</a></dt>
10136 <dd>The database is opened <a href="sharedcache.html">shared cache</a> disabled, overriding
10137 the default shared cache setting provided by
10138 <a href="#sqlite3_enable_shared_cache">sqlite3_enable_shared_cache()</a>.</p>
10139
10140 <p><a name="openexrescode"></a>
10141 <dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_EXRESCODE</a></dt>
10142 <dd>The database connection comes up in "extended result code mode".
10143 In other words, the database behaves has if
10144 <a href="#sqlite3_extended_result_codes">sqlite3_extended_result_codes(db,1)</a> where called on the database
10145 connection as soon as the connection is created. In addition to setting
10146 the extended result code mode, this flag also causes <a href="#sqlite3_open">sqlite3_open_v2()</a>
10147 to return an extended result code.</dd></p>
10148
10149 <p><a name="opennofollow"></a>
10150 <dt><a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_NOFOLLOW</a></dt>
10151 <dd>The database filename is not allowed to contain a symbolic link</dd>
10152 </dl></p>
10153
10154 <p>If the 3rd parameter to sqlite3_open_v2() is not one of the
10155 required combinations shown above optionally combined with other
10156 <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_* bits</a>
10157 then the behavior is undefined. Historic versions of SQLite
10158 have silently ignored surplus bits in the flags parameter to
10159 sqlite3_open_v2(), however that behavior might not be carried through
10160 into future versions of SQLite and so applications should not rely
10161 upon it. Note in particular that the SQLITE_OPEN_EXCLUSIVE flag is a no-op
10162 for sqlite3_open_v2(). The SQLITE_OPEN_EXCLUSIVE does *not* cause
10163 the open to fail if the database already exists. The SQLITE_OPEN_EXCLUSIVE
10164 flag is intended for use by the <a href="#sqlite3_vfs">VFS interface</a> only, and not
10165 by sqlite3_open_v2().</p>
10166
10167 <p>The fourth parameter to sqlite3_open_v2() is the name of the
10168 <a href="#sqlite3_vfs">sqlite3_vfs</a> object that defines the operating system interface that
10169 the new database connection should use. If the fourth parameter is
10170 a NULL pointer then the default <a href="#sqlite3_vfs">sqlite3_vfs</a> object is used.</p>
10171
10172 <p>If the filename is ":memory:", then a private, temporary in-memory database
10173 is created for the connection. This in-memory database will vanish when
10174 the database connection is closed. Future versions of SQLite might
10175 make use of additional special filenames that begin with the ":" character.
10176 It is recommended that when a database filename actually does begin with
10177 a ":" character you should prefix the filename with a pathname such as
10178 "./" to avoid ambiguity.</p>
10179
10180 <p>If the filename is an empty string, then a private, temporary
10181 on-disk database will be created. This private database will be
10182 automatically deleted as soon as the database connection is closed.</p>
10183
10184 <p><a name="urifilenamesinsqlite3open"></a>
10185 <h3>URI Filenames</h3></p>
10186
10187 <p>If <a href="uri.html">URI filename</a> interpretation is enabled, and the filename argument
10188 begins with "file:", then the filename is interpreted as a URI. URI
10189 filename interpretation is enabled if the <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_URI</a> flag is
10190 set in the third argument to sqlite3_open_v2(), or if it has
10191 been enabled globally using the <a href="#sqliteconfiguri">SQLITE_CONFIG_URI</a> option with the
10192 <a href="#sqlite3_config">sqlite3_config()</a> method or by the <a href="compile.html#use_uri">SQLITE_USE_URI</a> compile-time option.
10193 URI filename interpretation is turned off
10194 by default, but future releases of SQLite might enable URI filename
10195 interpretation by default. See "<a href="uri.html">URI filenames</a>" for additional
10196 information.</p>
10197
10198 <p>URI filenames are parsed according to RFC 3986. If the URI contains an
10199 authority, then it must be either an empty string or the string
10200 "localhost". If the authority is not an empty string or "localhost", an
10201 error is returned to the caller. The fragment component of a URI, if
10202 present, is ignored.</p>
10203
10204 <p>SQLite uses the path component of the URI as the name of the disk file
10205 which contains the database. If the path begins with a '/' character,
10206 then it is interpreted as an absolute path. If the path does not begin
10207 with a '/' (meaning that the authority section is omitted from the URI)
10208 then the path is interpreted as a relative path.
10209 On windows, the first component of an absolute path
10210 is a drive specification (e.g. "C:").</p>
10211
10212 <p><a name="coreuriqueryparameters"></a>
10213
10214 The query component of a URI may contain parameters that are interpreted
10215 either by SQLite itself, or by a <a href="vfs.html">custom VFS implementation</a>.
10216 SQLite and its built-in <a href="vfs.html">VFSes</a> interpret the
10217 following query parameters:</p>
10218
10219 <p><ul>
10220 <li> <b>vfs</b>: The "vfs" parameter may be used to specify the name of
10221 a VFS object that provides the operating system interface that should
10222 be used to access the database file on disk. If this option is set to
10223 an empty string the default VFS object is used. Specifying an unknown
10224 VFS is an error. If sqlite3_open_v2() is used and the vfs option is
10225 present, then the VFS specified by the option takes precedence over
10226 the value passed as the fourth parameter to sqlite3_open_v2().</p>
10227
10228 <p><li> <b>mode</b>: The mode parameter may be set to either "ro", "rw",
10229 "rwc", or "memory". Attempting to set it to any other value is
10230 an error.
10231 If "ro" is specified, then the database is opened for read-only
10232 access, just as if the <a href="#SQLITE_OPEN_AUTOPROXY">SQLITE_OPEN_READONLY</a> flag had been set in the
10233 third argument to sqlite3_open_v2(). If the mode option is set to
10234 "rw", then the database is opened for read-write (but not create)
10235 access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had
10236 been set. Value "rwc" is equivalent to setting both
10237 SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. If the mode option is
10238 set to "memory" then a pure <a href="inmemorydb.html">in-memory database</a> that never reads
10239 or writes from disk is used. It is an error to specify a value for
10240 the mode parameter that is less restrictive than that specified by
10241 the flags passed in the third parameter to sqlite3_open_v2().</p>
10242
10243 <p><li> <b>cache</b>: The cache parameter may be set to either "shared" or
10244 "private". Setting it to "shared" is equivalent to setting the
10245 SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
10246 sqlite3_open_v2(). Setting the cache parameter to "private" is
10247 equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
10248 If sqlite3_open_v2() is used and the "cache" parameter is present in
10249 a URI filename, its value overrides any behavior requested by setting
10250 SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.</p>
10251
10252 <p><li> <b>psow</b>: The psow parameter indicates whether or not the
10253 <a href="psow.html">powersafe overwrite</a> property does or does not apply to the
10254 storage media on which the database file resides.</p>
10255
10256 <p><li> <b>nolock</b>: The nolock parameter is a boolean query parameter
10257 which if set disables file locking in rollback journal modes. This
10258 is useful for accessing a database on a filesystem that does not
10259 support locking. Caution: Database corruption might result if two
10260 or more processes write to the same database and any one of those
10261 processes uses nolock=1.</p>
10262
10263 <p><li> <b>immutable</b>: The immutable parameter is a boolean query
10264 parameter that indicates that the database file is stored on
10265 read-only media. When immutable is set, SQLite assumes that the
10266 database file cannot be changed, even by a process with higher
10267 privilege, and so the database is opened read-only and all locking
10268 and change detection is disabled. Caution: Setting the immutable
10269 property on a database file that does in fact change can result
10270 in incorrect query results and/or <a href="#SQLITE_ABORT">SQLITE_CORRUPT</a> errors.
10271 See also: <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_IMMUTABLE</a>.</p>
10272
10273 <p></ul></p>
10274
10275 <p>Specifying an unknown parameter in the query component of a URI is not an
10276 error. Future versions of SQLite might understand additional query
10277 parameters. See "<a href="uri.html#coreqp">query parameters with special meaning to SQLite</a>" for
10278 additional information.</p>
10279
10280 <p><a name="urifilenameexamples"></a>
10281 <h3>URI filename examples</h3></p>
10282
10283 <p><table border="1" align=center cellpadding=5>
10284 <tr><th> URI filenames <th> Results
10285 <tr><td> file:data.db <td>
10286 Open the file "data.db" in the current directory.
10287 <tr><td> file:/home/fred/data.db<br>
10288 file:///home/fred/data.db <br>
10289 file://localhost/home/fred/data.db <br> <td>
10290 Open the database file "/home/fred/data.db".
10291 <tr><td> file://darkstar/home/fred/data.db <td>
10292 An error. "darkstar" is not a recognized authority.
10293 <tr><td style="white-space:nowrap">
10294 file:///C:/Documents%20and%20Settings/fred/Desktop/data.db
10295 <td> Windows only: Open the file "data.db" on fred's desktop on drive
10296 C:. Note that the %20 escaping in this example is not strictly
10297 necessary - space characters can be used literally
10298 in URI filenames.
10299 <tr><td> file:data.db?mode=ro&cache=private <td>
10300 Open file "data.db" in the current directory for read-only access.
10301 Regardless of whether or not shared-cache mode is enabled by
10302 default, use a private cache.
10303 <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>
10304 Open file "/home/fred/data.db". Use the special VFS "unix-dotfile"
10305 that uses dot-files in place of posix advisory locking.
10306 <tr><td> file:data.db?mode=readonly <td>
10307 An error. "readonly" is not a valid option for the "mode" parameter.
10308 Use "ro" instead: "file:data.db?mode=ro".
10309 </table></p>
10310
10311 <p>URI hexadecimal escape sequences (%HH) are supported within the path and
10312 query components of a URI. A hexadecimal escape sequence consists of a
10313 percent sign - "%" - followed by exactly two hexadecimal digits
10314 specifying an octet value. Before the path or query components of a
10315 URI filename are interpreted, they are encoded using UTF-8 and all
10316 hexadecimal escape sequences replaced by a single byte containing the
10317 corresponding octet. If this process generates an invalid UTF-8 encoding,
10318 the results are undefined.</p>
10319
10320 <p><b>Note to Windows users:</b> The encoding used for the filename argument
10321 of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
10322 codepage is currently defined. Filenames containing international
10323 characters must be converted to UTF-8 prior to passing them into
10324 sqlite3_open() or sqlite3_open_v2().</p>
10325
10326 <p><b>Note to Windows Runtime users:</b> The temporary directory must be set
10327 prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
10328 features that require the use of temporary files may fail.</p>
10329
10330 <p>See also: <a href="#sqlite3_temp_directory">sqlite3_temp_directory</a>
10331 </p><hr><a name="sqlite3_preupdate_blobwrite"></a>
10332 <h2>The pre-update hook.</h2>
10333 </div>
10334 <blockquote><pre>
10335 #if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
10336 void *sqlite3_preupdate_hook(
10337 sqlite3 *db,
10338 void(*xPreUpdate)(
10339 void *pCtx, /* Copy of third arg to preupdate_hook() */
10340 sqlite3 *db, /* Database handle */
10341 int op, /* SQLITE_UPDATE, DELETE or INSERT */
10342 char const *zDb, /* Database name */
10343 char const *zName, /* Table name */
10344 sqlite3_int64 iKey1, /* Rowid of row about to be deleted/updated */
10345 sqlite3_int64 iKey2 /* New rowid value (for a rowid UPDATE) */
10346 ),
10347 void*
10348 );
10349 int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
10350 int sqlite3_preupdate_count(sqlite3 *);
10351 int sqlite3_preupdate_depth(sqlite3 *);
10352 int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
10353 int sqlite3_preupdate_blobwrite(sqlite3 *);
10354 #endif
10355 </pre></blockquote>
10356 <p>
10357 These interfaces are only available if SQLite is compiled using the
10358 <a href="compile.html#enable_preupdate_hook">SQLITE_ENABLE_PREUPDATE_HOOK</a> compile-time option.</p>
10359
10360 <p>The <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_hook()</a> interface registers a callback function
10361 that is invoked prior to each <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a>, and <a href="lang_delete.html">DELETE</a> operation
10362 on a database table.
10363 At most one preupdate hook may be registered at a time on a single
10364 <a href="#sqlite3">database connection</a>; each call to <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_hook()</a> overrides
10365 the previous setting.
10366 The preupdate hook is disabled by invoking <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_hook()</a>
10367 with a NULL pointer as the second parameter.
10368 The third parameter to <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_hook()</a> is passed through as
10369 the first parameter to callbacks.</p>
10370
10371 <p>The preupdate hook only fires for changes to real database tables; the
10372 preupdate hook is not invoked for changes to <a href="vtab.html">virtual tables</a> or to
10373 system tables like sqlite_sequence or sqlite_stat1.</p>
10374
10375 <p>The second parameter to the preupdate callback is a pointer to
10376 the <a href="#sqlite3">database connection</a> that registered the preupdate hook.
10377 The third parameter to the preupdate callback is one of the constants
10378 <a href="#SQLITE_ALTER_TABLE">SQLITE_INSERT</a>, <a href="#SQLITE_ALTER_TABLE">SQLITE_DELETE</a>, or <a href="#SQLITE_ALTER_TABLE">SQLITE_UPDATE</a> to identify the
10379 kind of update operation that is about to occur.
10380 The fourth parameter to the preupdate callback is the name of the
10381 database within the database connection that is being modified. This
10382 will be "main" for the main database or "temp" for TEMP tables or
10383 the name given after the AS keyword in the <a href="lang_attach.html">ATTACH</a> statement for attached
10384 databases.
10385 The fifth parameter to the preupdate callback is the name of the
10386 table that is being modified.</p>
10387
10388 <p>For an UPDATE or DELETE operation on a <a href="rowidtable.html">rowid table</a>, the sixth
10389 parameter passed to the preupdate callback is the initial <a href="lang_createtable.html#rowid">rowid</a> of the
10390 row being modified or deleted. For an INSERT operation on a rowid table,
10391 or any operation on a WITHOUT ROWID table, the value of the sixth
10392 parameter is undefined. For an INSERT or UPDATE on a rowid table the
10393 seventh parameter is the final rowid value of the row being inserted
10394 or updated. The value of the seventh parameter passed to the callback
10395 function is not defined for operations on WITHOUT ROWID tables, or for
10396 DELETE operations on rowid tables.</p>
10397
10398 <p>The sqlite3_preupdate_hook(D,C,P) function returns the P argument from
10399 the previous call on the same <a href="#sqlite3">database connection</a> D, or NULL for
10400 the first call on D.</p>
10401
10402 <p>The <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_old()</a>, <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_new()</a>,
10403 <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_count()</a>, and <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_depth()</a> interfaces
10404 provide additional information about a preupdate event. These routines
10405 may only be called from within a preupdate callback. Invoking any of
10406 these routines from outside of a preupdate callback or with a
10407 <a href="#sqlite3">database connection</a> pointer that is different from the one supplied
10408 to the preupdate callback results in undefined and probably undesirable
10409 behavior.</p>
10410
10411 <p>The <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_count(D)</a> interface returns the number of columns
10412 in the row that is being inserted, updated, or deleted.</p>
10413
10414 <p>The <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_old(D,N,P)</a> interface writes into P a pointer to
10415 a <a href="#sqlite3_value">protected sqlite3_value</a> that contains the value of the Nth column of
10416 the table row before it is updated. The N parameter must be between 0
10417 and one less than the number of columns or the behavior will be
10418 undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE
10419 preupdate callbacks; if it is used by an SQLITE_INSERT callback then the
10420 behavior is undefined. The <a href="#sqlite3_value">sqlite3_value</a> that P points to
10421 will be destroyed when the preupdate callback returns.</p>
10422
10423 <p>The <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_new(D,N,P)</a> interface writes into P a pointer to
10424 a <a href="#sqlite3_value">protected sqlite3_value</a> that contains the value of the Nth column of
10425 the table row after it is updated. The N parameter must be between 0
10426 and one less than the number of columns or the behavior will be
10427 undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE
10428 preupdate callbacks; if it is used by an SQLITE_DELETE callback then the
10429 behavior is undefined. The <a href="#sqlite3_value">sqlite3_value</a> that P points to
10430 will be destroyed when the preupdate callback returns.</p>
10431
10432 <p>The <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_depth(D)</a> interface returns 0 if the preupdate
10433 callback was invoked as a result of a direct insert, update, or delete
10434 operation; or 1 for inserts, updates, or deletes invoked by top-level
10435 triggers; or 2 for changes resulting from triggers called by top-level
10436 triggers; and so forth.</p>
10437
10438 <p>When the <a href="#sqlite3_blob_write">sqlite3_blob_write()</a> API is used to update a blob column,
10439 the pre-update hook is invoked with SQLITE_DELETE. This is because the
10440 in this case the new values are not available. In this case, when a
10441 callback made with op==SQLITE_DELETE is actually a write using the
10442 sqlite3_blob_write() API, the <a href="#sqlite3_preupdate_blobwrite">sqlite3_preupdate_blobwrite()</a> returns
10443 the index of the column being written. In other cases, where the
10444 pre-update hook is being invoked for some other reason, including a
10445 regular DELETE, sqlite3_preupdate_blobwrite() returns -1.</p>
10446
10447 <p>See also: <a href="#sqlite3_update_hook">sqlite3_update_hook()</a>
10448 </p><hr><a name="sqlite3_profile"></a>
10449 <h2>Deprecated Tracing And Profiling Functions</h2>
10450 </div>
10451 <blockquote><pre>
10452 void *sqlite3_trace(sqlite3*,
10453 void(*xTrace)(void*,const char*), void*);
10454 void *sqlite3_profile(sqlite3*,
10455 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
10456 </pre></blockquote>
10457 <p>
10458 These routines are deprecated. Use the <a href="#sqlite3_trace_v2">sqlite3_trace_v2()</a> interface
10459 instead of the routines described here.</p>
10460
10461 <p>These routines register callback functions that can be used for
10462 tracing and profiling the execution of SQL statements.</p>
10463
10464 <p>The callback function registered by sqlite3_trace() is invoked at
10465 various times when an SQL statement is being run by <a href="#sqlite3_step">sqlite3_step()</a>.
10466 The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
10467 SQL statement text as the statement first begins executing.
10468 Additional sqlite3_trace() callbacks might occur
10469 as each triggered subprogram is entered. The callbacks for triggers
10470 contain a UTF-8 SQL comment that identifies the trigger.</p>
10471
10472 <p>The <a href="compile.html#trace_size_limit">SQLITE_TRACE_SIZE_LIMIT</a> compile-time option can be used to limit
10473 the length of <a href="lang_expr.html#varparam">bound parameter</a> expansion in the output of sqlite3_trace().</p>
10474
10475 <p>The callback function registered by sqlite3_profile() is invoked
10476 as each SQL statement finishes. The profile callback contains
10477 the original statement text and an estimate of wall-clock time
10478 of how long that statement took to run. The profile callback
10479 time is in units of nanoseconds, however the current implementation
10480 is only capable of millisecond resolution so the six least significant
10481 digits in the time are meaningless. Future versions of SQLite
10482 might provide greater resolution on the profiler callback. Invoking
10483 either <a href="#sqlite3_profile">sqlite3_trace()</a> or <a href="#sqlite3_trace_v2">sqlite3_trace_v2()</a> will cancel the
10484 profile callback.
10485 </p><hr><a name="sqlite3_result_blob"></a>
10486 <h2>Setting The Result Of An SQL Function</h2>
10487 </div>
10488 <blockquote><pre>
10489 void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
10490 void sqlite3_result_blob64(sqlite3_context*,const void*,
10491 sqlite3_uint64,void(*)(void*));
10492 void sqlite3_result_double(sqlite3_context*, double);
10493 void sqlite3_result_error(sqlite3_context*, const char*, int);
10494 void sqlite3_result_error16(sqlite3_context*, const void*, int);
10495 void sqlite3_result_error_toobig(sqlite3_context*);
10496 void sqlite3_result_error_nomem(sqlite3_context*);
10497 void sqlite3_result_error_code(sqlite3_context*, int);
10498 void sqlite3_result_int(sqlite3_context*, int);
10499 void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
10500 void sqlite3_result_null(sqlite3_context*);
10501 void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
10502 void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
10503 void(*)(void*), unsigned char encoding);
10504 void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
10505 void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
10506 void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
10507 void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
10508 void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));
10509 void sqlite3_result_zeroblob(sqlite3_context*, int n);
10510 int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
10511 </pre></blockquote>
10512 <p>
10513 These routines are used by the xFunc or xFinal callbacks that
10514 implement SQL functions and aggregates. See
10515 <a href="#sqlite3_create_function">sqlite3_create_function()</a> and <a href="#sqlite3_create_function">sqlite3_create_function16()</a>
10516 for additional information.</p>
10517
10518 <p>These functions work very much like the <a href="#sqlite3_bind_blob">parameter binding</a> family of
10519 functions used to bind values to host parameters in prepared statements.
10520 Refer to the <a href="#sqlite3_bind_blob">SQL parameter</a> documentation for additional information.</p>
10521
10522 <p>The sqlite3_result_blob() interface sets the result from
10523 an application-defined function to be the BLOB whose content is pointed
10524 to by the second parameter and which is N bytes long where N is the
10525 third parameter.</p>
10526
10527 <p>The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
10528 interfaces set the result of the application-defined function to be
10529 a BLOB containing all zero bytes and N bytes in size.</p>
10530
10531 <p>The sqlite3_result_double() interface sets the result from
10532 an application-defined function to be a floating point value specified
10533 by its 2nd argument.</p>
10534
10535 <p>The sqlite3_result_error() and sqlite3_result_error16() functions
10536 cause the implemented SQL function to throw an exception.
10537 SQLite uses the string pointed to by the
10538 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
10539 as the text of an error message. SQLite interprets the error
10540 message string from sqlite3_result_error() as UTF-8. SQLite
10541 interprets the string from sqlite3_result_error16() as UTF-16 using
10542 the same <a href="#byteorderdeterminationrules">byte-order determination rules</a> as <a href="#sqlite3_bind_blob">sqlite3_bind_text16()</a>.
10543 If the third parameter to sqlite3_result_error()
10544 or sqlite3_result_error16() is negative then SQLite takes as the error
10545 message all text up through the first zero character.
10546 If the third parameter to sqlite3_result_error() or
10547 sqlite3_result_error16() is non-negative then SQLite takes that many
10548 bytes (not characters) from the 2nd parameter as the error message.
10549 The sqlite3_result_error() and sqlite3_result_error16()
10550 routines make a private copy of the error message text before
10551 they return. Hence, the calling function can deallocate or
10552 modify the text after they return without harm.
10553 The sqlite3_result_error_code() function changes the error code
10554 returned by SQLite as a result of an error in a function. By default,
10555 the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error()
10556 or sqlite3_result_error16() resets the error code to SQLITE_ERROR.</p>
10557
10558 <p>The sqlite3_result_error_toobig() interface causes SQLite to throw an
10559 error indicating that a string or BLOB is too long to represent.</p>
10560
10561 <p>The sqlite3_result_error_nomem() interface causes SQLite to throw an
10562 error indicating that a memory allocation failed.</p>
10563
10564 <p>The sqlite3_result_int() interface sets the return value
10565 of the application-defined function to be the 32-bit signed integer
10566 value given in the 2nd argument.
10567 The sqlite3_result_int64() interface sets the return value
10568 of the application-defined function to be the 64-bit signed integer
10569 value given in the 2nd argument.</p>
10570
10571 <p>The sqlite3_result_null() interface sets the return value
10572 of the application-defined function to be NULL.</p>
10573
10574 <p>The sqlite3_result_text(), sqlite3_result_text16(),
10575 sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
10576 set the return value of the application-defined function to be
10577 a text string which is represented as UTF-8, UTF-16 native byte order,
10578 UTF-16 little endian, or UTF-16 big endian, respectively.
10579 The sqlite3_result_text64() interface sets the return value of an
10580 application-defined function to be a text string in an encoding
10581 specified by the fifth (and last) parameter, which must be one
10582 of <a href="#SQLITE_ANY">SQLITE_UTF8</a>, <a href="#SQLITE_ANY">SQLITE_UTF16</a>, <a href="#SQLITE_ANY">SQLITE_UTF16BE</a>, or <a href="#SQLITE_ANY">SQLITE_UTF16LE</a>.
10583 SQLite takes the text result from the application from
10584 the 2nd parameter of the sqlite3_result_text* interfaces.
10585 If the 3rd parameter to any of the sqlite3_result_text* interfaces
10586 other than sqlite3_result_text64() is negative, then SQLite computes
10587 the string length itself by searching the 2nd parameter for the first
10588 zero character.
10589 If the 3rd parameter to the sqlite3_result_text* interfaces
10590 is non-negative, then as many bytes (not characters) of the text
10591 pointed to by the 2nd parameter are taken as the application-defined
10592 function result. If the 3rd parameter is non-negative, then it
10593 must be the byte offset into the string where the NUL terminator would
10594 appear if the string where NUL terminated. If any NUL characters occur
10595 in the string at a byte offset that is less than the value of the 3rd
10596 parameter, then the resulting string will contain embedded NULs and the
10597 result of expressions operating on strings with embedded NULs is undefined.
10598 If the 4th parameter to the sqlite3_result_text* interfaces
10599 or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
10600 function as the destructor on the text or BLOB result when it has
10601 finished using that result.
10602 If the 4th parameter to the sqlite3_result_text* interfaces or to
10603 sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
10604 assumes that the text or BLOB result is in constant space and does not
10605 copy the content of the parameter nor call a destructor on the content
10606 when it has finished using that result.
10607 If the 4th parameter to the sqlite3_result_text* interfaces
10608 or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
10609 then SQLite makes a copy of the result into space obtained
10610 from <a href="#sqlite3_free">sqlite3_malloc()</a> before it returns.</p>
10611
10612 <p>For the sqlite3_result_text16(), sqlite3_result_text16le(), and
10613 sqlite3_result_text16be() routines, and for sqlite3_result_text64()
10614 when the encoding is not UTF8, if the input UTF16 begins with a
10615 byte-order mark (BOM, U+FEFF) then the BOM is removed from the
10616 string and the rest of the string is interpreted according to the
10617 byte-order specified by the BOM. The byte-order specified by
10618 the BOM at the beginning of the text overrides the byte-order
10619 specified by the interface procedure. So, for example, if
10620 sqlite3_result_text16le() is invoked with text that begins
10621 with bytes 0xfe, 0xff (a big-endian byte-order mark) then the
10622 first two bytes of input are skipped and the remaining input
10623 is interpreted as UTF16BE text.</p>
10624
10625 <p>For UTF16 input text to the sqlite3_result_text16(),
10626 sqlite3_result_text16be(), sqlite3_result_text16le(), and
10627 sqlite3_result_text64() routines, if the text contains invalid
10628 UTF16 characters, the invalid characters might be converted
10629 into the unicode replacement character, U+FFFD.</p>
10630
10631 <p>The sqlite3_result_value() interface sets the result of
10632 the application-defined function to be a copy of the
10633 <a href="#sqlite3_value">unprotected sqlite3_value</a> object specified by the 2nd parameter. The
10634 sqlite3_result_value() interface makes a copy of the <a href="#sqlite3_value">sqlite3_value</a>
10635 so that the <a href="#sqlite3_value">sqlite3_value</a> specified in the parameter may change or
10636 be deallocated after sqlite3_result_value() returns without harm.
10637 A <a href="#sqlite3_value">protected sqlite3_value</a> object may always be used where an
10638 <a href="#sqlite3_value">unprotected sqlite3_value</a> object is required, so either
10639 kind of <a href="#sqlite3_value">sqlite3_value</a> object can be used with this interface.</p>
10640
10641 <p>The sqlite3_result_pointer(C,P,T,D) interface sets the result to an
10642 SQL NULL value, just like <a href="#sqlite3_result_blob">sqlite3_result_null(C)</a>, except that it
10643 also associates the host-language pointer P or type T with that
10644 NULL value such that the pointer can be retrieved within an
10645 <a href="appfunc.html">application-defined SQL function</a> using <a href="#sqlite3_value_blob">sqlite3_value_pointer()</a>.
10646 If the D parameter is not NULL, then it is a pointer to a destructor
10647 for the P parameter. SQLite invokes D with P as its only argument
10648 when SQLite is finished with P. The T parameter should be a static
10649 string and preferably a string literal. The sqlite3_result_pointer()
10650 routine is part of the <a href="bindptr.html">pointer passing interface</a> added for SQLite 3.20.0.</p>
10651
10652 <p>If these routines are called from within the different thread
10653 than the one containing the application-defined function that received
10654 the <a href="#sqlite3_context">sqlite3_context</a> pointer, the results are undefined.
10655 </p><hr><a name="sqlite3_status"></a>
10656 <h2>SQLite Runtime Status</h2>
10657 </div>
10658 <blockquote><pre>
10659 int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
10660 int sqlite3_status64(
10661 int op,
10662 sqlite3_int64 *pCurrent,
10663 sqlite3_int64 *pHighwater,
10664 int resetFlag
10665 );
10666 </pre></blockquote>
10667 <p>
10668 These interfaces are used to retrieve runtime status information
10669 about the performance of SQLite, and optionally to reset various
10670 highwater marks. The first argument is an integer code for
10671 the specific parameter to measure. Recognized integer codes
10672 are of the form <a href="#SQLITE_STATUS_MALLOC_COUNT">SQLITE_STATUS_...</a>.
10673 The current value of the parameter is returned into *pCurrent.
10674 The highest recorded value is returned in *pHighwater. If the
10675 resetFlag is true, then the highest record value is reset after
10676 *pHighwater is written. Some parameters do not record the highest
10677 value. For those parameters
10678 nothing is written into *pHighwater and the resetFlag is ignored.
10679 Other parameters record only the highwater mark and not the current
10680 value. For these latter parameters nothing is written into *pCurrent.</p>
10681
10682 <p>The sqlite3_status() and sqlite3_status64() routines return
10683 SQLITE_OK on success and a non-zero <a href="rescode.html">error code</a> on failure.</p>
10684
10685 <p>If either the current value or the highwater mark is too large to
10686 be represented by a 32-bit integer, then the values returned by
10687 sqlite3_status() are undefined.</p>
10688
10689 <p>See also: <a href="#sqlite3_db_status">sqlite3_db_status()</a>
10690 </p><hr><a name="sqlite3_stmt_scanstatus"></a>
10691 <h2>Prepared Statement Scan Status</h2>
10692 </div>
10693 <blockquote><pre>
10694 int sqlite3_stmt_scanstatus(
10695 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
10696 int idx, /* Index of loop to report on */
10697 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
10698 void *pOut /* Result written here */
10699 );
10700 int sqlite3_stmt_scanstatus_v2(
10701 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
10702 int idx, /* Index of loop to report on */
10703 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
10704 int flags, /* Mask of flags defined below */
10705 void *pOut /* Result written here */
10706 );
10707 </pre></blockquote>
10708 <p>
10709 These interfaces return information about the predicted and measured
10710 performance for pStmt. Advanced applications can use this
10711 interface to compare the predicted and the measured performance and
10712 issue warnings and/or rerun <a href="lang_analyze.html">ANALYZE</a> if discrepancies are found.</p>
10713
10714 <p>Since this interface is expected to be rarely used, it is only
10715 available if SQLite is compiled using the <a href="compile.html#enable_stmt_scanstatus">SQLITE_ENABLE_STMT_SCANSTATUS</a>
10716 compile-time option.</p>
10717
10718 <p>The "iScanStatusOp" parameter determines which status information to return.
10719 The "iScanStatusOp" must be one of the <a href="#SQLITE_SCANSTAT_EST">scanstatus options</a> or the behavior
10720 of this interface is undefined. The requested measurement is written into
10721 a variable pointed to by the "pOut" parameter.</p>
10722
10723 <p>The "flags" parameter must be passed a mask of flags. At present only
10724 one flag is defined - SQLITE_SCANSTAT_COMPLEX. If SQLITE_SCANSTAT_COMPLEX
10725 is specified, then status information is available for all elements
10726 of a query plan that are reported by "EXPLAIN QUERY PLAN" output. If
10727 SQLITE_SCANSTAT_COMPLEX is not specified, then only query plan elements
10728 that correspond to query loops (the "SCAN..." and "SEARCH..." elements of
10729 the EXPLAIN QUERY PLAN output) are available. Invoking API
10730 sqlite3_stmt_scanstatus() is equivalent to calling
10731 sqlite3_stmt_scanstatus_v2() with a zeroed flags parameter.</p>
10732
10733 <p>Parameter "idx" identifies the specific query element to retrieve statistics
10734 for. Query elements are numbered starting from zero. A value of -1 may be
10735 to query for statistics regarding the entire query. If idx is out of range
10736 - less than -1 or greater than or equal to the total number of query
10737 elements used to implement the statement - a non-zero value is returned and
10738 the variable that pOut points to is unchanged.</p>
10739
10740 <p>See also: <a href="#sqlite3_stmt_scanstatus_reset">sqlite3_stmt_scanstatus_reset()</a>
10741 </p><hr><a name="sqlite3_str_append"></a>
10742 <h2>Add Content To A Dynamic String</h2>
10743 </div>
10744 <blockquote><pre>
10745 void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);
10746 void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);
10747 void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
10748 void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
10749 void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
10750 void sqlite3_str_reset(sqlite3_str*);
10751 </pre></blockquote>
10752 <p>
10753 These interfaces add content to an sqlite3_str object previously obtained
10754 from <a href="#sqlite3_str_new">sqlite3_str_new()</a>.</p>
10755
10756 <p>The <a href="#sqlite3_str_append">sqlite3_str_appendf(X,F,...)</a> and
10757 <a href="#sqlite3_str_append">sqlite3_str_vappendf(X,F,V)</a> interfaces uses the <a href="printf.html">built-in printf</a>
10758 functionality of SQLite to append formatted text onto the end of
10759 <a href="#sqlite3_str">sqlite3_str</a> object X.</p>
10760
10761 <p>The <a href="#sqlite3_str_append">sqlite3_str_append(X,S,N)</a> method appends exactly N bytes from string S
10762 onto the end of the <a href="#sqlite3_str">sqlite3_str</a> object X. N must be non-negative.
10763 S must contain at least N non-zero bytes of content. To append a
10764 zero-terminated string in its entirety, use the <a href="#sqlite3_str_append">sqlite3_str_appendall()</a>
10765 method instead.</p>
10766
10767 <p>The <a href="#sqlite3_str_append">sqlite3_str_appendall(X,S)</a> method appends the complete content of
10768 zero-terminated string S onto the end of <a href="#sqlite3_str">sqlite3_str</a> object X.</p>
10769
10770 <p>The <a href="#sqlite3_str_append">sqlite3_str_appendchar(X,N,C)</a> method appends N copies of the
10771 single-byte character C onto the end of <a href="#sqlite3_str">sqlite3_str</a> object X.
10772 This method can be used, for example, to add whitespace indentation.</p>
10773
10774 <p>The <a href="#sqlite3_str_append">sqlite3_str_reset(X)</a> method resets the string under construction
10775 inside <a href="#sqlite3_str">sqlite3_str</a> object X back to zero bytes in length.</p>
10776
10777 <p>These methods do not return a result code. If an error occurs, that fact
10778 is recorded in the <a href="#sqlite3_str">sqlite3_str</a> object and can be recovered by a
10779 subsequent call to <a href="#sqlite3_str_errcode">sqlite3_str_errcode(X)</a>.
10780 </p><hr><a name="sqlite3_str_errcode"></a>
10781 <h2>Status Of A Dynamic String</h2>
10782 </div>
10783 <blockquote><pre>
10784 int sqlite3_str_errcode(sqlite3_str*);
10785 int sqlite3_str_length(sqlite3_str*);
10786 char *sqlite3_str_value(sqlite3_str*);
10787 </pre></blockquote>
10788 <p>
10789 These interfaces return the current status of an <a href="#sqlite3_str">sqlite3_str</a> object.</p>
10790
10791 <p>If any prior errors have occurred while constructing the dynamic string
10792 in sqlite3_str X, then the <a href="#sqlite3_str_errcode">sqlite3_str_errcode(X)</a> method will return
10793 an appropriate error code. The <a href="#sqlite3_str_errcode">sqlite3_str_errcode(X)</a> method returns
10794 <a href="#SQLITE_ABORT">SQLITE_NOMEM</a> following any out-of-memory error, or
10795 <a href="#SQLITE_ABORT">SQLITE_TOOBIG</a> if the size of the dynamic string exceeds
10796 <a href="limits.html#max_length">SQLITE_MAX_LENGTH</a>, or <a href="#SQLITE_ABORT">SQLITE_OK</a> if there have been no errors.</p>
10797
10798 <p>The <a href="#sqlite3_str_errcode">sqlite3_str_length(X)</a> method returns the current length, in bytes,
10799 of the dynamic string under construction in <a href="#sqlite3_str">sqlite3_str</a> object X.
10800 The length returned by <a href="#sqlite3_str_errcode">sqlite3_str_length(X)</a> does not include the
10801 zero-termination byte.</p>
10802
10803 <p>The <a href="#sqlite3_str_errcode">sqlite3_str_value(X)</a> method returns a pointer to the current
10804 content of the dynamic string under construction in X. The value
10805 returned by <a href="#sqlite3_str_errcode">sqlite3_str_value(X)</a> is managed by the sqlite3_str object X
10806 and might be freed or altered by any subsequent method on the same
10807 <a href="#sqlite3_str">sqlite3_str</a> object. Applications must not used the pointer returned
10808 <a href="#sqlite3_str_errcode">sqlite3_str_value(X)</a> after any subsequent method call on the same
10809 object. Applications may change the content of the string returned
10810 by <a href="#sqlite3_str_errcode">sqlite3_str_value(X)</a> as long as they do not write into any bytes
10811 outside the range of 0 to <a href="#sqlite3_str_errcode">sqlite3_str_length(X)</a> and do not read or
10812 write any byte after any subsequent sqlite3_str method call.
10813 </p><hr><a name="sqlite3_stricmp"></a>
10814 <h2>String Comparison</h2>
10815 </div>
10816 <blockquote><pre>
10817 int sqlite3_stricmp(const char *, const char *);
10818 int sqlite3_strnicmp(const char *, const char *, int);
10819 </pre></blockquote>
10820 <p>
10821 The <a href="#sqlite3_stricmp">sqlite3_stricmp()</a> and <a href="#sqlite3_stricmp">sqlite3_strnicmp()</a> APIs allow applications
10822 and extensions to compare the contents of two buffers containing UTF-8
10823 strings in a case-independent fashion, using the same definition of "case
10824 independence" that SQLite uses internally when comparing identifiers.
10825 </p><hr><a name="sqlite3_total_changes"></a>
10826 <h2>Total Number Of Rows Modified</h2>
10827 </div>
10828 <blockquote><pre>
10829 int sqlite3_total_changes(sqlite3*);
10830 sqlite3_int64 sqlite3_total_changes64(sqlite3*);
10831 </pre></blockquote>
10832 <p>
10833 These functions return the total number of rows inserted, modified or
10834 deleted by all <a href="lang_insert.html">INSERT</a>, <a href="lang_update.html">UPDATE</a> or <a href="lang_delete.html">DELETE</a> statements completed
10835 since the database connection was opened, including those executed as
10836 part of trigger programs. The two functions are identical except for the
10837 type of the return value and that if the number of rows modified by the
10838 connection exceeds the maximum value supported by type "int", then
10839 the return value of sqlite3_total_changes() is undefined. Executing
10840 any other type of SQL statement does not affect the value returned by
10841 sqlite3_total_changes().</p>
10842
10843 <p>Changes made as part of <a href="foreignkeys.html#fk_actions">foreign key actions</a> are included in the
10844 count, but those made as part of REPLACE constraint resolution are
10845 not. Changes to a view that are intercepted by INSTEAD OF triggers
10846 are not counted.</p>
10847
10848 <p>The <a href="#sqlite3_total_changes">sqlite3_total_changes(D)</a> interface only reports the number
10849 of rows that changed due to SQL statement run against database
10850 connection D. Any changes by other database connections are ignored.
10851 To detect changes against a database file from other database
10852 connections use the <a href="pragma.html#pragma_data_version">PRAGMA data_version</a> command or the
10853 <a href="#sqlitefcntldataversion">SQLITE_FCNTL_DATA_VERSION</a> <a href="#sqlite3_file_control">file control</a>.</p>
10854
10855 <p>If a separate thread makes changes on the same database connection
10856 while <a href="#sqlite3_total_changes">sqlite3_total_changes()</a> is running then the value
10857 returned is unpredictable and not meaningful.</p>
10858
10859 <p>See also:
10860 <ul>
10861 <li> the <a href="#sqlite3_changes">sqlite3_changes()</a> interface
10862 <li> the <a href="pragma.html#pragma_count_changes">count_changes pragma</a>
10863 <li> the <a href="lang_corefunc.html#changes">changes() SQL function</a>
10864 <li> the <a href="pragma.html#pragma_data_version">data_version pragma</a>
10865 <li> the <a href="#sqlitefcntldataversion">SQLITE_FCNTL_DATA_VERSION</a> <a href="#sqlite3_file_control">file control</a>
10866 </ul>
10867 </p><hr><a name="sqlite3_uri_boolean"></a>
10868 <h2>Obtain Values For URI Parameters</h2>
10869 </div>
10870 <blockquote><pre>
10871 const char *sqlite3_uri_parameter(sqlite3_filename z, const char *zParam);
10872 int sqlite3_uri_boolean(sqlite3_filename z, const char *zParam, int bDefault);
10873 sqlite3_int64 sqlite3_uri_int64(sqlite3_filename, const char*, sqlite3_int64);
10874 const char *sqlite3_uri_key(sqlite3_filename z, int N);
10875 </pre></blockquote>
10876 <p>
10877 These are utility routines, useful to <a href="vfs.html">custom VFS implementations</a>,
10878 that check if a database file was a URI that contained a specific query
10879 parameter, and if so obtains the value of that query parameter.</p>
10880
10881 <p>The first parameter to these interfaces (hereafter referred to
10882 as F) must be one of:
10883 <ul>
10884 <li> A database filename pointer created by the SQLite core and
10885 passed into the xOpen() method of a VFS implementation, or
10886 <li> A filename obtained from <a href="#sqlite3_db_filename">sqlite3_db_filename()</a>, or
10887 <li> A new filename constructed using <a href="#sqlite3_create_filename">sqlite3_create_filename()</a>.
10888 </ul>
10889 If the F parameter is not one of the above, then the behavior is
10890 undefined and probably undesirable. Older versions of SQLite were
10891 more tolerant of invalid F parameters than newer versions.</p>
10892
10893 <p>If F is a suitable filename (as described in the previous paragraph)
10894 and if P is the name of the query parameter, then
10895 sqlite3_uri_parameter(F,P) returns the value of the P
10896 parameter if it exists or a NULL pointer if P does not appear as a
10897 query parameter on F. If P is a query parameter of F and it
10898 has no explicit value, then sqlite3_uri_parameter(F,P) returns
10899 a pointer to an empty string.</p>
10900
10901 <p>The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
10902 parameter and returns true (1) or false (0) according to the value
10903 of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the
10904 value of query parameter P is one of "yes", "true", or "on" in any
10905 case or if the value begins with a non-zero number. The
10906 sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
10907 query parameter P is one of "no", "false", or "off" in any case or
10908 if the value begins with a numeric zero. If P is not a query
10909 parameter on F or if the value of P does not match any of the
10910 above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).</p>
10911
10912 <p>The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
10913 64-bit signed integer and returns that integer, or D if P does not
10914 exist. If the value of P is something other than an integer, then
10915 zero is returned.</p>
10916
10917 <p>The sqlite3_uri_key(F,N) returns a pointer to the name (not
10918 the value) of the N-th query parameter for filename F, or a NULL
10919 pointer if N is less than zero or greater than the number of query
10920 parameters minus 1. The N value is zero-based so N should be 0 to obtain
10921 the name of the first query parameter, 1 for the second parameter, and
10922 so forth.</p>
10923
10924 <p>If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
10925 sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
10926 is not a database file pathname pointer that the SQLite core passed
10927 into the xOpen VFS method, then the behavior of this routine is undefined
10928 and probably undesirable.</p>
10929
10930 <p>Beginning with SQLite <a href="releaselog/3_31_0.html">version 3.31.0</a> (2020-01-22) the input F
10931 parameter can also be the name of a rollback journal file or WAL file
10932 in addition to the main database file. Prior to version 3.31.0, these
10933 routines would only work if F was the name of the main database file.
10934 When the F parameter is the name of the rollback journal or WAL file,
10935 it has access to all the same query parameters as were found on the
10936 main database file.</p>
10937
10938 <p>See the <a href="uri.html">URI filename</a> documentation for additional information.
10939 </p><hr><a name="sqlite3_value_blob"></a>
10940 <h2>Obtaining SQL Values</h2>
10941 </div>
10942 <blockquote><pre>
10943 const void *sqlite3_value_blob(sqlite3_value*);
10944 double sqlite3_value_double(sqlite3_value*);
10945 int sqlite3_value_int(sqlite3_value*);
10946 sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
10947 void *sqlite3_value_pointer(sqlite3_value*, const char*);
10948 const unsigned char *sqlite3_value_text(sqlite3_value*);
10949 const void *sqlite3_value_text16(sqlite3_value*);
10950 const void *sqlite3_value_text16le(sqlite3_value*);
10951 const void *sqlite3_value_text16be(sqlite3_value*);
10952 int sqlite3_value_bytes(sqlite3_value*);
10953 int sqlite3_value_bytes16(sqlite3_value*);
10954 int sqlite3_value_type(sqlite3_value*);
10955 int sqlite3_value_numeric_type(sqlite3_value*);
10956 int sqlite3_value_nochange(sqlite3_value*);
10957 int sqlite3_value_frombind(sqlite3_value*);
10958 </pre></blockquote>
10959 <p>
10960 <b>Summary:</b>
10961 <blockquote><table border=0 cellpadding=0 cellspacing=0>
10962 <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
10963 <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
10964 <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
10965 <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
10966 <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value
10967 <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
10968 <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
10969 the native byteorder
10970 <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
10971 <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
10972 <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
10973 <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB
10974 or a UTF-8 TEXT in bytes
10975 <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>
10976 <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
10977 TEXT in bytes
10978 <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default
10979 datatype of the value
10980 <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
10981 <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
10982 <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>
10983 <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE
10984 against a virtual table.
10985 <tr><td><b>sqlite3_value_frombind&nbsp;&nbsp;</b>
10986 <td>&rarr;&nbsp;&nbsp;<td>True if value originated from a <a href="lang_expr.html#varparam">bound parameter</a>
10987 </table></blockquote></p>
10988
10989 <p><b>Details:</b></p>
10990
10991 <p>These routines extract type, size, and content information from
10992 <a href="#sqlite3_value">protected sqlite3_value</a> objects. Protected sqlite3_value objects
10993 are used to pass parameter information into the functions that
10994 implement <a href="appfunc.html">application-defined SQL functions</a> and <a href="vtab.html">virtual tables</a>.</p>
10995
10996 <p>These routines work only with <a href="#sqlite3_value">protected sqlite3_value</a> objects.
10997 Any attempt to use these routines on an <a href="#sqlite3_value">unprotected sqlite3_value</a>
10998 is not threadsafe.</p>
10999
11000 <p>These routines work just like the corresponding <a href="#sqlite3_column_blob">column access functions</a>
11001 except that these routines take a single <a href="#sqlite3_value">protected sqlite3_value</a> object
11002 pointer instead of a <a href="#sqlite3_stmt">sqlite3_stmt*</a> pointer and an integer column number.</p>
11003
11004 <p>The sqlite3_value_text16() interface extracts a UTF-16 string
11005 in the native byte-order of the host machine. The
11006 sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
11007 extract UTF-16 strings as big-endian and little-endian respectively.</p>
11008
11009 <p>If <a href="#sqlite3_value">sqlite3_value</a> object V was initialized
11010 using <a href="#sqlite3_bind_blob">sqlite3_bind_pointer(S,I,P,X,D)</a> or <a href="#sqlite3_result_blob">sqlite3_result_pointer(C,P,X,D)</a>
11011 and if X and Y are strings that compare equal according to strcmp(X,Y),
11012 then sqlite3_value_pointer(V,Y) will return the pointer P. Otherwise,
11013 sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer()
11014 routine is part of the <a href="bindptr.html">pointer passing interface</a> added for SQLite 3.20.0.</p>
11015
11016 <p>The sqlite3_value_type(V) interface returns the
11017 <a href="#SQLITE_BLOB">datatype code</a> for the initial datatype of the
11018 <a href="#sqlite3_value">sqlite3_value</a> object V. The returned value is one of <a href="#SQLITE_BLOB">SQLITE_INTEGER</a>,
11019 <a href="#SQLITE_BLOB">SQLITE_FLOAT</a>, <a href="#SQLITE_BLOB">SQLITE_TEXT</a>, <a href="#SQLITE_BLOB">SQLITE_BLOB</a>, or <a href="#SQLITE_BLOB">SQLITE_NULL</a>.
11020 Other interfaces might change the datatype for an sqlite3_value object.
11021 For example, if the datatype is initially SQLITE_INTEGER and
11022 sqlite3_value_text(V) is called to extract a text value for that
11023 integer, then subsequent calls to sqlite3_value_type(V) might return
11024 SQLITE_TEXT. Whether or not a persistent internal datatype conversion
11025 occurs is undefined and may change from one release of SQLite to the next.</p>
11026
11027 <p>The sqlite3_value_numeric_type() interface attempts to apply
11028 numeric affinity to the value. This means that an attempt is
11029 made to convert the value to an integer or floating point. If
11030 such a conversion is possible without loss of information (in other
11031 words, if the value is a string that looks like a number)
11032 then the conversion is performed. Otherwise no conversion occurs.
11033 The <a href="#SQLITE_BLOB">datatype</a> after conversion is returned.</p>
11034
11035 <p>Within the <a href="vtab.html#xupdate">xUpdate</a> method of a <a href="vtab.html">virtual table</a>, the
11036 sqlite3_value_nochange(X) interface returns true if and only if
11037 the column corresponding to X is unchanged by the UPDATE operation
11038 that the xUpdate method call was invoked to implement and if
11039 and the prior <a href="vtab.html#xcolumn">xColumn</a> method call that was invoked to extracted
11040 the value for that column returned without setting a result (probably
11041 because it queried <a href="#sqlite3_vtab_nochange">sqlite3_vtab_nochange()</a> and found that the column
11042 was unchanging). Within an <a href="vtab.html#xupdate">xUpdate</a> method, any value for which
11043 sqlite3_value_nochange(X) is true will in all other respects appear
11044 to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other
11045 than within an <a href="vtab.html#xupdate">xUpdate</a> method call for an UPDATE statement, then
11046 the return value is arbitrary and meaningless.</p>
11047
11048 <p>The sqlite3_value_frombind(X) interface returns non-zero if the
11049 value X originated from one of the <a href="#sqlite3_bind_blob">sqlite3_bind()</a>
11050 interfaces. If X comes from an SQL literal value, or a table column,
11051 or an expression, then sqlite3_value_frombind(X) returns zero.</p>
11052
11053 <p>Please pay particular attention to the fact that the pointer returned
11054 from <a href="#sqlite3_value_blob">sqlite3_value_blob()</a>, <a href="#sqlite3_value_blob">sqlite3_value_text()</a>, or
11055 <a href="#sqlite3_value_blob">sqlite3_value_text16()</a> can be invalidated by a subsequent call to
11056 <a href="#sqlite3_value_blob">sqlite3_value_bytes()</a>, <a href="#sqlite3_value_blob">sqlite3_value_bytes16()</a>, <a href="#sqlite3_value_blob">sqlite3_value_text()</a>,
11057 or <a href="#sqlite3_value_blob">sqlite3_value_text16()</a>.</p>
11058
11059 <p>These routines must be called from the same thread as
11060 the SQL function that supplied the <a href="#sqlite3_value">sqlite3_value*</a> parameters.</p>
11061
11062 <p>As long as the input parameter is correct, these routines can only
11063 fail if an out-of-memory error occurs during a format conversion.
11064 Only the following subset of interfaces are subject to out-of-memory
11065 errors:</p>
11066
11067 <p><ul>
11068 <li> sqlite3_value_blob()
11069 <li> sqlite3_value_text()
11070 <li> sqlite3_value_text16()
11071 <li> sqlite3_value_text16le()
11072 <li> sqlite3_value_text16be()
11073 <li> sqlite3_value_bytes()
11074 <li> sqlite3_value_bytes16()
11075 </ul></p>
11076
11077 <p>If an out-of-memory error occurs, then the return value from these
11078 routines is the same as if the column had contained an SQL NULL value.
11079 Valid SQL NULL returns can be distinguished from out-of-memory errors
11080 by invoking the <a href="#sqlite3_errcode">sqlite3_errcode()</a> immediately after the suspect
11081 return value is obtained and before any
11082 other SQLite interface is called on the same <a href="#sqlite3">database connection</a>.
11083 </p><hr><a name="sqlite3_value_dup"></a>
11084 <h2>Copy And Free SQL Values</h2>
11085 </div>
11086 <blockquote><pre>
11087 sqlite3_value *sqlite3_value_dup(const sqlite3_value*);
11088 void sqlite3_value_free(sqlite3_value*);
11089 </pre></blockquote>
11090 <p>
11091 The sqlite3_value_dup(V) interface makes a copy of the <a href="#sqlite3_value">sqlite3_value</a>
11092 object D and returns a pointer to that copy. The <a href="#sqlite3_value">sqlite3_value</a> returned
11093 is a <a href="#sqlite3_value">protected sqlite3_value</a> object even if the input is not.
11094 The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
11095 memory allocation fails. If V is a <a href="bindptr.html">pointer value</a>, then the result
11096 of sqlite3_value_dup(V) is a NULL value.</p>
11097
11098 <p>The sqlite3_value_free(V) interface frees an <a href="#sqlite3_value">sqlite3_value</a> object
11099 previously obtained from <a href="#sqlite3_value_dup">sqlite3_value_dup()</a>. If V is a NULL pointer
11100 then sqlite3_value_free(V) is a harmless no-op.
11101 </p><hr><a name="sqlite3_vfs_find"></a>
11102 <h2>Virtual File System Objects</h2>
11103 </div>
11104 <blockquote><pre>
11105 sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
11106 int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
11107 int sqlite3_vfs_unregister(sqlite3_vfs*);
11108 </pre></blockquote>
11109 <p>
11110 A virtual filesystem (VFS) is an <a href="#sqlite3_vfs">sqlite3_vfs</a> object
11111 that SQLite uses to interact
11112 with the underlying operating system. Most SQLite builds come with a
11113 single default VFS that is appropriate for the host computer.
11114 New VFSes can be registered and existing VFSes can be unregistered.
11115 The following interfaces are provided.</p>
11116
11117 <p>The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
11118 Names are case sensitive.
11119 Names are zero-terminated UTF-8 strings.
11120 If there is no match, a NULL pointer is returned.
11121 If zVfsName is NULL then the default VFS is returned.</p>
11122
11123 <p>New VFSes are registered with sqlite3_vfs_register().
11124 Each new VFS becomes the default VFS if the makeDflt flag is set.
11125 The same VFS can be registered multiple times without injury.
11126 To make an existing VFS into the default VFS, register it again
11127 with the makeDflt flag set. If two different VFSes with the
11128 same name are registered, the behavior is undefined. If a
11129 VFS is registered with a name that is NULL or an empty string,
11130 then the behavior is undefined.</p>
11131
11132 <p>Unregister a VFS with the sqlite3_vfs_unregister() interface.
11133 If the default VFS is unregistered, another VFS is chosen as
11134 the default. The choice for the new VFS is arbitrary.
11135 </p><hr><a name="sqlite3_vtab_in_first"></a>
11136 <h2>Find all elements on the right-hand side of an IN constraint.</h2>
11137 </div>
11138 <blockquote><pre>
11139 int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
11140 int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
11141 </pre></blockquote>
11142 <p>
11143 These interfaces are only useful from within the
11144 <a href="vtab.html#xfilter">xFilter() method</a> of a <a href="vtab.html">virtual table</a> implementation.
11145 The result of invoking these interfaces from any other context
11146 is undefined and probably harmful.</p>
11147
11148 <p>The X parameter in a call to sqlite3_vtab_in_first(X,P) or
11149 sqlite3_vtab_in_next(X,P) should be one of the parameters to the
11150 xFilter method which invokes these routines, and specifically
11151 a parameter that was previously selected for all-at-once IN constraint
11152 processing use the <a href="#sqlite3_vtab_in">sqlite3_vtab_in()</a> interface in the
11153 <a href="vtab.html#xbestindex">xBestIndex method</a>. If the X parameter is not
11154 an xFilter argument that was selected for all-at-once IN constraint
11155 processing, then these routines return <a href="#SQLITE_ABORT">SQLITE_ERROR</a>.</p>
11156
11157 <p>Use these routines to access all values on the right-hand side
11158 of the IN constraint using code like the following:</p>
11159
11160 <p><blockquote><pre>
11161 &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
11162 &nbsp; rc==SQLITE_OK && pVal;
11163 &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
11164 &nbsp; ){
11165 &nbsp; // do something with pVal
11166 &nbsp; }
11167 &nbsp; if( rc!=SQLITE_OK ){
11168 &nbsp; // an error has occurred
11169 &nbsp; }
11170 </pre></blockquote></p>
11171
11172 <p>On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
11173 routines return SQLITE_OK and set *P to point to the first or next value
11174 on the RHS of the IN constraint. If there are no more values on the
11175 right hand side of the IN constraint, then *P is set to NULL and these
11176 routines return <a href="#SQLITE_ABORT">SQLITE_DONE</a>. The return value might be
11177 some other value, such as SQLITE_NOMEM, in the event of a malfunction.</p>
11178
11179 <p>The *ppOut values returned by these routines are only valid until the
11180 next call to either of these routines or until the end of the xFilter
11181 method from which these routines were called. If the virtual table
11182 implementation needs to retain the *ppOut values for longer, it must make
11183 copies. The *ppOut values are <a href="#sqlite3_value">protected</a>.
11184 </p><hr><a name="sqlite3_win32_set_directory"></a>
11185 <h2>Win32 Specific Interface</h2>
11186 </div>
11187 <blockquote><pre>
11188 int sqlite3_win32_set_directory(
11189 unsigned long type, /* Identifier for directory being set or reset */
11190 void *zValue /* New value for directory being set or reset */
11191 );
11192 int sqlite3_win32_set_directory8(unsigned long type, const char *zValue);
11193 int sqlite3_win32_set_directory16(unsigned long type, const void *zValue);
11194 </pre></blockquote>
11195 <p>
11196 These interfaces are available only on Windows. The
11197 <a href="#sqlite3_win32_set_directory">sqlite3_win32_set_directory</a> interface is used to set the value associated
11198 with the <a href="#sqlite3_temp_directory">sqlite3_temp_directory</a> or <a href="#sqlite3_data_directory">sqlite3_data_directory</a> variable, to
11199 zValue, depending on the value of the type parameter. The zValue parameter
11200 should be NULL to cause the previous value to be freed via <a href="#sqlite3_free">sqlite3_free</a>;
11201 a non-NULL value will be copied into memory obtained from <a href="#sqlite3_free">sqlite3_malloc</a>
11202 prior to being used. The <a href="#sqlite3_win32_set_directory">sqlite3_win32_set_directory</a> interface returns
11203 <a href="#SQLITE_ABORT">SQLITE_OK</a> to indicate success, <a href="#SQLITE_ABORT">SQLITE_ERROR</a> if the type is unsupported,
11204 or <a href="#SQLITE_ABORT">SQLITE_NOMEM</a> if memory could not be allocated. The value of the
11205 <a href="#sqlite3_data_directory">sqlite3_data_directory</a> variable is intended to act as a replacement for
11206 the current directory on the sub-platforms of Win32 where that concept is
11207 not present, e.g. WinRT and UWP. The <a href="#sqlite3_win32_set_directory">sqlite3_win32_set_directory8</a> and
11208 <a href="#sqlite3_win32_set_directory">sqlite3_win32_set_directory16</a> interfaces behave exactly the same as the
11209 sqlite3_win32_set_directory interface except the string parameter must be
11210 UTF-8 or UTF-16, respectively.
11211 </p><hr><a name="sqlite3_bind_blob"></a>
11212 <h2>Binding Values To Prepared Statements</h2>
11213 </div>
11214 <blockquote><pre>
11215 int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
11216 int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
11217 void(*)(void*));
11218 int sqlite3_bind_double(sqlite3_stmt*, int, double);
11219 int sqlite3_bind_int(sqlite3_stmt*, int, int);
11220 int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
11221 int sqlite3_bind_null(sqlite3_stmt*, int);
11222 int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
11223 int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
11224 int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
11225 void(*)(void*), unsigned char encoding);
11226 int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
11227 int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));
11228 int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
11229 int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
11230 </pre></blockquote>
11231 <p>
11232 In the SQL statement text input to <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> and its variants,
11233 literals may be replaced by a <a href="lang_expr.html#varparam">parameter</a> that matches one of following
11234 templates:</p>
11235
11236 <p><ul>
11237 <li> ?
11238 <li> ?NNN
11239 <li> :VVV
11240 <li> @VVV
11241 <li> $VVV
11242 </ul></p>
11243
11244 <p>In the templates above, NNN represents an integer literal,
11245 and VVV represents an alphanumeric identifier. The values of these
11246 parameters (also called "host parameter names" or "SQL parameters")
11247 can be set using the sqlite3_bind_*() routines defined here.</p>
11248
11249 <p>The first argument to the sqlite3_bind_*() routines is always
11250 a pointer to the <a href="#sqlite3_stmt">sqlite3_stmt</a> object returned from
11251 <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> or its variants.</p>
11252
11253 <p>The second argument is the index of the SQL parameter to be set.
11254 The leftmost SQL parameter has an index of 1. When the same named
11255 SQL parameter is used more than once, second and subsequent
11256 occurrences have the same index as the first occurrence.
11257 The index for named parameters can be looked up using the
11258 <a href="#sqlite3_bind_parameter_index">sqlite3_bind_parameter_index()</a> API if desired. The index
11259 for "?NNN" parameters is the value of NNN.
11260 The NNN value must be between 1 and the <a href="#sqlite3_limit">sqlite3_limit()</a>
11261 parameter <a href="#sqlitelimitvariablenumber">SQLITE_LIMIT_VARIABLE_NUMBER</a> (default value: 32766).</p>
11262
11263 <p>The third argument is the value to bind to the parameter.
11264 If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()
11265 or sqlite3_bind_blob() is a NULL pointer then the fourth parameter
11266 is ignored and the end result is the same as sqlite3_bind_null().
11267 If the third parameter to sqlite3_bind_text() is not NULL, then
11268 it should be a pointer to well-formed UTF8 text.
11269 If the third parameter to sqlite3_bind_text16() is not NULL, then
11270 it should be a pointer to well-formed UTF16 text.
11271 If the third parameter to sqlite3_bind_text64() is not NULL, then
11272 it should be a pointer to a well-formed unicode string that is
11273 either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16
11274 otherwise.</p>
11275
11276 <p><a name="byteorderdeterminationrules"></a>
11277 The byte-order of
11278 UTF16 input text is determined by the byte-order mark (BOM, U+FEFF)
11279 found in first character, which is removed, or in the absence of a BOM
11280 the byte order is the native byte order of the host
11281 machine for sqlite3_bind_text16() or the byte order specified in
11282 the 6th parameter for sqlite3_bind_text64().
11283 If UTF16 input text contains invalid unicode
11284 characters, then SQLite might change those invalid characters
11285 into the unicode replacement character: U+FFFD.</p>
11286
11287 <p>In those routines that have a fourth argument, its value is the
11288 number of bytes in the parameter. To be clear: the value is the
11289 number of <u>bytes</u> in the value, not the number of characters.
11290 If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()
11291 is negative, then the length of the string is
11292 the number of bytes up to the first zero terminator.
11293 If the fourth parameter to sqlite3_bind_blob() is negative, then
11294 the behavior is undefined.
11295 If a non-negative fourth parameter is provided to sqlite3_bind_text()
11296 or sqlite3_bind_text16() or sqlite3_bind_text64() then
11297 that parameter must be the byte offset
11298 where the NUL terminator would occur assuming the string were NUL
11299 terminated. If any NUL characters occurs at byte offsets less than
11300 the value of the fourth parameter then the resulting string value will
11301 contain embedded NULs. The result of expressions involving strings
11302 with embedded NULs is undefined.</p>
11303
11304 <p>The fifth argument to the BLOB and string binding interfaces controls
11305 or indicates the lifetime of the object referenced by the third parameter.
11306 These three options exist:
11307 (1) A destructor to dispose of the BLOB or string after SQLite has finished
11308 with it may be passed. It is called to dispose of the BLOB or string even
11309 if the call to the bind API fails, except the destructor is not called if
11310 the third parameter is a NULL pointer or the fourth parameter is negative.
11311 (2) The special constant, <a href="#SQLITE_STATIC">SQLITE_STATIC</a>, may be passed to indicate that
11312 the application remains responsible for disposing of the object. In this
11313 case, the object and the provided pointer to it must remain valid until
11314 either the prepared statement is finalized or the same SQL parameter is
11315 bound to something else, whichever occurs sooner.
11316 (3) The constant, <a href="#SQLITE_STATIC">SQLITE_TRANSIENT</a>, may be passed to indicate that the
11317 object is to be copied prior to the return from sqlite3_bind_*(). The
11318 object and pointer to it must remain valid until then. SQLite will then
11319 manage the lifetime of its private copy.</p>
11320
11321 <p>The sixth argument to sqlite3_bind_text64() must be one of
11322 <a href="#SQLITE_ANY">SQLITE_UTF8</a>, <a href="#SQLITE_ANY">SQLITE_UTF16</a>, <a href="#SQLITE_ANY">SQLITE_UTF16BE</a>, or <a href="#SQLITE_ANY">SQLITE_UTF16LE</a>
11323 to specify the encoding of the text in the third parameter. If
11324 the sixth argument to sqlite3_bind_text64() is not one of the
11325 allowed values shown above, or if the text encoding is different
11326 from the encoding specified by the sixth parameter, then the behavior
11327 is undefined.</p>
11328
11329 <p>The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
11330 is filled with zeroes. A zeroblob uses a fixed amount of memory
11331 (just an integer to hold its size) while it is being processed.
11332 Zeroblobs are intended to serve as placeholders for BLOBs whose
11333 content is later written using
11334 <a href="#sqlite3_blob_open">incremental BLOB I/O</a> routines.
11335 A negative value for the zeroblob results in a zero-length BLOB.</p>
11336
11337 <p>The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in
11338 <a href="#sqlite3_stmt">prepared statement</a> S to have an SQL value of NULL, but to also be
11339 associated with the pointer P of type T. D is either a NULL pointer or
11340 a pointer to a destructor function for P. SQLite will invoke the
11341 destructor D with a single argument of P when it is finished using
11342 P. The T parameter should be a static string, preferably a string
11343 literal. The sqlite3_bind_pointer() routine is part of the
11344 <a href="bindptr.html">pointer passing interface</a> added for SQLite 3.20.0.</p>
11345
11346 <p>If any of the sqlite3_bind_*() routines are called with a NULL pointer
11347 for the <a href="#sqlite3_stmt">prepared statement</a> or with a prepared statement for which
11348 <a href="#sqlite3_step">sqlite3_step()</a> has been called more recently than <a href="#sqlite3_reset">sqlite3_reset()</a>,
11349 then the call will return <a href="#SQLITE_ABORT">SQLITE_MISUSE</a>. If any sqlite3_bind_()
11350 routine is passed a <a href="#sqlite3_stmt">prepared statement</a> that has been finalized, the
11351 result is undefined and probably harmful.</p>
11352
11353 <p>Bindings are not cleared by the <a href="#sqlite3_reset">sqlite3_reset()</a> routine.
11354 Unbound parameters are interpreted as NULL.</p>
11355
11356 <p>The sqlite3_bind_* routines return <a href="#SQLITE_ABORT">SQLITE_OK</a> on success or an
11357 <a href="rescode.html">error code</a> if anything goes wrong.
11358 <a href="#SQLITE_ABORT">SQLITE_TOOBIG</a> might be returned if the size of a string or BLOB
11359 exceeds limits imposed by <a href="#sqlite3_limit">sqlite3_limit</a>(<a href="#sqlitelimitlength">SQLITE_LIMIT_LENGTH</a>) or
11360 <a href="limits.html#max_length">SQLITE_MAX_LENGTH</a>.
11361 <a href="#SQLITE_ABORT">SQLITE_RANGE</a> is returned if the parameter
11362 index is out of range. <a href="#SQLITE_ABORT">SQLITE_NOMEM</a> is returned if malloc() fails.</p>
11363
11364 <p>See also: <a href="#sqlite3_bind_parameter_count">sqlite3_bind_parameter_count()</a>,
11365 <a href="#sqlite3_bind_parameter_name">sqlite3_bind_parameter_name()</a>, and <a href="#sqlite3_bind_parameter_index">sqlite3_bind_parameter_index()</a>.
11366 </p><hr><a name="sqlite3_prepare"></a>
11367 <h2>Compiling An SQL Statement</h2>
11368 </div>
11369 <blockquote><pre>
11370 int sqlite3_prepare(
11371 sqlite3 *db, /* Database handle */
11372 const char *zSql, /* SQL statement, UTF-8 encoded */
11373 int nByte, /* Maximum length of zSql in bytes. */
11374 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
11375 const char **pzTail /* OUT: Pointer to unused portion of zSql */
11376 );
11377 int sqlite3_prepare_v2(
11378 sqlite3 *db, /* Database handle */
11379 const char *zSql, /* SQL statement, UTF-8 encoded */
11380 int nByte, /* Maximum length of zSql in bytes. */
11381 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
11382 const char **pzTail /* OUT: Pointer to unused portion of zSql */
11383 );
11384 int sqlite3_prepare_v3(
11385 sqlite3 *db, /* Database handle */
11386 const char *zSql, /* SQL statement, UTF-8 encoded */
11387 int nByte, /* Maximum length of zSql in bytes. */
11388 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
11389 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
11390 const char **pzTail /* OUT: Pointer to unused portion of zSql */
11391 );
11392 int sqlite3_prepare16(
11393 sqlite3 *db, /* Database handle */
11394 const void *zSql, /* SQL statement, UTF-16 encoded */
11395 int nByte, /* Maximum length of zSql in bytes. */
11396 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
11397 const void **pzTail /* OUT: Pointer to unused portion of zSql */
11398 );
11399 int sqlite3_prepare16_v2(
11400 sqlite3 *db, /* Database handle */
11401 const void *zSql, /* SQL statement, UTF-16 encoded */
11402 int nByte, /* Maximum length of zSql in bytes. */
11403 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
11404 const void **pzTail /* OUT: Pointer to unused portion of zSql */
11405 );
11406 int sqlite3_prepare16_v3(
11407 sqlite3 *db, /* Database handle */
11408 const void *zSql, /* SQL statement, UTF-16 encoded */
11409 int nByte, /* Maximum length of zSql in bytes. */
11410 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
11411 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
11412 const void **pzTail /* OUT: Pointer to unused portion of zSql */
11413 );
11414 </pre></blockquote>
11415 <p>
11416 To execute an SQL statement, it must first be compiled into a byte-code
11417 program using one of these routines. Or, in other words, these routines
11418 are constructors for the <a href="#sqlite3_stmt">prepared statement</a> object.</p>
11419
11420 <p>The preferred routine to use is <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>. The
11421 <a href="#sqlite3_prepare">sqlite3_prepare()</a> interface is legacy and should be avoided.
11422 <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a> has an extra "prepFlags" option that is used
11423 for special purposes.</p>
11424
11425 <p>The use of the UTF-8 interfaces is preferred, as SQLite currently
11426 does all parsing using UTF-8. The UTF-16 interfaces are provided
11427 as a convenience. The UTF-16 interfaces work by converting the
11428 input text into UTF-8, then invoking the corresponding UTF-8 interface.</p>
11429
11430 <p>The first argument, "db", is a <a href="#sqlite3">database connection</a> obtained from a
11431 prior successful call to <a href="#sqlite3_open">sqlite3_open()</a>, <a href="#sqlite3_open">sqlite3_open_v2()</a> or
11432 <a href="#sqlite3_open">sqlite3_open16()</a>. The database connection must not have been closed.</p>
11433
11434 <p>The second argument, "zSql", is the statement to be compiled, encoded
11435 as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
11436 and sqlite3_prepare_v3()
11437 interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
11438 and sqlite3_prepare16_v3() use UTF-16.</p>
11439
11440 <p>If the nByte argument is negative, then zSql is read up to the
11441 first zero terminator. If nByte is positive, then it is the
11442 number of bytes read from zSql. If nByte is zero, then no prepared
11443 statement is generated.
11444 If the caller knows that the supplied string is nul-terminated, then
11445 there is a small performance advantage to passing an nByte parameter that
11446 is the number of bytes in the input string <i>including</i>
11447 the nul-terminator.</p>
11448
11449 <p>If pzTail is not NULL then *pzTail is made to point to the first byte
11450 past the end of the first SQL statement in zSql. These routines only
11451 compile the first statement in zSql, so *pzTail is left pointing to
11452 what remains uncompiled.</p>
11453
11454 <p>*ppStmt is left pointing to a compiled <a href="#sqlite3_stmt">prepared statement</a> that can be
11455 executed using <a href="#sqlite3_step">sqlite3_step()</a>. If there is an error, *ppStmt is set
11456 to NULL. If the input text contains no SQL (if the input is an empty
11457 string or a comment) then *ppStmt is set to NULL.
11458 The calling procedure is responsible for deleting the compiled
11459 SQL statement using <a href="#sqlite3_finalize">sqlite3_finalize()</a> after it has finished with it.
11460 ppStmt may not be NULL.</p>
11461
11462 <p>On success, the sqlite3_prepare() family of routines return <a href="#SQLITE_ABORT">SQLITE_OK</a>;
11463 otherwise an <a href="rescode.html">error code</a> is returned.</p>
11464
11465 <p>The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
11466 and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
11467 The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
11468 are retained for backwards compatibility, but their use is discouraged.
11469 In the "vX" interfaces, the prepared statement
11470 that is returned (the <a href="#sqlite3_stmt">sqlite3_stmt</a> object) contains a copy of the
11471 original SQL text. This causes the <a href="#sqlite3_step">sqlite3_step()</a> interface to
11472 behave differently in three ways:</p>
11473
11474 <p><ol>
11475 <li>
11476 If the database schema changes, instead of returning <a href="#SQLITE_ABORT">SQLITE_SCHEMA</a> as it
11477 always used to do, <a href="#sqlite3_step">sqlite3_step()</a> will automatically recompile the SQL
11478 statement and try to run it again. As many as <a href="compile.html#max_schema_retry">SQLITE_MAX_SCHEMA_RETRY</a>
11479 retries will occur before sqlite3_step() gives up and returns an error.
11480 </li></p>
11481
11482 <p><li>
11483 When an error occurs, <a href="#sqlite3_step">sqlite3_step()</a> will return one of the detailed
11484 <a href="rescode.html">error codes</a> or <a href="rescode.html#extrc">extended error codes</a>. The legacy behavior was that
11485 <a href="#sqlite3_step">sqlite3_step()</a> would only return a generic <a href="#SQLITE_ABORT">SQLITE_ERROR</a> result code
11486 and the application would have to make a second call to <a href="#sqlite3_reset">sqlite3_reset()</a>
11487 in order to find the underlying cause of the problem. With the "v2" prepare
11488 interfaces, the underlying reason for the error is returned immediately.
11489 </li></p>
11490
11491 <p><li>
11492 If the specific value bound to a <a href="lang_expr.html#varparam">host parameter</a> in the
11493 WHERE clause might influence the choice of query plan for a statement,
11494 then the statement will be automatically recompiled, as if there had been
11495 a schema change, on the first <a href="#sqlite3_step">sqlite3_step()</a> call following any change
11496 to the <a href="#sqlite3_bind_blob">bindings</a> of that <a href="lang_expr.html#varparam">parameter</a>.
11497 The specific value of a WHERE-clause <a href="lang_expr.html#varparam">parameter</a> might influence the
11498 choice of query plan if the parameter is the left-hand side of a <a href="lang_expr.html#like">LIKE</a>
11499 or <a href="lang_expr.html#glob">GLOB</a> operator or if the parameter is compared to an indexed column
11500 and the <a href="compile.html#enable_stat4">SQLITE_ENABLE_STAT4</a> compile-time option is enabled.
11501 </li>
11502 </ol></p>
11503
11504 <p><p>sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
11505 the extra prepFlags parameter, which is a bit array consisting of zero or
11506 more of the <a href="#sqlitepreparepersistent">SQLITE_PREPARE_*</a> flags. The
11507 sqlite3_prepare_v2() interface works exactly the same as
11508 sqlite3_prepare_v3() with a zero prepFlags parameter.
11509 </p><hr><a name="sqlite3_set_authorizer"></a>
11510 <h2>Compile-Time Authorization Callbacks</h2>
11511 </div>
11512 <blockquote><pre>
11513 int sqlite3_set_authorizer(
11514 sqlite3*,
11515 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
11516 void *pUserData
11517 );
11518 </pre></blockquote>
11519 <p>
11520 This routine registers an authorizer callback with a particular
11521 <a href="#sqlite3">database connection</a>, supplied in the first argument.
11522 The authorizer callback is invoked as SQL statements are being compiled
11523 by <a href="#sqlite3_prepare">sqlite3_prepare()</a> or its variants <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a>,
11524 <a href="#sqlite3_prepare">sqlite3_prepare_v3()</a>, <a href="#sqlite3_prepare">sqlite3_prepare16()</a>, <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a>,
11525 and <a href="#sqlite3_prepare">sqlite3_prepare16_v3()</a>. At various
11526 points during the compilation process, as logic is being created
11527 to perform various actions, the authorizer callback is invoked to
11528 see if those actions are allowed. The authorizer callback should
11529 return <a href="#SQLITE_ABORT">SQLITE_OK</a> to allow the action, <a href="#SQLITE_DENY">SQLITE_IGNORE</a> to disallow the
11530 specific action but allow the SQL statement to continue to be
11531 compiled, or <a href="#SQLITE_DENY">SQLITE_DENY</a> to cause the entire SQL statement to be
11532 rejected with an error. If the authorizer callback returns
11533 any value other than <a href="#SQLITE_DENY">SQLITE_IGNORE</a>, <a href="#SQLITE_ABORT">SQLITE_OK</a>, or <a href="#SQLITE_DENY">SQLITE_DENY</a>
11534 then the <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> or equivalent call that triggered
11535 the authorizer will fail with an error message.</p>
11536
11537 <p>When the callback returns <a href="#SQLITE_ABORT">SQLITE_OK</a>, that means the operation
11538 requested is ok. When the callback returns <a href="#SQLITE_DENY">SQLITE_DENY</a>, the
11539 <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> or equivalent call that triggered the
11540 authorizer will fail with an error message explaining that
11541 access is denied.</p>
11542
11543 <p>The first parameter to the authorizer callback is a copy of the third
11544 parameter to the sqlite3_set_authorizer() interface. The second parameter
11545 to the callback is an integer <a href="#SQLITE_ALTER_TABLE">action code</a> that specifies
11546 the particular action to be authorized. The third through sixth parameters
11547 to the callback are either NULL pointers or zero-terminated strings
11548 that contain additional details about the action to be authorized.
11549 Applications must always be prepared to encounter a NULL pointer in any
11550 of the third through the sixth parameters of the authorization callback.</p>
11551
11552 <p>If the action code is <a href="#SQLITE_ALTER_TABLE">SQLITE_READ</a>
11553 and the callback returns <a href="#SQLITE_DENY">SQLITE_IGNORE</a> then the
11554 <a href="#sqlite3_stmt">prepared statement</a> statement is constructed to substitute
11555 a NULL value in place of the table column that would have
11556 been read if <a href="#SQLITE_ABORT">SQLITE_OK</a> had been returned. The <a href="#SQLITE_DENY">SQLITE_IGNORE</a>
11557 return can be used to deny an untrusted user access to individual
11558 columns of a table.
11559 When a table is referenced by a <a href="lang_select.html">SELECT</a> but no column values are
11560 extracted from that table (for example in a query like
11561 "SELECT count(*) FROM tab") then the <a href="#SQLITE_ALTER_TABLE">SQLITE_READ</a> authorizer callback
11562 is invoked once for that table with a column name that is an empty string.
11563 If the action code is <a href="#SQLITE_ALTER_TABLE">SQLITE_DELETE</a> and the callback returns
11564 <a href="#SQLITE_DENY">SQLITE_IGNORE</a> then the <a href="lang_delete.html">DELETE</a> operation proceeds but the
11565 <a href="lang_delete.html#truncateopt">truncate optimization</a> is disabled and all rows are deleted individually.</p>
11566
11567 <p>An authorizer is used when <a href="#sqlite3_prepare">preparing</a>
11568 SQL statements from an untrusted source, to ensure that the SQL statements
11569 do not try to access data they are not allowed to see, or that they do not
11570 try to execute malicious statements that damage the database. For
11571 example, an application may allow a user to enter arbitrary
11572 SQL queries for evaluation by a database. But the application does
11573 not want the user to be able to make arbitrary changes to the
11574 database. An authorizer could then be put in place while the
11575 user-entered SQL is being <a href="#sqlite3_prepare">prepared</a> that
11576 disallows everything except <a href="lang_select.html">SELECT</a> statements.</p>
11577
11578 <p>Applications that need to process SQL from untrusted sources
11579 might also consider lowering resource limits using <a href="#sqlite3_limit">sqlite3_limit()</a>
11580 and limiting database size using the <a href="pragma.html#pragma_max_page_count">max_page_count</a> <a href="pragma.html#syntax">PRAGMA</a>
11581 in addition to using an authorizer.</p>
11582
11583 <p>Only a single authorizer can be in place on a database connection
11584 at a time. Each call to sqlite3_set_authorizer overrides the
11585 previous call. Disable the authorizer by installing a NULL callback.
11586 The authorizer is disabled by default.</p>
11587
11588 <p>The authorizer callback must not do anything that will modify
11589 the database connection that invoked the authorizer callback.
11590 Note that <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> and <a href="#sqlite3_step">sqlite3_step()</a> both modify their
11591 database connections for the meaning of "modify" in this paragraph.</p>
11592
11593 <p>When <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> is used to prepare a statement, the
11594 statement might be re-prepared during <a href="#sqlite3_step">sqlite3_step()</a> due to a
11595 schema change. Hence, the application should ensure that the
11596 correct authorizer callback remains in place during the <a href="#sqlite3_step">sqlite3_step()</a>.</p>
11597
11598 <p>Note that the authorizer callback is invoked only during
11599 <a href="#sqlite3_prepare">sqlite3_prepare()</a> or its variants. Authorization is not
11600 performed during statement evaluation in <a href="#sqlite3_step">sqlite3_step()</a>, unless
11601 as stated in the previous paragraph, sqlite3_step() invokes
11602 sqlite3_prepare_v2() to reprepare a statement after a schema change.
11603 </p><hr><a name="sqlite3_get_autocommit"></a>
11604 <h2>Test For Auto-Commit Mode</h2>
11605 </div>
11606 <blockquote><pre>
11607 int sqlite3_get_autocommit(sqlite3*);
11608 </pre></blockquote>
11609 <p>
11610 The sqlite3_get_autocommit() interface returns non-zero or
11611 zero if the given database connection is or is not in autocommit mode,
11612 respectively. Autocommit mode is on by default.
11613 Autocommit mode is disabled by a <a href="lang_transaction.html">BEGIN</a> statement.
11614 Autocommit mode is re-enabled by a <a href="lang_transaction.html">COMMIT</a> or <a href="lang_transaction.html">ROLLBACK</a>.</p>
11615
11616 <p>If certain kinds of errors occur on a statement within a multi-statement
11617 transaction (errors including <a href="#SQLITE_ABORT">SQLITE_FULL</a>, <a href="#SQLITE_ABORT">SQLITE_IOERR</a>,
11618 <a href="#SQLITE_ABORT">SQLITE_NOMEM</a>, <a href="#SQLITE_ABORT">SQLITE_BUSY</a>, and <a href="#SQLITE_ABORT">SQLITE_INTERRUPT</a>) then the
11619 transaction might be rolled back automatically. The only way to
11620 find out whether SQLite automatically rolled back the transaction after
11621 an error is to use this function.</p>
11622
11623 <p>If another thread changes the autocommit status of the database
11624 connection while this routine is running, then the return value
11625 is undefined.
11626 </p><hr><a name="sqlite3_busy_handler"></a>
11627 <h2>Register A Callback To Handle SQLITE_BUSY Errors</h2>
11628 </div>
11629 <blockquote><pre>
11630 int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
11631 </pre></blockquote>
11632 <p>
11633 The sqlite3_busy_handler(D,X,P) routine sets a callback function X
11634 that might be invoked with argument P whenever
11635 an attempt is made to access a database table associated with
11636 <a href="#sqlite3">database connection</a> D when another thread
11637 or process has the table locked.
11638 The sqlite3_busy_handler() interface is used to implement
11639 <a href="#sqlite3_busy_timeout">sqlite3_busy_timeout()</a> and <a href="pragma.html#pragma_busy_timeout">PRAGMA busy_timeout</a>.</p>
11640
11641 <p>If the busy callback is NULL, then <a href="#SQLITE_ABORT">SQLITE_BUSY</a>
11642 is returned immediately upon encountering the lock. If the busy callback
11643 is not NULL, then the callback might be invoked with two arguments.</p>
11644
11645 <p>The first argument to the busy handler is a copy of the void* pointer which
11646 is the third argument to sqlite3_busy_handler(). The second argument to
11647 the busy handler callback is the number of times that the busy handler has
11648 been invoked previously for the same locking event. If the
11649 busy callback returns 0, then no additional attempts are made to
11650 access the database and <a href="#SQLITE_ABORT">SQLITE_BUSY</a> is returned
11651 to the application.
11652 If the callback returns non-zero, then another attempt
11653 is made to access the database and the cycle repeats.</p>
11654
11655 <p>The presence of a busy handler does not guarantee that it will be invoked
11656 when there is lock contention. If SQLite determines that invoking the busy
11657 handler could result in a deadlock, it will go ahead and return <a href="#SQLITE_ABORT">SQLITE_BUSY</a>
11658 to the application instead of invoking the
11659 busy handler.
11660 Consider a scenario where one process is holding a read lock that
11661 it is trying to promote to a reserved lock and
11662 a second process is holding a reserved lock that it is trying
11663 to promote to an exclusive lock. The first process cannot proceed
11664 because it is blocked by the second and the second process cannot
11665 proceed because it is blocked by the first. If both processes
11666 invoke the busy handlers, neither will make any progress. Therefore,
11667 SQLite returns <a href="#SQLITE_ABORT">SQLITE_BUSY</a> for the first process, hoping that this
11668 will induce the first process to release its read lock and allow
11669 the second process to proceed.</p>
11670
11671 <p>The default busy callback is NULL.</p>
11672
11673 <p>There can only be a single busy handler defined for each
11674 <a href="#sqlite3">database connection</a>. Setting a new busy handler clears any
11675 previously set handler. Note that calling <a href="#sqlite3_busy_timeout">sqlite3_busy_timeout()</a>
11676 or evaluating <a href="pragma.html#pragma_busy_timeout">PRAGMA busy_timeout=N</a> will change the
11677 busy handler and thus clear any previously set busy handler.</p>
11678
11679 <p>The busy callback should not take any actions which modify the
11680 database connection that invoked the busy handler. In other words,
11681 the busy handler is not reentrant. Any such actions
11682 result in undefined behavior.</p>
11683
11684 <p>A busy handler must not close the database connection
11685 or <a href="#sqlite3_stmt">prepared statement</a> that invoked the busy handler.
11686 </p><hr><a name="sqlite3_column_blob"></a>
11687 <h2>Result Values From A Query</h2>
11688 </div>
11689 <blockquote><pre>
11690 const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
11691 double sqlite3_column_double(sqlite3_stmt*, int iCol);
11692 int sqlite3_column_int(sqlite3_stmt*, int iCol);
11693 sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
11694 const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
11695 const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
11696 sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
11697 int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
11698 int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
11699 int sqlite3_column_type(sqlite3_stmt*, int iCol);
11700 </pre></blockquote>
11701 <p>
11702 <b>Summary:</b>
11703 <blockquote><table border=0 cellpadding=0 cellspacing=0>
11704 <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result
11705 <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result
11706 <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result
11707 <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result
11708 <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result
11709 <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result
11710 <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an
11711 <a href="#sqlite3_value">unprotected sqlite3_value</a> object.
11712 <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
11713 <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB
11714 or a UTF-8 TEXT result in bytes
11715 <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>
11716 <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
11717 TEXT in bytes
11718 <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default
11719 datatype of the result
11720 </table></blockquote></p>
11721
11722 <p><b>Details:</b></p>
11723
11724 <p>These routines return information about a single column of the current
11725 result row of a query. In every case the first argument is a pointer
11726 to the <a href="#sqlite3_stmt">prepared statement</a> that is being evaluated (the <a href="#sqlite3_stmt">sqlite3_stmt*</a>
11727 that was returned from <a href="#sqlite3_prepare">sqlite3_prepare_v2()</a> or one of its variants)
11728 and the second argument is the index of the column for which information
11729 should be returned. The leftmost column of the result set has the index 0.
11730 The number of columns in the result can be determined using
11731 <a href="#sqlite3_column_count">sqlite3_column_count()</a>.</p>
11732
11733 <p>If the SQL statement does not currently point to a valid row, or if the
11734 column index is out of range, the result is undefined.
11735 These routines may only be called when the most recent call to
11736 <a href="#sqlite3_step">sqlite3_step()</a> has returned <a href="#SQLITE_ABORT">SQLITE_ROW</a> and neither
11737 <a href="#sqlite3_reset">sqlite3_reset()</a> nor <a href="#sqlite3_finalize">sqlite3_finalize()</a> have been called subsequently.
11738 If any of these routines are called after <a href="#sqlite3_reset">sqlite3_reset()</a> or
11739 <a href="#sqlite3_finalize">sqlite3_finalize()</a> or after <a href="#sqlite3_step">sqlite3_step()</a> has returned
11740 something other than <a href="#SQLITE_ABORT">SQLITE_ROW</a>, the results are undefined.
11741 If <a href="#sqlite3_step">sqlite3_step()</a> or <a href="#sqlite3_reset">sqlite3_reset()</a> or <a href="#sqlite3_finalize">sqlite3_finalize()</a>
11742 are called from a different thread while any of these routines
11743 are pending, then the results are undefined.</p>
11744
11745 <p>The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)
11746 each return the value of a result column in a specific data format. If
11747 the result column is not initially in the requested format (for example,
11748 if the query returns an integer but the sqlite3_column_text() interface
11749 is used to extract the value) then an automatic type conversion is performed.</p>
11750
11751 <p>The sqlite3_column_type() routine returns the
11752 <a href="#SQLITE_BLOB">datatype code</a> for the initial data type
11753 of the result column. The returned value is one of <a href="#SQLITE_BLOB">SQLITE_INTEGER</a>,
11754 <a href="#SQLITE_BLOB">SQLITE_FLOAT</a>, <a href="#SQLITE_BLOB">SQLITE_TEXT</a>, <a href="#SQLITE_BLOB">SQLITE_BLOB</a>, or <a href="#SQLITE_BLOB">SQLITE_NULL</a>.
11755 The return value of sqlite3_column_type() can be used to decide which
11756 of the first six interface should be used to extract the column value.
11757 The value returned by sqlite3_column_type() is only meaningful if no
11758 automatic type conversions have occurred for the value in question.
11759 After a type conversion, the result of calling sqlite3_column_type()
11760 is undefined, though harmless. Future
11761 versions of SQLite may change the behavior of sqlite3_column_type()
11762 following a type conversion.</p>
11763
11764 <p>If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()
11765 or sqlite3_column_bytes16() interfaces can be used to determine the size
11766 of that BLOB or string.</p>
11767
11768 <p>If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
11769 routine returns the number of bytes in that BLOB or string.
11770 If the result is a UTF-16 string, then sqlite3_column_bytes() converts
11771 the string to UTF-8 and then returns the number of bytes.
11772 If the result is a numeric value then sqlite3_column_bytes() uses
11773 <a href="#sqlite3_mprintf">sqlite3_snprintf()</a> to convert that value to a UTF-8 string and returns
11774 the number of bytes in that string.
11775 If the result is NULL, then sqlite3_column_bytes() returns zero.</p>
11776
11777 <p>If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()
11778 routine returns the number of bytes in that BLOB or string.
11779 If the result is a UTF-8 string, then sqlite3_column_bytes16() converts
11780 the string to UTF-16 and then returns the number of bytes.
11781 If the result is a numeric value then sqlite3_column_bytes16() uses
11782 <a href="#sqlite3_mprintf">sqlite3_snprintf()</a> to convert that value to a UTF-16 string and returns
11783 the number of bytes in that string.
11784 If the result is NULL, then sqlite3_column_bytes16() returns zero.</p>
11785
11786 <p>The values returned by <a href="#sqlite3_column_blob">sqlite3_column_bytes()</a> and
11787 <a href="#sqlite3_column_blob">sqlite3_column_bytes16()</a> do not include the zero terminators at the end
11788 of the string. For clarity: the values returned by
11789 <a href="#sqlite3_column_blob">sqlite3_column_bytes()</a> and <a href="#sqlite3_column_blob">sqlite3_column_bytes16()</a> are the number of
11790 bytes in the string, not the number of characters.</p>
11791
11792 <p>Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
11793 even empty strings, are always zero-terminated. The return
11794 value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.</p>
11795
11796 <p>Strings returned by sqlite3_column_text16() always have the endianness
11797 which is native to the platform, regardless of the text encoding set
11798 for the database.</p>
11799
11800 <p><b>Warning:</b> The object returned by <a href="#sqlite3_column_blob">sqlite3_column_value()</a> is an
11801 <a href="#sqlite3_value">unprotected sqlite3_value</a> object. In a multithreaded environment,
11802 an unprotected sqlite3_value object may only be used safely with
11803 <a href="#sqlite3_bind_blob">sqlite3_bind_value()</a> and <a href="#sqlite3_result_blob">sqlite3_result_value()</a>.
11804 If the <a href="#sqlite3_value">unprotected sqlite3_value</a> object returned by
11805 <a href="#sqlite3_column_blob">sqlite3_column_value()</a> is used in any other way, including calls
11806 to routines like <a href="#sqlite3_value_blob">sqlite3_value_int()</a>, <a href="#sqlite3_value_blob">sqlite3_value_text()</a>,
11807 or <a href="#sqlite3_value_blob">sqlite3_value_bytes()</a>, the behavior is not threadsafe.
11808 Hence, the sqlite3_column_value() interface
11809 is normally only useful within the implementation of
11810 <a href="appfunc.html">application-defined SQL functions</a> or <a href="vtab.html">virtual tables</a>, not within
11811 top-level application code.</p>
11812
11813 <p>These routines may attempt to convert the datatype of the result.
11814 For example, if the internal representation is FLOAT and a text result
11815 is requested, <a href="#sqlite3_mprintf">sqlite3_snprintf()</a> is used internally to perform the
11816 conversion automatically. The following table details the conversions
11817 that are applied:</p>
11818
11819 <p><blockquote>
11820 <table border="1">
11821 <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion</p>
11822
11823 <p><tr><td> NULL <td> INTEGER <td> Result is 0
11824 <tr><td> NULL <td> FLOAT <td> Result is 0.0
11825 <tr><td> NULL <td> TEXT <td> Result is a NULL pointer
11826 <tr><td> NULL <td> BLOB <td> Result is a NULL pointer
11827 <tr><td> INTEGER <td> FLOAT <td> Convert from integer to float
11828 <tr><td> INTEGER <td> TEXT <td> ASCII rendering of the integer
11829 <tr><td> INTEGER <td> BLOB <td> Same as INTEGER->TEXT
11830 <tr><td> FLOAT <td> INTEGER <td> <a href="lang_expr.html#castexpr">CAST</a> to INTEGER
11831 <tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float
11832 <tr><td> FLOAT <td> BLOB <td> <a href="lang_expr.html#castexpr">CAST</a> to BLOB
11833 <tr><td> TEXT <td> INTEGER <td> <a href="lang_expr.html#castexpr">CAST</a> to INTEGER
11834 <tr><td> TEXT <td> FLOAT <td> <a href="lang_expr.html#castexpr">CAST</a> to REAL
11835 <tr><td> TEXT <td> BLOB <td> No change
11836 <tr><td> BLOB <td> INTEGER <td> <a href="lang_expr.html#castexpr">CAST</a> to INTEGER
11837 <tr><td> BLOB <td> FLOAT <td> <a href="lang_expr.html#castexpr">CAST</a> to REAL
11838 <tr><td> BLOB <td> TEXT <td> <a href="lang_expr.html#castexpr">CAST</a> to TEXT, ensure zero terminator
11839 </table>
11840 </blockquote></p>
11841
11842 <p>Note that when type conversions occur, pointers returned by prior
11843 calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
11844 sqlite3_column_text16() may be invalidated.
11845 Type conversions and pointer invalidations might occur
11846 in the following cases:</p>
11847
11848 <p><ul>
11849 <li> The initial content is a BLOB and sqlite3_column_text() or
11850 sqlite3_column_text16() is called. A zero-terminator might
11851 need to be added to the string.</li>
11852 <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or
11853 sqlite3_column_text16() is called. The content must be converted
11854 to UTF-16.</li>
11855 <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
11856 sqlite3_column_text() is called. The content must be converted
11857 to UTF-8.</li>
11858 </ul></p>
11859
11860 <p>Conversions between UTF-16be and UTF-16le are always done in place and do
11861 not invalidate a prior pointer, though of course the content of the buffer
11862 that the prior pointer references will have been modified. Other kinds
11863 of conversion are done in place when it is possible, but sometimes they
11864 are not possible and in those cases prior pointers are invalidated.</p>
11865
11866 <p>The safest policy is to invoke these routines
11867 in one of the following ways:</p>
11868
11869 <p><ul>
11870 <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
11871 <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
11872 <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
11873 </ul></p>
11874
11875 <p>In other words, you should call sqlite3_column_text(),
11876 sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
11877 into the desired format, then invoke sqlite3_column_bytes() or
11878 sqlite3_column_bytes16() to find the size of the result. Do not mix calls
11879 to sqlite3_column_text() or sqlite3_column_blob() with calls to
11880 sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
11881 with calls to sqlite3_column_bytes().</p>
11882
11883 <p>The pointers returned are valid until a type conversion occurs as
11884 described above, or until <a href="#sqlite3_step">sqlite3_step()</a> or <a href="#sqlite3_reset">sqlite3_reset()</a> or
11885 <a href="#sqlite3_finalize">sqlite3_finalize()</a> is called. The memory space used to hold strings
11886 and BLOBs is freed automatically. Do not pass the pointers returned
11887 from <a href="#sqlite3_column_blob">sqlite3_column_blob()</a>, <a href="#sqlite3_column_blob">sqlite3_column_text()</a>, etc. into
11888 <a href="#sqlite3_free">sqlite3_free()</a>.</p>
11889
11890 <p>As long as the input parameters are correct, these routines will only
11891 fail if an out-of-memory error occurs during a format conversion.
11892 Only the following subset of interfaces are subject to out-of-memory
11893 errors:</p>
11894
11895 <p><ul>
11896 <li> sqlite3_column_blob()
11897 <li> sqlite3_column_text()
11898 <li> sqlite3_column_text16()
11899 <li> sqlite3_column_bytes()
11900 <li> sqlite3_column_bytes16()
11901 </ul></p>
11902
11903 <p>If an out-of-memory error occurs, then the return value from these
11904 routines is the same as if the column had contained an SQL NULL value.
11905 Valid SQL NULL returns can be distinguished from out-of-memory errors
11906 by invoking the <a href="#sqlite3_errcode">sqlite3_errcode()</a> immediately after the suspect
11907 return value is obtained and before any
11908 other SQLite interface is called on the same <a href="#sqlite3">database connection</a>.
11909 </p><hr><a name="sqlite3_file_control"></a>
11910 <h2>Low-Level Control Of Database Files</h2>
11911 </div>
11912 <blockquote><pre>
11913 int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
11914 </pre></blockquote>
11915 <p>
11916 The <a href="#sqlite3_file_control">sqlite3_file_control()</a> interface makes a direct call to the
11917 xFileControl method for the <a href="#sqlite3_io_methods">sqlite3_io_methods</a> object associated
11918 with a particular database identified by the second argument. The
11919 name of the database is "main" for the main database or "temp" for the
11920 TEMP database, or the name that appears after the AS keyword for
11921 databases that are added using the <a href="lang_attach.html">ATTACH</a> SQL command.
11922 A NULL pointer can be used in place of "main" to refer to the
11923 main database file.
11924 The third and fourth parameters to this routine
11925 are passed directly through to the second and third parameters of
11926 the xFileControl method. The return value of the xFileControl
11927 method becomes the return value of this routine.</p>
11928
11929 <p>A few opcodes for <a href="#sqlite3_file_control">sqlite3_file_control()</a> are handled directly
11930 by the SQLite core and never invoke the
11931 sqlite3_io_methods.xFileControl method.
11932 The <a href="#sqlitefcntlfilepointer">SQLITE_FCNTL_FILE_POINTER</a> value for the op parameter causes
11933 a pointer to the underlying <a href="#sqlite3_file">sqlite3_file</a> object to be written into
11934 the space pointed to by the 4th parameter. The
11935 <a href="#sqlitefcntljournalpointer">SQLITE_FCNTL_JOURNAL_POINTER</a> works similarly except that it returns
11936 the <a href="#sqlite3_file">sqlite3_file</a> object associated with the journal file instead of
11937 the main database. The <a href="#sqlitefcntlvfspointer">SQLITE_FCNTL_VFS_POINTER</a> opcode returns
11938 a pointer to the underlying <a href="#sqlite3_vfs">sqlite3_vfs</a> object for the file.
11939 The <a href="#sqlitefcntldataversion">SQLITE_FCNTL_DATA_VERSION</a> returns the data version counter
11940 from the pager.</p>
11941
11942 <p>If the second parameter (zDbName) does not match the name of any
11943 open database file, then SQLITE_ERROR is returned. This error
11944 code is not remembered and will not be recalled by <a href="#sqlite3_errcode">sqlite3_errcode()</a>
11945 or <a href="#sqlite3_errcode">sqlite3_errmsg()</a>. The underlying xFileControl method might
11946 also return SQLITE_ERROR. There is no way to distinguish between
11947 an incorrect zDbName and an SQLITE_ERROR return from the underlying
11948 xFileControl method.</p>
11949
11950 <p>See also: <a href="#SQLITE_FCNTL_BEGIN_ATOMIC_WRITE">file control opcodes</a>
11951 </p><hr><a name="sqlite3_create_function"></a>
11952 <h2>Create Or Redefine SQL Functions</h2>
11953 </div>
11954 <blockquote><pre>
11955 int sqlite3_create_function(
11956 sqlite3 *db,
11957 const char *zFunctionName,
11958 int nArg,
11959 int eTextRep,
11960 void *pApp,
11961 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
11962 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
11963 void (*xFinal)(sqlite3_context*)
11964 );
11965 int sqlite3_create_function16(
11966 sqlite3 *db,
11967 const void *zFunctionName,
11968 int nArg,
11969 int eTextRep,
11970 void *pApp,
11971 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
11972 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
11973 void (*xFinal)(sqlite3_context*)
11974 );
11975 int sqlite3_create_function_v2(
11976 sqlite3 *db,
11977 const char *zFunctionName,
11978 int nArg,
11979 int eTextRep,
11980 void *pApp,
11981 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
11982 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
11983 void (*xFinal)(sqlite3_context*),
11984 void(*xDestroy)(void*)
11985 );
11986 int sqlite3_create_window_function(
11987 sqlite3 *db,
11988 const char *zFunctionName,
11989 int nArg,
11990 int eTextRep,
11991 void *pApp,
11992 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
11993 void (*xFinal)(sqlite3_context*),
11994 void (*xValue)(sqlite3_context*),
11995 void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
11996 void(*xDestroy)(void*)
11997 );
11998 </pre></blockquote>
11999 <p>
12000 These functions (collectively known as "function creation routines")
12001 are used to add SQL functions or aggregates or to redefine the behavior
12002 of existing SQL functions or aggregates. The only differences between
12003 the three "sqlite3_create_function*" routines are the text encoding
12004 expected for the second parameter (the name of the function being
12005 created) and the presence or absence of a destructor callback for
12006 the application data pointer. Function sqlite3_create_window_function()
12007 is similar, but allows the user to supply the extra callback functions
12008 needed by <a href="windowfunctions.html#aggwinfunc">aggregate window functions</a>.</p>
12009
12010 <p>The first parameter is the <a href="#sqlite3">database connection</a> to which the SQL
12011 function is to be added. If an application uses more than one database
12012 connection then application-defined SQL functions must be added
12013 to each database connection separately.</p>
12014
12015 <p>The second parameter is the name of the SQL function to be created or
12016 redefined. The length of the name is limited to 255 bytes in a UTF-8
12017 representation, exclusive of the zero-terminator. Note that the name
12018 length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.
12019 Any attempt to create a function with a longer name
12020 will result in <a href="#SQLITE_ABORT">SQLITE_MISUSE</a> being returned.</p>
12021
12022 <p>The third parameter (nArg)
12023 is the number of arguments that the SQL function or
12024 aggregate takes. If this parameter is -1, then the SQL function or
12025 aggregate may take any number of arguments between 0 and the limit
12026 set by <a href="#sqlite3_limit">sqlite3_limit</a>(<a href="#sqlitelimitfunctionarg">SQLITE_LIMIT_FUNCTION_ARG</a>). If the third
12027 parameter is less than -1 or greater than 127 then the behavior is
12028 undefined.</p>
12029
12030 <p>The fourth parameter, eTextRep, specifies what
12031 <a href="#SQLITE_ANY">text encoding</a> this SQL function prefers for
12032 its parameters. The application should set this parameter to
12033 <a href="#SQLITE_ANY">SQLITE_UTF16LE</a> if the function implementation invokes
12034 <a href="#sqlite3_value_blob">sqlite3_value_text16le()</a> on an input, or <a href="#SQLITE_ANY">SQLITE_UTF16BE</a> if the
12035 implementation invokes <a href="#sqlite3_value_blob">sqlite3_value_text16be()</a> on an input, or
12036 <a href="#SQLITE_ANY">SQLITE_UTF16</a> if <a href="#sqlite3_value_blob">sqlite3_value_text16()</a> is used, or <a href="#SQLITE_ANY">SQLITE_UTF8</a>
12037 otherwise. The same SQL function may be registered multiple times using
12038 different preferred text encodings, with different implementations for
12039 each encoding.
12040 When multiple implementations of the same function are available, SQLite
12041 will pick the one that involves the least amount of data conversion.</p>
12042
12043 <p>The fourth parameter may optionally be ORed with <a href="#sqlitedeterministic">SQLITE_DETERMINISTIC</a>
12044 to signal that the function will always return the same result given
12045 the same inputs within a single SQL statement. Most SQL functions are
12046 deterministic. The built-in <a href="lang_corefunc.html#random">random()</a> SQL function is an example of a
12047 function that is not deterministic. The SQLite query planner is able to
12048 perform additional optimizations on deterministic functions, so use
12049 of the <a href="#sqlitedeterministic">SQLITE_DETERMINISTIC</a> flag is recommended where possible.</p>
12050
12051 <p>The fourth parameter may also optionally include the <a href="#sqlitedirectonly">SQLITE_DIRECTONLY</a>
12052 flag, which if present prevents the function from being invoked from
12053 within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
12054 index expressions, or the WHERE clause of partial indexes.</p>
12055
12056 <p>For best security, the <a href="#sqlitedirectonly">SQLITE_DIRECTONLY</a> flag is recommended for
12057 all application-defined SQL functions that do not need to be
12058 used inside of triggers, view, CHECK constraints, or other elements of
12059 the database schema. This flags is especially recommended for SQL
12060 functions that have side effects or reveal internal application state.
12061 Without this flag, an attacker might be able to modify the schema of
12062 a database file to include invocations of the function with parameters
12063 chosen by the attacker, which the application will then execute when
12064 the database file is opened and read.</p>
12065
12066 <p>The fifth parameter is an arbitrary pointer. The implementation of the
12067 function can gain access to this pointer using <a href="#sqlite3_user_data">sqlite3_user_data()</a>.</p>
12068
12069 <p>The sixth, seventh and eighth parameters passed to the three
12070 "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
12071 pointers to C-language functions that implement the SQL function or
12072 aggregate. A scalar SQL function requires an implementation of the xFunc
12073 callback only; NULL pointers must be passed as the xStep and xFinal
12074 parameters. An aggregate SQL function requires an implementation of xStep
12075 and xFinal and NULL pointer must be passed for xFunc. To delete an existing
12076 SQL function or aggregate, pass NULL pointers for all three function
12077 callbacks.</p>
12078
12079 <p>The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
12080 and xInverse) passed to sqlite3_create_window_function are pointers to
12081 C-language callbacks that implement the new function. xStep and xFinal
12082 must both be non-NULL. xValue and xInverse may either both be NULL, in
12083 which case a regular aggregate function is created, or must both be
12084 non-NULL, in which case the new function may be used as either an aggregate
12085 or aggregate window function. More details regarding the implementation
12086 of aggregate window functions are
12087 <a href="windowfunctions.html#udfwinfunc">available here</a>.</p>
12088
12089 <p>If the final parameter to sqlite3_create_function_v2() or
12090 sqlite3_create_window_function() is not NULL, then it is destructor for
12091 the application data pointer. The destructor is invoked when the function
12092 is deleted, either by being overloaded or when the database connection
12093 closes. The destructor is also invoked if the call to
12094 sqlite3_create_function_v2() fails. When the destructor callback is
12095 invoked, it is passed a single argument which is a copy of the application
12096 data pointer which was the fifth parameter to sqlite3_create_function_v2().</p>
12097
12098 <p>It is permitted to register multiple implementations of the same
12099 functions with the same name but with either differing numbers of
12100 arguments or differing preferred text encodings. SQLite will use
12101 the implementation that most closely matches the way in which the
12102 SQL function is used. A function implementation with a non-negative
12103 nArg parameter is a better match than a function implementation with
12104 a negative nArg. A function where the preferred text encoding
12105 matches the database encoding is a better
12106 match than a function where the encoding is different.
12107 A function where the encoding difference is between UTF16le and UTF16be
12108 is a closer match than a function where the encoding difference is
12109 between UTF8 and UTF16.</p>
12110
12111 <p>Built-in functions may be overloaded by new application-defined functions.</p>
12112
12113 <p>An application-defined function is permitted to call other
12114 SQLite interfaces. However, such calls must not
12115 close the database connection nor finalize or reset the prepared
12116 statement in which the function is running.
12117 </p><hr>
12118
12119