Patch level : 12.0 no-patch

Files correlati     :
Commento            :

Aggiunta documentazione di sqlite 3
This commit is contained in:
Alessandro Bonazzi 2020-11-29 00:32:36 +01:00
parent e075990ed3
commit 5c7aa8c1c0
986 changed files with 232462 additions and 0 deletions

View File

@ -0,0 +1,920 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Changes From Version 3.4.2 To 3.5.0</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<?xml version="1.0" encoding="Windows-1252"?>
<h1> Moving From SQLite 3.4.2 to 3.5.0</h1><p>
SQLite version 3.5.0 (2007-09-04) introduces a new OS interface layer that
is incompatible with all prior versions of SQLite. In addition,
a few existing interfaces have been generalized to work across all
database connections within a process rather than just all
connections within a thread. The purpose of this article
is to describe the changes to 3.5.0 in detail so that users
of prior versions of SQLite can judge what, if any, effort will
be required to upgrade to newer versions.
</p>
<h2>1.0 Overview Of Changes</h2><p>
A quick enumeration of the changes in SQLite version 3.5.0
is provided here. Subsequent sections will describe these
changes in more detail.
</p>
<p>
<ol>
<li>The OS interface layer has been completely reworked:
<ol type="a">
<li>The undocumented <b>sqlite3_os_switch()</b> interface has
been removed.</li>
<li>The <b>SQLITE_ENABLE_REDEF_IO</b> compile-time flag no longer functions.
I/O procedures are now always redefinable.</li>
<li>Three new objects are defined for specifying I/O procedures:
<a href="c3ref/vfs.html">sqlite3_vfs</a>, <a href="c3ref/file.html">sqlite3_file</a>, and <a href="c3ref/io_methods.html">sqlite3_io_methods</a>.</li>
<li>Three new interfaces are used to create alternative OS interfaces:
<a href="c3ref/vfs_find.html">sqlite3_vfs_register()</a>, <a href="c3ref/vfs_find.html">sqlite3_vfs_unregister()</a>, and
<a href="c3ref/vfs_find.html">sqlite3_vfs_find()</a>.</li>
<li>A new interface has been added to provided additional control over
the creation of new database connections: <a href="c3ref/open.html">sqlite3_open_v2()</a>.
The legacy interfaces of <a href="c3ref/open.html">sqlite3_open()</a> and
<a href="c3ref/open.html">sqlite3_open16()</a> continue to be fully supported.</li>
</ol></li>
<li>The optional shared cache and memory management features that
were introduced in version 3.3.0 can now be used across multiple
threads within the same process. Formerly, these extensions only
applied to database connections operating within a single thread.
<ol type="a">
<li>The <a href="c3ref/enable_shared_cache.html">sqlite3_enable_shared_cache()</a> interface now applies to all
threads within a process, not to just the one thread in which it
was run.</li>
<li>The <a href="c3ref/soft_heap_limit.html">sqlite3_soft_heap_limit()</a> interface now applies to all threads
within a process, not to just the one thread in which it was run.</li>
<li>The <a href="c3ref/release_memory.html">sqlite3_release_memory()</a> interface will now attempt to reduce
the memory usages across all database connections in all threads, not
just connections in the thread where the interface is called.</li>
<li>The <a href="c3ref/aggregate_count.html">sqlite3_thread_cleanup()</a> interface has become a no-op.</li>
</ol></li>
<li>Restrictions on the use of the same database connection by multiple
threads have been dropped. It is now safe for
multiple threads to use the same database connection at the same
time.</li>
<li>There is now a compile-time option that allows an application to
define alternative malloc()/free() implementations without having
to modify any core SQLite code.</li>
<li>There is now a compile-time option that allows an application to
define alternative mutex implementations without having
to modify any core SQLite code.</li>
</ol>
</p>
<p>
Of these changes, only 1a and 2a through 2c are incompatibilities
in any formal sense.
But users who have previously made custom modifications to the
SQLite source (for example to add a custom OS layer for embedded
hardware) might find that these changes have a larger impact.
On the other hand, an important goal of these changes is to make
it much easier to customize SQLite for use on different operating
systems.
</p>
<h2>2.0 The OS Interface Layer</h2><p>
If your system defines a custom OS interface for SQLite or if you
were using the undocumented <b>sqlite3_os_switch()</b>
interface, then you will need to make modifications in order to
upgrade to SQLite version 3.5.0. This may seem painful at first
glance. But as you look more closely, you will probably discover
that your changes are made smaller and easier to understand and manage
by the new SQLite interface. It is likely that your changes will
now also work seamlessly with the SQLite amalgamation. You will
no longer need to make any changes to the code SQLite source code.
All of your changes can be effected by application code and you can
link against a standard, unmodified version of the SQLite amalgamation.
Furthermore, the OS interface layer, which was formerly undocumented,
is now an officially support interface for SQLite. So you have
some assurance that this will be a one-time change and that your
new backend will continue to work in future versions of SQLite.
</p>
<h3>2.1 The Virtual File System Object</h3><p>
The new OS interface for SQLite is built around an object named
<a href="c3ref/vfs.html">sqlite3_vfs</a>. The "vfs" stands for "Virtual File System".
The sqlite3_vfs object is basically a structure containing pointers
to functions that implement the primitive disk I/O operations that
SQLite needs to perform in order to read and write databases.
In this article, we will often refer to an sqlite3_vfs objects as a "VFS".
</p>
<p>
SQLite is able to use multiple VFSes at the same time. Each
individual database connection is associated with just one VFS.
But if you have multiple database connections, each connection
can be associated with a different VFS.
</p>
<p>
There is always a default VFS.
The legacy interfaces <a href="c3ref/open.html">sqlite3_open()</a> and <a href="c3ref/open.html">sqlite3_open16()</a> always
use the default VFS.
The new interface for creating database connections,
<a href="c3ref/open.html">sqlite3_open_v2()</a>, allows you to specify which VFS you want to
use by name.
</p>
<h4>2.1.1 Registering New VFS Objects</h4><p>
Standard builds of SQLite for Unix or Windows come with a single
VFS named "unix" or "win32", as appropriate. This one VFS is also
the default. So if you are using the legacy open functions, everything
will continue to operate as it has before. The change is that an application
now has the flexibility of adding new VFS modules to implement a
customized OS layer. The <a href="c3ref/vfs_find.html">sqlite3_vfs_register()</a> API can be used
to tell SQLite about one or more application-defined VFS modules:
</p>
<blockquote><pre>
int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
</pre></blockquote><p>
Applications can call sqlite3_vfs_register() at any time, though of course
a VFS needs to be registered before it can be used. The first argument
is a pointer to a customized VFS object that the application has prepared.
The second argument is true to make the new VFS the default VFS so that
it will be used by the legacy <a href="c3ref/open.html">sqlite3_open()</a> and <a href="c3ref/open.html">sqlite3_open16()</a> APIs.
If the new VFS is not the default, then you will probably have to use
the new <a href="c3ref/open.html">sqlite3_open_v2()</a> API to use it. Note, however, that if
a new VFS is the only VFS known to SQLite (if SQLite was compiled without
its usual default VFS or if the precompiled default VFS was removed
using <a href="c3ref/vfs_find.html">sqlite3_vfs_unregister()</a>) then the new VFS automatically becomes the
default VFS regardless of the makeDflt argument to <a href="c3ref/vfs_find.html">sqlite3_vfs_register()</a>.
</p>
<p>
Standard builds include the default "unix" or "win32" VFSes.
But if you use the -DOS_OTHER=1 compile-time option, then SQLite is
built without a default VFS. In that case, the application must
register at least one VFS prior to calling <a href="c3ref/open.html">sqlite3_open()</a>.
This is the approach that embedded applications should use.
Rather than modifying the SQLite source to insert an alternative
OS layer as was done in prior releases of SQLite, instead compile
an unmodified SQLite source file (preferably the amalgamation)
with the -DOS_OTHER=1 option, then invoke <a href="c3ref/vfs_find.html">sqlite3_vfs_register()</a>
to define the interface to the underlying filesystem prior to
creating any database connections.
</p>
<h4>2.1.2 Additional Control Over VFS Objects</h4><p>
The <a href="c3ref/vfs_find.html">sqlite3_vfs_unregister()</a> API is used to remove an existing
VFS from the system.
</p>
<blockquote><pre>
int sqlite3_vfs_unregister(sqlite3_vfs*);
</pre></blockquote><p>
The <a href="c3ref/vfs_find.html">sqlite3_vfs_find()</a> API is used to locate a particular VFS
by name. Its prototype is as follows:
</p>
<blockquote><pre>
sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
</pre></blockquote><p>
The argument is the symbolic name for the desired VFS. If the
argument is a NULL pointer, then the default VFS is returned.
The function returns a pointer to the <a href="c3ref/vfs.html">sqlite3_vfs</a> object that
implements the VFS. Or it returns a NULL pointer if no object
could be found that matched the search criteria.
</p>
<h4>2.1.3 Modifications Of Existing VFSes</h4><p>
Once a VFS has been registered, it should never be modified. If
a change in behavior is required, a new VFS should be registered.
The application could, perhaps, use <a href="c3ref/vfs_find.html">sqlite3_vfs_find()</a> to locate
the old VFS, make a copy of the old VFS into a new <a href="c3ref/vfs.html">sqlite3_vfs</a>
object, make the desired modifications to the new VFS, unregister
the old VFS, then register the new VFS in its place. Existing
database connections would continue to use the old VFS even after
it is unregistered, but new database connections would use the
new VFS.
</p>
<h4>2.1.4 The VFS Object</h4><p>
A VFS object is an instance of the following structure:
</p>
<blockquote><pre>
typedef struct sqlite3_vfs sqlite3_vfs;
struct sqlite3_vfs {
int iVersion; /* Structure version number */
int szOsFile; /* Size of subclassed sqlite3_file */
int mxPathname; /* Maximum file pathname length */
sqlite3_vfs *pNext; /* Next registered VFS */
const char *zName; /* Name of this virtual file system */
void *pAppData; /* Pointer to application-specific data */
int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
int flags, int *pOutFlags);
int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
int (*xAccess)(sqlite3_vfs*, const char *zName, int flags);
int (*xGetTempName)(sqlite3_vfs*, char *zOut);
int (*xFullPathname)(sqlite3_vfs*, const char *zName, char *zOut);
void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
void *(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol);
void (*xDlClose)(sqlite3_vfs*, void*);
int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
int (*xSleep)(sqlite3_vfs*, int microseconds);
int (*xCurrentTime)(sqlite3_vfs*, double*);
/* New fields may be appended in figure versions. The iVersion
** value will increment whenever this happens. */
};
</pre></blockquote><p>
To create a new VFS, an application fills in an instance of this
structure with appropriate values and then calls <a href="c3ref/vfs_find.html">sqlite3_vfs_register()</a>.
</p>
<p>
The iVersion field of <a href="c3ref/vfs.html">sqlite3_vfs</a> should be 1 for SQLite version 3.5.0.
This number may increase in future versions of SQLite if we have to
modify the VFS object in some way. We hope that this never happens,
but the provision is made in case it does.
</p>
<p>
The szOsFile field is the size in bytes of the structure that defines
an open file: the <a href="c3ref/file.html">sqlite3_file</a> object. This object will be described
more fully below. The point here is that each VFS implementation can
define its own <a href="c3ref/file.html">sqlite3_file</a> object containing whatever information
the VFS implementation needs to store about an open file. SQLite needs
to know how big this object is, however, in order to preallocate enough
space to hold it.
</p>
<p>
The mxPathname field is the maximum length of a file pathname that
this VFS can use. SQLite sometimes has to preallocate buffers of
this size, so it should be as small as reasonably possible. Some
filesystems permit huge pathnames, but in practice pathnames rarely
extend beyond 100 bytes or so. You do not have to put the longest
pathname that the underlying filesystem can handle here. You only
have to put the longest pathname that you want SQLite to be able to
handle. A few hundred is a good value in most cases.
</p>
<p>
The pNext field is used internally by SQLite. Specifically, SQLite
uses this field to form a linked list of registered VFSes.
</p>
<p>
The zName field is the symbolic name of the VFS. This is the name
that the <a href="c3ref/vfs_find.html">sqlite3_vfs_find()</a> compares against when it is looking for
a VFS.
</p>
<p>
The pAppData pointer is unused by the SQLite core. The pointer is
available to store auxiliary information that a VFS information might
want to carry around.
</p>
<p>
The remaining fields of the <a href="c3ref/vfs.html">sqlite3_vfs</a> object all store pointers
to functions that implement primitive operations. We call these
"methods". The first method, xOpen, is used to open files on
the underlying storage media. The result is an <a href="c3ref/file.html">sqlite3_file</a>
object. There are additional methods, defined by the <a href="c3ref/file.html">sqlite3_file</a>
object itself that are used to read and write and close the file.
The additional methods are detailed below. The filename is in UTF-8.
SQLite will guarantee that the zFilename string passed to
xOpen() is a full pathname as generated by xFullPathname() and
that the string will be valid and unchanged until xClose() is
called. So the <a href="c3ref/file.html">sqlite3_file</a> can store a pointer to the
filename if it needs to remember the filename for some reason.
The flags argument to xOpen() is a copy of the flags argument
to sqlite3_open_v2(). If sqlite3_open() or sqlite3_open16()
is used, then flags is <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_READWRITE</a> | <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_CREATE</a>.
If xOpen() opens a file read-only then it sets *pOutFlags to
include <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_READONLY</a>. Other bits in *pOutFlags may be
set.
SQLite will also add one of the following flags to the xOpen()
call, depending on the object being opened:
<ul>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_MAIN_DB</a>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_MAIN_JOURNAL</a>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_TEMP_DB</a>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_TEMP_JOURNAL</a>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_TRANSIENT_DB</a>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_SUBJOURNAL</a>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_SUPER_JOURNAL</a>
</ul>
The file I/O implementation can use the object type flags to
changes the way it deals with files. For example, an application
that does not care about crash recovery or rollback, might make
the open of a journal file a no-op. Writes to this journal are
also a no-op. Any attempt to read the journal returns <a href="rescode.html#ioerr">SQLITE_IOERR</a>.
Or the implementation might recognize the a database file will
be doing page-aligned sector reads and writes in a random order
and set up its I/O subsystem accordingly.
SQLite might also add one of the following flags to the xOpen
method:
<ul>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_DELETEONCLOSE</a>
<li> <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_EXCLUSIVE</a>
</ul>
The <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_DELETEONCLOSE</a> flag means the file should be
deleted when it is closed. This will always be set for TEMP
databases and journals and for subjournals. The
<a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_EXCLUSIVE</a> flag means the file should be opened
for exclusive access. This flag is set for all files except
for the main database file.
The <a href="c3ref/file.html">sqlite3_file</a> structure passed as the third argument to
xOpen is allocated by the caller. xOpen just fills it in. The
caller allocates a minimum of szOsFile bytes for the <a href="c3ref/file.html">sqlite3_file</a>
structure.
</p>
<p>
The differences between an <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_TEMP_DB</a> database and an
<a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_TRANSIENT_DB</a> database is this: The <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_TEMP_DB</a>
is used for explicitly declared and named TEMP tables (using the
CREATE TEMP TABLE syntax) or for named tables in a temporary database
that is created by opening a database with a filename that is an empty
string. An <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_TRANSIENT_DB</a> holds a database table that
SQLite creates automatically in order to evaluate a subquery or
ORDER BY or GROUP BY clause. Both TEMP_DB and TRANSIENT_DB databases
are private and are deleted automatically. TEMP_DB databases last
for the duration of the database connection. TRANSIENT_DB databases
last only for the duration of a single SQL statement.
</p>
<p>
The xDelete method is used to delete a file. The name of the file is
given in the second parameter. The filename will be in UTF-8.
The VFS must convert the filename into whatever character representation
the underlying operating system expects. If the syncDir parameter is
true, then the xDelete method should not return until the change
to the directory contents for the directory containing the
deleted file have been synced to disk in order to ensure that the
file does not "reappear" if a power failure occurs soon after.
</p>
<p>
The xAccess method is used to check for access permissions on a file.
The filename will be UTF-8 encoded. The flags argument will be
<a href="c3ref/c_access_exists.html">SQLITE_ACCESS_EXISTS</a> to check for the existence of the file,
<a href="c3ref/c_access_exists.html">SQLITE_ACCESS_READWRITE</a> to check to see if the file is both readable
and writable, or <a href="c3ref/c_access_exists.html">SQLITE_ACCESS_READ</a> to check to see if the file is
at least readable. The "file" named by the second parameter might
be a directory or folder name.
</p>
<p>
The xGetTempName method computes the name of a temporary file that
SQLite can use. The name should be written into the buffer given
by the second parameter. SQLite will size that buffer to hold
at least mxPathname bytes. The generated filename should be in UTF-8.
To avoid security problems, the generated temporary filename should
contain enough randomness to prevent an attacker from guessing the
temporary filename in advance.
</p>
<p>
The xFullPathname method is used to convert a relative pathname
into a full pathname. The resulting full pathname is written into
the buffer provided by the third parameter. SQLite will size the
output buffer to at least mxPathname bytes. Both the input and
output names should be in UTF-8.
</p>
<p>
The xDlOpen, xDlError, xDlSym, and xDlClose methods are all used for
accessing shared libraries at run-time. These methods may be omitted
(and their pointers set to zero) if the library is compiled with
<a href="compile.html#omit_load_extension">SQLITE_OMIT_LOAD_EXTENSION</a> or if the <a href="c3ref/enable_load_extension.html">sqlite3_enable_load_extension()</a>
interface is never used to enable dynamic extension loading. The
xDlOpen method opens a shared library or DLL and returns a pointer to
a handle. NULL is returned if the open fails. If the open fails,
the xDlError method can be used to obtain a text error message.
The message is written into the zErrMsg buffer of the third parameter
which is at least nByte bytes in length. The xDlSym returns a pointer
to a symbol in the shared library. The name of the symbol is given
by the second parameter. UTF-8 encoding is assumed. If the symbol
is not found a NULL pointer is returned. The xDlClose routine closes
the shared library.
</p>
<p>
The xRandomness method is used exactly once to initialize the
pseudo-random number generator (PRNG) inside of SQLite. Only
the xRandomness method on the default VFS is used. The xRandomness
methods on other VFSes are never accessed by SQLite.
The xRandomness routine requests that nByte bytes of randomness
be written into zOut. The routine returns the actual number of
bytes of randomness obtained. The quality of the randomness so obtained
will determine the quality of the randomness generated by built-in
SQLite functions such as random() and randomblob(). SQLite also
uses its PRNG to generate temporary file names. On some platforms
(ex: Windows) SQLite assumes that temporary file names are unique
without actually testing for collisions, so it is important to have
good-quality randomness even if the random() and randomblob()
functions are never used.
</p>
<p>
The xSleep method is used to suspend the calling thread for at
least the number of microseconds given. This method is used to
implement the <a href="c3ref/sleep.html">sqlite3_sleep()</a> and <a href="c3ref/busy_timeout.html">sqlite3_busy_timeout()</a> APIs.
In the case of <a href="c3ref/sleep.html">sqlite3_sleep()</a> the xSleep method of the default
VFS is always used. If the underlying system does not have a
microsecond resolution sleep capability, then the sleep time should
be rounded up. xSleep returns this rounded-up value.
</p>
<p>
The xCurrentTime method finds the current time and date and writes
the result as a double-precision floating point value into pointer
provided by the second parameter. The time and date is in
coordinated universal time (UTC) and is a fractional Julian day number.
</p>
<h4>2.1.5 The Open File Object</h4><p>
The result of opening a file is an instance of an <a href="c3ref/file.html">sqlite3_file</a> object.
The <a href="c3ref/file.html">sqlite3_file</a> object is an abstract base class defined as follows:
</p>
<blockquote><pre>
typedef struct sqlite3_file sqlite3_file;
struct sqlite3_file {
const struct sqlite3_io_methods *pMethods;
};
</pre></blockquote><p>
Each VFS implementation will subclass the <a href="c3ref/file.html">sqlite3_file</a> by adding
additional fields at the end to hold whatever information the VFS
needs to know about an open file. It does not matter what information
is stored as long as the total size of the structure does not exceed
the szOsFile value recorded in the <a href="c3ref/vfs.html">sqlite3_vfs</a> object.
</p>
<p>
The <a href="c3ref/io_methods.html">sqlite3_io_methods</a> object is a structure that contains pointers
to methods for reading, writing, and otherwise dealing with files.
This object is defined as follows:
</p>
<blockquote><pre>
typedef struct sqlite3_io_methods sqlite3_io_methods;
struct sqlite3_io_methods {
int iVersion;
int (*xClose)(sqlite3_file*);
int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
int (*xSync)(sqlite3_file*, int flags);
int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
int (*xLock)(sqlite3_file*, int);
int (*xUnlock)(sqlite3_file*, int);
int (*xCheckReservedLock)(sqlite3_file*);
int (*xFileControl)(sqlite3_file*, int op, void *pArg);
int (*xSectorSize)(sqlite3_file*);
int (*xDeviceCharacteristics)(sqlite3_file*);
/* Additional methods may be added in future releases */
};
</pre></blockquote><p>
The iVersion field of <a href="c3ref/io_methods.html">sqlite3_io_methods</a> is provided as insurance
against future enhancements. The iVersion value should always be
1 for SQLite version 3.5.
</p>
<p>
The xClose method closes the file. The space for the <a href="c3ref/file.html">sqlite3_file</a>
structure is deallocated by the caller. But if the <a href="c3ref/file.html">sqlite3_file</a>
contains pointers to other allocated memory or resources, those
allocations should be released by the xClose method.
</p>
<p>
The xRead method reads iAmt bytes from the file beginning at a byte
offset to iOfst. The data read is stored in the pointer of the
second parameter. xRead returns the <a href="rescode.html#ok">SQLITE_OK</a> on success,
<a href="rescode.html#ioerr_short_read">SQLITE_IOERR_SHORT_READ</a> if it was not able to read the full number
of bytes because it reached end-of-file, or <a href="rescode.html#ioerr_read">SQLITE_IOERR_READ</a> for
any other error.
</p>
<p>
The xWrite method writes iAmt bytes of data from the second parameter
into the file beginning at an offset of iOfst bytes. If the size of
the file is less than iOfst bytes prior to the write, then xWrite should
ensure that the file is extended with zeros up to iOfst bytes prior
to beginning its write. xWrite continues to extends the file as
necessary so that the size of the file is at least iAmt+iOfst bytes
at the conclusion of the xWrite call. The xWrite method returns
<a href="rescode.html#ok">SQLITE_OK</a> on success. If the write cannot complete because the
underlying storage medium is full, then <a href="rescode.html#full">SQLITE_FULL</a> is returned.
<a href="rescode.html#ioerr_write">SQLITE_IOERR_WRITE</a> should be returned for any other error.
</p>
<p>
The xTruncate method truncates a file to be nByte bytes in length.
If the file is already nByte bytes or less in length then this
method is a no-op. The xTruncate method returns <a href="rescode.html#ok">SQLITE_OK</a> on
success and <a href="rescode.html#ioerr_truncate">SQLITE_IOERR_TRUNCATE</a> if anything goes wrong.
</p>
<p>
The xSync method is used to force previously written data out of
operating system cache and into non-volatile memory. The second
parameter is usually <a href="c3ref/c_sync_dataonly.html">SQLITE_SYNC_NORMAL</a>. If the second parameter
is <a href="c3ref/c_sync_dataonly.html">SQLITE_SYNC_FULL</a> then the xSync method should make sure that
data has also been flushed through the disk controllers cache.
The <a href="c3ref/c_sync_dataonly.html">SQLITE_SYNC_FULL</a> parameter is the equivalent of the F_FULLSYNC
ioctl() on Mac OS X. The xSync method returns
<a href="rescode.html#ok">SQLITE_OK</a> on success and <a href="rescode.html#ioerr_fsync">SQLITE_IOERR_FSYNC</a> if anything goes wrong.
</p>
<p>
The xFileSize() method determines the current size of the file
in bytes and writes that value into *pSize. It returns <a href="rescode.html#ok">SQLITE_OK</a>
on success and <a href="rescode.html#ioerr_fstat">SQLITE_IOERR_FSTAT</a> if something goes wrong.
</p>
<p>
The xLock and xUnlock methods are used to set and clear file locks.
SQLite supports five levels of file locks, in order:
<ul>
<li> <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_NONE</a>
<li> <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_SHARED</a>
<li> <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_RESERVED</a>
<li> <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_PENDING</a>
<li> <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_EXCLUSIVE</a>
</ul>
The underlying implementation can support some subset of these locking
levels as long as it meets the other requirements of this paragraph.
The locking level is specified as the second argument to both xLock
and xUnlock. The xLock method increases the locking level to the
specified locking level or higher. The xUnlock method decreases the
locking level to no lower than the level specified.
<a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_NONE</a> means that the file is unlocked. <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_SHARED</a>
gives permission to read the file. Multiple database connections can
hold <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_SHARED</a> at the same time.
<a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_RESERVED</a> is like <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_SHARED</a> in that it is permission
to read the file. But only a single connection can hold a reserved lock
at any point in time. The <a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_PENDING</a> is also permission to
read the file. Other connections can continue to read the file as well,
but no other connection is allowed to escalate a lock from none to shared.
<a href="c3ref/c_lock_exclusive.html">SQLITE_LOCK_EXCLUSIVE</a> is permission to write on the file. Only a single
connection can hold an exclusive lock and no other connection can hold
any lock (other than "none") while one connection holds an exclusive
lock. The xLock returns <a href="rescode.html#ok">SQLITE_OK</a> on success, <a href="rescode.html#busy">SQLITE_BUSY</a> if it
is unable to obtain the lock, or <a href="rescode.html#ioerr_rdlock">SQLITE_IOERR_RDLOCK</a> if something else
goes wrong. The xUnlock method returns <a href="rescode.html#ok">SQLITE_OK</a> on success and
<a href="rescode.html#ioerr_unlock">SQLITE_IOERR_UNLOCK</a> for problems.
</p>
<p>
The xCheckReservedLock() method checks to see if another connection or
another process is currently holding a reserved, pending, or exclusive
lock on the file. It returns true or false.
</p>
<p>
The xFileControl() method is a generic interface that allows custom
VFS implementations to directly control an open file using the
(new and experimental)
<a href="c3ref/file_control.html">sqlite3_file_control()</a> interface. The second "op" argument
is an integer opcode. The third
argument is a generic pointer which is intended to be a pointer
to a structure that may contain arguments or space in which to
write return values. Potential uses for xFileControl() might be
functions to enable blocking locks with timeouts, to change the
locking strategy (for example to use dot-file locks), to inquire
about the status of a lock, or to break stale locks. The SQLite
core reserves opcodes less than 100 for its own use.
A <a href="c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntllockstate">list of opcodes</a> less than 100 is available.
Applications that define a custom xFileControl method should use opcodes
greater than 100 to avoid conflicts.
</p>
<p>
The xSectorSize returns the "sector size" of the underlying
non-volatile media. A "sector" is defined as the smallest unit of
storage that can be written without disturbing adjacent storage.
On a disk drive the "sector size" has until recently been 512 bytes,
though there is a push to increase this value to 4KiB. SQLite needs
to know the sector size so that it can write a full sector at a
time, and thus avoid corrupting adjacent storage space if a power
loss occurs in the middle of a write.
</p>
<p>
The xDeviceCharacteristics method returns an integer bit vector that
defines any special properties that the underlying storage medium might
have that SQLite can use to increase performance. The allowed return
is the bit-wise OR of the following values:
<ul>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC512</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC1K</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC2K</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC4K</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC8K</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC16K</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC32K</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC64K</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_SAFE_APPEND</a>
<li> <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_SEQUENTIAL</a>
</ul>
The <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC</a> bit means that all writes to this device are
atomic in the sense that either the entire write occurs or none of it
occurs. The other
<a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC<i>nnn</i></a> values indicate that
writes of aligned blocks of the indicated size are atomic.
<a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_SAFE_APPEND</a> means that when extending a file with new
data, the new data is written first and then the file size is updated.
So if a power failure occurs, there is no chance that the file might have
been extended with randomness. The <a href="c3ref/c_iocap_atomic.html">SQLITE_IOCAP_SEQUENTIAL</a> bit means
that all writes occur in the order that they are issued and are not
reordered by the underlying file system.
</p>
<h4>2.1.6 Checklist For Constructing A New VFS</h4><p>
The preceding paragraphs contain a lot of information.
To ease the task of constructing
a new VFS for SQLite we offer the following implementation checklist:
</p>
<p>
<ol>
<li> Define an appropriate subclass of the <a href="c3ref/file.html">sqlite3_file</a> object.
<li> Implement the methods required by the <a href="c3ref/io_methods.html">sqlite3_io_methods</a> object.
<li> Create a static and
constant <a href="c3ref/io_methods.html">sqlite3_io_methods</a> object containing pointers
to the methods from the previous step.
<li> Implement the xOpen method that opens a file and populates an
<a href="c3ref/file.html">sqlite3_file</a> object, including setting pMethods to
point to the <a href="c3ref/io_methods.html">sqlite3_io_methods</a> object from the previous step.
<li> Implement the other methods required by <a href="c3ref/vfs.html">sqlite3_vfs</a>.
<li> Define a static (but not constant) <a href="c3ref/vfs.html">sqlite3_vfs</a> structure that
contains pointers to the xOpen method and the other methods and
which contains the appropriate values for iVersion, szOsFile,
mxPathname, zName, and pAppData.
<li> Implement a procedure that calls <a href="c3ref/vfs_find.html">sqlite3_vfs_register()</a> and
passes it a pointer to the <a href="c3ref/vfs.html">sqlite3_vfs</a> structure from the previous
step. This procedure is probably the only exported symbol in the
source file that implements your VFS.
</ol>
</p>
<p>
Within your application, call the procedure implemented in the last
step above as part of your initialization process before any
database connections are opened.
</p>
<h2>3.0 The Memory Allocation Subsystem</h2><p>
Beginning with version 3.5, SQLite obtains all of the heap memory it
needs using the routines <a href="c3ref/free.html">sqlite3_malloc()</a>, <a href="c3ref/free.html">sqlite3_free()</a>, and
<a href="c3ref/free.html">sqlite3_realloc()</a>. These routines have existed in prior versions
of SQLite, but SQLite has previously bypassed these routines and used
its own memory allocator. This all changes in version 3.5.0.
</p>
<p>
The SQLite source tree actually contains multiple versions of the
memory allocator. The default high-speed version found in the
"mem1.c" source file is used for most builds. But if the SQLITE_MEMDEBUG
flag is enabled, a separate memory allocator the "mem2.c" source file
is used instead. The mem2.c allocator implements lots of hooks to
do error checking and to simulate memory allocation failures for testing
purposes. Both of these allocators use the malloc()/free() implementation
in the standard C library.
</p>
<p>
Applications are not required to use either of these standard memory
allocators. If SQLite is compiled with <a href="compile.html#omitfeatures">SQLITE_OMIT_MEMORY_ALLOCATION</a>
then no implementation for the <a href="c3ref/free.html">sqlite3_malloc()</a>, <a href="c3ref/free.html">sqlite3_realloc()</a>,
and <a href="c3ref/free.html">sqlite3_free()</a> functions is provided. Instead, the application
that links against SQLite must provide its own implementation of these
functions. The application provided memory allocator is not required
to use the malloc()/free() implementation in the standard C library.
An embedded application might provide an alternative memory allocator
that uses memory for a fixed memory pool set aside for the exclusive
use of SQLite, for example.
</p>
<p>
Applications that implement their own memory allocator must provide
implementation for the usual three allocation functions
<a href="c3ref/free.html">sqlite3_malloc()</a>, <a href="c3ref/free.html">sqlite3_realloc()</a>, and <a href="c3ref/free.html">sqlite3_free()</a>.
And they must also implement a fourth function:
</p>
<blockquote><pre>
int sqlite3_memory_alarm(
void(*xCallback)(void *pArg, sqlite3_int64 used, int N),
void *pArg,
sqlite3_int64 iThreshold
);
</pre></blockquote><p>
The <a href="c3ref/aggregate_count.html">sqlite3_memory_alarm</a> routine is used to register
a callback on memory allocation events.
This routine registers or clears a callback that fires when
the amount of memory allocated exceeds iThreshold. Only
a single callback can be registered at a time. Each call
to <a href="c3ref/aggregate_count.html">sqlite3_memory_alarm()</a> overwrites the previous callback.
The callback is disabled by setting xCallback to a NULL
pointer.
</p>
<p>
The parameters to the callback are the pArg value, the
amount of memory currently in use, and the size of the
allocation that provoked the callback. The callback will
presumably invoke <a href="c3ref/free.html">sqlite3_free()</a> to free up memory space.
The callback may invoke <a href="c3ref/free.html">sqlite3_malloc()</a> or <a href="c3ref/free.html">sqlite3_realloc()</a>
but if it does, no additional callbacks will be invoked by
the recursive calls.
</p>
<p>
The <a href="c3ref/soft_heap_limit.html">sqlite3_soft_heap_limit()</a> interface works by registering
a memory alarm at the soft heap limit and invoking
<a href="c3ref/release_memory.html">sqlite3_release_memory()</a> in the alarm callback. Application
programs should not attempt to use the <a href="c3ref/aggregate_count.html">sqlite3_memory_alarm()</a>
interface because doing so will interfere with the
<a href="c3ref/soft_heap_limit.html">sqlite3_soft_heap_limit()</a> module. This interface is exposed
only so that applications can provide their own
alternative implementation when the SQLite core is
compiled with <a href="compile.html#omitfeatures">SQLITE_OMIT_MEMORY_ALLOCATION</a>.
</p>
<p>
The built-in memory allocators in SQLite also provide the following
additional interfaces:
</p>
<blockquote><pre>
sqlite3_int64 sqlite3_memory_used(void);
sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
</pre></blockquote><p>
These interfaces can be used by an application to monitor how
much memory SQLite is using. The <a href="c3ref/memory_highwater.html">sqlite3_memory_used()</a> routine
returns the number of bytes of memory currently in use and the
<a href="c3ref/memory_highwater.html">sqlite3_memory_highwater()</a> returns the maximum instantaneous
memory usage. Neither routine includes the overhead associated
with the memory allocator. These routines are provided for use
by the application. SQLite never invokes them itself. So if
the application is providing its own memory allocation subsystem,
it can omit these interfaces if desired.
</p>
<h2>4.0 The Mutex Subsystem</h2><p>
SQLite has always been threadsafe in the sense that it is safe to
use different SQLite database connections in different threads at the
same time. The constraint was that the same database connection
could not be used in two separate threads at once. SQLite version 3.5.0
relaxes this constraint.
</p>
<p>
In order to allow multiple threads to use the same database connection
at the same time, SQLite must make extensive use of mutexes. And for
this reason a new mutex subsystem as been added. The mutex subsystem
as the following interface:
</p>
<blockquote><pre>
sqlite3_mutex *sqlite3_mutex_alloc(int);
void sqlite3_mutex_free(sqlite3_mutex*);
void sqlite3_mutex_enter(sqlite3_mutex*);
int sqlite3_mutex_try(sqlite3_mutex*);
void sqlite3_mutex_leave(sqlite3_mutex*);
</pre></blockquote><p>
Though these routines exist for the use of the SQLite core,
application code is free to use these routines as well, if desired.
A mutex is an <a href="c3ref/mutex.html">sqlite3_mutex</a> object. The <a href="c3ref/mutex_alloc.html">sqlite3_mutex_alloc()</a>
routine allocates a new mutex object and returns a pointer to it.
The argument to <a href="c3ref/mutex_alloc.html">sqlite3_mutex_alloc()</a> should be
<a href="c3ref/c_mutex_fast.html">SQLITE_MUTEX_FAST</a> or <a href="c3ref/c_mutex_fast.html">SQLITE_MUTEX_RECURSIVE</a> for non-recursive
and recursive mutexes, respectively. If the underlying system does
not provide non-recursive mutexes, then a recursive mutex can be
substituted in that case. The argument to <a href="c3ref/mutex_alloc.html">sqlite3_mutex_alloc()</a>
can also be a constant designating one of several static mutexes:
<ul>
<li> <a href="c3ref/c_mutex_fast.html">SQLITE_MUTEX_STATIC_MAIN</a>
<li> <a href="c3ref/c_mutex_fast.html">SQLITE_MUTEX_STATIC_MEM</a>
<li> <a href="c3ref/c_mutex_fast.html">SQLITE_MUTEX_STATIC_MEM2</a>
<li> <a href="c3ref/c_mutex_fast.html">SQLITE_MUTEX_STATIC_PRNG</a>
<li> <a href="c3ref/c_mutex_fast.html">SQLITE_MUTEX_STATIC_LRU</a>
</ul>
These static mutexes are reserved for use internally by SQLite
and should not be used by the application. The static mutexes
are all non-recursive.
</p>
<p>
The <a href="c3ref/mutex_alloc.html">sqlite3_mutex_free()</a> routine should be used to deallocate
a non-static mutex. If a static mutex is passed to this routine
then the behavior is undefined.
</p>
<p>
The <a href="c3ref/mutex_alloc.html">sqlite3_mutex_enter()</a> attempts to enter the mutex and blocks
if another threads is already there. <a href="c3ref/mutex_alloc.html">sqlite3_mutex_try()</a> attempts
to enter and returns <a href="rescode.html#ok">SQLITE_OK</a> on success or <a href="rescode.html#busy">SQLITE_BUSY</a> if another
thread is already there. <a href="c3ref/mutex_alloc.html">sqlite3_mutex_leave()</a> exits a mutex.
The mutex is held until the number of exits matches the number of
entrances. If <a href="c3ref/mutex_alloc.html">sqlite3_mutex_leave()</a> is called on a mutex that
the thread is not currently holding, then the behavior is undefined.
If any routine is called for a deallocated mutex, then the behavior
is undefined.
</p>
<p>
The SQLite source code provides multiple implementations of these
APIs, suitable for varying environments. If SQLite is compiled with
the SQLITE_THREADSAFE=0 flag then a no-op mutex implementation that
is fast but does no real mutual exclusion is provided. That
implementation is suitable for use in single-threaded applications
or applications that only use SQLite in a single thread. Other
real mutex implementations are provided based on the underlying
operating system.
</p>
<p>
Embedded applications may wish to provide their own mutex implementation.
If SQLite is compiled with the -DSQLITE_MUTEX_APPDEF=1 compile-time flag
then the SQLite core provides no mutex subsystem and a mutex subsystem
that matches the interface described above must be provided by the
application that links against SQLite.
</p>
<h2>5.0 Other Interface Changes</h2><p>
Version 3.5.0 of SQLite changes the behavior of a few APIs in ways
that are technically incompatible. However, these APIs are seldom
used and even when they are used it is difficult to imagine a
scenario where the change might break something. The changes
actually makes these interface much more useful and powerful.
</p>
<p>
Prior to version 3.5.0, the <a href="c3ref/enable_shared_cache.html">sqlite3_enable_shared_cache()</a> API
would enable and disable the shared cache feature for all connections
within a single thread - the same thread from which the
sqlite3_enable_shared_cache() routine was called. Database connections
that used the shared cache were restricted to running in the same
thread in which they were opened. Beginning with version 3.5.0,
the sqlite3_enable_shared_cache() applies to all database connections
in all threads within the process. Now database connections running
in separate threads can share a cache. And database connections that
use shared cache can migrate from one thread to another.
</p>
<p>
Prior to version 3.5.0 the <a href="c3ref/soft_heap_limit.html">sqlite3_soft_heap_limit()</a> set an upper
bound on heap memory usage for all database connections within a
single thread. Each thread could have its own heap limit. Beginning
in version 3.5.0, there is a single heap limit for the entire process.
This seems more restrictive (one limit as opposed to many) but in
practice it is what most users want.
</p>
<p>
Prior to version 3.5.0 the <a href="c3ref/release_memory.html">sqlite3_release_memory()</a> function would
try to reclaim memory from all database connections in the same thread
as the sqlite3_release_memory() call. Beginning with version 3.5.0,
the sqlite3_release_memory() function will attempt to reclaim memory
from all database connections in all threads.
</p>
<h2>6.0 Summary</h2><p>
The transition from SQLite version 3.4.2 to 3.5.0 is a major change.
Every source code file in the SQLite core had to be modified, some
extensively. And the change introduced some minor incompatibilities
in the C interface. But we feel that the benefits of the transition
from 3.4.2 to 3.5.0 far outweigh the pain of porting. The new
VFS layer is now well-defined and stable and should simplify future
customizations. The VFS layer, and the separable memory allocator
and mutex subsystems allow a standard SQLite source code amalgamation
to be used in an embedded project without change, greatly simplifying
configuration management. And the resulting system is much more
tolerant of highly threaded designs.
</p>

View File

@ -0,0 +1,330 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Changes From Version 3.5.9 To 3.6.0</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<h1> Moving From SQLite 3.5.9 to 3.6.0</h1><p>
SQLite version 3.6.0 (2008-07-16)
contains many changes. As is the custom with
the SQLite project, most changes are fully backwards compatible.
However, a few of the changes in version 3.6.0 are incompatible and
might require modifications to application code and/or makefiles.
This document is a briefing on the changes in SQLite 3.6.0
with special attention to the incompatible changes.
</p>
<blockquote>
<strong>Key Points:</strong>
<ul>
<li> The database file format is unchanged. </li>
<li> All incompatibilities are on obscure interfaces and hence should
have zero impact on most applications. </li>
</ul>
</blockquote>
<h2>1.0 Incompatible Changes</h2><p>
Incompatible changes are covered first since they are the most
important to maintainers and programmers.
</p>
<h3>1.1 Overview Of Incompatible Changes</h3><p>
<ol>
<li><p>Changes to the <a href="c3ref/vfs.html">sqlite3_vfs</a> object</p>
<ol type="a">
<li><p>The signature of the xAccess method has been modified to
return an <a href="rescode.html">error code</a> and to store its output into an integer pointed
to by a parameter, rather than returning the output directly.
This change allows the xAccess() method to report failures.
In association with this signature change, a new
extended error code <a href="rescode.html#ioerr_access">SQLITE_IOERR_ACCESS</a> has been added.
</p></li>
<li><p>The xGetTempname method has been removed from <a href="c3ref/vfs.html">sqlite3_vfs</a>.
In its place, the xOpen method is enhanced to open a temporary file
of its own invention when the filename parameter is NULL.</p></li>
<li><p>Added the xGetLastError() method to <a href="c3ref/vfs.html">sqlite3_vfs</a> for returning
filesystem-specific error messages and error codes back to
SQLite.</p></li>
</ol>
</li>
<li><p>The signature of the xCheckReservedLock method on <a href="c3ref/io_methods.html">sqlite3_io_methods</a>
has been modified so that it returns an <a href="rescode.html">error code</a> and stores its
boolean result into an integer pointed to by a parameter. In
association with this change, a new extended error code
<a href="rescode.html#ioerr_checkreservedlock">SQLITE_IOERR_CHECKRESERVEDLOCK</a> has been added.</p></li>
<li><p>When SQLite is ported to new operating systems (operating systems
other than Unix, Windows, and OS/2 for which ports are provided together
with the core)
two new functions, <a href="c3ref/initialize.html">sqlite3_os_init()</a> and <a href="c3ref/initialize.html">sqlite3_os_end()</a>, must
be provided as part of the port.</p></li>
<li><p>The way in which the IN and NOT IN operators handle NULL values
in their right-hand expressions has been brought into compliance with
the SQL standard and with other SQL database engines.</p></li>
<li><p>The column names for the result sets of <a href="lang_select.html">SELECT</a> statements have
been tweaked in some cases to work more like other SQL database
engines.</p></li>
<li><p>Changes to compile-time options:</p>
<ol type="a">
<li><p>The SQLITE_MUTEX_APPDEF compile-time parameter is no longer
recognized. As a replacement, alternative
<a href="c3ref/mutex_alloc.html">mutex implementations</a> may be created
at runtime using <a href="c3ref/config.html">sqlite3_config()</a> with the <a href="c3ref/c_config_covering_index_scan.html#sqliteconfigmutex">SQLITE_CONFIG_MUTEX</a>
operator and the <a href="c3ref/mutex_methods.html">sqlite3_mutex_methods</a> object.</p></li>
<li><p>Compile-time options OS_UNIX, OS_WIN, OS_OS2, OS_OTHER, and
TEMP_STORE have been renamed to include an "SQLITE_" prefix in order
to help avoid namespace collisions with application software. The
new names of these options are respectively:
SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, SQLITE_OS_OTHER,
and <a href="compile.html#temp_store">SQLITE_TEMP_STORE</a>.</p></li>
</ol>
</li>
</ol>
</p>
<h3>1.2 Changes To The VFS Layer</h3><p>
SQLite <a href="releaselog/3_5_0.html">version 3.5.0</a> introduced a <a href="34to35.html">new OS interface layer</a> that
provided an abstraction of the underlying operating system.
This was an important innovation and has proven to be helpful
in porting and maintaining SQLite.
However, the developers have discovered some minor flaws in the
original "virtual file system" design introduced in version 3.5.0
and so SQLite 3.6.0 includes some small incompatible changes
to address these flaws.
</p>
<blockquote>
<strong>Key Point:</strong> The incompatible
changes in the SQLite operating-system interface for version 3.6.0
only affect the rare applications that make use of the
<a href="c3ref/vfs.html">virtual file system</a> interface or that
supply an application-defined <a href="c3ref/mutex_alloc.html">mutex implementation</a>
or that make use of other obscure compile-time options. The
changes introduced by SQLite version 3.6.0 will have zero impact on the
vast majority of SQLite applications that use the built-in interfaces
to Unix, Windows, and OS/2 and that use the standard build configuration.
</blockquote>
<h3>1.3 Changes In The Way The IN Operator Handles NULLs</h3><p>
All versions of SQLite up to and including version 3.5.9 have mishandled
NULL values on the right-hand side of IN and NOT IN operators.
Specifically, SQLite has previously ignored NULLs on the right-hand side
of IN and NOT IN.
</p>
<p>
Suppose we have a table X1 defined as follows:
</p>
<blockquote><pre>
CREATE TABLE x1(x INTEGER);
INSERT INTO x1 VALUES(1);
INSERT INTO x1 VALUES(2);
INSERT INTO x1 VALUES(NULL);
</pre></blockquote><p>
Given the definition of X1 above, the following expressions have
historically evaluated to FALSE in SQLite, though the correct
answer is actually NULL:
</p>
<blockquote><pre>
3 IN (1,2,NULL)
3 IN (SELECT * FROM x1)
</pre></blockquote><p>
Similarly, the following expressions have historically evaluated to
TRUE when in fact NULL is also the correct answer here:
</p>
<blockquote><pre>
3 NOT IN (1,2,NULL)
3 NOT IN (SELECT * FROM x1)
</pre></blockquote><p>
The historical behavior of SQLite is incorrect according to the SQL:1999
standard and it is inconsistent with the behavior of MySQL and
PostgreSQL. Version 3.6.0 changes the behavior of the IN and
NOT IN operators to conform to the standard and to give the same
results as other SQL database engines.
</p>
<blockquote>
<strong>Key Point:</strong> The change to the way NULL values are handled
by the IN and NOT IN operators is technically a bug fix, not a design
change. However, maintainers should check to ensure that applications
do not depend on the older, buggy behavior prior to upgrading to
version 3.6.0.
</blockquote>
<h3>1.4 Changes To Column Naming Rules</h3><p>
The column names reported by join subqueries have been modified slightly
in order to work more like other database engines. Consider the following
query:
</p>
<blockquote><pre>
CREATE TABLE t1(a);
CREATE TABLE t2(x);
SELECT * FROM (SELECT t1.a FROM t1 JOIN t2 ORDER BY t2.x LIMIT 1) ORDER BY 1;
</pre></blockquote><p>
In version 3.5.9 the query above would return a single column named "t1.a".
In version 3.6.0 the column name is just "a".
</p>
<p>
SQLite has never made any promises about the names of columns in the
result set of <a href="lang_select.html">SELECT</a> statement unless the column contains an AS clause.
So this change to column name is technically not an incompatibility.
SQLite is merely changing from one undefined behavior to another.
Nevertheless, many applications depend on the unspecified column naming
behavior of SQLite and so this change is discussed under the
incompatible changes subheading.
</p>
<h3>1.5 Changes To Compile-Time Options</h3><p>
Compile-time options to SQLite are controlled by C-preprocessor
macros. SQLite version 3.6.0 changes the names of some of these
macros so that all C-preprocessor macros that are specific to
SQLite begin with the "SQLITE_" prefix. This is done to reduce the
risk of name collisions with other software modules.
</p>
<blockquote>
<strong>Key Point:</strong> Changes to compile-time options have the
potential to affect makefiles in projects that do customized builds of
SQLite. These changes should have zero impact on application code and for
most projects which use a standard, default build of SQLite.
</blockquote>
<h2>2.0 Fully Backwards-Compatible Enhancements</h2><p>
In addition to the incompatible changes listed above, SQLite
version 3.6.0 adds the following backwards compatible changes and
enhancements:
</p>
<p>
<ol>
<li value="7"><p>The new <a href="c3ref/config.html">sqlite3_config()</a> interface allows an application
to customize the behavior of SQLite at run-time. Customizations possible
using <a href="c3ref/config.html">sqlite3_config()</a> include the following:</p>
<ol type="a">
<li><p>Specify an alternative mutex implementation using the
<a href="c3ref/c_config_covering_index_scan.html#sqliteconfigmutex">SQLITE_CONFIG_MUTEX</a> verb with the <a href="c3ref/mutex_methods.html">sqlite3_mutex_methods</a> object.</p></li>
<li><p>Specify an alternative malloc implementation using the
<a href="c3ref/c_config_covering_index_scan.html#sqliteconfigmalloc">SQLITE_CONFIG_MALLOC</a> verb with the <a href="c3ref/mem_methods.html">sqlite3_mem_methods</a> object.</p></li>
<li><p>Partially or fully disable the use of mutexes using
<a href="c3ref/c_config_covering_index_scan.html#sqliteconfigsinglethread">SQLITE_CONFIG_SINGLETHREAD</a>, <a href="c3ref/c_config_covering_index_scan.html#sqliteconfigmultithread">SQLITE_CONFIG_MULTITHREAD</a> and
<a href="c3ref/c_config_covering_index_scan.html#sqliteconfigserialized">SQLITE_CONFIG_SERIALIZED</a>.</p></li>
</ol>
</li>
<li><p>A new flag <a href="c3ref/c_open_autoproxy.html">SQLITE_OPEN_NOMUTEX</a> is made available to the
<a href="c3ref/open.html">sqlite3_open_v2()</a> interface.</p></li>
<li><p>The new <a href="c3ref/status.html">sqlite3_status()</a> interface allows an application to query
the performance status of SQLite at runtime.
</p></li>
<li><p>The <a href="c3ref/memory_highwater.html">sqlite3_memory_used()</a> and <a href="c3ref/memory_highwater.html">sqlite3_memory_highwater()</a>
interfaces are deprecated. The equivalent functionality is now available
through <a href="c3ref/status.html">sqlite3_status()</a>.</p></li>
<li><p>The <a href="c3ref/initialize.html">sqlite3_initialize()</a> interface can be called to explicitly
initialize the SQLite subsystem. The <a href="c3ref/initialize.html">sqlite3_initialize()</a> interface is
called automatically when invoking certain interfaces so the use of
<a href="c3ref/initialize.html">sqlite3_initialize()</a> is not required, but it is recommended.</p></li>
<li><p>The <a href="c3ref/initialize.html">sqlite3_shutdown()</a> interface causes SQLite to release any
system resources (memory allocations, mutexes, open file handles)
that might have been allocated by <a href="c3ref/initialize.html">sqlite3_initialize()</a>.</p></li>
<li><p>The <a href="c3ref/next_stmt.html">sqlite3_next_stmt()</a> interface allows an application to discover
all <a href="c3ref/stmt.html">prepared statements</a> associated with a <a href="c3ref/sqlite3.html">database connection</a>.</p></li>
<li><p>Added the <a href="pragma.html#pragma_page_count">page_count</a> PRAGMA for returning the size of the underlying
database file in pages.</p></li>
<li><p>Added a new <a href="rtree.html">R*Tree index extension</a>.</p></li>
</ol>
</p>

View File

@ -0,0 +1,203 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>About SQLite</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<h1 align=center>About SQLite</h1>
<div class="rightsidebar border2px">
<h4 align="center">Executive Summary</h4>
<ul>
<li> <a href="fullsql.html">Full-featured SQL</a>
<li> <a href='mostdeployed.html'>Billions and billions of deployments</a>
<li> <a href='onefile.html'>Single-file database</a>
<li> <a href='copyright.html'>Public domain source code</a>
<li> All source code in one file (<a href='amalgamation.html'>sqlite3.c</a>)
<li> <a href='footprint.html'>Small footprint</a>
<li> Max DB size: <a href='limits.html'>281 terabytes</a>
(2<sup><small>48</small></sup> bytes)
<li> Max row size: <a href='limits.html'>1 gigabyte</a>
<li> <a href='fasterthanfs.html'>Faster than direct file I/O</a>
<li> <a href='testing.html'>Aviation-grade quality and testing</a>
<li> <a href='zeroconf.html'>Zero-configuration</a>
<li> <a href='transactional.html'>ACID transactions, even after power loss</a>
<li> <a href='fileformat.html'>Stable, enduring file format</a>
<li> <a href='doclist.html'>Extensive, detailed documentation</a>
<li> <a href='lts.html'>Long-term support</a>
</div>
<p>SQLite is an in-process library that implements a
<a href="selfcontained.html">self-contained</a>,
<a href="serverless.html">serverless</a>,
<a href="zeroconf.html">zero-configuration</a>,
<a href="transactional.html">transactional</a>
SQL database engine.
The code for SQLite is in the
<a href="copyright.html">public domain</a> and is thus free for
use for any purpose, commercial or private.
SQLite is the <a href="mostdeployed.html">most widely deployed</a> database in the world
with more applications than we can
count, including several <a href="famous.html">high-profile projects.</a></p>
<p>SQLite is an embedded SQL database engine.
Unlike most other SQL databases, SQLite does not have a separate
server process. SQLite reads and writes directly to ordinary disk
files. A complete SQL database with multiple tables, indices,
triggers, and views, is contained in a single disk file.
The database <a href="fileformat2.html">file format</a> is cross-platform - you can freely copy a database
between 32-bit and 64-bit systems or between
<a href="http://en.wikipedia.org/wiki/Endianness">big-endian</a> and
<a href="http://en.wikipedia.org/wiki/Endianness">little-endian</a>
architectures. These features make SQLite a popular choice as
an <a href="appfileformat.html">Application File Format</a>. SQLite database files are a
<a href="locrsf.html">recommended storage format</a> by the US Library of Congress.
Think of SQLite not as a replacement for
<a href="http://www.oracle.com/database/index.html">Oracle</a> but
as a replacement for <a href="http://man.he.net/man3/fopen">fopen()</a></p>
<p>SQLite is a compact library.
With all features enabled, the <a href="footprint.html">library size</a> can be less than 600KiB,
depending on the target platform and compiler optimization settings.
(64-bit code is larger. And some compiler optimizations
such as aggressive function inlining and loop unrolling can cause the
object code to be much larger.)
There is a tradeoff between memory usage and speed.
SQLite generally runs faster the more memory
you give it. Nevertheless, performance is usually quite good even
in low-memory environments. Depending on how it is used, SQLite can be
<a href="fasterthanfs.html">faster than direct filesystem I/O</a>.</p>
<p>SQLite is
<a href="testing.html">very carefully tested</a> prior to every
release and has a reputation for being very reliable.
Most of the SQLite source code is devoted purely to testing and
verification. An automated test suite runs millions and millions of
test cases involving hundreds of millions of individual SQL statements
and achieves <a href="testing.html#coverage">100% branch test coverage</a>.
SQLite responds gracefully to memory
allocation failures and disk I/O errors. Transactions are
<a href="http://en.wikipedia.org/wiki/ACID">ACID</a>
even if interrupted by system crashes or power failures.
All of this is verified by
the automated tests using special test harnesses which simulate
system failures.
Of course, even with all this testing, there are still bugs.
But unlike some similar projects (especially commercial competitors)
SQLite is open and honest about all bugs and provides
<a href="http://www.sqlite.org/src/rptview?rn=1">bugs lists</a> and
minute-by-minute <a href="http://www.sqlite.org/src/timeline">
chronologies</a> of code changes.</p>
<p>The SQLite code base is supported by an
<a href="crew.html">international team</a> of developers who work on
SQLite full-time.
The developers continue to expand the capabilities of SQLite
and enhance its reliability and performance while maintaining
backwards compatibility with the
<a href="c3ref/intro.html">published interface spec</a>,
<a href="lang.html">SQL syntax</a>, and database <a href="fileformat2.html">file format</a>.
The source code is absolutely free to anybody who wants it,
but <a href="prosupport.html">professional support</a> is also available.</p>
<p>The SQLite project was started on
<a href="https://www.sqlite.org/src/timeline?c=2000-05-29+14:26:00">2000-05-09</a>.
The future is always hard to predict, but the intent of the developers
is to support SQLite through the year 2050. Design decisions are made
with that objective in mind.</p>
<p>We the developers hope that you find SQLite useful and we
entreat you to use it well: to make good and beautiful products that
are fast, reliable, and simple to use. Seek forgiveness for yourself
as you forgive others. And just as you have received SQLite for free,
so also freely give, paying the debt forward.</p>

View File

@ -0,0 +1,190 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Benefits of SQLite As A File Format</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<h1 align="center">
SQLite As An Application File Format
</h1>
<p><i>(Note: The current page is a brief summary of why SQLite makes
a good application file format. The topic is considered at greater
detail in a <a href="appfileformat.html">separate technical note</a>.)</i></p>
<p>
SQLite has been used with great success as the on-disk file format
for desktop applications such as version control systems,
financial analysis tools, media cataloging and editing suites, CAD
packages, record keeping programs, and so forth. The traditional
File/Open operation calls sqlite3_open() to attach to the database
file. Updates happen automatically as application content is revised
so the File/Save menu option becomes superfluous. The File/Save_As
menu option can be implemented using the <a href="backup.html">backup API</a>.
</p>
<p>
There are many advantages to using SQLite as an application file format,
including:
</p>
<ol type="1">
<li><b>Better performance</b>
<ul>
<li> Reading and writing from an SQLite database
is often faster than reading and writing individual files from disk.
See <a href="fasterthanfs.html">35% Faster Than The Filesystem</a>
and <a href="intern-v-extern-blob.html">Internal Versus External BLOBs</a>.
<li> The application only has to load the data it needs, rather
than reading the entire file and holding a complete parse
in memory.
<li> Small edits only overwrite the parts of the file that change,
reducing write time and wear on SSD drives.
</ul>
<li><b>Reduced application cost and complexity</b>
<ul>
<li> No application file I/O code to write and debug.
<li> Content can be accessed and updated using concise SQL queries instead
of lengthy and error-prone procedural routines.
<li> The file format can be extended in future releases simply
by adding new tables and/or column, preserving backwards compatibility.
<li> Applications can leverage the
<a href="fts3.html">full-text search</a> and <a href="rtree.html">RTREE</a> indexes and use triggers to implement
an <a href="undoredo.html">automated undo/redo stack</a>.
<li> Performance problems can often be resolved, even late in the
development cycle, using <a href="lang_createindex.html">CREATE INDEX</a>, avoiding costly
redesign, rewrite, and retest efforts.
</ul>
<li><b>Portability</b>
<ul>
<li> The application file is portable across all operating systems,
32-bit and 64-bit and big- and little-endian architectures.
<li> A federation of programs, perhaps all written in different programming
languages, can access the same application file with no
compatibility concerns.
<li> Multiple processes can attach to the same application
file and can read and write without interfering with each another.
<li> Diverse content which might otherwise be stored as a "pile-of-files"
is encapsulated into a single disk file for simpler transport
via scp/ftp, USB stick, and/or email attachment.
</ul>
<li><b>Reliability</b>
<ul>
<li> Content can be updated continuously and atomically so
that little or no work is lost in a power failure or crash.
<li> Bugs are far less likely in SQLite than in custom-written file I/O code.
<li> SQL queries are many times smaller than the equivalent procedural
code, and since the number of bugs per line of code is roughly
constant, this means fewer bugs overall.
</ul>
<li><b>Accessibility</b>
<ul>
<li> SQLite database content can be viewed using a wide variety
third-party tools.
<li> Content stored in an SQLite database is more likely to be
recoverable decades in the future, long after all traces of
the original application have been lost. Data lives longer than code.
<li> SQLite database files are <a href="locrsf.html">recommended by the US Library of Congress</a>
as a storage format for long-term preservation of digital content.
</ul>
</ol>
<p>
SQLite allows database files to have any desired filename extension, so
an application can choose a custom filename extension for its own use, if
desired. The <a href="pragma.html#pragma_application_id">application_id pragma</a> can be used to set an "Application ID"
integer in the database file so that tools like
<a href="http://www.darwinsys.com/file/">file(1)</a> can determine that the file
is associated with your application and is not just a generic
SQL database.</p>

View File

@ -0,0 +1,661 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>What If OpenDocument Used SQLite?</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<h1 align="center">
What If OpenDocument Used SQLite?</h1>
<h2>Introduction</h2>
<p>Suppose the
<a href="http://en.wikipedia.org/wiki/OpenDocument">OpenDocument</a> file format,
and specifically the "ODP" OpenDocument Presentation format, were
built around SQLite. Benefits would include:
<ul>
<li>Smaller documents
<li>Faster File/Save times
<li>Faster startup times
<li>Less memory used
<li>Document versioning
<li>A better user experience
</ul>
<p>
Note that this is only a thought experiment.
We are not suggesting that OpenDocument be changed.
Nor is this article a criticism of the current OpenDocument
design. The point of this essay is to suggest ways to improve
future file format designs.
<h2>About OpenDocument And OpenDocument Presentation</h2>
<p>
The OpenDocument file format is used for office applications:
word processors, spreadsheets, and presentations. It was originally
designed for the OpenOffice suite but has since been incorporated into
other desktop application suites. The OpenOffice application has been
forked and renamed a few times. This author's primary use for OpenDocument is
building slide presentations with either
<a href="https://www.neooffice.org/neojava/en/index.php">NeoOffice</a> on Mac, or
<a href="http://www.libreoffice.org/">LibreOffice</a> on Linux and Windows.
<p>
An OpenDocument Presentation or "ODP" file is a
<a href="http://en.wikipedia.org/wiki/Zip_%28file_format%29">ZIP archive</a> containing
XML files describing presentation slides and separate image files for the
various images that are included as part of the presentation.
(OpenDocument word processor and spreadsheet files are similarly
structured but are not considered by this article.) The reader can
easily see the content of an ODP file by using the "zip -l" command.
For example, the following is the "zip -l" output from a 49-slide presentation
about SQLite from the 2014
<a href="http://southeastlinuxfest.org/">SouthEast LinuxFest</a>
conference:
<blockquote><pre>
Archive: self2014.odp
Length Date Time Name
--------- ---------- ----- ----
47 2014-06-21 12:34 mimetype
0 2014-06-21 12:34 Configurations2/statusbar/
0 2014-06-21 12:34 Configurations2/accelerator/current.xml
0 2014-06-21 12:34 Configurations2/floater/
0 2014-06-21 12:34 Configurations2/popupmenu/
0 2014-06-21 12:34 Configurations2/progressbar/
0 2014-06-21 12:34 Configurations2/menubar/
0 2014-06-21 12:34 Configurations2/toolbar/
0 2014-06-21 12:34 Configurations2/images/Bitmaps/
54702 2014-06-21 12:34 Pictures/10000000000001F40000018C595A5A3D.png
46269 2014-06-21 12:34 Pictures/100000000000012C000000A8ED96BFD9.png
<i>... 58 other pictures omitted...</i>
13013 2014-06-21 12:34 Pictures/10000000000000EE0000004765E03BA8.png
1005059 2014-06-21 12:34 Pictures/10000000000004760000034223EACEFD.png
211831 2014-06-21 12:34 content.xml
46169 2014-06-21 12:34 styles.xml
1001 2014-06-21 12:34 meta.xml
9291 2014-06-21 12:34 Thumbnails/thumbnail.png
38705 2014-06-21 12:34 Thumbnails/thumbnail.pdf
9664 2014-06-21 12:34 settings.xml
9704 2014-06-21 12:34 META-INF/manifest.xml
--------- -------
10961006 78 files
</pre></blockquote>
<p>
The ODP ZIP archive contains four different XML files:
content.xml, styles.xml, meta.xml, and settings.xml. Those four files
define the slide layout, text content, and styling. This particular
presentation contains 62 images, ranging from full-screen pictures to
tiny icons, each stored as a separate file in the Pictures
folder. The "mimetype" file contains a single line of text that says:
<blockquote><pre>
application/vnd.oasis.opendocument.presentation
</pre></blockquote>
<p>The purpose of the other files and folders is presently
unknown to the author but is probably not difficult to figure out.
<h2>Limitations Of The OpenDocument Presentation Format</h2>
<p>
The use of a ZIP archive to encapsulate XML files plus resources is an
elegant approach to an application file format.
It is clearly superior to a custom binary file format.
But using an SQLite database as the
container, instead of ZIP, would be more elegant still.
<p>A ZIP archive is basically a key/value database, optimized for
the case of write-once/read-many and for a relatively small number
of distinct keys (a few hundred to a few thousand) each with a large BLOB
as its value. A ZIP archive can be viewed as a "pile-of-files"
database. This works, but it has some shortcomings relative to an
SQLite database, as follows:
<ol>
<li><p><b>Incremental update is hard.</b>
<p>
It is difficult to update individual entries in a ZIP archive.
It is especially difficult to update individual entries in a ZIP
archive in a way that does not destroy
the entire document if the computer loses power and/or crashes
in the middle of the update. It is not impossible to do this, but
it is sufficiently difficult that nobody actually does it. Instead, whenever
the user selects "File/Save", the entire ZIP archive is rewritten.
Hence, "File/Save" takes longer than it ought, especially on
older hardware. Newer machines are faster, but it is still bothersome
that changing a single character in a 50 megabyte presentation causes one
to burn through 50 megabytes of the finite write life on the SSD.
<li><p><b>Startup is slow.</b>
<p>
In keeping with the pile-of-files theme, OpenDocument stores all slide
content in a single big XML file named "content.xml".
LibreOffice reads and parses this entire file just to display
the first slide.
LibreOffice also seems to
read all images into memory as well, which makes sense seeing as when
the user does "File/Save" it is going to have to write them all back out
again, even though none of them changed. The net effect is that
start-up is slow. Double-clicking an OpenDocument file brings up a
progress bar rather than the first slide.
This results in a bad user experience.
The situation grows ever more annoying as
the document size increases.
<li><p><b>More memory is required.</b>
<p>
Because ZIP archives are optimized for storing big chunks of content, they
encourage a style of programming where the entire document is read into
memory at startup, all editing occurs in memory, then the entire document
is written to disk during "File/Save". OpenOffice and its descendants
embrace that pattern.
<p>
One might argue that it is ok, in this era of multi-gigabyte desktops, to
read the entire document into memory.
But it is not ok.
For one, the amount of memory used far exceeds the (compressed) file size
on disk. So a 50MB presentation might take 200MB or more RAM.
That still is not a problem if one only edits a single document at a time.
But when working on a talk, this author will typically have 10 or 15 different
presentations up all at the same
time (to facilitate copy/paste of slides from past presentation) and so
gigabytes of memory are required.
Add in an open web browser or two and a few other
desktop apps, and suddenly the disk is whirling and the machine is swapping.
And even having just a single document is a problem when working
on an inexpensive Chromebook retrofitted with Ubuntu.
Using less memory is always better.
</p>
<li><p><b>Crash recovery is difficult.</b>
<p>
The descendants of OpenOffice tend to segfault more often than commercial
competitors. Perhaps for this reason, the OpenOffice forks make
periodic backups of their in-memory documents so that users do not lose
all pending edits when the inevitable application crash does occur.
This causes frustrating pauses in the application for the few seconds
while each backup is being made.
After restarting from a crash, the user is presented with a dialog box
that walks them through the recovery process. Managing the crash
recovery this way involves lots of extra application logic and is
generally an annoyance to the user.
<li><p><b>Content is inaccessible.</b>
<p>
One cannot easily view, change, or extract the content of an
OpenDocument presentation using generic tools.
The only reasonable way to view or edit an OpenDocument document is to open
it up using an application that is specifically designed to read or write
OpenDocument (read: LibreOffice or one of its cousins). The situation
could be worse. One can extract and view individual images (say) from
a presentation using just the "zip" archiver tool. But it is not reasonable
try to extract the text from a slide. Remember that all content is stored
in a single "context.xml" file. That file is XML, so it is a text file.
But it is not a text file that can be managed with an ordinary text
editor. For the example presentation above, the content.xml file
consist of exactly two lines. The first line of the file is just:
<blockquote><pre>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
</pre></blockquote>
<p>The second line of the file contains 211792 characters of
impenetrable XML. Yes, 211792 characters all on one line.
This file is a good stress-test for a text editor.
Thankfully, the file is not some obscure
binary format, but in terms of accessibility, it might as well be
written in Klingon.
</ol>
<h2>First Improvement: Replace ZIP with SQLite</h2>
<p>
Let us suppose that instead of using a ZIP archive to store its files,
OpenDocument used a very simple SQLite database with the following
single-table schema:
<blockquote><pre>
CREATE TABLE OpenDocTree(
filename TEXT PRIMARY KEY, -- Name of file
filesize BIGINT, -- Size of file after decompression
content BLOB -- Compressed file content
);
</pre></blockquote>
<p>
For this first experiment, nothing else about the file format is changed.
The OpenDocument is still a pile-of-files, only now each file is a row
in an SQLite database rather than an entry in a ZIP archive.
This simple change does not use the power of a relational
database. Even so, this simple change shows some improvements.
<a name="smaller"></a>
<p>
Surprisingly, using SQLite in place of ZIP makes the presentation
file smaller. Really. One would think that a relational database file
would be larger than a ZIP archive, but at least in the case of NeoOffice
that is not so. The following is an actual screen-scrape showing
the sizes of the same NeoOffice presentation, both in its original
ZIP archive format as generated by NeoOffice (self2014.odp), and
as repacked as an SQLite database using the
<a href="http://www.sqlite.org/sqlar/doc/trunk/README.md">SQLAR</a> utility:
<blockquote><pre>
-rw-r--r-- 1 drh staff 10514994 Jun 8 14:32 self2014.odp
-rw-r--r-- 1 drh staff 10464256 Jun 8 14:37 self2014.sqlar
-rw-r--r-- 1 drh staff 10416644 Jun 8 14:40 zip.odp
</pre></blockquote>
<p>
The SQLite database file ("self2014.sqlar") is about a
half percent smaller than the equivalent ODP file! How can this be?
Apparently the ZIP archive generator logic in NeoOffice
is not as efficient as it could be, because when the same pile-of-files
is recompressed using the command-line "zip" utility, one gets a file
("zip.odp") that is smaller still, by another half percent, as seen
in the third line above. So, a well-written ZIP archive
can be slightly smaller than the equivalent SQLite database, as one would
expect. But the difference is slight. The key take-away is that an
SQLite database is size-competitive with a ZIP archive.
<p>
The other advantage to using SQLite in place of
ZIP is that the document can now be updated incrementally, without risk
of corrupting the document if a power loss or other crash occurs in the
middle of the update. (Remember that writes to
<a href="atomiccommit.html">SQLite databases are atomic</a>.) True, all the
content is still kept in a single big XML file ("content.xml") which must
be completely rewritten if so much as a single character changes. But
with SQLite, only that one file needs to change. The other 77 files in the
repository can remain unaltered. They do not all have to be rewritten,
which in turn makes "File/Save" run much faster and saves wear on SSDs.
<h2>Second Improvement: Split content into smaller pieces</h2>
<p>
A pile-of-files encourages content to be stored in a few large chunks.
In the case of ODP, there are just four XML files that define the layout
off all slides in a presentation. An SQLite database allows storing
information in a few large chunks, but SQLite is also adept and efficient
at storing information in numerous smaller pieces.
<p>
So then, instead of storing all content for all slides in a single
oversized XML file ("content.xml"), suppose there was a separate table
for storing the content of each slide separately. The table schema
might look something like this:
<blockquote><pre>
CREATE TABLE slide(
pageNumber INTEGER, -- The slide page number
slideContent TEXT -- Slide content as XML or JSON
);
CREATE INDEX slide_pgnum ON slide(pageNumber); -- Optional
</pre></blockquote>
<p>The content of each slide could still be stored as compressed XML.
But now each page is stored separately. So when opening a new document,
the application could simply run:
<blockquote><pre>
SELECT slideContent FROM slide WHERE pageNumber=1;
</pre></blockquote>
<p>This query will quickly and efficiently return the content of the first
slide, which could then be speedily parsed and displayed to the user.
Only one page needs to be read and parsed in order render the first screen,
which means that the first screen appears much faster and
there is no longer a need for an annoying progress bar.
<p>If the application wanted
to keep all content in memory, it could continue reading and parsing the
other pages using a background thread after drawing the first page. Or,
since reading from SQLite is so efficient, the application might
instead choose to reduce its memory footprint and only keep a single
slide in memory at a time. Or maybe it keeps the current slide and the
next slide in memory, to facility rapid transitions to the next slide.
<p>
Notice that dividing up the content into smaller pieces using an SQLite
table gives flexibility to the implementation. The application can choose
to read all content into memory at startup. Or it can read just a
few pages into memory and keep the rest on disk. Or it can read just
single page into memory at a time. And different versions of the application
can make different choices without having to make any changes to the
file format. Such options are not available when all content is in
a single big XML file in a ZIP archive.
<p>
Splitting content into smaller pieces also helps File/Save operations
to go faster. Instead of having to write back the content of all pages
when doing a File/Save, the application only has to write back those
pages that have actually changed.
<p>
One minor downside of splitting content into smaller pieces is that
compression does not work as well on shorter texts and so the size of
the document might increase. But as the bulk of the document space
is used to store images, a small reduction in the compression efficiency
of the text content will hardly be noticeable, and is a small price
to pay for an improved user experience.
<h2>Third Improvement: Versioning</h2>
<p>
Once one is comfortable with the concept of storing each slide separately,
it is a small step to support versioning of the presentation. Consider
the following schema:
<blockquote><pre>
CREATE TABLE slide(
slideId INTEGER PRIMARY KEY,
derivedFrom INTEGER REFERENCES slide,
content TEXT -- XML or JSON or whatever
);
CREATE TABLE version(
versionId INTEGER PRIMARY KEY,
priorVersion INTEGER REFERENCES version,
checkinTime DATETIME, -- When this version was saved
comment TEXT, -- Description of this version
manifest TEXT -- List of integer slideIds
);
</pre></blockquote>
<p>
In this schema, instead of each slide having a page number that determines
its order within the presentation, each slide has a unique
integer identifier that is unrelated to where it occurs in sequence.
The order of slides in the presentation is determined by a list of
slideIds, stored as a text string in the MANIFEST column of the VERSION
table.
Since multiple entries are allowed in the VERSION table, that means that
multiple presentations can be stored in the same document.
<p>
On startup, the application first decides which version it
wants to display. Since the versionId will naturally increase in time
and one would normally want to see the latest version, an appropriate
query might be:
<blockquote><pre>
SELECT manifest, versionId FROM version ORDER BY versionId DESC LIMIT 1;
</pre></blockquote>
<p>
Or perhaps the application would rather use the
most recent checkinTime:
<blockquote><pre>
SELECT manifest, versionId, max(checkinTime) FROM version;
</pre></blockquote>
<p>
Using a single query such as the above, the application obtains a list
of the slideIds for all slides in the presentation. The application then
queries for the content of the first slide, and parses and displays that
content, as before.
<p>(Aside: Yes, that second query above that uses "max(checkinTime)"
really does work and really does return a well-defined answer in SQLite.
Such a query either returns an undefined answer or generates an error
in many other SQL database engines, but in SQLite it does what you would
expect: it returns the manifest and versionId of the entry that has the
maximum checkinTime.)
<p>When the user does a "File/Save", instead of overwriting the modified
slides, the application can now make new entries in the SLIDE table for
just those slides that have been added or altered. Then it creates a
new entry in the VERSION table containing the revised manifest.
<p>The VERSION table shown above has columns to record a check-in comment
(presumably supplied by the user) and the time and date at which the File/Save
action occurred. It also records the parent version to record the history
of changes. Perhaps the manifest could be stored as a delta from the
parent version, though typically the manifest will be small enough that
storing a delta might be more trouble than it is worth. The SLIDE table
also contains a derivedFrom column which could be used for delta encoding
if it is determined that saving the slide content as a delta from its
previous version is a worthwhile optimization.
<p>So with this simple change, the ODP file now stores not just the most
recent edit to the presentation, but a history of all historic edits. The
user would normally want to see just the most recent edition of the
presentation, but if desired, the user can now go backwards in time to
see historical versions of the same presentation.
<p>Or, multiple presentations could be stored within the same document.
<p>With such a schema, the application would no longer need to make
periodic backups of the unsaved changes to a separate file to avoid lost
work in the event of a crash. Instead, a special "pending" version could
be allocated and unsaved changes could be written into the pending version.
Because only changes would need to be written, not the entire document,
saving the pending changes would only involve writing a few kilobytes of
content, not multiple megabytes, and would take milliseconds instead of
seconds, and so it could be done frequently and silently in the background.
Then when a crash occurs and the user reboots, all (or almost all)
of their work is retained. If the user decides to discard unsaved changes,
they simply go back to the previous version.
<p>
There are details to fill in here.
Perhaps a screen can be provided that displays a history changes
(perhaps with a graph) allowing the user to select which version they
want to view or edit. Perhaps some facility can be provided to merge
forks that might occur in the version history. And perhaps the
application should provide a means to purge old and unwanted versions.
The key point is that using an SQLite database to store the content,
rather than a ZIP archive, makes all of these features much, much easier
to implement, which increases the possibility that they will eventually
get implemented.
<h2>And So Forth...</h2>
<p>
In the previous sections, we have seen how moving from a key/value
store implemented as a ZIP archive to a simple SQLite database
with just three tables can add significant capabilities to an application
file format.
We could continue to enhance the schema with new tables, with indexes
added for performance, with triggers and views for programming convenience,
and constraints to enforce consistency of content even in the face of
programming errors. Further enhancement ideas include:
<ul>
<li> Store an <a href="undoredo.html">automated undo/redo stack</a> in a database table so that
Undo could go back into prior edit sessions.
<li> Add <a href="fts3.html#fts4">full text search</a> capabilities to the slide deck, or across
multiple slide decks.
<li> Decompose the "settings.xml" file into an SQL table that
is more easily viewed and edited by separate applications.
<li> Break out the "Presentor Notes" from each slide into a separate
table, for easier access from third-party applications and/or scripts.
<li> Enhance the presentation concept beyond the simple linear sequence of
slides to allow for side-tracks and excursions to be taken depending on
how the audience is responding.
</ul>
<p>
An SQLite database has a lot of capability, which
this essay has only begun to touch upon. But hopefully this quick glimpse
has convinced some readers that using an SQL database as an application
file format is worth a second look.
<p>
Some readers might resist using SQLite as an application
file format due to prior exposure to enterprise SQL databases and
the caveats and limitations of those other systems.
For example, many enterprise database
engines advise against storing large strings or BLOBs in the database
and instead suggest that large strings and BLOBs be stored as separate
files and the filename stored in the database. But SQLite
is not like that. Any column of an SQLite database can hold
a string or BLOB up to about a gigabyte in size. And for strings and
BLOBs of 100 kilobytes or less,
<a href="intern-v-extern-blob.html">I/O performance is better</a> than using separate
files.
<p>
Some readers might be reluctant to consider SQLite as an application
file format because they have been inculcated with the idea that all
SQL database schemas must be factored into third normal form and store
only small primitive data types such as strings and integers. Certainly
relational theory is important and designers should strive to understand
it. But, as demonstrated above, it is often quite acceptable to store
complex information as XML or JSON in text fields of a database.
Do what works, not what your database professor said you ought to do.
<h2>Review Of The Benefits Of Using SQLite</h2>
<p>
In summary,
the claim of this essay is that using SQLite as a container for an application
file format like OpenDocument
and storing lots of smaller objects in that container
works out much better than using a ZIP archive holding a few larger objects.
To wit:
<ol>
<li><p>
An SQLite database file is approximately the same size, and in some cases
smaller, than a ZIP archive holding the same information.
<li><p>
The <a href="atomiccommit.html">atomic update capabilities</a>
of SQLite allow small incremental changes
to be safely written into the document. This reduces total disk I/O
and improves File/Save performance, enhancing the user experience.
<li><p>
Startup time is reduced by allowing the application to read in only the
content shown for the initial screen. This largely eliminates the
need to show a progress bar when opening a new document. The document
just pops up immediately, further enhancing the user experience.
<li><p>
The memory footprint of the application can be dramatically reduced by
only loading content that is relevant to the current display and keeping
the bulk of the content on disk. The fast query capability of SQLite
make this a viable alternative to keeping all content in memory at all times.
And when applications use less memory, it makes the entire computer more
responsive, further enhancing the user experience.
<li><p>
The schema of an SQL database is able to represent information more directly
and succinctly than a key/value database such as a ZIP archive. This makes
the document content more accessible to third-party applications and scripts
and facilitates advanced features such as built-in document versioning, and
incremental saving of work in progress for recovery after a crash.
</ol>
<p>
These are just a few of the benefits of using SQLite as an application file
format &mdash; the benefits that seem most likely to improve the user
experience for applications like OpenOffice. Other applications might
benefit from SQLite in different ways. See the <a href="appfileformat.html">Application File Format</a>
document for additional ideas.
<p>
Finally, let us reiterate that this essay is a thought experiment.
The OpenDocument format is well-established and already well-designed.
Nobody really believes that OpenDocument should be changed to use SQLite
as its container instead of ZIP. Nor is this article a criticism of
OpenDocument for not choosing SQLite as its container since OpenDocument
predates SQLite. Rather, the point of this article is to use OpenDocument
as a concrete example of how SQLite can be used to build better
application file formats for future projects.

View File

@ -0,0 +1,263 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>The SQLite Amalgamation</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
The SQLite Amalgamation
</div>
</div>
<h1 id="executive_summary"><span>1. </span>Executive Summary</h1>
<p>Over 100 separate source files are concatenated into a
single large files of C-code named "sqlite3.c" and
called "the amalgamation". The amalgamation
contains everything an application needs to embed SQLite.
The amalgamation file is more than 220,000 lines long and over 7.5
megabytes in size (as of 2018-11-24).
</p><p>Combining all the code for SQLite into one big file makes SQLite
easier to deploy &mdash; there is just one file to keep track of.
And because all code is in
a single translation unit, compilers can do better inter-procedure
optimization resulting in machine code that is between 5% and 10% faster.
</p><h1 id="the_sqlite_amalgamation"><span>2. </span>The SQLite Amalgamation</h1>
<p>The SQLite library consists of 102 files of C code
(as of <a href="releaselog/3_9_0.html">Version 3.9.0</a> - 2015-10-14)
in the core with 32 additional files that
implement the <a href="fts3.html">FTS3</a>, <a href="fts5.html">FTS5</a>, <a href="rtree.html">RTREE</a>, <a href="dbstat.html">DBSTAT</a>, <a href="json1.html">JSON1</a>, and
<a href="rbu.html">RBU</a> extensions.
Of the 102
main source files, about 75% are C code and about 25% are C header files.
Most of these are "source" files in the sense that they are stored
in the <a href="https://www.sqlite.org/src">SQLite version control system</a>
and are edited manually in an ordinary text editor.
But some of the C-language files are generated using scripts
or auxiliary programs. For example, the
<a href="https://www.sqlite.org/src/artifact?ci=trunk&filename=src/parse.y">parse.y</a>
file contains an LALR(1) grammar of the SQL language which is compiled
down into are parser in files "parse.c" and "parse.h" by the
<a href="lemon.html">Lemon parser generator</a>.
</p>
<p>The makefiles for SQLite have an "sqlite3.c" target for building the
file we call "the amalgamation".
The amalgamation is a single C code file, named "sqlite3.c",
that contains all C code
for the core SQLite library and the <a href="fts3.html">FTS3</a>, <a href="fts5.html">FTS5</a>, <a href="rtree.html">RTREE</a>,
<a href="dbstat.html">DBSTAT</a>, <a href="json1.html">JSON1</a>, and <a href="rbu.html">RBU</a> extensions.
This file contains about 184K lines of code
(113K if you omit blank lines and comments) and is over 6.4 megabytes
in size.
Though the various extensions are included in the
"sqlite3.c" amalgamation file, they are disabled using #ifdef statements.
Activate the extensions using <a href="compile.html">compile-time options</a> like:
</p><ul>
<li> <a href="compile.html#enable_fts3">-DSQLITE_ENABLE_FTS3</a>
</li><li> <a href="compile.html#enable_fts5">-DSQLITE_ENABLE_FTS5</a>
</li><li> <a href="compile.html#enable_rtree">-DSQLITE_ENABLE_RTREE</a>
</li><li> <a href="compile.html#enable_dbstat_vtab">-DSQLITE_ENABLE_DBSTAT_VTAB</a>
</li><li> <a href="compile.html#enable_json1">-DSQLITE_ENABLE_JSON1</a>
</li><li> <a href="compile.html#enable_rbu">-DSQLITE_ENABLE_RBU</a>
</li></ul>
<p>The amalgamation contains everything you need to integrate SQLite
into a larger project. Just copy the amalgamation into your source
directory and compile it along with the other C code files in your project.
(A <a href="howtocompile.html">more detailed discussion</a> of the compilation process is
available.)
You may also want to make use of the "sqlite3.h" header file that
defines the programming API for SQLite.
The sqlite3.h header file is available separately.
The sqlite3.h file is also contained within the amalgamation, in
the first few thousand lines. So if you have a copy of
sqlite3.c but cannot seem to locate sqlite3.h, you can always
regenerate the sqlite3.h by copying and pasting from the amalgamation.</p>
<p>In addition to making SQLite easier to incorporate into other
projects, the amalgamation also makes it run faster. Many
compilers are able to do additional optimizations on code when
it is contained with in a single translation unit such as it
is in the amalgamation. We have measured performance improvements
of between 5 and 10% when we use the amalgamation to compile
SQLite rather than individual source files. The downside of this
is that the additional optimizations often take the form of
function inlining which tends to make the size of the resulting
binary image larger.</p>
<a name="amal32k"></a>
<h1 id="the_split_amalgamation"><span>3. </span>The Split Amalgamation</h1>
<p>Developers sometimes experience trouble debugging the
185,000-line-long amalgamation source file because some debuggers
are only able to handle source code line numbers less than 32,768.
The amalgamation source code runs fine. One just cannot single-step
through it in a debugger.
</p><p>To circumvent this limitation, the amalgamation is also available in
a split form, consisting of files "sqlite3-1.c", "sqlite3-2.c", and
so forth, where each file is less than 32,768 lines in length and
where the concatenation of the files contain all of the code for the
complete amalgamation. Then there is a separate source file named
"sqlite3-all.c" which basically consists of code like this:
</p><div class="codeblock"><pre>#include "sqlite3-1.c"
#include "sqlite3-2.c"
#include "sqlite3-3.c"
#include "sqlite3-4.c"
#include "sqlite3-5.c"
#include "sqlite3-6.c"
#include "sqlite3-7.c"
</pre></div>
<p>Applications using the split amalgamation simply compile against
"sqlite3-all.c" instead of "sqlite3.c". The two files work exactly
the same. But with "sqlite3-all.c", no single source file contains more
than 32,767 lines of code, and so it is more convenient to use some
debuggers. The downside of the split amalgamation is that it consists
of 6 C source code files instead of just 1.
</p><h1 id="download_copies_of_the_amalgamation"><span>4. </span>Download Copies Of The Amalgamation</h1>
<p>The amalgamation and
the sqlite3.h header file are available on
the <a href="download.html">download page</a> as a file
named sqlite-amalgamation-X.zip
where the X is replaced by the appropriate version number.</p>
<a name="amalgbuild"></a>
<h1 id="building_the_amalgamation_from_canonical_source_code"><span>5. </span>Building The Amalgamation From Canonical Source Code</h1>
<p>To build the amalgamation (either the full amalgamation or the
split amalgamation), first
<a href="getthecode.html">get the canonical source code</a> from one of the three servers.
Then, on both unix-like systems and on Windows systems that have the
free <a href="http://mingw.org/wiki/msys">MinGW</a> development environment
installed, the amalgamation can be built using the
following commands:
</p><div class="codeblock"><pre>sh configure
make sqlite3.c
</pre></div>
<p>To build using Microsoft Visual C++, run this command:
</p><div class="codeblock"><pre>nmake /f makefile.msc sqlite3.c
</pre></div>
<p>In both cases, the split amalgamation can be obtained by
substituting "sqlite3-all.c" for "sqlite3.c" as the make target.
</p><h2 id="dependencies"><span>5.1. </span>Dependencies</h2>
<p>The build process makes extensive use of the
<a href="http://www.tcl-lang.org/">Tcl</a> scripting language. You will need to have a
copy of TCL installed in order for the make targets above to work.
Easy-to-use installers can be obtained from <a href="http://www.tcl-lang.org/">http://www.tcl-lang.org/</a>.
Many unix workstations have Tcl installed by default.
</p><h2 id="see_also"><span>5.2. </span>See Also</h2>
<p>Additional notes on compiling SQLite can be found on the
<a href="howtocompile.html">How To Compile SQLite</a> page.
</p>

View File

@ -0,0 +1,532 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite As An Application File Format</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<h1 align="center">
SQLite As An Application File Format
</h1>
<h2>Executive Summary</h2>
<p>An SQLite database file with a defined schema
often makes an excellent application file format.
Here are a dozen reasons why this is so:
<ol>
<li> Simplified Application Development
<li> Single-File Documents
<li> High-Level Query Language
<li> Accessible Content
<li> Cross-Platform
<li> Atomic Transactions
<li> Incremental And Continuous Updates
<li> Easily Extensible
<li> Performance
<li> Concurrent Use By Multiple Processes
<li> Multiple Programming Languages
<li> Better Applications
</ol>
<p>Each of these points will be described in more detail below,
after first considering more closely the meaning of
"application file format". See also the <a href="aff_short.html">short version</a> of this
whitepaper.
<h2>What Is An Application File Format?</h2>
<p>
An "application file format" is the file format
used to persist application state to disk or to exchange
information between programs.
There are thousands of application file formats in use today.
Here are just a few examples:
<ul>
<li>DOC - Word Perfect and Microsoft Office documents
<li>DWG - AutoCAD drawings
<li>PDF - Portable Document Format from Adobe
<li>XLS - Microsoft Excel Spreadsheet
<li>GIT - Git source code repository
<li>EPUB - The Electronic Publication format used by non-Kindle eBooks
<li>ODT - The Open Document format used by OpenOffice and others
<li>PPT - Microsoft PowerPoint presentations
<li>ODP - The Open Document presentation format used by OpenOffice and others
</ul>
<p>We make a distinction between a "file format" and an "application format".
A file format is used to store a single object. So, for example, a GIF or
JPEG file stores a single image, and an XHTML file stores text,
so those are "file formats" and not "application formats". An EPUB file,
in contrast, stores both text and images (as contained XHTML and GIF/JPEG
files) and so it is considered an "application format". This article is
about "application formats".
<p>The boundary between a file format and an application format is fuzzy.
This article calls JPEG a file format, but for an image editor, JPEG
might be considered the application format. Much depends on context.
For this article, let us say that a file format stores a single object
and an application format stores many different objects and their relationships
to one another.
<p>Most application formats fit into one of these three categories:
<ol>
<li><p><b>Fully Custom Formats.</b>
Custom formats are specifically designed for a single application.
DOC, DWG, PDF, XLS, and PPT are examples of custom formats. Custom
formats are usually contained within a single file, for ease of transport.
They are also usually binary, though the DWG format is a notable exception.
Custom file formats require specialized application code
to read and write and are not normally accessible from commonly
available tools such as unix command-line programs and text editors.
In other words, custom formats are usually "opaque blobs".
To access the content of a custom application file format, one needs
a tool specifically engineered to read and/or write that format.
<li><p><b>Pile-of-Files Formats.</b>
Sometimes the application state is stored as a hierarchy of
files. Git is a prime example of this, though the phenomenon occurs
frequently in one-off and bespoke applications. A pile-of-files format
essentially uses the filesystem as a key/value database, storing small
chunks of information into separate files. This gives the
advantage of making the content more accessible to common utility
programs such as text editors or "awk" or "grep". But even if many
of the files in a pile-of-files format
are easily readable, there are usually some files that have their
own custom format (example: Git "Packfiles") and are hence
"opaque blobs" that are not readable
or writable without specialized tools. It is also much less convenient
to move a pile-of-files from one place or machine to another, than
it is to move a single file. And it is hard to make a pile-of-files
document into an email attachment, for example. Finally, a pile-of-files
format breaks the "document metaphor":
there is no one file that a user can point to
that is "the document".
<li><p><b>Wrapped Pile-of-Files Formats.</b>
Some applications use a Pile-of-Files that is then encapsulated into
some kind of single-file container, usually a ZIP archive.
EPUB, ODT,and ODP are examples of this approach.
An EPUB book is really just a ZIP archive that contains various
XHTML files for the text of book chapters, GIF and JPEG images for
the artwork, and a specialized catalog file that tells the eBook
reader how all the XML and image files fit together. OpenOffice
documents (ODT and ODP) are also ZIP archives containing XML and
images that represent their content as well as "catalog" files that
show the interrelationships between the component parts.
<p>A wrapped pile-of-files format is a compromise between a full
custom file format and a pure pile-of-files format.
A wrapped pile-of-files format is not an opaque blob in the same sense
as a custom format, since the component parts can still be accessed
using any common ZIP archiver, but the format is not quite as accessible
as a pure pile-of-files format because one does still need the ZIP
archiver, and one cannot normally use command-line tools like "find"
on the file hierarchy without first un-zipping it. On the other
hand, a wrapped pile-of-files format does preserve the document
metaphor by putting all content into a single disk file. And
because it is compressed, the wrapped pile-of-files format tends to
be more compact.
<p>As with custom file formats, and unlike pure pile-of-file formats,
a wrapped pile-of-files format is not as easy to edit, since
usually the entire file must be rewritten in order to change any
component part.
</ol>
<p>The purpose of this document is to argue in favor of a fourth
new category of application file format: An SQLite database file.
<h2>SQLite As The Application File Format</h2>
<p>
Any application state that can be recorded in a pile-of-files can
also be recorded in an SQLite database with a simple key/value schema
like this:
<blockquote><pre>
CREATE TABLE files(filename TEXT PRIMARY KEY, content BLOB);
</pre></blockquote>
If the content is compressed, then such an <a href="sqlar.html">SQLite Archive</a> database is
<a href="affcase1.html#smaller">the same size</a> (&#177;1%)
as an equivalent ZIP archive, and it has the advantage
of being able to update individual "files" without rewriting
the entire document.
<p>
But an SQLite database is not limited to a simple key/value structure
like a pile-of-files database. An SQLite database can have dozens
or hundreds or thousands of different tables, with dozens or
hundreds or thousands of fields per table, each with different datatypes
and constraints and particular meanings, all cross-referencing each other,
appropriately and automatically indexed for rapid retrieval,
and all stored efficiently and compactly in a single disk file.
And all of this structure is succinctly documented for humans
by the SQL schema.
<p>In other words, an SQLite database can do everything that a
pile-of-files or wrapped pile-of-files format can do, plus much more,
and with greater lucidity.
An SQLite database is a more versatile container than key/value
filesystem or a ZIP archive. (For a detailed example, see the
<a href="affcase1.html">OpenOffice case study</a> essay.)
<p>The power of an SQLite database could, in theory, be achieved using
a custom file format. But any custom file format that is as expressive
as a relational database would likely require an enormous design specification
and many tens or hundreds of thousands of lines of code to
implement. And the end result would be an "opaque blob" that is
inaccessible without specialized tools.
<p>
Hence, in comparison to other approaches, the use of
an SQLite database as an application file format has
compelling advantages. Here are a few of these advantages,
enumerated and expounded:
</p>
<ol>
<li><p><b>Simplified Application Development.</b>
No new code is needed for reading or writing the application file.
One has merely to link against the SQLite library, or include the
<a href="amalgamation.html">single "sqlite3.c" source file</a> with the rest of the
application C code, and SQLite will take care of all of the application
file I/O. This can reduce application code size by many thousands of
lines, with corresponding saving in development and maintenance costs.
<p>SQLite is one of the
<a href="mostdeployed.html">most used</a> software libraries in the world.
There are literally tens of billions of SQLite database files in use
daily, on smartphones and gadgets and in desktop applications.
SQLite is <a href="testing.html">carefully tested</a> and proven reliable. It is not
a component that needs much tuning or debugging, allowing developers
to stay focused on application logic.
<li><p><b>Single-File Documents.</b>
An SQLite database is contained in a single file, which is easily
copied or moved or attached. The "document" metaphor is preserved.
<p>SQLite does not have any file naming requirements
and so the application can use any custom file suffix that it wants
to help identify the file as "belonging" to the application.
SQLite database files contain a 4-byte <a href="fileformat2.html#appid">Application ID</a> in
their headers that can be set to an application-defined value
and then used to identify the "type" of the document for utility
programs such as <a href="http://linux.die.net/man/1/file">file(1)</a>, further
enhancing the document metaphor.
<li><p><b>High-Level Query Language.</b>
SQLite is a complete relational database engine, which means that the
application can access content using high-level queries. Application
developers need not spend time thinking about "how" to retrieve the
information they need from a document. Developers write SQL that
expresses "what" information they want and let the database engine
to figure out how to best retrieve that content. This helps developers
operate "heads up" and remain focused on solving the user's problem,
and avoid time spent "heads down" fiddling with low-level file
formatting details.
<p>A pile-of-files format can be viewed as a key/value database.
A key/value database is better than no database at all.
But without transactions or indices or a high-level query language or
a proper schema,
it is much harder and more error prone to use a key/value database than
a relational database.
<li><p><b>Accessible Content.</b>
Information held in an SQLite database file is accessible using
commonly available open-source command-line tools - tools that
are installed by default on Mac and Linux systems and that are
freely available as a self-contained EXE file on Windows.
Unlike custom file formats, application-specific programs are
not required to read or write content in an SQLite database.
An SQLite database file is not an opaque blob. It is true
that command-line tools such as text editors or "grep" or "awk" are
not useful on an SQLite database, but the SQL query language is a much
more powerful and convenient way for examining the content, so the
inability to use "grep" and "awk" and the like is not seen as a loss.
<p>An SQLite database is a <a href="fileformat2.html">well-defined and well-documented</a>
file format that is in widespread use by literally millions of applications
and is backwards compatible to its inception in 2004 and which promises
to continue to be compatible in decades to come. The longevity of
SQLite database files is particularly important to bespoke applications,
since it allows the document content to be accessed far in the
future, long after all traces of the original application have been lost.
Data lives longer than code.
SQLite databases are <a href="locrsf.html">recommended by the US Library of Congress</a>
as a storage format for long-term preservation of digital content.
<li><p><b>Cross-Platform.</b>
SQLite database files are portable between 32-bit and 64-bit machines and
between big-endian and little-endian architectures and between any of the
various flavors of Windows and Unix-like operating systems.
The application using an SQLite application file format can store
binary numeric data without having to worry about the byte-order of
integers or floating point numbers.
Text content can be read or written as UTF-8, UTF-16LE, or UTF-16BE and
SQLite will automatically perform any necessary translations on-the-fly.
<li><p><b>Atomic Transactions.</b>
Writes to an SQLite database are <a href="atomiccommit.html">atomic</a>.
They either happen completely
or not at all, even during system crashes or power failures. So
there is no danger of corrupting a document just because the power happened
to go out at the same instant that a change was being written to disk.
<p>SQLite is transactional, meaning that multiple changes can be grouped
together such that either all or none of them occur, and so that the
changes can be rolled back if a problem is found prior to commit.
This allows an application to make a change incrementally, then run
various sanity and consistency checks on the resulting data prior to
committing the changes to disk. The
<a href="http://www.fossil-scm.org/">Fossil</a> DVCS
<a href="http://www.fossil-scm.org/fossil/doc/tip/www/selfcheck.wiki">uses this technique</a>
to verify that no repository history has been lost prior to each change.
<li><p><b>Incremental And Continuous Updates.</b>
When writing to an SQLite database file, only those parts of the file that
actually change are written out to disk. This makes the writing happen faster
and saves wear on SSDs. This is an enormous advantage over custom
and wrapped pile-of-files formats, both of which usually require a
rewrite of the entire document in order to change a single byte.
Pure pile-of-files formats can also
do incremental updates to some extent, though the granularity of writes is
usually larger with pile-of-file formats (a single file) than with SQLite
(a single page).
<p>SQLite also supports continuous update.
Instead of collecting changes in memory and then writing
them to disk only on a File/Save action, changes can be written back to
the disk as they occur. This avoids loss of work on a system crash or
power failure. An <a href="undoredo.html">automated undo/redo stack</a>, managed using triggers,
can be kept in the on-disk database, meaning that undo/redo can occur
across session boundaries.
<li><p><b>Easily Extensible.</b>
As an application grows, new features can be added to an
SQLite application file format simply by adding new tables to the schema
or by adding new columns to existing tables. Adding columns or tables
does not change the meaning of prior queries, so with a
modicum of care to ensuring that the meaning of legacy columns and
tables are preserved, backwards compatibility is maintained.
<p>It is possible to extend custom or pile-of-files formats too, of course,
but doing is often much harder. If indices are added, then all application
code that changes the corresponding tables must be located and modified to
keep those indices up-to-date. If columns are added, then all application
code that accesses the corresponding table must be located and modified to
take into account the new columns.
<li><p><b>Performance.</b>
In many cases, an SQLite application file format will be
<a href="fasterthanfs.html">faster than a pile-of-files format</a> or
a custom format. In addition to being faster for raw read and
writes, SQLite can often dramatically improves start-up times because
instead of having to
read and parse the entire document into memory, the application can
do queries to extract only the information needed for the initial screen.
As the application progresses, it only needs to load as much material as
is needed to draw the next screen, and can discard information from
prior screens that is no longer in use. This helps keep the memory
footprint of the application under control.
<p>A pile-of-files format can be read incrementally just like SQLite.
But many developers are surprised to learn that SQLite can read and
write smaller BLOBs (less than about 100KB in size) from its database
faster than those same blobs can be read or written as separate files
from the filesystem. (See
<a href="fasterthanfs.html">35% Faster Than The Filesystem</a> and
<a href="intern-v-extern-blob.html">Internal Versus External BLOBs</a> for further information.)
There is overhead associated with operating a relational
database engine, however one should not assume that direct file I/O
is faster than SQLite database I/O, as often it is not.
<p>In either case, if performance problems do arise in an SQLite application
those problems can often be resolved by adding one or two <a href="lang_createindex.html">CREATE INDEX</a>
statements to the schema or perhaps running <a href="lang_analyze.html">ANALYZE</a> one time
and without having to touch a single line of
application code. But if a performance problem comes up in a custom or
pile-of-files format, the fix will often require extensive changes
to application code to add and maintain new indices or to extract
information using different algorithms.
<li><p><b>Concurrent Use By Multiple Processes.</b>
SQLite automatically coordinates concurrent access to the same
document from multiple threads and/or processes. Two or more
applications can connect and read from the same document at the
same time. Writes are serialized, but as writes normally only
take milliseconds, applications simply take turns writing.
SQLite automatically ensures that the low-level format of the
document is uncorrupted. Accomplishing the same with a custom
or pile-of-files format, in contrast, requires extensive support
in the application. And the application logic needed to support
concurrency is a notorious bug-magnet.
<li><p><b>Multiple Programming Languages.</b>
Though SQLite is itself written in ANSI-C, interfaces exist for
just about every other programming language you can think of:
C++, C#, Objective-C, Java, Tcl, Perl, Python, Ruby, Erlang,
JavaScript, and so forth. So programmers can develop in whatever
language they are most comfortable with and which best matches
the needs of the project.
<p>An SQLite application file format is a great
choice in cases where there is a collection or "federation" of
separate programs, often written in different languages and by
different development teams.
This comes up commonly in research or laboratory
environments where one team is responsible for data acquisition
and other teams are responsible for various stages of analysis.
Each team can use whatever hardware, operating system,
programming language and development methodology that they are
most comfortable with, and as long as all programs use an SQLite
database with a common schema, they can all interoperate.
<li><p><b>Better Applications.</b>
If the application file format is an SQLite database, the complete
documentation for that file format consists of the database schema,
with perhaps a few extra words about what each table and column
represents. The description of a custom file format,
on the other hand, typically runs on for hundreds of
pages. A pile-of-files format, while much simpler and easier to
describe than a fully custom format, still tends to be much larger
and more complex than an SQL schema dump, since the names and format
for the individual files must still be described.
<p>This is not a trivial point. A clear, concise, and easy to understand
file format is a crucial part of any application design.
Fred Brooks, in his all-time best-selling computer science text,
<i>The Mythical Man-Month</i> says:
<blockquote><i>Representation is the
essence of computer programming.<br />...<br />
Show me your flowcharts and conceal your tables, and I shall
continue to be mystified. Show me your tables, and I won't usually
need your flowcharts; they'll be obvious.</i></blockquote>
<p>Rob Pike, in his
<i>Rules of Programming</i> expresses the same idea this way:
<blockquote>
<i>Data dominates. If you've chosen the right data structures
and organized things well, the algorithms will almost always
be self-evident. Data structures, not algorithms, are central
to programming.</i></blockquote>
<p> Linus Torvalds used different words to say
much the same thing on the Git mailing list on 2006-06-27:
<blockquote>
<i>Bad programmers worry about the code. Good programmers worry
about data structures and their relationships.</i>
</blockquote>
<p>The point is this: an SQL database schema almost always does
a far better job of defining and organizing the tables and
data structures and their relationships.
And having clear, concise, and well-defined representation
almost always results in an application that performs better,
has fewer problems, and is easier to develop and maintain.
</ol>
<h2>Conclusion</h2>
<p>
SQLite is not the perfect application file format for every situation.
But in many cases, SQLite is a far better choice than either a custom
file format, a pile-of-files, or a wrapped pile-of-files.
SQLite is a high-level, stable, reliable, cross-platform, widely-deployed,
extensible, performant, accessible, concurrent file format. It deserves
your consideration as the standard file format on your next application
design.

View File

@ -0,0 +1,541 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Application-Defined SQL Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Application-Defined SQL Functions
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#executive_summary">1. Executive Summary</a></div>
<div class="fancy-toc1"><a href="#defining_new_sql_functions">2. Defining New SQL Functions</a></div>
<div class="fancy-toc2"><a href="#common_parameters">2.1. Common Parameters</a></div>
<div class="fancy-toc2"><a href="#multiple_calls_to_sqlite3_create_function_for_the_same_function">2.2. Multiple Calls To sqlite3_create_function() For The Same Function</a></div>
<div class="fancy-toc2"><a href="#callbacks">2.3. Callbacks</a></div>
<div class="fancy-toc3"><a href="#the_scalar_function_callback">2.3.1. The Scalar Function Callback</a></div>
<div class="fancy-toc3"><a href="#the_aggregate_function_callbacks">2.3.2. The Aggregate Function Callbacks</a></div>
<div class="fancy-toc3"><a href="#the_window_function_callbacks">2.3.3. The Window Function Callbacks</a></div>
<div class="fancy-toc3"><a href="#examples">2.3.4. Examples</a></div>
<div class="fancy-toc1"><a href="#security_implications">3. Security Implications</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>
<h1 id="executive_summary"><span>1. </span>Executive Summary</h1>
<p>Applications that use SQLite can define custom SQL functions that call
back into application code to compute their results. The custom SQL
function implementations can be embedded in the application code itself,
or can be <a href="loadext.html">loadable extensions</a>.
</p><p>Application-defined or custom SQL functions are created using the
<a href="c3ref/create_function.html">sqlite3_create_function()</a> family of interfaces.
Custom SQL functions can be scalar functions, aggregate functions,
or <a href="windowfunctions.html">window functions</a>.
Custom SQL functions can have any number of arguments from 0 up to
<a href="limits.html#max_function_arg">SQLITE_MAX_FUNCTION_ARG</a>.
The <a href="c3ref/create_function.html">sqlite3_create_function()</a> interface specifies callbacks that are
invoked to carry out the processing for the new SQL function.
</p><p>SQLite also supports custom <a href="vtab.html#tabfunc2">table-valued functions</a>, but they are
implemented by a different mechanism that is not covered in this document.
</p><h1 id="defining_new_sql_functions"><span>2. </span>Defining New SQL Functions</h1>
<p>
The <a href="c3ref/create_function.html">sqlite3_create_function()</a> family of interfaces is used to create
new custom SQL functions. Each member of this family is a wrapper around
a common core. All family members accomplish the same thing; they merely
have different calling signatures.
</p><ul>
<li><p><b><a href="c3ref/create_function.html">sqlite3_create_function()</a></b> &rarr;
The original version of sqlite3_create_function() allows the application
to create a single new SQL function that can be either a scalar or an
aggregate. The name of the function is specified using UTF8.
</p></li><li><p><b><a href="c3ref/create_function.html">sqlite3_create_function16()</a></b> &rarr;
This variant works exactly like the sqlite3_create_function() original
except that the name of the function itself is specified as a UTF16
string rather than as a UTF8 string.
</p></li><li><p><b><a href="c3ref/create_function.html">sqlite3_create_function_v2()</a></b> &rarr;
This variant works like the original sqlite3_create_function() except
that it includes an additional parameter that is a pointer to a
destructor for the <a href="c3ref/user_data.html">sqlite3_user_data()</a> pointer that is passed in
as the 5th argument to all of the sqlite3_create_function() variants.
That destructor function (if it is non-NULL) is called when the
custom function is deleted - usually when the database connection is
closing.
</p></li><li><p><b><a href="c3ref/create_function.html">sqlite3_create_window_function()</a></b> &rarr;
This variant works like the original sqlite3_create_function() except
that it accepts a different set of callback pointers - the callback
pointers used by <a href="windowfunctions.html">window function</a> definitions.
</p></li></ul>
<h2 id="common_parameters"><span>2.1. </span>Common Parameters</h2>
<p>Many of the parameters passed to the <a href="c3ref/create_function.html">sqlite3_create_function()</a>
family of interfaces are common across the entire family.
</p><ol>
<li><p><b>db</b> &rarr;
The 1st parameter is always a pointer to the <a href="c3ref/sqlite3.html">database connection</a>
on which the custom SQL function will work. Custom SQL functions are
created separately for each database connection. There is no short-hand
mechanism for creating SQL functions that work across all database
connections.
</p></li><li><p><b>zFunctionName</b> &rarr;
The 2nd parameter is the name of the SQL function that is being
created. The name is usually in UTF8, except that the name should
be in UTF16 in the native byte order for <a href="c3ref/create_function.html">sqlite3_create_function16()</a>.
</p><p>
The maximum length of a SQL function name is 255 bytes of UTF8.
Any attempt to create a function with a longer name will result in
an <a href="rescode.html#misuse">SQLITE_MISUSE</a> error.
</p>
The SQL function creation interfaces may be called multiple
times with the same function name.
If two calls have the same function number but a different number of
arguments, for example, then two variants of the SQL function will
be registered, each taking a different number of arguments.
</li><li><p><b>nArg</b> &rarr;
The 3rd parameter is always the number of arguments that the function
accepts. The value must be an integer between -1 and
<a href="limits.html#max_function_arg">SQLITE_MAX_FUNCTION_ARG</a> (default value: 127). A value of -1 means
that the SQL function is a variadic function that can take any number
of arguments between 0 and <a href="limits.html#max_function_arg">SQLITE_MAX_FUNCTION_ARG</a>.
</p></li><li><p><b>eTextRep</b> &rarr;
The 4th parameter is a 32-bit integer flag whose bits convey various
properties about the new function. The original purpose of this
parameter was to specify the preferred text encoding for the function,
using one of the following constants:
</p><ul>
<li> <a href="c3ref/c_any.html">SQLITE_UTF8</a>
</li><li> <a href="c3ref/c_any.html">SQLITE_UTF16BE</a>
</li><li> <a href="c3ref/c_any.html">SQLITE_UTF16LE</a>
</li></ul>
All custom SQL functions will accept text in any encoding. Encoding
conversions will happen automatically. The preferred encoding merely
specifies the encoding for which the function implementation is optimized.
It is possible to specify multiple functions with the same name and the
same number of arguments, but different preferred encodings and different
callbacks used to implement the function, and SQLite will chose the
set of callbacks for which the input encodings most closely match the
preferred encoding.
<p>
The 4th parameter as more recently be extended with additional flag bits
to convey additional information about the function. The additional
bits include:
</p><ul>
<li> <a href="c3ref/c_deterministic.html#sqlitedeterministic">SQLITE_DETERMINISTIC</a>
</li><li> <a href="c3ref/c_deterministic.html#sqlitedirectonly">SQLITE_DIRECTONLY</a>
</li><li> <a href="c3ref/c_deterministic.html#sqliteinnocuous">SQLITE_INNOCUOUS</a>
</li><li> <a href="c3ref/c_deterministic.html#sqlitesubtype">SQLITE_SUBTYPE</a>
</li></ul>
<p>
Additional bits may be added in future versions of SQLite.
</p></li><li><p><b>pApp</b> &rarr;
The 5th parameter is an arbitrary pointer that is passed through
into the callback routines. SQLite itself does nothing with this
pointer, except to make it available to the callbacks, and to pass
it into the destructor when the function is unregistered.
</p></li></ol>
<h2 id="multiple_calls_to_sqlite3_create_function_for_the_same_function"><span>2.2. </span>Multiple Calls To sqlite3_create_function() For The Same Function</h2>
<p>
It is common for an application to invoke sqlite3_create_function() multiple
times for the same SQL function. For example, if an SQL function can take
either 2 or 3 arguments, then sqlite3_create_function() would be invoked
once for the 2-argument version and a second time for the 3-argument version.
The underlying implementation (the callbacks) can be different for both
variants.
</p><p>
An application can also register multiple SQL functions with the same name
and same number of arguments, but a different preferred text encoding.
In that case, SQLite will invoke the function using the callbacks for
the version whose preferred text encoding most closely matches the database
text encoding. In this way, multiple implementations of the same function
can be provided that are optimized for UTF8 or UTF16.
</p><p>
If multiple calls to sqlite3_create_function() specify the same function name,
and the same number of arguments, and the same preferred text encoding, then
the callbacks and other parameters of the second call overwrite the first,
and the destructor callback from the first call (if it exists) is invoked.
</p><h2 id="callbacks"><span>2.3. </span>Callbacks</h2>
<p>
SQLite evaluates an SQL function by invoking callback routines.
</p><h3 id="the_scalar_function_callback"><span>2.3.1. </span>The Scalar Function Callback</h3>
<p>Scalar SQL functions are implemented by a single callback in the
<b>xFunc</b> parameter to sqlite3_create_function().
The following code demonstrations the implementation of a "noop(X)"
scalar SQL function that merely returns its argument:
</p><div class="codeblock"><pre>static void noopfunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
assert( argc==1 );
sqlite3_result_value(context, argv&#91;0&#93;);
}
</pre></div>
<p>
The 1st parameter, <b>context</b>, is a pointer to an opaque object
that describes the content from which the SQL function was invoked. This
context point becomes the first parameter to many other routines that
the function implement might to invoke, including:
<div class='columns' style='columns: 15em auto;'>
<ul style='padding-top:0;'>
<li><a href='c3ref/aggregate_context.html'>sqlite3_aggregate_context</a></li>
<li><a href='c3ref/context_db_handle.html'>sqlite3_context_db_handle</a></li>
<li><a href='c3ref/get_auxdata.html'>sqlite3_get_auxdata</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_blob</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_blob64</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_double</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_error</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_error16</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_error_code</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_error_nomem</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_error_toobig</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_int</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_int64</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_null</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_pointer</a></li>
<li><a href='c3ref/result_subtype.html'>sqlite3_result_subtype</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_text</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_text16</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_text16be</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_text16le</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_text64</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_value</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_zeroblob</a></li>
<li><a href='c3ref/result_blob.html'>sqlite3_result_zeroblob64</a></li>
<li><a href='c3ref/get_auxdata.html'>sqlite3_set_auxdata</a></li>
<li><a href='c3ref/user_data.html'>sqlite3_user_data</a></li>
</ul>
</div>
</p><p>The <a href="c3ref/result_blob.html">sqlite3_result() family of functions</a> are
used to specify the result of the scalar SQL function. One or more of
these should be invoked by the callback to set the function return value.
If none of these routines are invoked for a specific callback, then the
return value will be NULL.
</p><p>The <a href="c3ref/user_data.html">sqlite3_user_data()</a> routine returns a copy of the <b>pArg</b>
pointer that was given to <a href="c3ref/create_function.html">sqlite3_create_function()</a> when the SQL
function was created.
</p><p>The <a href="c3ref/context_db_handle.html">sqlite3_context_db_handle()</a> routine returns a pointer to the
<a href="c3ref/sqlite3.html">database connection</a> object.
</p><p>The <a href="c3ref/aggregate_context.html">sqlite3_aggregate_context()</a> routine is used only in the
implementations of aggregate and window functions. Scalar functions
may not use <a href="c3ref/aggregate_context.html">sqlite3_aggregate_context()</a>. The <a href="c3ref/aggregate_context.html">sqlite3_aggregate_context()</a>
function is included in the interface list only for completeness.
</p><p>
The 2nd and 3rd arguments to the scalar SQL function implemenetation,
<b>argc</b> and <b>argv</b>, are
the number of arguments to the SQL function itself and the values for
each argument of the SQL function.
Argument values can be of any datatype and are thus stored in
instances of the <a href="c3ref/value.html">sqlite3_value</a> object.
Specific C-language values can be extracted from this object using
the <a href="c3ref/value_blob.html">sqlite3_value() family of interfaces</a>.
</p><h3 id="the_aggregate_function_callbacks"><span>2.3.2. </span>The Aggregate Function Callbacks</h3>
<p>Aggregate SQL functions are implemented by using two callback
functions, <b>xStep</b> and <b>xFinal</b>. The xStep() function
is called for each row of the aggregate and the xFinal() function
is invoked to compute the final answer at the end.
The following (slightly simplified) version of the built-in
count() function illustrates:
</p><div class="codeblock"><pre>typedef struct CountCtx CountCtx;
struct CountCtx {
i64 n;
};
static void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){
CountCtx *p;
p = sqlite3_aggregate_context(context, sizeof(*p));
if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv}; hd_resolve_one {0}; hd_puts {)) && p ){
p->n++;
}
}
static void countFinalize(sqlite3_context *context){
CountCtx *p;
p = sqlite3_aggregate_context(context, 0);
sqlite3_result_int64(context, p ? p->n : 0);
}
</pre></div>
<p>Recall that there are two versions of the count() aggregate.
With zero arguments, count() returns a count of the number of rows.
With one argument, count() returns the number of times that the
argument was non-NULL.
</p><p>The countStep() callback is invoked once for each row in the aggregate.
As you can see, the count is incremented if either there are no arguments,
or if the one argument is not NULL.
</p><p>The step function for an aggregate should always begin with a call
to the <a href="c3ref/aggregate_context.html">sqlite3_aggregate_context()</a> routine to fetch the persistent
state of the aggregate function. On the first invocation of the step()
function, the aggregate context is initialized to a block of memory
that is N bytes in size, where N is the second parameter to
sqlite3_aggregate_context() and that memory is zeroed. On all subsequent
calls to the step() function, the same block of memory is returned.
Except, sqlite3_aggregate_context() might return NULL in the case of
an out-of-memory error, so aggregate functions should be prepared to
deal with that case.
</p><p>After all rows are processed the countFinalize() routine is called
exactly once. This routine computes the final result and invokes
one of the <a href="c3ref/result_blob.html">sqlite3_result()</a> family of functions
to set the final result. The aggregate context will be freed automatically
by SQLite, though the xFinalize() routine must clean up any substructure
associated with the aggregate context before it returns. If the xStep()
method is called one or more times, then SQLite guarantees thta the
xFinal() method will be called at once, even if the query aborts.
</p><h3 id="the_window_function_callbacks"><span>2.3.3. </span>The Window Function Callbacks</h3>
<p><a href="windowfunctions.html">Window functions</a> use the same xStep() and xFinal() callbacks that
aggregate functions use, plus two others: <b>xValue</b> and <b>xInverse</b>.
See the documentation on
<a href="windowfunctions.html#udfwinfunc">application-defined window functions</a> for further details.
</p><h3 id="examples"><span>2.3.4. </span>Examples</h3>
<p>There are dozens and dozens of SQL function implementations scattered
throughout the SQLite source code that can be used as example applications.
The built-in SQL functions use the same interface as application-defined
SQL functions, so built-in functions can be used as examples too.
Search for "sqlite3_context" in the SQLite source code to find examples.
<a name="sec"></a>
</p><h1 id="security_implications"><span>3. </span>Security Implications</h1>
<p>
Application-defined SQL functions can become security vulnerabilities if
not carefully managed. Suppose, for example, an application defines
a new "system(X)" SQL function that runs its argument X as a command and
returns the integer result code. Perhaps the implementation is like this:
</p><div class="codeblock"><pre>static void systemFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
const char *zCmd = (const char*)sqlite3_value_text(argv}; hd_resolve_one {0}; hd_puts {);
if( zCmd!=0 ){
int rc = system(zCmd);
sqlite3_result_int(context, rc);
}
}
</pre></div>
<p>
This is a function with powerful side-effects. Most programmers would
be naturally cautious about using it, but probably would not see the
harm in merely having it available. But there is great risk in merely
defining such a function, even if the application itself never invokes
it!
</p><p>
Suppose the application normally does a query against table TAB1
when it starts up. If an attacker can gain access to the database
file and modify the schema like this:
</p><div class="codeblock"><pre>ALTER TABLE tab1 RENAME TO tab1_real;
CREATE VIEW tab1 AS SELECT * FROM tab1 WHERE system('rm -rf *') IS NOT NULL;
</pre></div>
<p>
Then, when the application attempts to open the database, register the
system() function, then run an innocent query against the "tab1" table,
it instead deletes all the files in its working directory. Yikes!
</p><p>
To prevent this kind of mischief, applications that create their own
custom SQL functions should take one or more of the following safety
precautions. The more precautions taken the better:
</p><ol>
<li><p>
Invoke <a href="c3ref/db_config.html">sqlite3_db_config</a>(db,<a href="c3ref/c_dbconfig_defensive.html#sqlitedbconfigtrustedschema">SQLITE_DBCONFIG_TRUSTED_SCHEMA</a>,0,0)
on each <a href="c3ref/sqlite3.html">database connection</a> as soon as it is opened.
This prevents application-defined functions from being used in places
where an attacker might be able to surreptiously invoke them by modifying
a database schema:
</p><ul>
<li> In in VIEWs.
</li><li> In in TRIGGERSs.
</li><li> In CHECK constraints of a table definition.
</li><li> In DEFAULT constraints of a table definition.
</li><li> In the definitions of generated columns.
</li><li> In the expression part of an index on an expression.
</li><li> In the WHERE clause of a partial index.
</li></ul>
<p>
To put it another way, this setting requires that application-defined
functions only be run directly by top-level SQL invoked from the application
itself, not as a consequence of doing some other innocent-looking query.
</p></li><li><p>
Use the <a href="pragma.html#pragma_trusted_schema">PRAGMA trusted_schema=OFF</a> SQL statement to disable trusted
schema. This has the same effect as the previous bullet, but does not
require the use of C-code and hence can be performed in programs written
in another programming language and that do not have access SQLite
C-language APIs.
</p></li><li><p>
Compile SQLite using the <a href="compile.html#trusted_schema">-DSQLITE_TRUSTED_SCHEMA=0</a> compile-time option.
This make SQLite distrust application-defined functions inside of
the schema by default.
</p></li><li><p>
If any application-defined SQL functions have potentially dangerous
side-effects, or if they could potentially leak sensitive information
to an attacker if misused, then tag those functions using the
<a href="c3ref/c_deterministic.html#sqlitedirectonly">SQLITE_DIRECTONLY</a> option on the "enc" parameter. This means
that the function can never be run from schema-code even if the
trusted-schema option is on.
</p></li><li><p>
Never tag an application-defined SQL function with <a href="c3ref/c_deterministic.html#sqliteinnocuous">SQLITE_INNOCUOUS</a>
unless you really need to and you have checked the implementation closely
and are certain that it can do no harm even if it falls under the
control of an attacker.
</p></li></ol>

View File

@ -0,0 +1,332 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Architecture of SQLite</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Architecture of SQLite
</div>
</div>
<h1>Introduction</h1>
<p>This document describes the architecture of the SQLite library.
The information here is useful to those who want to understand or
modify the inner workings of SQLite.
</p>
<div class="rightsidebar border2px imgcontainer">
<img src="images/arch2.gif"></img>
</div>
<p>
A nearby diagram shows the main components of SQLite
and how they interoperate. The text below
explains the roles of the various components.
</p>
<h1>Overview</h1>
<p>SQLite works by compiling SQL text into <a href="opcode.html">bytecode</a>, then running
that bytecode using a virtual machine.
<p>The <a href="c3ref/prepare.html">sqlite3_prepare_v2()</a> and related interfaces act as a compiler
for converting SQL text into bytecode. The <a href="c3ref/stmt.html">sqlite3_stmt</a> object is
a container for a single bytecode program using to implement a single
SQL statement. The <a href="c3ref/step.html">sqlite3_step()</a> interface passes a bytecode program
into the virtual machine, and runs the program until it either completes,
or forms a row of result to be returned, or hits a fatal error, or is
<a href="c3ref/interrupt.html">interrupted</a>.
<h1>Interface</h1>
<p>Much of the <a href="c3ref/intro.html">C-language Interface</a> is found in source
files <a href='https://sqlite.org/src/file/src/main.c'>main.c</a>, <a href='https://sqlite.org/src/file/src/legacy.c'>legacy.c</a>, and
<a href='https://sqlite.org/src/file/src/vdbeapi.c'>vdbeapi.c</a>
though some routines are
scattered about in other files where they can have access to data
structures with file scope.
The <a href="c3ref/free_table.html">sqlite3_get_table()</a> routine is implemented in <a href='https://sqlite.org/src/file/src/table.c'>table.c</a>.
The <a href="c3ref/mprintf.html">sqlite3_mprintf()</a> routine is found in <a href='https://sqlite.org/src/file/src/printf.c'>printf.c</a>.
The <a href="c3ref/complete.html">sqlite3_complete()</a> interface is in <a href='https://sqlite.org/src/file/src/complete.c'>complete.c</a>.
The <a href="tclsqlite.html">TCL Interface</a> is implemented by <a href='https://sqlite.org/src/file/src/tclsqlite.c'>tclsqlite.c</a>.
<p>To avoid name collisions, all external
symbols in the SQLite library begin with the prefix <b>sqlite3</b>.
Those symbols that are intended for external use (in other words,
those symbols which form the API for SQLite) add an underscore, and
thus begin with <b>sqlite3_</b>. Extension APIs sometimes add the
extension name prior to the underscore; for example:
<b>sqlite3rbu_</b> or <b>sqlite3session_</b>.</p>
<h1>Tokenizer</h1>
<p>When a string containing SQL statements is to be evaluated it is
first sent to the tokenizer.
The tokenizer breaks
the SQL text into tokens and hands those tokens
one by one to the parser. The tokenizer is hand-coded in
the file <file>tokenize.c</b>.
<p>Note that in this design, the tokenizer calls the parser. People
who are familiar with YACC and BISON may be accustomed to doing things the
other way around &mdash; having the parser call the tokenizer. Having
the tokenizer call the parser is better, though, because it can be made
threadsafe and it runs faster.</p>
<h1>Parser</h1>
<p>The parser assigns meaning to tokens based on
their context. The parser for SQLite is generated using the
<a href="lemon.html">Lemon parser generator</a>.
Lemon does the same job as YACC/BISON, but it uses
a different input syntax which is less error-prone.
Lemon also generates a parser which is reentrant and thread-safe.
And Lemon defines the concept of a non-terminal destructor so
that it does not leak memory when syntax errors are encountered.
The grammar file that drives Lemon and that defines the SQL language
that SQLite understands is found in <a href='https://sqlite.org/src/file/src/parse.y'>parse.y</a>.
<p>Because
Lemon is a program not normally found on development machines, the
complete source code to Lemon (just one C file) is included in the
SQLite distribution in the "tool" subdirectory.
</p>
<h1>Code Generator</h1>
<p>After the parser assembles tokens into a parse tree,
the code generator runs to analyze the parser tree and generate
<a href="opcode.html">bytecode</a> that performs the work of the SQL statement.
The <a href="c3ref/stmt.html">prepared statement</a> object is a container for this bytecode.
There are many files in the code generator, including:
<a href='https://sqlite.org/src/file/src/attach.c'>attach.c</a>,
<a href='https://sqlite.org/src/file/src/auth.c'>auth.c</a>,
<a href='https://sqlite.org/src/file/src/build.c'>build.c</a>,
<a href='https://sqlite.org/src/file/src/delete.c'>delete.c</a>,
<a href='https://sqlite.org/src/file/src/expr.c'>expr.c</a>,
<a href='https://sqlite.org/src/file/src/insert.c'>insert.c</a>,
<a href='https://sqlite.org/src/file/src/pragma.c'>pragma.c</a>,
<a href='https://sqlite.org/src/file/src/select.c'>select.c</a>,
<a href='https://sqlite.org/src/file/src/trigger.c'>trigger.c</a>,
<a href='https://sqlite.org/src/file/src/update.c'>update.c</a>,
<a href='https://sqlite.org/src/file/src/vacuum.c'>vacuum.c</a>,
<a href='https://sqlite.org/src/file/src/where.c'>where.c</a>,
<a href='https://sqlite.org/src/file/src/wherecode.c'>wherecode.c</a>, and
<a href='https://sqlite.org/src/file/src/whereexpr.c'>whereexpr.c</a>.
In these files is where most of the serious magic happens.
<a href='https://sqlite.org/src/file/src/expr.c'>expr.c</a> handles code generation for expressions.
<b>where*.c</b> handles code generation for WHERE clauses on
SELECT, UPDATE and DELETE statements. The files <a href='https://sqlite.org/src/file/src/attach.c'>attach.c</a>,
<a href='https://sqlite.org/src/file/src/delete.c'>delete.c</a>, <a href='https://sqlite.org/src/file/src/insert.c'>insert.c</a>, <a href='https://sqlite.org/src/file/src/select.c'>select.c</a>,
<a href='https://sqlite.org/src/file/src/trigger.c'>trigger.c</a>
<a href='https://sqlite.org/src/file/src/update.c'>update.c</a>, and <a href='https://sqlite.org/src/file/src/vacuum.c'>vacuum.c</a> handle the code generation
for SQL statements with the same names. (Each of these files calls routines
in <a href='https://sqlite.org/src/file/src/expr.c'>expr.c</a> and <a href='https://sqlite.org/src/file/src/where.c'>where.c</a> as necessary.) All other
SQL statements are coded out of <a href='https://sqlite.org/src/file/src/build.c'>build.c</a>.
The <a href='https://sqlite.org/src/file/src/auth.c'>auth.c</a> file implements the functionality of
<a href="c3ref/set_authorizer.html">sqlite3_set_authorizer()</a>.</p>
<p>The code generator, and especially the logic in <b>where*.c</b>
and in <a href='https://sqlite.org/src/file/src/select.c'>select.c</a>, is sometimes called the
<a href="optoverview.html">query planner</a>. For any particular SQL statement, there might be
hundreds, thousands, or millions of different algorithms to compute
the answer. The query planner is an AI that strives to select the
best algorithm from these millions of choices.
<h1>Bytecode Engine</h1>
<p>The <a href="opcode.html">bytecode</a> program created by the code generator is run by
a virtual machine.
<p>The virtual machine itself is entirely contained in a single
source file <a href='https://sqlite.org/src/file/src/vdbe.c'>vdbe.c</a>. The
<a href='https://sqlite.org/src/file/src/vdbe.h'>vdbe.h</a> header file defines an interface
between the virtual machine and the rest of the SQLite library and
<a href='https://sqlite.org/src/file/src/vdbeInt.h'>vdbeInt.h</a> which defines structures and interfaces that
are private the virtual machine itself.
Various other <b>vdbe*.c</b> files are helpers to the virtual machine.
The <a href='https://sqlite.org/src/file/src/vdbeaux.c'>vdbeaux.c</a> file contains utilities used by the virtual
machine and interface modules used by the rest of the library to
construct VM programs. The <a href='https://sqlite.org/src/file/src/vdbeapi.c'>vdbeapi.c</a> file contains external
interfaces to the virtual machine such as the
<a href="c3ref/bind_blob.html">sqlite3_bind_int()</a> and <a href="c3ref/step.html">sqlite3_step()</a>. Individual values
(strings, integer, floating point numbers, and BLOBs) are stored
in an internal object named "Mem" which is implemented by
<a href='https://sqlite.org/src/file/src/vdbemem.c'>vdbemem.c</a>.</p>
<p>
SQLite implements SQL functions using callbacks to C-language routines.
Even the built-in SQL functions are implemented this way. Most of
the built-in SQL functions (ex: <a href="lang_corefunc.html#abs">abs()</a>, <a href="lang_aggfunc.html#count">count()</a>,
<a href="lang_corefunc.html#substr">substr()</a>, and so forth) can be found in <a href='https://sqlite.org/src/file/src/func.c'>func.c</a> source
file.
Date and time conversion functions are found in <a href='https://sqlite.org/src/file/src/date.c'>date.c</a>.
Some functions such as <a href="lang_corefunc.html#coalesce">coalesce()</a> and <a href="lang_corefunc.html#typeof">typeof()</a> are implemented
as bytecode directly by the code generator.
</p>
<h1>B-Tree</h1>
<p>An SQLite database is maintained on disk using a B-tree implementation
found in the <a href='https://sqlite.org/src/file/src/btree.c'>btree.c</a> source file. A separate B-tree is used for
each table and index in the database. All B-trees are stored in the
same disk file. The <a href="fileformat2.html">file format</a> details are stable and well-defined and
are guaranteed to be compatible moving forward.</p>
<p>The interface to the B-tree subsystem and the rest of the SQLite library
is defined by the header file <a href='https://sqlite.org/src/file/src/btree.h'>btree.h</a>.
</p>
<h1>Page Cache</h1>
<p>The B-tree module requests information from the disk in fixed-size
pages. The default <a href="pragma.html#pragma_page_size">page_size</a> is 4096 bytes but can be any power of
two between 512 and 65536 bytes.
The page cache is responsible for reading, writing, and
caching these pages.
The page cache also provides the rollback and atomic commit abstraction
and takes care of locking of the database file. The
B-tree driver requests particular pages from the page cache and notifies
the page cache when it wants to modify pages or commit or rollback
changes. The page cache handles all the messy details of making sure
the requests are handled quickly, safely, and efficiently.</p>
<p>The primary page cache implementation is in the
<a href='https://sqlite.org/src/file/src/pager.c'>pager.c</a> file. <a href="wal.html">WAL mode</a> logic is in the separate
<a href='https://sqlite.org/src/file/src/wal.c'>wal.c</a>. In-memory caching is implemented by the
<a href='https://sqlite.org/src/file/src/pcache.c'>pcache.c</a> and <a href='https://sqlite.org/src/file/src/pcache1.c'>pcache1.c</a> files.
The interface between page cache subsystem
and the rest of SQLite is defined by the header file <a href='https://sqlite.org/src/file/src/pager.h'>pager.h</a>.
</p>
<h1>OS Interface</h1>
<p>
In order to provide portability between across operating systems,
SQLite uses abstract object called the <a href="vfs.html">VFS</a>. Each VFS provides methods
for opening, read, writing, and closing files on disk, and for other
OS-specific task such as finding the current time, or obtaining randomness
to initialize the built-in pseudo-random number generator.
SQLite currently provides VFSes for unix (in the <a href='https://sqlite.org/src/file/src/os_unix.c'>os_unix.c</a>
file) and Windows (in the <a href='https://sqlite.org/src/file/src/os_win.c'>os_win.c</a> file).
</p>
<h1>Utilities</h1>
<p>
Memory allocation, caseless string comparison routines,
portable text-to-number conversion routines, and other utilities
are located in <a href='https://sqlite.org/src/file/src/util.c'>util.c</a>.
Symbol tables used by the parser are maintained by hash tables found
in <a href='https://sqlite.org/src/file/src/hash.c'>hash.c</a>. The <a href='https://sqlite.org/src/file/src/utf.c'>utf.c</a> source file contains Unicode
conversion subroutines.
SQLite has its own private implementation of
<a href="printf.html">printf()</a> (with
some extensions) in <a href='https://sqlite.org/src/file/src/printf.c'>printf.c</a> and its own
pseudo-random number generator (PRNG) in <a href='https://sqlite.org/src/file/src/random.c'>random.c</a>.
</p>
<h1>Test Code</h1>
<p>
Files in the "src/" folder of the source tree whose names begin with
<b>test</b> are for testing only and are not included in a standard
build of the library.
</p>

View File

@ -0,0 +1,345 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>The Use Of assert() In SQLite</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
The Use Of assert() In SQLite
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#assert_and_similar_macros_in_sqlite">1. Assert() And Similar Macros In SQLite</a></div>
<div class="fancy-toc2"><a href="#philosophy_of_assert_">1.1. Philosophy of assert()</a></div>
<div class="fancy-toc2"><a href="#different_behaviors_according_to_build_type">1.2. Different Behaviors According To Build Type</a></div>
<div class="fancy-toc1"><a href="#examples">2. Examples</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>
<h1 id="assert_and_similar_macros_in_sqlite"><span>1. </span>Assert() And Similar Macros In SQLite</h1>
<p>
The assert(X) macro is
<a href="https://en.wikipedia.org/wiki/Assert.h">part of standard C</a>, in the
&lt;assert.h&gt; header file.
SQLite adds three other assert()-like macros named NEVER(X), ALWAYS(X),
and testcase(X).
</p><ul>
<li><p><b>assert(X)</b> &rarr;
The assert(X) statement indicates that the condition X is always true.
In other words, X is an invariant. The assert(X) macro works like a
procedure in that it has no return value.
</p></li><li><p><b>ALWAYS(X)</b> &rarr;
The ALWAYS(X) function indicates that condition X is always true as far
as the developers know, but there is no proof the X is true, or the
proof is complex and error-prone, or the proof depends on implementation
details that are likely to change in the future. ALWAYS(X) behaves like
a function that returns the boolean value X, and is intended to be used
within the conditional of an "if" statement.
</p></li><li><p><b>NEVER(X)</b> &rarr;
The NEVER(X) function indicates that condition X is never true. This
is the negative analog of the ALWAYS(X) function.
</p></li><li><p><b>testcase(X)</b> &rarr;
The testcase(X) statement indicates that X is sometimes true and sometimes
false. In other words, testcase(X) indicates that X is definitely not an
invariant. Since SQLite uses 100% <a href="testing.html#mcdc">MC/DC testing</a>, the presence of a
testcase(X) macro indicates that not only is it possible for X to be either
true or false, but there are test cases to demonstrate this.
</p></li></ul>
<p>
SQLite version 3.22.0 (2018-01-22) contains 5290 assert() macros,
839 testcase() macros, 88 ALWAYS() macros, and 63 NEVER() macros.
</p><h2 id="philosophy_of_assert_"><span>1.1. </span>Philosophy of assert()</h2>
<p>In SQLite, the presence of assert(X) means that the developers have
a proof that X is always true. Readers can depend upon X being true to
help them reason about the code. An assert(X) is a strong statement
about the truth of X. There is no doubt.
</p><p>The ALWAYS(X) and NEVER(X) macros are a weaker statement about the
truth of X. The presence of ALWAYS(X) or NEVER(X) means that the developers
believe X is always or never true, but there is no proof, or the proof
is complex and error-prone, or the proof depends on other aspects
of the system that seem likely to change.
</p><p>Other systems sometimes use assert(X) in a way that is
similar to the use of ALWAYS(X) or NEVER(X) in SQLite.
Developers will add an assert(X) as a
<a href="https://blog.regehr.org/archives/1576">tacit acknowledgement that they
do not fully believe that X is always true</a>.
We believe that this use of assert(X) is wrong and violates the intent
and purpose of having assert(X) available in C in the first place.
An assert(X) should not be seen as a safety-net or top-rope used to
guard against mistakes. Nor is assert(X) appropriate for defense-in-depth.
An ALWAYS(X) or NEVER(X) macro, or something similar, should be used in
those cases because ALWAYS(X) or NEVER(X) will be followed by code to
actually deal with the problem when the programmers reasoning
turns out to be wrong. Since the code that follows ALWAYS(X) or NEVER(X)
is untested, it should be something very simple, like a "return" statement,
that is easily verified by inspection.
</p><p>
Because assert() can be and is commonly misused, some programming language
theorists and designers look upon it with disfavor.
For example, the designers of the <a href="https://golang.org">Go programming language</a>
intentionally <a href="https://golang.org/doc/faq#assertions">omit a built-in assert()</a>.
They feel that the harm caused by misuse of assert()
outweighs the benefits of including it as a language built-in.
The SQLite developers disagree. In fact, the original purpose of this
article is to push back against the common notion that assert() is harmful.
In our experience, SQLite would be much more difficult to develop, test,
and maintain without assert().
</p><h2 id="different_behaviors_according_to_build_type"><span>1.2. </span>Different Behaviors According To Build Type</h2>
<p>Three separate builds are used to validate the SQLite software.
</p><ol>
<li> A functionality testing build is used to validate the source code.
</li><li> A coverage testing build is used to validate the test suite, to confirm
that the test suite provides 100% MC/DC.
</li><li> The release build is used to validate the generated machine code.
</li></ol>
<p>All tests must give the same answer in all three
builds. See the <a href="testing.html">"How SQLite Is Tested"</a> document for more detail.
</p><p>The various assert()-like
macros behave differently according to how SQLite is built.
</p><table striped="1" style="margin:1em auto; width:80%; border-spacing:0">
<tr style="text-align:left"><th></th><th>Functionality Testing</th><th>Coverage Testing</th><th>Release</th></tr>
<tr style="text-align:left;background-color:#DDDDDD"><th valign="top">assert(X)
</th><td>abort() if X is false
</td><td>no-op
</td><td>no-op
</td></tr>
<tr style="text-align:left"><th valign="top">ALWAYS(X)
</th><td>abort() if X is false
</td><td>always true
</td><td>pass through the value X
</td></tr>
<tr style="text-align:left;background-color:#DDDDDD"><th valign="top">NEVER(X)
</th><td>abort() if X is true
</td><td>always false
</td><td>pass through the value X
</td></tr>
<tr style="text-align:left"><th valign="top">testcase(X)
</th><td>no-op
</td><td>do some harmless work if X is true
</td><td>no-op
</td></tr>
</table>
<p>The default behavior of assert(X) in standard C is that it is enabled
for release builds. This is a reasonable default. However, the
SQLite code base has many assert() statements in performance-sensitive
areas of the code. Leaving assert(X) turned on causes SQLite to run about
three times slower. Also, SQLite strives to provide 100% MC/DC in an
as-delivered configuration, which is obviously impossible if assert(X)
statements are enabled. For these reasons, assert(X) is a no-op for
release builds in SQLite.
</p><p>The ALWAYS(X) and NEVER(X) macros behave like assert(X) during
functionality testing, because the developers want to be immediately
alerted to the issue if the value of X is different from what is expected.
But for delivery, ALWAYS(X) and NEVER(X) are simple pass-through macros,
which provide defense-in-depth. For coverage testing ALWAYS(X) and NEVER(X)
are hard-coded boolean values so that they do not cause unreachable
machine code to be generated.
</p><p>The testcase(X) macro is normally a no-op, but for a coverage test
build it does generate a small amount of extra code that includes at least
one branch, in order to verify that test cases exist for which X is both
true and false.
</p><h1 id="examples"><span>2. </span>Examples</h1>
<p>An assert() statement is often used to validate pre-conditions on
internal functions and methods.
Example: <a href="https://sqlite.org/src/artifact/c1e97e4c6f?ln=1048">https://sqlite.org/src/artifact/c1e97e4c6f?ln=1048</a>.
This is deemed better than simply stating the pre-condition in a header
comment, since the assert() is actually executed. In a highly tested
program like SQLite, the reader knows that the pre-condition is true
for all of the hundreds of millions of test cases run against SQLite,
since it has been verified by the assert().
In contrast, a text pre-condition statement in a header comment
is untested. It might have been true when the code was written,
but who is to say that it is still true now?
</p><p>
Sometimes SQLite uses compile-time evaluatable assert() statements.
Consider the code at
<a href="https://sqlite.org/src/artifact/c1e97e4c6f?ln=2130-2138">https://sqlite.org/src/artifact/c1e97e4c6f?ln=2130-2138</a>.
Four assert() statements verify the values for compile-time constants
so that the reader can quickly check the validity of the if-statement
that follows, without having to look up the constant values in a separate
header file.
</p><p>
Sometimes compile-time assert() statements are used to verify that
SQLite has been correctly compiled. For example, the code at
<a href="https://sqlite.org/src/artifact/c1e97e4c6f?ln=157">https://sqlite.org/src/artifact/c1e97e4c6f?ln=157</a>
verifies that the SQLITE_PTRSIZE preprocessor macro is set correctly
for the target architecture.
</p><p>
The CORRUPT_DB macro is used in many assert() statements.
In functional testing builds, CORRUPT_DB references a global variable
that is true if the database file might contain corruption. This variable
is true by default, since we do not normally know whether or not a database
is corrupt, but during testing while working on databases that are known
to be well-formed, that global variable can be set to false.
Then the CORRUPT_DB macro
can be used in assert() statements such as seen at
<a href="https://sqlite.org/src/artifact/18a53540aa3?ln=1679-1680">https://sqlite.org/src/artifact/18a53540aa3?ln=1679-1680</a>.
Those assert()s specify pre-conditions to the routine that are true for
consistent database files, but which might be false if the database file
is corrupt. Knowledge of these kinds of conditions is very helpful to
readers who are trying to understand a block of code in isolation.
</p><p>
ALWAYS(X) and NEVER(X) functions are used in places where we always
want the test to occur even though the developers believe the value of
X is always true or false. For example, the sqlite3BtreeCloseCursor()
routine shown must remove the closing cursor from a linked list of all
cursors. We know that the cursor is on the list, so that the loop
must terminate by the "break" statement, but it is convenient to
use the ALWAYS(X) test at
<a href="https://sqlite.org/src/artifact/18a53540aa3?ln=4371">https://sqlite.org/src/artifact/18a53540aa3?ln=4371</a> to prevent
running off the end of the linked list in case there is an error in some
other part of the code that has corrupted the linked list.
</p><p>
An ALWAYS(X) or NEVER(X) sometimes verifies pre-conditions that are
subject to change if other parts of the code are modified in
subtle ways. At <a href="https://sqlite.org/src/artifact/18a53540aa3?ln=5512-5516">https://sqlite.org/src/artifact/18a53540aa3?ln=5512-5516</a>
we have a test for two pre-conditions that are true only because
of the limited scope of use of the sqlite3BtreeRowCountEst() function.
Future enhancements to SQLite might use sqlite3BtreeRowCountEst() in
new ways where those preconditions no longer hold, and the NEVER()
macros will quickly alert the developers to that fact when the
situation arises. But if, for some reason, the pre-conditions are
not satisfied in a release build, the program will still behave sanely
and will not do an undefined memory access.
</p><p>
The testcase() macro is often used to verify that boundary
cases of an inequality comparison are checked. For example, at
<a href="https://sqlite.org/src/artifact/18a53540aa3?ln=5766">https://sqlite.org/src/artifact/18a53540aa3?ln=5766</a>. These
kind of checks help to prevent off-by-one errors.
</p>

View File

@ -0,0 +1,272 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>An Asynchronous I/O Module For SQLite</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<h1 align="center">An Asynchronous I/O Module For SQLite</h1>
<hr>
<p><font size=+1><b>NOTE:</b>
<a href="wal.html">WAL mode</a> with <a href="pragma.html#pragma_synchronous">PRAGMA synchronous</a> set to NORMAL avoids calls to
fsync() during transaction commit and only invokes fsync() during
a <a href="wal.html#ckpt">checkpoint</a> operation. The use of <a href="wal.html">WAL mode</a> largely obviates the
need for this asynchronous I/O module. Hence, this module is no longer
supported. The source code continues to exist in the SQLite source tree,
but it is not a part of any standard build and is no longer maintained.
This documentation is retained for historical reference.</font></p><hr>
<p>Normally, when SQLite writes to a database file, it waits until the write
operation is finished before returning control to the calling application.
Since writing to the file-system is usually very slow compared with CPU
bound operations, this can be a performance bottleneck. The asynchronous I/O
backend is an extension that causes SQLite to perform all write requests
using a separate thread running in the background. Although this does not
reduce the overall system resources (CPU, disk bandwidth etc.), it does
allow SQLite to return control to the caller quickly even when writing to
the database.
<h2>1.0 FUNCTIONALITY</h2>
<p>With asynchronous I/O, write requests are handled by a separate thread
running in the background. This means that the thread that initiates
a database write does not have to wait for (sometimes slow) disk I/O
to occur. The write seems to happen very quickly, though in reality
it is happening at its usual slow pace in the background.
<p>Asynchronous I/O appears to give better responsiveness, but at a price.
You lose the Durable property. With the default I/O backend of SQLite,
once a write completes, you know that the information you wrote is
safely on disk. With the asynchronous I/O, this is not the case. If
your program crashes or if a power loss occurs after the database
write but before the asynchronous write thread has completed, then the
database change might never make it to disk and the next user of the
database might not see your change.
<p>You lose Durability with asynchronous I/O, but you still retain the
other parts of ACID: Atomic, Consistent, and Isolated. Many
applications get along fine without the Durability.
<h3>1.1 How it Works</h3>
<p>Asynchronous I/O works by creating an SQLite <a href="c3ref/vfs.html">VFS object</a>
and registering it with <a href="c3ref/vfs_find.html">sqlite3_vfs_register()</a>.
When files opened via
this VFS are written to (using the vfs xWrite() method), the data is not
written directly to disk, but is placed in the "write-queue" to be
handled by the background thread.
<p>When files opened with the asynchronous VFS are read from
(using the vfs xRead() method), the data is read from the file on
disk and the write-queue, so that from the point of view of
the vfs reader the xWrite() appears to have already completed.
<p>The asynchronous I/O VFS is registered (and unregistered) by calls to the
API functions sqlite3async_initialize() and sqlite3async_shutdown().
See section "Compilation and Usage" below for details.
<h3>1.2 Limitations</h3>
<p>In order to gain experience with the main ideas surrounding asynchronous
IO, this implementation is deliberately kept simple. Additional
capabilities may be added in the future.
<p>For example, as currently implemented, if writes are happening at a
steady stream that exceeds the I/O capability of the background writer
thread, the queue of pending write operations will grow without bound.
If this goes on for long enough, the host system could run out of memory.
A more sophisticated module could to keep track of the quantity of
pending writes and stop accepting new write requests when the queue of
pending writes grows too large.
<h3>1.3 Locking and Concurrency</h3>
<p>Multiple connections from within a single process that use this
implementation of asynchronous IO may access a single database
file concurrently. From the point of view of the user, if all
connections are from within a single process, there is no difference
between the concurrency offered by "normal" SQLite and SQLite
using the asynchronous backend.
<p>If file-locking is enabled (it is enabled by default), then connections
from multiple processes may also read and write the database file.
However concurrency is reduced as follows:
<ul>
<li><p> When a connection using asynchronous IO begins a database
transaction, the database is locked immediately. However the
lock is not released until after all relevant operations
in the write-queue have been flushed to disk. This means
(for example) that the database may remain locked for some
time after a "<a href="lang_transaction.html">COMMIT</a>" or "<a href="lang_transaction.html">ROLLBACK</a>" is issued.
<li><p> If an application using asynchronous IO executes transactions
in quick succession, other database users may be effectively
locked out of the database. This is because when a <a href="lang_transaction.html">BEGIN</a>
is executed, a database lock is established immediately. But
when the corresponding COMMIT or ROLLBACK occurs, the lock
is not released until the relevant part of the write-queue
has been flushed through. As a result, if a COMMIT is followed
by a BEGIN before the write-queue is flushed through, the database
is never unlocked,preventing other processes from accessing
the database.
</ul>
<p>File-locking may be disabled at runtime using the sqlite3async_control()
API (see below). This may improve performance when an NFS or other
network file-system, as the synchronous round-trips to the server be
required to establish file locks are avoided. However, if multiple
connections attempt to access the same database file when file-locking
is disabled, application crashes and database corruption is a likely
outcome.
<h2>2.0 COMPILATION AND USAGE</h2>
<p>
The asynchronous IO extension consists of a single file of C code
(sqlite3async.c), and a header file (sqlite3async.h), located in the
<a href="http://www.sqlite.org/src/dir?name=ext/async">
<tt>ext/async/</tt> subfolder</a> of the SQLite source tree, that defines the
C API used by applications to activate and control the modules
functionality.
<p>
To use the asynchronous IO extension, compile sqlite3async.c as
part of the application that uses SQLite. Then use the APIs defined
in sqlite3async.h to initialize and configure the module.
<p>
The asynchronous IO VFS API is described in detail in comments in
sqlite3async.h. Using the API usually consists of the following steps:
<ol>
<li><p>Register the asynchronous IO VFS with SQLite by calling the
sqlite3async_initialize() function.
<li><p>Create a background thread to perform write operations and call
sqlite3async_run().
<li><p>Use the normal SQLite API to read and write to databases via
the asynchronous IO VFS.
</ol>
<p>Refer to comments in the
<a href="http://www.sqlite.org/src/finfo?name=ext/async/sqlite3async.h">
sqlite3async.h header file</a> for details.
<h2>3.0 PORTING</h2>
<p>Currently the asynchronous IO extension is compatible with win32 systems
and systems that support the pthreads interface, including Mac OS X, Linux,
and other varieties of Unix.
<p>To port the asynchronous IO extension to another platform, the user must
implement mutex and condition variable primitives for the new platform.
Currently there is no externally available interface to allow this, but
modifying the code within sqlite3async.c to include the new platforms
concurrency primitives is relatively easy. Search within sqlite3async.c
for the comment string "PORTING FUNCTIONS" for details. Then implement
new versions of each of the following:
<blockquote><pre>
static void async_mutex_enter(int eMutex);
static void async_mutex_leave(int eMutex);
static void async_cond_wait(int eCond, int eMutex);
static void async_cond_signal(int eCond);
static void async_sched_yield(void);
</pre></blockquote>
<p>The functionality required of each of the above functions is described
in comments in sqlite3async.c.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,245 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Autoincrement</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
SQLite Autoincrement
</div>
</div>
<h1 id="summary"><span>1. </span>Summary</h1>
<ol type="1">
<li><p>
The AUTOINCREMENT keyword imposes extra CPU, memory, disk space,
and disk I/O overhead and should be avoided if not strictly needed.
It is usually not needed.
</p></li><li><p>
In SQLite, a column with type INTEGER PRIMARY KEY is an alias for the <a href="lang_createtable.html#rowid">ROWID</a>
(except in <a href="withoutrowid.html">WITHOUT ROWID</a> tables) which is always a 64-bit signed integer.
</p></li><li><p>
On an <a href="lang_insert.html">INSERT</a>, if the ROWID or INTEGER PRIMARY KEY column is not
explicitly given a value, then it
will be filled automatically with an unused integer, usually
one more than the largest ROWID currently in use.
This is true regardless of whether or not the AUTOINCREMENT keyword is used.
</p></li><li><p>
If the AUTOINCREMENT keyword appears after INTEGER PRIMARY KEY, that
changes the automatic ROWID assignment algorithm to prevent
the reuse of ROWIDs over the lifetime of the database. In other words,
the purpose of AUTOINCREMENT is to prevent the reuse of ROWIDs from
previously deleted rows.
</p></li></ol>
<h1 id="background"><span>2. </span>Background</h1>
<p>
In SQLite, table rows normally have a 64-bit signed integer <a href="lang_createtable.html#rowid">ROWID</a>
which is unique among all rows in the same table.
(<a href="withoutrowid.html">WITHOUT ROWID</a> tables are the exception.)
</p>
<p>
You can access the ROWID of an SQLite table using one of the special column
names ROWID, _ROWID_, or OID.
Except if you declare an ordinary table column to use one of those special
names, then the use of that name will refer to the declared column not
to the internal ROWID.
</p>
<p>
If a table contains a column of type <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>, then that
column becomes an alias for the ROWID. You can then access the ROWID
using any of four different names, the original three names described above
or the name given to the <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a> column. All these names are
aliases for one another and work equally well in any context.
</p>
<p>
When a new row is inserted into an SQLite table, the ROWID can either
be specified as part of the INSERT statement or it can be assigned
automatically by the database engine. To specify a ROWID manually,
just include it in the list of values to be inserted. For example:
</p>
<div class="codeblock"><pre>CREATE TABLE test1(a INT, b TEXT);
INSERT INTO test1(rowid, a, b) VALUES(123, 5, 'hello');
</pre></div>
<p>
If no ROWID is specified on the insert, or if the specified ROWID has a value
of NULL, then an appropriate ROWID is created
automatically. The usual algorithm is to give the newly created row
a ROWID that is one larger than the largest ROWID in the table prior
to the insert. If the table is initially empty, then a ROWID of 1 is
used. If the largest ROWID is equal to the largest possible integer
(9223372036854775807) then the database
engine starts picking positive candidate ROWIDs at random until it finds one
that is not previously used.
If no unused ROWID can be found after a reasonable number of attempts,
the insert operation fails with an <a href="rescode.html#full">SQLITE_FULL</a> error.
If no negative ROWID values are inserted explicitly, then automatically
generated ROWID values will always be greater than zero.
</p>
<p>
The normal ROWID selection algorithm described above
will generate monotonically increasing
unique ROWIDs as long as you never use the maximum ROWID value and you never
delete the entry in the table with the largest ROWID.
If you ever delete rows or if you ever create a row with the maximum possible
ROWID, then ROWIDs from previously deleted rows might be reused when creating
new rows and newly created ROWIDs might not be in strictly ascending order.
</p>
<h1 id="the_autoincrement_keyword"><span>3. </span>The AUTOINCREMENT Keyword</h1>
<p>
If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT then a slightly
different ROWID selection algorithm is used.
The ROWID chosen for the new row is at least one larger than the largest ROWID
that has ever before existed in that same table. If the table has never
before contained any data, then a ROWID of 1 is used. If the largest possible
ROWID has previously been inserted, then
new INSERTs are not allowed and any attempt to insert a new row will
fail with an SQLITE_FULL error.
Only ROWID values from previous transactions that
were committed are considered. ROWID values that were rolled back
are ignored and can be reused.
</p>
<p>
SQLite keeps track of the largest ROWID
using an <a href="fileformat2.html#intschema">internal table</a> named "<a href="fileformat2.html#seqtab">sqlite_sequence</a>".
The sqlite_sequence table is created
and initialized automatically whenever a normal table that contains an
AUTOINCREMENT column is created. The content of the sqlite_sequence table
can be modified using ordinary UPDATE, INSERT, and DELETE statements.
But making modifications to this table will likely perturb the AUTOINCREMENT
key generation algorithm. Make sure you know what you are doing before
you undertake such changes.
The sqlite_sequence table does not track ROWID changes associated with
UPDATE statement, only INSERT statements.
</p>
<p>
The behavior implemented by the AUTOINCREMENT keyword is subtly different
from the default behavior. With AUTOINCREMENT, rows with automatically
selected ROWIDs are guaranteed to have ROWIDs that have never been used
before by the same table in the same database. And the automatically generated
ROWIDs are guaranteed to be monotonically increasing. These are important
properties in certain applications. But if your application does not
need these properties, you should probably stay with the default behavior
since the use of AUTOINCREMENT requires additional work to be done
as each row is inserted and thus causes INSERTs to run a little slower.
</p>
<p>Note that "monotonically increasing" does not imply that the ROWID always
increases by exactly one. One is the usual increment. However, if an
insert fails due to (for example) a uniqueness constraint, the ROWID of
the failed insertion attempt might not be reused on subsequent inserts,
resulting in gaps in the ROWID sequence. AUTOINCREMENT guarantees that
automatically chosen ROWIDs will be increasing but not that they will be
sequential.</p>
<p>Because AUTOINCREMENT keyword changes the behavior of the ROWID selection
algorithm, AUTOINCREMENT is not allowed on <a href="withoutrowid.html">WITHOUT ROWID</a> tables or on any
table column other than INTEGER PRIMARY KEY. Any attempt to use
AUTOINCREMENT on a <a href="withoutrowid.html">WITHOUT ROWID</a> table or on a column other than the
INTEGER PRIMARY KEY column results in an error.</p>

View File

@ -0,0 +1,462 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>SQLite Backup API</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<style>
/* Formatting for the blocks containing the example code */
pre a:visited, pre a:link { text-decoration: none ; color: #40534b }
pre {
background: #F3F3F3;
float: right;
padding: 1ex 2ex;
margin-left: 1em;
border: solid black 1px;
}
h1,h2 { clear: both }
</style>
<div class=fancy>
<h1>Using the SQLite Online Backup API</h1>
<p>
Historically, backups (copies) of SQLite databases have been created
using the following method:
<ol>
<li> Establish a shared lock on the database file using the SQLite API (i.e.
the shell tool).
<li> Copy the database file using an external tool (for example the unix 'cp'
utility or the DOS 'copy' command).
<li> Relinquish the shared lock on the database file obtained in step 1.
</ol>
<p>
This procedure works well in many scenarios and is usually very
fast. However, this technique has the following shortcomings:
<ul>
<li> Any database clients wishing to write to the database file while a
backup is being created must wait until the shared lock is
relinquished.
<li> It cannot be used to copy data to or from in-memory databases.
<li> If a power failure or operating system failure occurs while copying
the database file the backup database may be corrupted following
system recovery.
</ul>
<p>
The <a href="c3ref/backup_finish.html#sqlite3backupinit">Online Backup API</a> was created to
address these concerns. The online backup API allows the contents of
one database to be copied into another database, overwriting the
original contents of the target database. The copy operation may be
done incrementally, in which case the source database does not need
to be locked for the duration of the copy, only for the brief periods
of time when it is actually being read from. This allows other database
users to continue uninterrupted while a backup of an online database is
made.
<p>
The online backup API is <a href="c3ref/backup_finish.html#sqlite3backupinit">documented here</a>.
The remainder of this page contains two C language examples illustrating
common uses of the API and discussions thereof. Reading these examples
is no substitute for reading the API documentation!
<p>
Update: The <a href="lang_vacuum.html#vacuuminto">VACUUM INTO</a> command introduced in
SQLite version 3.27.0 (2019-02-07) can serve as an
alternative to the backup API.
<h2>Example 1: Loading and Saving In-Memory Databases</h2>
<pre>
<span style="color:blue;font-style:italic">/*</span>
<span style="color:blue;font-style:italic">** This function is used to load the contents of a database file on disk </span>
<span style="color:blue;font-style:italic">** into the "main" database of open database connection pInMemory, or</span>
<span style="color:blue;font-style:italic">** to save the current contents of the database opened by pInMemory into</span>
<span style="color:blue;font-style:italic">** a database file on disk. pInMemory is probably an in-memory database, </span>
<span style="color:blue;font-style:italic">** but this function will also work fine if it is not.</span>
<span style="color:blue;font-style:italic">**</span>
<span style="color:blue;font-style:italic">** Parameter zFilename points to a nul-terminated string containing the</span>
<span style="color:blue;font-style:italic">** name of the database file on disk to load from or save to. If parameter</span>
<span style="color:blue;font-style:italic">** isSave is non-zero, then the contents of the file zFilename are </span>
<span style="color:blue;font-style:italic">** overwritten with the contents of the database opened by pInMemory. If</span>
<span style="color:blue;font-style:italic">** parameter isSave is zero, then the contents of the database opened by</span>
<span style="color:blue;font-style:italic">** pInMemory are replaced by data loaded from the file zFilename.</span>
<span style="color:blue;font-style:italic">**</span>
<span style="color:blue;font-style:italic">** If the operation is successful, SQLITE_OK is returned. Otherwise, if</span>
<span style="color:blue;font-style:italic">** an error occurs, an SQLite error code is returned.</span>
<span style="color:blue;font-style:italic">*/</span>
int loadOrSaveDb(<a href="c3ref/sqlite3.html">sqlite3</a> *pInMemory, const char *zFilename, int isSave){
int rc; <span style="color:blue;font-style:italic">/* Function return code */</span>
<a href="c3ref/sqlite3.html">sqlite3</a> *pFile; <span style="color:blue;font-style:italic">/* Database connection opened on zFilename */</span>
<a href="c3ref/backup.html">sqlite3_backup</a> *pBackup; <span style="color:blue;font-style:italic">/* Backup object used to copy data */</span>
<a href="c3ref/sqlite3.html">sqlite3</a> *pTo; <span style="color:blue;font-style:italic">/* Database to copy to (pFile or pInMemory) */</span>
<a href="c3ref/sqlite3.html">sqlite3</a> *pFrom; <span style="color:blue;font-style:italic">/* Database to copy from (pFile or pInMemory) */</span>
<span style="color:blue;font-style:italic">/* Open the database file identified by zFilename. Exit early if this fails</span>
<span style="color:blue;font-style:italic">** for any reason. */</span>
rc = <a href="c3ref/open.html">sqlite3_open</a>(zFilename, &pFile);
if( rc==SQLITE_OK ){
<span style="color:blue;font-style:italic">/* If this is a 'load' operation (isSave==0), then data is copied</span>
<span style="color:blue;font-style:italic">** from the database file just opened to database pInMemory. </span>
<span style="color:blue;font-style:italic">** Otherwise, if this is a 'save' operation (isSave==1), then data</span>
<span style="color:blue;font-style:italic">** is copied from pInMemory to pFile. Set the variables pFrom and</span>
<span style="color:blue;font-style:italic">** pTo accordingly. */</span>
pFrom = (isSave ? pInMemory : pFile);
pTo = (isSave ? pFile : pInMemory);
<span style="color:blue;font-style:italic">/* Set up the backup procedure to copy from the "main" database of </span>
<span style="color:blue;font-style:italic">** connection pFile to the main database of connection pInMemory.</span>
<span style="color:blue;font-style:italic">** If something goes wrong, pBackup will be set to NULL and an error</span>
<span style="color:blue;font-style:italic">** code and message left in connection pTo.</span>
<span style="color:blue;font-style:italic">**</span>
<span style="color:blue;font-style:italic">** If the backup object is successfully created, call backup_step()</span>
<span style="color:blue;font-style:italic">** to copy data from pFile to pInMemory. Then call backup_finish()</span>
<span style="color:blue;font-style:italic">** to release resources associated with the pBackup object. If an</span>
<span style="color:blue;font-style:italic">** error occurred, then an error code and message will be left in</span>
<span style="color:blue;font-style:italic">** connection pTo. If no error occurred, then the error code belonging</span>
<span style="color:blue;font-style:italic">** to pTo is set to SQLITE_OK.</span>
<span style="color:blue;font-style:italic">*/</span>
pBackup = <a href="c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init</a>(pTo, "main", pFrom, "main");
if( pBackup ){
(void)<a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step</a>(pBackup, -1);
(void)<a href="c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish</a>(pBackup);
}
rc = <a href="c3ref/errcode.html">sqlite3_errcode</a>(pTo);
}
<span style="color:blue;font-style:italic">/* Close the database connection opened on database file zFilename</span>
<span style="color:blue;font-style:italic">** and return the result of this function. */</span>
(void)<a href="c3ref/close.html">sqlite3_close</a>(pFile);
return rc;
}
</pre>
<p>
The C function to the right demonstrates one of the simplest,
and most common, uses of the backup API: loading and saving the contents
of an in-memory database to a file on disk. The backup API is used as
follows in this example:
<ol>
<li>Function <a href="c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init()</a> is called to create an <a href="c3ref/backup.html">sqlite3_backup</a>
object to copy data between the two databases (either from a file and
into the in-memory database, or vice-versa).
<li>Function <a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a> is called with a parameter of
<tt>-1</tt> to copy the entire source database to the destination.
<li>Function <a href="c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish()</a> is called to clean up resources
allocated by <a href="c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init()</a>.
</ol>
<p><b>Error handling</b>
<p>
If an error occurs in any of the three main backup API routines
then the <a href="rescode.html">error code</a> and <a href="c3ref/errcode.html">message</a> are attached to
the destination <a href="c3ref/sqlite3.html">database connection</a>.
Additionally, if
<a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a> encounters an error, then the <a href="rescode.html">error code</a> is returned
by both the <a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a> call itself, and by the subsequent call
to <a href="c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish()</a>. So a call to <a href="c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish()</a>
does not overwrite an <a href="rescode.html">error code</a> stored in the destination
<a href="c3ref/sqlite3.html">database connection</a> by <a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a>. This feature
is used in the example code to reduce amount of error handling required.
The return values of the <a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a> and <a href="c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish()</a>
calls are ignored and the error code indicating the success or failure of
the copy operation collected from the destination <a href="c3ref/sqlite3.html">database connection</a>
afterward.
<p><b>Possible Enhancements</b>
<p>
The implementation of this function could be enhanced in at least two ways:
<ol>
<li> Failing to obtain the lock on database file zFilename (an <a href="rescode.html#busy">SQLITE_BUSY</a>
error) could be handled, and
<li> Cases where the page-sizes of database pInMemory and zFilename are
different could be handled better.
</ol>
<p>
Since database zFilename is a file on disk, then it may be accessed
externally by another process. This means that when the call to
sqlite3_backup_step() attempts to read from or write data to it, it may
fail to obtain the required file lock. If this happens, this implementation
will fail, returning SQLITE_BUSY immediately. The solution would be to
register a busy-handler callback or
timeout with <a href="c3ref/sqlite3.html">database connection</a> pFile
using <a href="c3ref/busy_handler.html">sqlite3_busy_handler()</a> or <a href="c3ref/busy_timeout.html">sqlite3_busy_timeout()</a>
as soon as it is opened. If it fails to obtain a required lock immediately,
<a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a> uses any registered busy-handler callback or timeout
in the same way as <a href="c3ref/step.html">sqlite3_step()</a> or <a href="c3ref/exec.html">sqlite3_exec()</a> does.
<p>
Usually, it does not matter if the page-sizes of the source database and the
destination database are different before the contents of the destination
are overwritten. The page-size of the destination database is simply changed
as part of the backup operation. The exception is if the destination database
happens to be an in-memory database. In this case, if the page sizes
are not the same at the start of the backup operation, then the operation
fails with an SQLITE_READONLY error. Unfortunately, this could occur when
loading a database image from a file into an in-memory database using
function loadOrSaveDb().
<p>
However, if in-memory database pInMemory has just been opened (and is
therefore completely empty) before being passed to function loadOrSaveDb(),
then it is still possible to change its page size using an SQLite "PRAGMA
page_size" command. Function loadOrSaveDb() could detect this case, and
attempt to set the page-size of the in-memory database to the page-size
of database zFilename before invoking the online backup API functions.
<h2>Example 2: Online Backup of a Running Database</h2>
<pre>
<span style="color:blue;font-style:italic">/*</span>
<span style="color:blue;font-style:italic">** Perform an online backup of database pDb to the database file named</span>
<span style="color:blue;font-style:italic">** by zFilename. This function copies 5 database pages from pDb to</span>
<span style="color:blue;font-style:italic">** zFilename, then unlocks pDb and sleeps for 250 ms, then repeats the</span>
<span style="color:blue;font-style:italic">** process until the entire database is backed up.</span>
<span style="color:blue;font-style:italic">** </span>
<span style="color:blue;font-style:italic">** The third argument passed to this function must be a pointer to a progress</span>
<span style="color:blue;font-style:italic">** function. After each set of 5 pages is backed up, the progress function</span>
<span style="color:blue;font-style:italic">** is invoked with two integer parameters: the number of pages left to</span>
<span style="color:blue;font-style:italic">** copy, and the total number of pages in the source file. This information</span>
<span style="color:blue;font-style:italic">** may be used, for example, to update a GUI progress bar.</span>
<span style="color:blue;font-style:italic">**</span>
<span style="color:blue;font-style:italic">** While this function is running, another thread may use the database pDb, or</span>
<span style="color:blue;font-style:italic">** another process may access the underlying database file via a separate </span>
<span style="color:blue;font-style:italic">** connection.</span>
<span style="color:blue;font-style:italic">**</span>
<span style="color:blue;font-style:italic">** If the backup process is successfully completed, SQLITE_OK is returned.</span>
<span style="color:blue;font-style:italic">** Otherwise, if an error occurs, an SQLite error code is returned.</span>
<span style="color:blue;font-style:italic">*/</span>
int backupDb(
<a href="c3ref/sqlite3.html">sqlite3</a> *pDb, <span style="color:blue;font-style:italic">/* Database to back up */</span>
const char *zFilename, <span style="color:blue;font-style:italic">/* Name of file to back up to */</span>
void(*xProgress)(int, int) <span style="color:blue;font-style:italic">/* Progress function to invoke */ </span>
){
int rc; <span style="color:blue;font-style:italic">/* Function return code */</span>
<a href="c3ref/sqlite3.html">sqlite3</a> *pFile; <span style="color:blue;font-style:italic">/* Database connection opened on zFilename */</span>
<a href="c3ref/backup.html">sqlite3_backup</a> *pBackup; <span style="color:blue;font-style:italic">/* Backup handle used to copy data */</span>
<span style="color:blue;font-style:italic">/* Open the database file identified by zFilename. */</span>
rc = <a href="c3ref/open.html">sqlite3_open</a>(zFilename, &pFile);
if( rc==SQLITE_OK ){
<span style="color:blue;font-style:italic">/* Open the <a href="c3ref/backup.html">sqlite3_backup</a> object used to accomplish the transfer */</span>
pBackup = <a href="c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init</a>(pFile, "main", pDb, "main");
if( pBackup ){
<span style="color:blue;font-style:italic">/* Each iteration of this loop copies 5 database pages from database</span>
<span style="color:blue;font-style:italic">** pDb to the backup database. If the return value of backup_step()</span>
<span style="color:blue;font-style:italic">** indicates that there are still further pages to copy, sleep for</span>
<span style="color:blue;font-style:italic">** 250 ms before repeating. */</span>
do {
rc = <a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step</a>(pBackup, 5);
xProgress(
<a href="c3ref/backup_finish.html#sqlite3backupremaining">sqlite3_backup_remaining</a>(pBackup),
<a href="c3ref/backup_finish.html#sqlite3backuppagecount">sqlite3_backup_pagecount</a>(pBackup)
);
if( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){
<a href="c3ref/sleep.html">sqlite3_sleep</a>(250);
}
} while( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED );
<span style="color:blue;font-style:italic">/* Release resources allocated by backup_init(). */</span>
(void)<a href="c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish</a>(pBackup);
}
rc = <a href="c3ref/errcode.html">sqlite3_errcode</a>(pFile);
}
<span style="color:blue;font-style:italic">/* Close the database connection opened on database file zFilename</span>
<span style="color:blue;font-style:italic">** and return the result of this function. */</span>
(void)<a href="c3ref/close.html">sqlite3_close</a>(pFile);
return rc;
}
</pre>
<p>
The function presented in the previous example copies the entire source
database in one call to <a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a>. This requires holding a
read-lock on the source database file for the duration of the operation,
preventing any other database user from writing to the database. It also
holds the mutex associated with database pInMemory throughout the copy,
preventing any other thread from using it. The C function in this section,
designed to be called by a background thread or process for creating a
backup of an online database, avoids these problems using the following
approach:
<ol>
<li>Function <a href="c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init()</a> is called to create an <a href="c3ref/backup.html">sqlite3_backup</a>
object to copy data from database pDb to the backup database file
identified by zFilename.
<li>Function <a href="c3ref/backup_finish.html#sqlite3backupstep">sqlite3_backup_step()</a> is called with a parameter of 5 to
copy 5 pages of database pDb to the backup database (file zFilename).
<li>If there are still more pages to copy from database pDb, then the
function sleeps for 250 milliseconds (using the <a href="c3ref/sleep.html">sqlite3_sleep()</a>
utility) and then returns to step 2.
<li>Function <a href="c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish()</a> is called to clean up resources
allocated by <a href="c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init()</a>.
</ol>
<p><b>File and Database Connection Locking</b>
<p>
During the 250 ms sleep in step 3 above, no read-lock is held on the database
file and the mutex associated with pDb is not held. This allows other threads
to use <a href="c3ref/sqlite3.html">database connection</a> pDb and other connections to write to the
underlying database file.
<p>
If another thread or process writes to the source database while this
function is sleeping, then SQLite detects this and usually restarts the
backup process when sqlite3_backup_step() is next called. There is one
exception to this rule: If the source database is not an in-memory database,
and the write is performed from within the same process as the backup
operation and uses the same database handle (pDb), then the destination
database (the one opened using connection pFile) is automatically updated
along with the source. The backup process may then be continued after the
sqlite3_sleep() call returns as if nothing had happened.
<p>
Whether or not the backup process is restarted as a result of writes to
the source database mid-backup, the user can be sure that when the backup
operation is completed the backup database contains a consistent and
up-to-date snapshot of the original. However:
<ul>
<li> Writes to an in-memory source database, or writes to a file-based
source database by an external process or thread using a
database connection other than pDb are significantly more expensive
than writes made to a file-based source database using pDb (as the
entire backup operation must be restarted in the former two cases).
<li> If the backup process is restarted frequently enough it may never
run to completion and the backupDb() function may never return.
</ul>
<p><b>backup_remaining() and backup_pagecount()</b>
<p>
The backupDb() function uses the sqlite3_backup_remaining() and
sqlite3_backup_pagecount() functions to report its progress via the
user-supplied xProgress() callback. Function sqlite3_backup_remaining()
returns the number of pages left to copy and sqlite3_backup_pagecount()
returns the total number of pages in the source database (in this case
the database opened by pDb). So the percentage completion of the process
may be calculated as:
<p style="font-family:fixed;margin-left:5em">
Completion = 100% * (pagecount() - remaining()) / pagecount()
<p>
The sqlite3_backup_remaining() and sqlite3_backup_pagecount() APIs report
values stored by the previous call to sqlite3_backup_step(), they do not
actually inspect the source database file. This means that if the source
database is written to by another thread or process after the call to
sqlite3_backup_step() returns but before the values returned by
sqlite3_backup_remaining() and sqlite3_backup_pagecount() are used, the
values may be technically incorrect. This is not usually a problem.
<div style="clear:both"></div>

View File

@ -0,0 +1,578 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Pointer Passing Interfaces</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
Pointer Passing Interfaces
</div>
<div class="fancy_toc">
<a onclick="toggle_toc()">
<span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
Table Of Contents
</a>
<div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
<div class="fancy-toc1"><a href="#a_brief_history_of_pointer_passing_in_sqlite">2. A Brief History Of Pointer Passing In SQLite</a></div>
<div class="fancy-toc2"><a href="#upping_the_threat_level">2.1. Upping The Threat Level</a></div>
<div class="fancy-toc2"><a href="#preventing_forged_pointers">2.2. Preventing Forged Pointers</a></div>
<div class="fancy-toc2"><a href="#pointer_leaks">2.3. Pointer Leaks</a></div>
<div class="fancy-toc1"><a href="#the_new_pointer_passing_interfaces">3. The New Pointer-Passing Interfaces</a></div>
<div class="fancy-toc2"><a href="#pointer_types">3.1. Pointer Types</a></div>
<div class="fancy-toc3"><a href="#pointer_types_are_static_strings">3.1.1. Pointer types are static strings</a></div>
<div class="fancy-toc2"><a href="#destructor_functions">3.2. Destructor Functions</a></div>
<div class="fancy-toc1"><a href="#restrictions_on_the_use_of_pointer_values">4. Restrictions On The Use of Pointer Values</a></div>
<div class="fancy-toc1"><a href="#summary">5. Summary</a></div>
</div>
</div>
<script>
function toggle_toc(){
var sub = document.getElementById("toc_sub")
var mk = document.getElementById("toc_mk")
if( sub.style.display!="block" ){
sub.style.display = "block";
mk.innerHTML = "&#x25bc;";
} else {
sub.style.display = "none";
mk.innerHTML = "&#x25ba;";
}
}
</script>
</div>
<h1 id="overview"><span>1. </span>Overview</h1>
<p>
Three new "_pointer()" interfaces were added to SQLite 3.20.0 (2017-08-01):
</p><ul>
<li> <a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a>,
</li><li> <a href="c3ref/result_blob.html">sqlite3_result_pointer()</a>, and
</li><li> <a href="c3ref/value_blob.html">sqlite3_value_pointer()</a>.
</li></ul>
<p>Questions and confusion quickly arose
on the <a href="support.html#mailinglists">mailing lists</a> about the purpose behind these new interfaces,
why they were introduced, and what problem they solve. This essay attempts
to answer those questions and clear up the confusion.
</p><h1 id="a_brief_history_of_pointer_passing_in_sqlite"><span>2. </span>A Brief History Of Pointer Passing In SQLite</h1>
<p>
It is sometimes convenient for SQLite extensions to
communicate non-SQL values between subcomponents or between the extension
and the application. Some examples:
</p><ul>
<li><p>
In the <a href="fts3.html">FTS3</a> extension, the
<a href="fts3.html#full_text_index_queries">MATCH operator</a> (which does the full-text search)
needs to communicate details of matching entries
to the <a href="fts3.html#snippet">snippet()</a>, <a href="fts3.html#offsets">offsets()</a>,
and <a href="fts3.html#matchinfo">matchinfo()</a> functions so that those functions can convert the details
of the match into useful output.
</p></li><li><p>
In order for an application to
<a href="fts5.html#extending_fts5">add new extensions to FTS5</a>, such as new tokenizers,
the application needs a pointer to the "fts5_api" object.
</p></li><li><p>
In the <a href="carray.html">CARRAY extension</a>, the application needs to tell the
extension the
location of a C-language array that contains the data for the table-valued
function that the extension implements.
</p></li></ul>
<p>
The traditional way of communicating this information was to transform a
C-language pointer into a BLOB or a 64-bit integer, then move that BLOB or
integer through SQLite using the usual interfaces like
<a href="c3ref/bind_blob.html">sqlite3_bind_blob()</a>, <a href="c3ref/result_blob.html">sqlite3_result_blob()</a>, <a href="c3ref/value_blob.html">sqlite3_value_blob()</a> or
the integer equivalents.
</p><h2 id="upping_the_threat_level"><span>2.1. </span>Upping The Threat Level</h2>
<p>
Passing around pointers as if they were integers or BLOBs is easy,
effective, and works well in an environment where the application
components are all friendly toward one another. However, passing pointers
as integers and BLOBs allows hostile SQL text to forge invalid pointers that
can carry out mischief.
</p><p>
For example, the first argument to the <a href="fts3.html#snippet">snippet()</a> function is supposed to
be a special column of the FTS3 table that contains a pointer to an fts3cursor
object that contains information about the current full text search match.
That pointer was formerly passed as a BLOB.
For example, if the FTS3 table is named "t1" and has a column named "cx",
one might write:
</p><div class="codeblock"><pre>SELECT snippet(t1) FROM t1 WHERE cx MATCH $pattern;
</pre></div>
<p>
But if a hacker is able to run arbitrary SQL, he might run a slightly
different query, like this:
</p><div class="codeblock"><pre>SELECT hex(t1) FROM t1 WHERE cx MATCH $pattern;
</pre></div>
<p>
Because the pointer is passed in the t1 column of the t1
table as a BLOB (in older versions of SQLite), such a query would have
shown the value of the
pointer in hex. The attacker could then modify that pointer to try to
get the snippet() function to modify memory in some other part of
the application address space instead of the fts3cursor object it
was supposed to be operating on:
</p><div class="codeblock"><pre>SELECT snippet(x'6092310100000000') FROM t1 WHERE cx MATCH $pattern;
</pre></div>
<p>
Historically, this was not considered a threat. The argument was that if
a hostile agent is able to inject arbitrary SQL text into the application,
then that agent is already in full control of the application, so
letting the hostile agent forge a pointer does not give the agent
any new capability.
</p><p>
For most cases, it is true that potential attackers have no way of injecting
arbitrary SQL, and so most uses of SQLite are immune to the attack above.
But there are some notable exceptions. To wit:
</p><ul>
<li><p>
The <a href="https://en.wikipedia.org/wiki/Web_SQL_Database">WebSQL</a> interface
to webkit allowed any webpage to run arbitrary SQL in the browser
for Chrome and Safari. That arbitrary SQL was supposed to be run inside
a sandbox where it could do no harm even if exploited, but that sandbox
turned out to be less secure than people supposed. In the spring of 2017,
one team of hackers was able to root an iMac using a long sequence of
exploits, one of which involved corrupting the pointers passed as BLOB
values to the snippet() FTS3 function of an SQLite database running via
the WebSQL interface inside of Safari.
</p></li><li><p>
On Android, we are told, there are many services that will blindly
run arbitrary SQL that is passed to them by untrustworthy apps
that have been downloaded from dodgy corners of the internet.
Android services are suppose to be more guarded about running SQL
from unvetted sources. This author does not have any specific examples
to the contrary, but he has heard rumors that they exist. Even if
all Android services are more careful and properly vet all the SQL
they run, it would be difficult to audit them
all in order to verify that they are safe. Hence, security-minded people
are keen to ensure that no exploits are possible by passing arbitrary
SQL text.
</p></li><li><p>
The <a href="https://www.fossil-scm.org/">Fossil</a> version control system (designed
and written for the purpose of supporting SQLite development) allows
mildly trusted users to enter arbitrary SQL for generating trouble-ticket
reports. That SQL is sanitized using the
<a href="c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> interface, and no exploits have ever been
found. But this is an example of potentially hostile agents being able to
inject arbitrary SQL into the system.
</p></li></ul>
<h2 id="preventing_forged_pointers"><span>2.2. </span>Preventing Forged Pointers</h2>
<p>
The first attempt at closing security gaps in pointer passing was to
prevent pointer values from being forged. This was accomplished by
having the sender attach a subtype to each pointer using
<a href="c3ref/result_subtype.html">sqlite3_result_subtype()</a> and having the receiver verify that subtype
using <a href="c3ref/value_subtype.html">sqlite3_value_subtype()</a> and reject pointers that had an incorrect
subtype. Since there is no way to attach a subtype to a result using
pure SQL, this prevents pointers from being forged using SQL. The only
way to send a pointer is to use C code. If an attacker can set a subtype,
then he is also able to forge a pointer without the help of SQLite.
</p><p>
Using subtypes to identify valid pointers prevented the WebSQL exploit.
But it turned out to be an incomplete solution.
<a name="ptrleak"></a>
</p><h2 id="pointer_leaks"><span>2.3. </span>Pointer Leaks</h2>
<p>
The use of subtypes on pointers prevented pointer forgery using
pure SQL. But subtypes do nothing to prevent an attacker from reading
the values of pointers. In other words, subtypes on pointer values
prevent attacks using SQL statements like this:
</p><div class="codeblock"><pre>SELECT snippet(x'6092310100000000') FROM t1 WHERE cx MATCH $pattern;
</pre></div>
<p>
The BLOB argument to snippet() does not have the correct subtype, so the
snippet function ignores it, makes no changes to any data structures,
and harmlessly returns NULL.
</p><p>
But the use of subtypes does nothing to prevent the value of a
pointer from being read using SQL code like this:
</p><div class="codeblock"><pre>SELECT hex(t1) FROM t1 WHERE cx MATCH $pattern;
</pre></div>
<p>
What harm could come of that, you ask? The SQLite developers (including
this author) wondered the same thing. But then security researchers
pointed out that knowledge of pointers can help attackers to circumvent
address-space randomization defenses. This is called a "pointer leak".
A pointer leak is not itself a vulnerability, but it can aid an attacker
in effectively exploiting other vulnerabilities.
</p><h1 id="the_new_pointer_passing_interfaces"><span>3. </span>The New Pointer-Passing Interfaces</h1>
<p>
Allowing extension components to pass private information to one another
securely and without introducing pointer leaks requires new interfaces:
</p><ul>
<li><b><a href="c3ref/bind_blob.html">sqlite3_bind_pointer</a>(S,I,P,T,D)</b> &rarr;
Bind pointer P of type T to the I-th parameter of prepared statement S.
D is an optional destructor function for P.
</li><li><b><a href="c3ref/result_blob.html">sqlite3_result_pointer</a>(C,P,T,D)</b> &rarr;
Return pointer P of type T as the argument of function C.
D is an optional destructor function for P.
</li><li><b><a href="c3ref/value_blob.html">sqlite3_value_pointer</a>(V,T)</b> &rarr;
Return the pointer of type T associated with value V, or if V has no
associated pointer, or if the pointer on V is of a type different from
T, then return NULL.
</li></ul>
<p>
To SQL, the values created by <a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> and
<a href="c3ref/result_blob.html">sqlite3_result_pointer()</a> are indistinguishable from NULL. An
SQL statement that tries to use the <a href="lang_corefunc.html#hex">hex()</a> function to read the
value of a pointer will get an SQL NULL answer. The only way to
discover whether or not a value has an associated pointer is to
use the <a href="c3ref/value_blob.html">sqlite3_value_pointer()</a> interface with the appropriate
type string T.
</p><p>
Pointer values read by <a href="c3ref/value_blob.html">sqlite3_value_pointer()</a>
cannot be generated by pure SQL. Hence, it is not possible for SQL to
forge pointers.
</p><p>
Pointer values generated by <a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> and
<a href="c3ref/result_blob.html">sqlite3_result_pointer()</a> cannot be read by pure SQL.
Hence, it is not possible for SQL to leak the value of pointers.
</p><p>
In this way the new pointer-passing interface seems to solve all of the
security problems associated with passing pointer values from one
extension to another in SQLite.
<a name="ptrtyp"></a>
</p><h2 id="pointer_types"><span>3.1. </span>Pointer Types</h2>
<p>
The "pointer type" in the last parameter to <a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a>,
<a href="c3ref/result_blob.html">sqlite3_result_pointer()</a>, and <a href="c3ref/value_blob.html">sqlite3_value_pointer()</a> is used to prevent
pointers intended for one extension from being redirected to a different
extension. For example, without the use of pointer types, an attacker
could still get access to pointer information in a system that included
both the <a href="fts3.html">FTS3</a> and the <a href="carray.html">CARRAY extension</a> using SQL like this:
</p><div class="codeblock"><pre>SELECT ca.value FROM t1, carray(t1,10) AS ca WHERE cx MATCH $pattern
</pre></div>
<p>
In the statement above, the FTS3 cursor pointer generated by the
MATCH operator is send into the carray() table-valued function instead
of its intended recipient snippet(). The carray() function treats the
pointer as a pointer to an array of integers and returns each integer
one by one, thus leaking the content of the FTS3 cursor object. Since
the FTS3 cursor object contains pointers to other objects, the statement
above would be a pointer leak.
</p><p>
Except, the statement above does not work, thanks to pointer types.
The pointer generated by the MATCH operator has a type of "fts3cursor"
but the carray() function expects to receives a pointer of type "carray".
Because the pointer type on the <a href="c3ref/result_blob.html">sqlite3_result_pointer()</a> does not match
the pointer type on the <a href="c3ref/value_blob.html">sqlite3_value_pointer()</a> call,
<a href="c3ref/value_blob.html">sqlite3_value_pointer()</a> returns NULL in carray() and thus signals
the CARRAY extension that it has been passed an invalid pointer.
</p><h3 id="pointer_types_are_static_strings"><span>3.1.1. </span>Pointer types are static strings</h3>
<p>
Pointer types are static strings, which ideally should be string literals
embedded directly in the SQLite API call, not parameters passed in from
other functions. Consideration was given to using integer values as
the pointer type, but static strings provides a much larger name space
which reduces the chance of accidental type-name collisions between
unrelated extensions.
</p><p>
By "static string", we mean a zero-terminated array of bytes that is
fixed and unchanging for the life of the program. In other words, the
pointer type string should be a string constant.
In contrast, a "dynamic string" is a zero-terminated array of bytes
that is held in memory allocated
from the heap, and which must be freed to avoid a memory leak.
Do not use dynamic strings as the pointer type string.
</p><p>
Multiple commentators have expressed a desire to use dynamic strings
for the pointer type, and to have SQLite take ownership of the type strings
and to automatically free the type string
when it has finished using it. That design is rejected for the
following reasons:
</p><ol>
<li><p>
The pointer type is not intended to be flexible and dynamic. The
pointer type is intended to be a design-time constant. Applications
should not synthesize pointer type strings at run-time. Providing
support for dynamic pointer type strings would lead developers
to misuse the pointer-passing interfaces by creating run-time
synthesized pointer type strings. Requiring the pointer type strings
to be static encourages developers to do the right thing by choosing
fixed pointer type names at design-time and encoding those names
as constant strings.
</p></li><li><p>
All string values at the SQL level in SQLite are dynamic strings.
Requiring type strings to be static makes it difficult to
create an application-defined SQL function that
can synthesize a pointer of an arbitrary type. We do not want users
to create such SQL functions, since such functions would compromise the
security of the system. Thus, the requirement to use static strings
helps to defend that the integrity of the pointer-passing interfaces against
ill-designed SQL functions. The static string requirement is not
a perfect defense, since a sophisticated programmer can code around
it, and a novice program can simply take the memory leak. But by
stating that the pointer type string must be static, we hope to encourage
developers who might otherwise use a dynamic string for the pointer type
to think more carefully about the problem and avoid introducing
security issues.
</p></li><li><p>
Having SQLite take ownership of the type strings would impose a performance
cost on all applications, even applications that do not use the
pointer-passing interfaces. SQLite passes values around as instances
of the <a href="c3ref/value.html">sqlite3_value</a> object. That object has a destructor, which because
of the fact that sqlite3_value objects are used for nearly everything, is
invoked frequently. If the destructor needs to check to see if there is
a pointer type string that needs to be freed, that is a few extra CPU
cycles that need to be burned on each call to the destructor. Those
cycles add up. We would be willing to bear the cost of the extra CPU
cycles if pointer-passing was a commonly used programming paradigm, but
pointer-passing is rare, and so it seems unwise to impose a run-time cost
on billions and billions of applications that do not use pointer passing
just for convenience of a few applications that do.
</p></li></ol>
<p>
If you feel that you need dynamic pointer type strings in your application,
that is a strong indicator that you are misusing the pointer-passing interface.
Your intended use may be unsafe.
Please rethink your design. Determine if you really need to be passing
pointers through SQL in the first place. Or perhaps find a different
mechanism other than the pointer-passing interfaces described by this
article.
</p><h2 id="destructor_functions"><span>3.2. </span>Destructor Functions</h2>
<p>
The last parameter to the <a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> and
<a href="c3ref/result_blob.html">sqlite3_result_pointer()</a> routines is a pointer to a procedure
used to dispose of the P pointer once SQLite has finished with it.
This pointer can be NULL, in which case no destructor is called.
</p><p>
When the D parameter is not NULL, that means that ownership of the
pointer is being transferred to SQLite. SQLite will take responsibility
for freeing resources associated with the pointer when it has finished
using the pointer. If the D parameter is NULL, that means that ownership
of the pointer remains with the caller and the caller is responsible for
disposing of the pointer.
</p><p>
Note that the destructor function D is for the pointer value P, not for
the type string T. The type string T should be a static string with an
infinite lifetime.
</p><p>
If ownership of the pointer is passed into SQLite by providing a
non-NULL D parameter to <a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> or <a href="c3ref/result_blob.html">sqlite3_result_pointer()</a>
then the ownership remains with SQLite until the object is destroyed.
There is no way to transfer ownership out of SQLite and back into the
application again.
</p><h1 id="restrictions_on_the_use_of_pointer_values"><span>4. </span>Restrictions On The Use of Pointer Values</h1>
<p>
The pointers that piggy-back on SQL NULL values using the
<a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a>, <a href="c3ref/result_blob.html">sqlite3_result_pointer()</a>, and
<a href="c3ref/value_blob.html">sqlite3_value_pointer()</a> interface are transient and ephemeral.
The pointers are never written into the database. The pointers
will not survive sorting. The latter fact is why there is no
sqlite3_column_pointer() interface, since it is impossible to
predict whether or not the query planner will insert a sort operation
prior to returning a value from a query, so it would be impossible to
know if a pointer value inserted into a query by
<a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> or <a href="c3ref/result_blob.html">sqlite3_result_pointer()</a> would survive
through to the result set.
</p><p>
Pointer values must flow directly from their producer into their
consumer, with no intermediate operators or functions. Any transformation
of a pointer value destroys the pointer and transforms the value into
an ordinary SQL NULL.
</p><p>
Both the pointer and the pointer type parameter to the
<a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> and <a href="c3ref/result_blob.html">sqlite3_result_pointer()</a> interfaces
are "owned" by the caller. In other words, the caller is responsible
for ensuring that both values remain valid until after the last access
via <a href="c3ref/value_blob.html">sqlite3_value_pointer()</a>.
</p><h1 id="summary"><span>5. </span>Summary</h1>
<p>Key take-aways from this essay:
</p><ol>
<li><p>
The internet is an increasingly hostile place. These day, developers
should assume that attackers will find a way to execute arbitrary SQL
in an application.
Applications should be designed to prevent the execution of arbitrary
SQL from escalating into a more severe exploit.
</p></li><li><p>
A few SQLite extensions benefit from passing pointers:
</p><ul>
<li>The <a href="fts3.html">FTS3</a> MATCH operator passes pointers into <a href="fts3.html#snippet">snippet()</a>,
<a href="fts3.html#offsets">offsets()</a>, and <a href="fts3.html#matchinfo">matchinfo()</a>.
</li><li>The <a href="carray.html">carray table-valued function</a> needs to accept a pointer to
an array of C-language values from the application.
</li><li>The <a href="https://sqlite.org/src/file/ext/misc/remember.c">remember() extension</a>
needs a pointer to a C-language integer variable in which to remember
the value it passes.
</li><li>Applications need to receive a pointer to the "fts5_api" object in order
to add extensions, such as custom tokenizers, to the <a href="fts5.html">FTS5</a> extension.
</li></ul>
</li><li><p>
Pointers should <u>never</u> be exchanged by encoding them as some other
SQL datatype, such as integers or BLOBs. Instead, use the interfaces
designed to facilitate secure pointer passing:
<a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a>, <a href="c3ref/result_blob.html">sqlite3_result_pointer()</a>, and
<a href="c3ref/value_blob.html">sqlite3_value_pointer()</a>.
</p></li><li><p>
The use of pointer-passing is an advanced technique that should be used
infrequently and cautiously. Pointer-passing should not be
used haphazardly or carelessly. Pointer-passing is a sharp tool
that can leave deep scars if misused.
</p></li><li><p>
The "pointer type" string which is the last parameter to each of the
pointer-passing interfaces should be a distinct, application-specific
string literal that appears directly in the API call. The pointer type
should not be a parameter passed in from a higher-level function.
</p></li></ol>

View File

@ -0,0 +1,417 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>Books About SQLite</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<h1 align=center>Books About SQLite</h1>
<hr>
<table border=0><tr><td valign=top><img src="images/books/sanderson2018.jpg" style="border:44px solid white;">
<td valign=top>
<h2>SQLite Forensics (2018)</h2>
<p>
Author: Paul Sanderson<br>
Publisher: <a href='https://www.amazon.com/SQLite-Forensics-Paul-Sanderson/dp/1980293074'>Amazon</a>
<p>
This text by noted digital forensics expert, Paul Sanderson, provides
investigators with low-level technical details useful in analysing
SQLite database files.
<p>
Every computer and phone uses hundreds of SQLite databases and there are
over one trillion SQLite databases in active use. Hence, the importance
of examining the data held in these databases in an
investigation, including deleted data when possible, is paramount. This
book fully explains the format of the SQLite database file. It shows how
records are encoded, how to decode them manually and how to decode
records that are partially overwritten. It also describe how the
workings of SQLite, and in particular the journal and WAL, can be used
to ascertain what has happened in a manner that cannot be determined
from the data alone. The book covers basic SQL queries and how they can
be used to create a custom report that includes data from different
tables, and shows how one can use SQL queries to test hypotheses about
the relationships of data in different tables.
<p>
This book is aimed mainly at
forensic practitioners, and it is assumed that the reader has some basic
knowledge of computer forensics; it will also be of interest to computer
professionals in general particularly those who have an interest in the
SQLite file format.
</table>
<hr>
<table border=0><tr><td valign=top><img src="images/books/darocha2016.jpg">
<td valign=top>
<h2>Learning SQLite for iOS (2016)</h2>
<p>
Author: Gene Da Rocha<br>
Publisher: <a href="https://www.packtpub.com/application-development/learning-sqlite-ios">Packt Publishing</a>
<p>
This book starts with the architecture of SQLite database and introduces
you to concepts in SQL. You will find yourself equipped to design your
own database system, administer it, and maintain it. Further, you will
learn how to operate your SQLite databases smoothly using SQL commands.
<p>
You will be able to extend the functionality of SQLite by using its vast
arsenal of C API calls to build some interesting, exciting, new, and
intelligent data-driven applications. Understand how Xcode, HTML5, and
Phonegap can be used to build a cross-platform modern app which can
benefit from all these technologies - all through creating a complete,
customizable application skeleton that you can build on for your own
apps. This book provides a comprehensive description of SQLite database
system. It describes design principles, engineering trade-offs,
implementation issues, and operations of SQLite.
</table>
<hr>
<table border=0><tr><td valign=top><img src="images/books/haldar2.jpg">
<td valign=top>
<h2>SQLite Database System Design and Implementation (2015)</h2>
<p>
Author: Sibsankar Haldar<br>
Publisher: <a href="https://books.google.com/books?id=OEJ1CQAAQBAJ">https://books.google.com/</a><br>
<p>
This book provides a comprehensive description of SQLite database system.
It describes design principles, engineering trade-offs, implementation issues,
and operations of SQLite.
</table>
<hr>
<table border=0><tr><td valign=top><img src="images/books/aditya.jpg">
<td valign=top>
<h2>Android SQLite Essentials (2014)</h2>
<p>
Authors: Sunny Kumar Aditya and Vikash Kumar Karn<br>
Publisher: <a href="https://www.packtpub.com/application-development/android-sqlite-essentials">
Packt Publishing</a><br>
<p>
Android SQLite Essentials focuses on the core concepts behind building
database-driven applications. This book covers the basic and advanced
topics with equivalent simplicity and detail, in order to enable
readers to quickly grasp and implement the concepts to build an
application database.
<p>This book takes a hands-on, example-based approach to help readers
understand the core topics of SQLite and Android database-driven
applications. This book focuses on providing you with latent as well
as widespread knowledge about practices and approaches towards
development in an easily understandable manner.
</table>
<hr>
<table border=0><tr><td valign=top><img src="images/books/das.jpg">
<td valign=top>
<h2>SQLite for Mobile Apps Simplified (2014)</h2>
<p>
Author: Sribatsa Das<br>
Publisher: Amazon<br>
<a href="http://amzn.com/B00M3OVSRK">Amazon</a>
<p>
SQLite for Mobile Apps Simplified is devoted to presenting approach
and implementation methodology for using SQLite database in mobile apps.
It presents step-by-step examples to create schema, execute transactions
and access data from Android, BlackBerry and iOS applications.
In addition, it presents ADB Shell and SQLite command-line shell from
ADB Shell to access the SQLite Database created by the Android apps.
For BlackBerry and iOS application, the book presents ways to access
the data using the command line shell.
</table>
<hr>
<table border=0><tr><td valign=top><img src="images/books/owens.jpg">
<td valign=top>
<h2>The Definitive Guide to SQLite (2nd edition, 2010)</h2>
<p>
Authors: Mike Owens and Grant Allen<br>
Publisher: Apress<br>
<a href="http://www.amazon.com/gp/product/1430232250">Amazon</a></p>
<p>
Outside of the world of enterprise computing, there is one database
that enables a huge range of software and hardware to flex relational
database capabilities, without the baggage and cost of traditional
database management systems. That database is SQLite - an embeddable
database with an amazingly small footprint, yet able to handle databases
of enormous size. SQLite comes equipped with an array of powerful
features available through a host of programming and development
environments. It is supported by languages such as C, Java, Perl,
PHP, Python, Ruby, TCL, and more.</p>
<p><i>The Definitive Guide to SQLite, Second Edition</i>
is devoted to complete coverage of the latest version of this powerful
database. It offers a thorough overview of SQLite's capabilities
and APIs. The book also uses SQLite as the basis for helping newcomers
make their first foray into database development. In only a short time
you can be writing programs as diverse as a server-side browser plug-in
or the next great iPhone or Android application!
</p>
</table>
<hr>
<table border=0><tr><td valign=top><p><img src="images/books/kreibich.gif">
<td valign=top>
<h2>Using SQLite (2010)</h2>
<p>
Author: Jay A. Kreibich<br>
Publisher: O'Reilly Media<br>
<a href="http://oreilly.com/catalog/9780596521196/">O'Reilly</a></p>
<p>Developers, take note: databases aren't just for the IS group any more.
You can build database-backed applications for the desktop, Web,
embedded systems, or operating systems without linking to heavy-duty
client-server databases such as Oracle and MySQL.
This book shows how you to use SQLite, a small and lightweight
database that you can build right into your application during development.
Applications that handle data have an enormous advantage today, and
with SQLite, you'll discover how to develop a database-backed application
that remains manageable in size and complexity. This book guides
you every step of the way. You'll get a crash course in data modeling,
become familiar with SQLite's dialect of the SQL database language,
and learn how you to work with SQLite using either a scripting
language or a C-based language, such as C# or Objective C.Now,
even relatively small and nimble applications can be a part of
the data revolution. Using SQLite shows you how.
</p>
</table>
<hr>
<table border=0><tr><td valign=top><p><img src="images/books/droessler.jpg">
<td valign=top>
<h2>SQLite 3 - Einstieg in die Datenbankwelt (2010)</h2>
<p>
Author: Key Droessler<br>
Publisher: Lulu.com<br>
<a href="http://www.amazon.com/SQLite-Einstieg-die-Datenbankwelt-German/dp/1445741075">Amazon</a></p>
<p>Die Datenbanksprache SQL ( Structured Query Language ) wird in Datenbanken
zur Definition, Manipulation, Sicherung, aber hauptsaechlich zur Abfrage
von Daten aus der Datenbank eingesetzt. Unabhaengig vom Betriebssystem oder
aufwendigen, benutzerfreundlichen, graphischen Oberflaechen bleibt die
Logik aber immer gleich.SQLite ist eine freie Desktop-Datenbank,
sie kostet nichts, ist fuer viele Betriebssysteme verfuegbar,
schnell heruntergeladen und installiert und auf das Notwendigste
reduziert. Fuer den Einsteiger sind das die besten Voraussetzungen,
ohne viel Aufwand schnell in die Welt der Datenbanken und Datenbanksprache
reinzuschnuppern.Wer nach den Uebungen aber auf den Geschmack gekommen ist,
hat schon den groessten Teil an Datenbanken und SQL gelernt, denn alles
Besprochene ist Wissen, welches auch auf jedes andere der vielen
Datenbanken grundlegend anwendbar ist. Nun koennen Sie auf die richtig
Grossen zugehen, vom grossen Fachbuch bis zum riesigen Datenbanksystem.
</p>
</table>
<hr>
<table border=0>
<tr><td valign=top><img src="images/books/symbiansql.jpg"><td valign=top>
<h2>Inside Symbian SQL (2010)</h2>
<p>Authors: Ivan Litovski &amp; Richard Maynard<br>
Publisher: Wiley<br>
<a href="http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470744022.html">wiley.com</a></p>
<p>
This is the definitive reference book on the Symbian SQL database
which is based on SQLite. The authors (both members of the Symbian
engineering team responsible for the implementation of the code)
show you how to design code
and ease migration from an internal and external point of view,
plus they reveal the dos and don'ts of writing high-performance
database applications. Packed with resources and sample code,
this timely book reveals how to design and tune applications
that use the Symbian SQL framework to ultimately improve performance.</p>
<p>With its sample code and insider expertise, this text has everything
you need to keep you ahead of the curve.
</p>
</table>
<hr>
<table border=0>
<tr><td valign=top><img src="images/books/vanderLans.jpg"><td valign=top>
<h2>The SQL Guide to SQLite (2009)</h2>
<p>Author: Rick F. van der Lans<br>
Publisher: Lulu.com<br>
<a href="http://www.amazon.com/SQL-Guide-SQLite-Rick-Lans/dp/0557076765/ref=sr_1_3?ie=UTF8&s=books&qid=1256736387&sr=1-3">Amazon</a></p>
<p>SQLite is a small, fast, embeddable, SQL-based database server.
It is easy to install, needs no management, and is open source.
This book describes SQLite in detail. With hundreds of examples, plus a
proven approach and structure, the book teaches you how to use SQLite
efficiently and effectively. It contains a complete description of the
SQL dialect as implemented in SQLite version 3.6. The book can be seen
as a tutorial and a reference book. Source code for the numerous SQL
examples and exercises included in this book can be downloaded from www.r20.nl.
</p>
</table>
<hr>
<table border=0>
<tr><td valign=top><img src="images/books/nishizawa2.jpg"><td valign=top>
<h2>An Introduction to SQLite - 2nd Edition (2009)</h2>
<p>Author: Naoki Nishizawa<br>
Publisher: Shoeisha<br>
<a href="http://www.amazon.co.jp/SQLite%E5%85%A5%E9%96%80-%E7%AC%AC2%E7%89%88-%E8%A5%BF%E6%B2%A2-%E7%9B%B4%E6%9C%A8/dp/479811944X/ref=pd_sim_b_2">Amazon.jp</a></p>
<p>This text is written in fluent Japanese specifically for a Japanese
audience. This is the second edition of the book - the first edition
was published in 2005.
</p>
</table>
<hr>
<table border=0><tr><td valign=top><p><img src="images/books/haldar.gif">
<td valign=top>
<h2>Inside SQLite (2007)</h2>
<p>
Author: Sibsankar Haldar<br>
Publisher: O'Reilly Media<br>
<a href="http://oreilly.com/catalog/9780596550066">O'Reilly</a></p>
<p>SQLite is a small, zero-configuration, custom-tailored, embeddable,
thread-safe, easily maintainable, transaction-oriented, SQL-based,
relational database management system. There is no separate install or
setup procedure to initialize SQLite before using it.
There is no configuration file.
SQLite is open source, and is available in the public domain
(for more information on open source, visit http://opensource.org).
You can download SQLite source code from its homepage http://www.sqlite.org,
compile it using your favorite C compiler, and start using the compiled
library. SQLite runs on Linux, Windows, Mac OS X, and a few other operating systems. It has been widely used in low-to-medium tier database applications.
This Short Cut discusses design principles, engineering trade-offs,
implementation issues, and operations of SQLite. It presents a
comprehensive description of all important components of the SQLite engine.</p>
</table>
<hr>
<table border=0><tr><td valign=top><img src="images/books/newman.jpg">
<td valign=top>
<h2>SQLite (2004)</h2>
<p>Author: Chris Newman<br>
Publisher: Sams<br>
<a href="http://www.amazon.com/SQLite-Chris-Newman/dp/067232685X/ref=sr_1_2?ie=UTF8&s=books&qid=1256736664&sr=1-2">Amazon</a></p>
<p>
SQLite is a small, fast, embeddable database. What makes it popular is
the combination of the database engine and interface into a single library
as well as the ability to store all the data in a single file.
Its functionality lies between MySQL and PostgreSQL, however it is faster
than both databases.</p>
<p>In <i>SQLite</i>,
author Chris Newman provides a thorough, practical guide to
using, administering and programming this up-and-coming database.
If you want to learn about SQLite or about its use in conjunction with
PHP this is the book for you.</p>
</table>

View File

@ -0,0 +1,207 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="sqlite.css" rel="stylesheet">
<title>The Bytecode() And Tables_Used() Table-Valued Functions</title>
<!-- path= -->
</head>
<body>
<div class=nosearch>
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='about.html'>About</a>
<li class='desktoponly'><a href="docs.html">Documentation</a>
<li class='desktoponly'><a href="download.html">Download</a>
<li class='wideonly'><a href='copyright.html'>License</a>
<li class='desktoponly'><a href="support.html">Support</a>
<li class='desktoponly'><a href="prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='about.html'>About</a>
<li><a href='docs.html'>Documentation</a>
<li><a href='download.html'>Download</a>
<li><a href='support.html'>Support</a>
<li><a href='prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<div class=fancy>
<div class=nosearch>
<div class="fancy_title">
The Bytecode() And Tables_Used() Table-Valued Functions
</div>
</div>
<h1 id="overview"><span>1. </span>Overview</h1>
<p>
Bytecode and tables_used are <a href="vtab.html">virtual tables</a> built into SQLite that
access information about <a href="c3ref/stmt.html">prepared statements</a>.
Both bytecode and tables_used operate as <a href="vtab.html#tabfunc2">table-valued functions</a>.
They take a single required argument which is either the text of
an SQL statement, or a pointer to an existing prepared statement.
The bytecode function returns one row of result for each <a href="opcode.html">bytecode</a>
operation in the prepared statement. The tables_used function returns
one row for each persistent btree (either a table or an index) accessed
by the prepared statement.
</p><h1 id="usage"><span>2. </span>Usage</h1>
<p>
The bytecode and tables_used tables are only available if SQLite has
been compiled with the <a href="compile.html#enable_bytecode_vtab">-DSQLITE_ENABLE_BYTECODE_VTAB</a> compile-time option.
The <a href="cli.html">CLI</a> has been compiled that way, and so you can use the standard
<a href="cli.html">CLI</a> as a test platform to experiement.
</p><p>
Both virtual tables are read-only <a href="vtab.html#epoonlyvtab">eponymous-only virtual tables</a>. You use them
by mentioning them directly in the FROM clause of a SELECT statement.
They both require a single argument which is the SQL statement to be
analyzed. For example:
</p><div class="codeblock"><pre>SELECT * FROM bytecode('SELECT * FROM bytecode(?1)');
</pre></div>
<p>
The argument can be either the text of an SQL statement, in which case
the bytecode (or tables_used) for that statement is returned, or the
argument can be a parameter such as ?1 or $stmt that is later bound
to a <a href="c3ref/stmt.html">prepared statement</a> object using the
<a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> interface. Use a pointer type of
"stmt-pointer" for the <a href="c3ref/bind_blob.html">sqlite3_bind_pointer()</a> interface.
</p><h2 id="schema"><span>2.1. </span>Schema</h2>
<p>
The schema of the bytecode table is:
</p><div class="codeblock"><pre>CREATE TABLE bytecode(
addr INT,
opcode TEXT,
p1 INT,
p2 INT,
p3 INT,
p4 TEXT,
p5 INT,
comment TEXT,
subprog TEXT,
stmt HIDDEN
);
</pre></div>
<p>
The first eight columns are the address, opcode, and operands for a
single <a href="opcode.html">bytecode</a> in the virtual machine that implements the statement.
These columns are the same columns output when using EXPLAIN. The
bytecode virtual tables shows all operations in the prepared statement,
both the main body of the prepared statement and in subprograms used
to implement triggers or foreign key actions. The "subprog" field
is NULL for the main body of the prepared statement, or is the trigger
name or the string "(FK)" for triggers and foreign key actions.
</p><p>
The schema for the tables_used table is:
</p><div class="codeblock"><pre>CREATE TABLE tables_used(
type TEXT,
schema TEXT,
name TEXT,
wr INT,
subprog TEXT,
stmt HIDDEN
);
</pre></div>
<p>
The tables_used table is intended to show which btrees of the database file
are read or written by a prepared statement, both by the main statement
itself but also by related triggers and foreign key actions. The columns
are as follows:
</p><ul>
<li><p><b>type</b> &rarr; Either "table" or "index", depending on what role
the btree is serving.
</p></li><li><p><b>schema</b> &rarr; Which database file the btree is located in.
This will be "main" for the main database (the usual case), or "temp" for
TEMP tables and indexes, or the name assigned to <a href="lang_attach.html">attached</a> databases by
the <a href="lang_attach.html">ATTACH</a> statement.
</p></li><li><p><b>name</b> &rarr; The name of the table or index
</p></li><li><p><b>wr</b> &rarr; 0 if the object is read, 1 if the object is written
</p></li><li><p><b>subprog</b> &rarr; The sub-program in which the object is
accessed. NULL means the main body of the prepared statement. Otherwise
this field is the name of a trigger or "(FK)" for a foreign key action.
</p></li></ul>

View File

@ -0,0 +1,144 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Obtain Aggregate Function Context</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_aggregate_context -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Obtain Aggregate Function Context</h2>
</div>
<blockquote><pre>
void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
</pre></blockquote>
<p>
Implementations of aggregate SQL functions use this
routine to allocate memory for storing their state.</p>
<p>The first time the sqlite3_aggregate_context(C,N) routine is called
for a particular aggregate function, SQLite allocates
N bytes of memory, zeroes out that memory, and returns a pointer
to the new memory. On second and subsequent calls to
sqlite3_aggregate_context() for the same aggregate function instance,
the same buffer is returned. Sqlite3_aggregate_context() is normally
called once for each invocation of the xStep callback and then one
last time when the xFinal callback is invoked. When no rows match
an aggregate query, the xStep() callback of the aggregate function
implementation is never called and xFinal() is called exactly once.
In those cases, sqlite3_aggregate_context() might be called for the
first time from within xFinal().</p>
<p>The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
when first called if N is less than or equal to zero or if a memory
allocate error occurs.</p>
<p>The amount of space allocated by sqlite3_aggregate_context(C,N) is
determined by the N parameter on first successful call. Changing the
value of N in any subsequent call to sqlite3_aggregate_context() within
the same aggregate function instance will not resize the memory
allocation. Within the xFinal callback, it is customary to set
N=0 in calls to sqlite3_aggregate_context(C,N) so that no
pointless memory allocations occur.</p>
<p>SQLite automatically frees the memory allocated by
sqlite3_aggregate_context() when the aggregate query concludes.</p>
<p>The first parameter must be a copy of the
<a href="../c3ref/context.html">SQL function context</a> that is the first parameter
to the xStep or xFinal callback routine that implements the aggregate
function.</p>
<p>This routine must be called from the same thread in which
the aggregate SQL function is running.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,119 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Deprecated Functions</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_aggregate_count sqlite3_expired sqlite3_global_recover sqlite3_memory_alarm sqlite3_thread_cleanup sqlite3_transfer_bindings -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Deprecated Functions</h2>
</div>
<blockquote><pre>
#ifndef SQLITE_OMIT_DEPRECATED
int sqlite3_aggregate_count(sqlite3_context*);
int sqlite3_expired(sqlite3_stmt*);
int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
int sqlite3_global_recover(void);
void sqlite3_thread_cleanup(void);
int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
void*,sqlite3_int64);
#endif
</pre></blockquote>
<p>
These functions are <a href="../c3ref/experimental.html">deprecated</a>. In order to maintain
backwards compatibility with older code, these functions continue
to be supported. However, new applications should avoid
the use of these functions. To encourage programmers to avoid
these functions, we will not explain what they do.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,110 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Loadable Extension Thunk</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_api_routines -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Loadable Extension Thunk</h2>
</div>
<blockquote><pre>
typedef struct sqlite3_api_routines sqlite3_api_routines;
</pre></blockquote>
<p>
A pointer to the opaque sqlite3_api_routines structure is passed as
the third parameter to entry points of <a href="../loadext.html">loadable extensions</a>. This
structure must be typedefed in order to work around compiler warnings
on some platforms.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,138 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Automatically Load Statically Linked Extensions</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_auto_extension -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Automatically Load Statically Linked Extensions</h2>
</div>
<blockquote><pre>
int sqlite3_auto_extension(void(*xEntryPoint)(void));
</pre></blockquote>
<p>
This interface causes the xEntryPoint() function to be invoked for
each new <a href="../c3ref/sqlite3.html">database connection</a> that is created. The idea here is that
xEntryPoint() is the entry point for a statically linked <a href="../loadext.html">SQLite extension</a>
that is to be automatically loaded into all new database connections.</p>
<p>Even though the function prototype shows that xEntryPoint() takes
no arguments and returns void, SQLite invokes xEntryPoint() with three
arguments and expects an integer result as if the signature of the
entry point where as follows:</p>
<p><blockquote><pre>
&nbsp; int xEntryPoint(
&nbsp; sqlite3 *db,
&nbsp; const char **pzErrMsg,
&nbsp; const struct sqlite3_api_routines *pThunk
&nbsp; );
</pre></blockquote></p>
<p>If the xEntryPoint routine encounters an error, it should make *pzErrMsg
point to an appropriate error message (obtained from <a href="../c3ref/mprintf.html">sqlite3_mprintf()</a>)
and return an appropriate <a href="../rescode.html">error code</a>. SQLite ensures that *pzErrMsg
is NULL before calling the xEntryPoint(). SQLite will invoke
<a href="../c3ref/free.html">sqlite3_free()</a> on *pzErrMsg after xEntryPoint() returns. If any
xEntryPoint() returns an error, the <a href="../c3ref/open.html">sqlite3_open()</a>, <a href="../c3ref/open.html">sqlite3_open16()</a>,
or <a href="../c3ref/open.html">sqlite3_open_v2()</a> call that provoked the xEntryPoint() will fail.</p>
<p>Calling sqlite3_auto_extension(X) with an entry point X that is already
on the list of automatic extensions is a harmless no-op. No entry point
will be called more than once for each database connection that is opened.</p>
<p>See also: <a href="../c3ref/reset_auto_extension.html">sqlite3_reset_auto_extension()</a>
and <a href="../c3ref/cancel_auto_extension.html">sqlite3_cancel_auto_extension()</a>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,112 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Online Backup Object</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_backup -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Online Backup Object</h2>
</div>
<blockquote><pre>
typedef struct sqlite3_backup sqlite3_backup;
</pre></blockquote>
<p>
The sqlite3_backup object records state information about an ongoing
online backup operation. The sqlite3_backup object is created by
a call to <a href="../c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init()</a> and is destroyed by a call to
<a href="../c3ref/backup_finish.html#sqlite3backupfinish">sqlite3_backup_finish()</a>.</p>
<p>See Also: <a href="../backup.html">Using the SQLite Online Backup API</a>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,302 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Online Backup API.</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_backup_finish sqlite3_backup_init sqlite3_backup_pagecount sqlite3_backup_remaining sqlite3_backup_step -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Online Backup API.</h2>
</div>
<blockquote><pre>
sqlite3_backup *sqlite3_backup_init(
sqlite3 *pDest, /* Destination database handle */
const char *zDestName, /* Destination database name */
sqlite3 *pSource, /* Source database handle */
const char *zSourceName /* Source database name */
);
int sqlite3_backup_step(sqlite3_backup *p, int nPage);
int sqlite3_backup_finish(sqlite3_backup *p);
int sqlite3_backup_remaining(sqlite3_backup *p);
int sqlite3_backup_pagecount(sqlite3_backup *p);
</pre></blockquote>
<p>
The backup API copies the content of one database into another.
It is useful either for creating backups of databases or
for copying in-memory databases to or from persistent files.</p>
<p>See Also: <a href="../backup.html">Using the SQLite Online Backup API</a></p>
<p>SQLite holds a write transaction open on the destination database file
for the duration of the backup operation.
The source database is read-locked only while it is being read;
it is not locked continuously for the entire backup operation.
Thus, the backup may be performed on a live source database without
preventing other database connections from
reading or writing to the source database while the backup is underway.</p>
<p>To perform a backup operation:
<ol>
<li><b>sqlite3_backup_init()</b> is called once to initialize the
backup,
<li><b>sqlite3_backup_step()</b> is called one or more times to transfer
the data between the two databases, and finally
<li><b>sqlite3_backup_finish()</b> is called to release all resources
associated with the backup operation.
</ol>
There should be exactly one call to sqlite3_backup_finish() for each
successful call to sqlite3_backup_init().</p>
<p><a name="sqlite3backupinit"></a>
<b>sqlite3_backup_init()</b></p>
<p>The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
<a href="../c3ref/sqlite3.html">database connection</a> associated with the destination database
and the database name, respectively.
The database name is "main" for the main database, "temp" for the
temporary database, or the name specified after the AS keyword in
an <a href="../lang_attach.html">ATTACH</a> statement for an attached database.
The S and M arguments passed to
sqlite3_backup_init(D,N,S,M) identify the <a href="../c3ref/sqlite3.html">database connection</a>
and database name of the source database, respectively.
The source and destination <a href="../c3ref/sqlite3.html">database connections</a> (parameters S and D)
must be different or else sqlite3_backup_init(D,N,S,M) will fail with
an error.</p>
<p>A call to sqlite3_backup_init() will fail, returning NULL, if
there is already a read or read-write transaction open on the
destination database.</p>
<p>If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
returned and an error code and error message are stored in the
destination <a href="../c3ref/sqlite3.html">database connection</a> D.
The error code and message for the failed call to sqlite3_backup_init()
can be retrieved using the <a href="../c3ref/errcode.html">sqlite3_errcode()</a>, <a href="../c3ref/errcode.html">sqlite3_errmsg()</a>, and/or
<a href="../c3ref/errcode.html">sqlite3_errmsg16()</a> functions.
A successful call to sqlite3_backup_init() returns a pointer to an
<a href="../c3ref/backup.html">sqlite3_backup</a> object.
The <a href="../c3ref/backup.html">sqlite3_backup</a> object may be used with the sqlite3_backup_step() and
sqlite3_backup_finish() functions to perform the specified backup
operation.</p>
<p><a name="sqlite3backupstep"></a>
<b>sqlite3_backup_step()</b></p>
<p>Function sqlite3_backup_step(B,N) will copy up to N pages between
the source and destination databases specified by <a href="../c3ref/backup.html">sqlite3_backup</a> object B.
If N is negative, all remaining source pages are copied.
If sqlite3_backup_step(B,N) successfully copies N pages and there
are still more pages to be copied, then the function returns <a href="../rescode.html#ok">SQLITE_OK</a>.
If sqlite3_backup_step(B,N) successfully finishes copying all pages
from source to destination, then it returns <a href="../rescode.html#done">SQLITE_DONE</a>.
If an error occurs while running sqlite3_backup_step(B,N),
then an <a href="../rescode.html">error code</a> is returned. As well as <a href="../rescode.html#ok">SQLITE_OK</a> and
<a href="../rescode.html#done">SQLITE_DONE</a>, a call to sqlite3_backup_step() may return <a href="../rescode.html#readonly">SQLITE_READONLY</a>,
<a href="../rescode.html#nomem">SQLITE_NOMEM</a>, <a href="../rescode.html#busy">SQLITE_BUSY</a>, <a href="../rescode.html#locked">SQLITE_LOCKED</a>, or an
<a href="../rescode.html#ioerr_access">SQLITE_IOERR_XXX</a> extended error code.</p>
<p>The sqlite3_backup_step() might return <a href="../rescode.html#readonly">SQLITE_READONLY</a> if
<ol>
<li> the destination database was opened read-only, or
<li> the destination database is using write-ahead-log journaling
and the destination and source page sizes differ, or
<li> the destination database is an in-memory database and the
destination and source page sizes differ.
</ol></p>
<p>If sqlite3_backup_step() cannot obtain a required file-system lock, then
the <a href="../c3ref/busy_handler.html">busy-handler function</a>
is invoked (if one is specified). If the
busy-handler returns non-zero before the lock is available, then
<a href="../rescode.html#busy">SQLITE_BUSY</a> is returned to the caller. In this case the call to
sqlite3_backup_step() can be retried later. If the source
<a href="../c3ref/sqlite3.html">database connection</a>
is being used to write to the source database when sqlite3_backup_step()
is called, then <a href="../rescode.html#locked">SQLITE_LOCKED</a> is returned immediately. Again, in this
case the call to sqlite3_backup_step() can be retried later on. If
<a href="../rescode.html#ioerr_access">SQLITE_IOERR_XXX</a>, <a href="../rescode.html#nomem">SQLITE_NOMEM</a>, or
<a href="../rescode.html#readonly">SQLITE_READONLY</a> is returned, then
there is no point in retrying the call to sqlite3_backup_step(). These
errors are considered fatal. The application must accept
that the backup operation has failed and pass the backup operation handle
to the sqlite3_backup_finish() to release associated resources.</p>
<p>The first call to sqlite3_backup_step() obtains an exclusive lock
on the destination file. The exclusive lock is not released until either
sqlite3_backup_finish() is called or the backup operation is complete
and sqlite3_backup_step() returns <a href="../rescode.html#done">SQLITE_DONE</a>. Every call to
sqlite3_backup_step() obtains a <a href="../lockingv3.html#shared_lock">shared lock</a> on the source database that
lasts for the duration of the sqlite3_backup_step() call.
Because the source database is not locked between calls to
sqlite3_backup_step(), the source database may be modified mid-way
through the backup process. If the source database is modified by an
external process or via a database connection other than the one being
used by the backup operation, then the backup will be automatically
restarted by the next call to sqlite3_backup_step(). If the source
database is modified by the using the same database connection as is used
by the backup operation, then the backup database is automatically
updated at the same time.</p>
<p><a name="sqlite3backupfinish"></a>
<b>sqlite3_backup_finish()</b></p>
<p>When sqlite3_backup_step() has returned <a href="../rescode.html#done">SQLITE_DONE</a>, or when the
application wishes to abandon the backup operation, the application
should destroy the <a href="../c3ref/backup.html">sqlite3_backup</a> by passing it to sqlite3_backup_finish().
The sqlite3_backup_finish() interfaces releases all
resources associated with the <a href="../c3ref/backup.html">sqlite3_backup</a> object.
If sqlite3_backup_step() has not yet returned <a href="../rescode.html#done">SQLITE_DONE</a>, then any
active write-transaction on the destination database is rolled back.
The <a href="../c3ref/backup.html">sqlite3_backup</a> object is invalid
and may not be used following a call to sqlite3_backup_finish().</p>
<p>The value returned by sqlite3_backup_finish is <a href="../rescode.html#ok">SQLITE_OK</a> if no
sqlite3_backup_step() errors occurred, regardless or whether or not
sqlite3_backup_step() completed.
If an out-of-memory condition or IO error occurred during any prior
sqlite3_backup_step() call on the same <a href="../c3ref/backup.html">sqlite3_backup</a> object, then
sqlite3_backup_finish() returns the corresponding <a href="../rescode.html">error code</a>.</p>
<p>A return of <a href="../rescode.html#busy">SQLITE_BUSY</a> or <a href="../rescode.html#locked">SQLITE_LOCKED</a> from sqlite3_backup_step()
is not a permanent error and does not affect the return value of
sqlite3_backup_finish().</p>
<p><a name="sqlite3backupremaining"></a>
<a name="sqlite3backuppagecount"></a>
<b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b></p>
<p>The sqlite3_backup_remaining() routine returns the number of pages still
to be backed up at the conclusion of the most recent sqlite3_backup_step().
The sqlite3_backup_pagecount() routine returns the total number of pages
in the source database at the conclusion of the most recent
sqlite3_backup_step().
The values returned by these functions are only updated by
sqlite3_backup_step(). If the source database is modified in a way that
changes the size of the source database or the number of pages remaining,
those changes are not reflected in the output of sqlite3_backup_pagecount()
and sqlite3_backup_remaining() until after the next
sqlite3_backup_step().</p>
<p><b>Concurrent Usage of Database Handles</b></p>
<p>The source <a href="../c3ref/sqlite3.html">database connection</a> may be used by the application for other
purposes while a backup operation is underway or being initialized.
If SQLite is compiled and configured to support threadsafe database
connections, then the source database connection may be used concurrently
from within other threads.</p>
<p>However, the application must guarantee that the destination
<a href="../c3ref/sqlite3.html">database connection</a> is not passed to any other API (by any thread) after
sqlite3_backup_init() is called and before the corresponding call to
sqlite3_backup_finish(). SQLite does not currently check to see
if the application incorrectly accesses the destination <a href="../c3ref/sqlite3.html">database connection</a>
and so no error code is reported, but the operations may malfunction
nevertheless. Use of the destination database connection while a
backup is in progress might also also cause a mutex deadlock.</p>
<p>If running in <a href="../sharedcache.html">shared cache mode</a>, the application must
guarantee that the shared cache used by the destination database
is not accessed while the backup is running. In practice this means
that the application must guarantee that the disk file being
backed up to is not accessed by any connection within the process,
not just the specific connection that was passed to sqlite3_backup_init().</p>
<p>The <a href="../c3ref/backup.html">sqlite3_backup</a> object itself is partially threadsafe. Multiple
threads may safely make multiple concurrent calls to sqlite3_backup_step().
However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
APIs are not strictly speaking threadsafe. If they are invoked at the
same time as another thread is invoking sqlite3_backup_step() it is
possible that they return invalid values.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,250 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Binding Values To Prepared Statements</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {SQL parameter} {SQL parameters} {host parameter} {host parameter name} {host parameters} {parameter binding} sqlite3_bind_blob sqlite3_bind_blob64 sqlite3_bind_double sqlite3_bind_int sqlite3_bind_int64 sqlite3_bind_null sqlite3_bind_pointer sqlite3_bind_text sqlite3_bind_text16 sqlite3_bind_text64 sqlite3_bind_value sqlite3_bind_zeroblob sqlite3_bind_zeroblob64 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Binding Values To Prepared Statements</h2>
</div>
<blockquote><pre>
int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
void(*)(void*));
int sqlite3_bind_double(sqlite3_stmt*, int, double);
int sqlite3_bind_int(sqlite3_stmt*, int, int);
int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
int sqlite3_bind_null(sqlite3_stmt*, int);
int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));
int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
</pre></blockquote>
<p>
In the SQL statement text input to <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> and its variants,
literals may be replaced by a <a href="../lang_expr.html#varparam">parameter</a> that matches one of following
templates:</p>
<p><ul>
<li> ?
<li> ?NNN
<li> :VVV
<li> @VVV
<li> $VVV
</ul></p>
<p>In the templates above, NNN represents an integer literal,
and VVV represents an alphanumeric identifier. The values of these
parameters (also called "host parameter names" or "SQL parameters")
can be set using the sqlite3_bind_*() routines defined here.</p>
<p>The first argument to the sqlite3_bind_*() routines is always
a pointer to the <a href="../c3ref/stmt.html">sqlite3_stmt</a> object returned from
<a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> or its variants.</p>
<p>The second argument is the index of the SQL parameter to be set.
The leftmost SQL parameter has an index of 1. When the same named
SQL parameter is used more than once, second and subsequent
occurrences have the same index as the first occurrence.
The index for named parameters can be looked up using the
<a href="../c3ref/bind_parameter_index.html">sqlite3_bind_parameter_index()</a> API if desired. The index
for "?NNN" parameters is the value of NNN.
The NNN value must be between 1 and the <a href="../c3ref/limit.html">sqlite3_limit()</a>
parameter <a href="../c3ref/c_limit_attached.html#sqlitelimitvariablenumber">SQLITE_LIMIT_VARIABLE_NUMBER</a> (default value: 32766).</p>
<p>The third argument is the value to bind to the parameter.
If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()
or sqlite3_bind_blob() is a NULL pointer then the fourth parameter
is ignored and the end result is the same as sqlite3_bind_null().
If the third parameter to sqlite3_bind_text() is not NULL, then
it should be a pointer to well-formed UTF8 text.
If the third parameter to sqlite3_bind_text16() is not NULL, then
it should be a pointer to well-formed UTF16 text.
If the third parameter to sqlite3_bind_text64() is not NULL, then
it should be a pointer to a well-formed unicode string that is
either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16
otherwise.</p>
<p><a name="byteorderdeterminationrules"></a>
The byte-order of
UTF16 input text is determined by the byte-order mark (BOM, U+FEFF)
found in first character, which is removed, or in the absence of a BOM
the byte order is the native byte order of the host
machine for sqlite3_bind_text16() or the byte order specified in
the 6th parameter for sqlite3_bind_text64().
If UTF16 input text contains invalid unicode
characters, then SQLite might change those invalid characters
into the unicode replacement character: U+FFFD.</p>
<p>In those routines that have a fourth argument, its value is the
number of bytes in the parameter. To be clear: the value is the
number of <u>bytes</u> in the value, not the number of characters.
If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()
is negative, then the length of the string is
the number of bytes up to the first zero terminator.
If the fourth parameter to sqlite3_bind_blob() is negative, then
the behavior is undefined.
If a non-negative fourth parameter is provided to sqlite3_bind_text()
or sqlite3_bind_text16() or sqlite3_bind_text64() then
that parameter must be the byte offset
where the NUL terminator would occur assuming the string were NUL
terminated. If any NUL characters occurs at byte offsets less than
the value of the fourth parameter then the resulting string value will
contain embedded NULs. The result of expressions involving strings
with embedded NULs is undefined.</p>
<p>The fifth argument to the BLOB and string binding interfaces
is a destructor used to dispose of the BLOB or
string after SQLite has finished with it. The destructor is called
to dispose of the BLOB or string even if the call to the bind API fails,
except the destructor is not called if the third parameter is a NULL
pointer or the fourth parameter is negative.
If the fifth argument is
the special value <a href="../c3ref/c_static.html">SQLITE_STATIC</a>, then SQLite assumes that the
information is in static, unmanaged space and does not need to be freed.
If the fifth argument has the value <a href="../c3ref/c_static.html">SQLITE_TRANSIENT</a>, then
SQLite makes its own private copy of the data immediately, before
the sqlite3_bind_*() routine returns.</p>
<p>The sixth argument to sqlite3_bind_text64() must be one of
<a href="../c3ref/c_any.html">SQLITE_UTF8</a>, <a href="../c3ref/c_any.html">SQLITE_UTF16</a>, <a href="../c3ref/c_any.html">SQLITE_UTF16BE</a>, or <a href="../c3ref/c_any.html">SQLITE_UTF16LE</a>
to specify the encoding of the text in the third parameter. If
the sixth argument to sqlite3_bind_text64() is not one of the
allowed values shown above, or if the text encoding is different
from the encoding specified by the sixth parameter, then the behavior
is undefined.</p>
<p>The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
is filled with zeroes. A zeroblob uses a fixed amount of memory
(just an integer to hold its size) while it is being processed.
Zeroblobs are intended to serve as placeholders for BLOBs whose
content is later written using
<a href="../c3ref/blob_open.html">incremental BLOB I/O</a> routines.
A negative value for the zeroblob results in a zero-length BLOB.</p>
<p>The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in
<a href="../c3ref/stmt.html">prepared statement</a> S to have an SQL value of NULL, but to also be
associated with the pointer P of type T. D is either a NULL pointer or
a pointer to a destructor function for P. SQLite will invoke the
destructor D with a single argument of P when it is finished using
P. The T parameter should be a static string, preferably a string
literal. The sqlite3_bind_pointer() routine is part of the
<a href="../bindptr.html">pointer passing interface</a> added for SQLite 3.20.0.</p>
<p>If any of the sqlite3_bind_*() routines are called with a NULL pointer
for the <a href="../c3ref/stmt.html">prepared statement</a> or with a prepared statement for which
<a href="../c3ref/step.html">sqlite3_step()</a> has been called more recently than <a href="../c3ref/reset.html">sqlite3_reset()</a>,
then the call will return <a href="../rescode.html#misuse">SQLITE_MISUSE</a>. If any sqlite3_bind_()
routine is passed a <a href="../c3ref/stmt.html">prepared statement</a> that has been finalized, the
result is undefined and probably harmful.</p>
<p>Bindings are not cleared by the <a href="../c3ref/reset.html">sqlite3_reset()</a> routine.
Unbound parameters are interpreted as NULL.</p>
<p>The sqlite3_bind_* routines return <a href="../rescode.html#ok">SQLITE_OK</a> on success or an
<a href="../rescode.html">error code</a> if anything goes wrong.
<a href="../rescode.html#toobig">SQLITE_TOOBIG</a> might be returned if the size of a string or BLOB
exceeds limits imposed by <a href="../c3ref/limit.html">sqlite3_limit</a>(<a href="../c3ref/c_limit_attached.html#sqlitelimitlength">SQLITE_LIMIT_LENGTH</a>) or
<a href="../limits.html#max_length">SQLITE_MAX_LENGTH</a>.
<a href="../rescode.html#range">SQLITE_RANGE</a> is returned if the parameter
index is out of range. <a href="../rescode.html#nomem">SQLITE_NOMEM</a> is returned if malloc() fails.</p>
<p>See also: <a href="../c3ref/bind_parameter_count.html">sqlite3_bind_parameter_count()</a>,
<a href="../c3ref/bind_parameter_name.html">sqlite3_bind_parameter_name()</a>, and <a href="../c3ref/bind_parameter_index.html">sqlite3_bind_parameter_index()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Number Of SQL Parameters</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_bind_parameter_count -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Number Of SQL Parameters</h2>
</div>
<blockquote><pre>
int sqlite3_bind_parameter_count(sqlite3_stmt*);
</pre></blockquote>
<p>
This routine can be used to find the number of <a href="../c3ref/bind_blob.html">SQL parameters</a>
in a <a href="../c3ref/stmt.html">prepared statement</a>. SQL parameters are tokens of the
form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
placeholders for values that are <a href="../c3ref/bind_blob.html">bound</a>
to the parameters at a later time.</p>
<p>This routine actually returns the index of the largest (rightmost)
parameter. For all forms except ?NNN, this will correspond to the
number of unique parameters. If parameters of the ?NNN form are used,
there may be gaps in the list.</p>
<p>See also: <a href="../c3ref/bind_blob.html">sqlite3_bind()</a>,
<a href="../c3ref/bind_parameter_name.html">sqlite3_bind_parameter_name()</a>, and
<a href="../c3ref/bind_parameter_index.html">sqlite3_bind_parameter_index()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,117 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Index Of A Parameter With A Given Name</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_bind_parameter_index -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Index Of A Parameter With A Given Name</h2>
</div>
<blockquote><pre>
int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
</pre></blockquote>
<p>
Return the index of an SQL parameter given its name. The
index value returned is suitable for use as the second
parameter to <a href="../c3ref/bind_blob.html">sqlite3_bind()</a>. A zero
is returned if no matching parameter is found. The parameter
name must be given in UTF-8 even if the original statement
was prepared from UTF-16 text using <a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a> or
<a href="../c3ref/prepare.html">sqlite3_prepare16_v3()</a>.</p>
<p>See also: <a href="../c3ref/bind_blob.html">sqlite3_bind()</a>,
<a href="../c3ref/bind_parameter_count.html">sqlite3_bind_parameter_count()</a>, and
<a href="../c3ref/bind_parameter_name.html">sqlite3_bind_parameter_name()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Name Of A Host Parameter</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_bind_parameter_name -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Name Of A Host Parameter</h2>
</div>
<blockquote><pre>
const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
</pre></blockquote>
<p>
The sqlite3_bind_parameter_name(P,N) interface returns
the name of the N-th <a href="../c3ref/bind_blob.html">SQL parameter</a> in the <a href="../c3ref/stmt.html">prepared statement</a> P.
SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
respectively.
In other words, the initial ":" or "$" or "@" or "?"
is included as part of the name.
Parameters of the form "?" without a following integer have no name
and are referred to as "nameless" or "anonymous parameters".</p>
<p>The first host parameter has an index of 1, not 0.</p>
<p>If the value N is out of range or if the N-th parameter is
nameless, then NULL is returned. The returned string is
always in UTF-8 encoding even if the named parameter was
originally specified as UTF-16 in <a href="../c3ref/prepare.html">sqlite3_prepare16()</a>,
<a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a>, or <a href="../c3ref/prepare.html">sqlite3_prepare16_v3()</a>.</p>
<p>See also: <a href="../c3ref/bind_blob.html">sqlite3_bind()</a>,
<a href="../c3ref/bind_parameter_count.html">sqlite3_bind_parameter_count()</a>, and
<a href="../c3ref/bind_parameter_index.html">sqlite3_bind_parameter_index()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>A Handle To An Open BLOB</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {BLOB handle} {BLOB handles} sqlite3_blob -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>A Handle To An Open BLOB</h2>
</div>
<blockquote><pre>
typedef struct sqlite3_blob sqlite3_blob;
</pre></blockquote>
<p>
An instance of this object represents an open BLOB on which
<a href="../c3ref/blob_open.html">incremental BLOB I/O</a> can be performed.
Objects of this type are created by <a href="../c3ref/blob_open.html">sqlite3_blob_open()</a>
and destroyed by <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a>.
The <a href="../c3ref/blob_read.html">sqlite3_blob_read()</a> and <a href="../c3ref/blob_write.html">sqlite3_blob_write()</a> interfaces
can be used to read or write small subsections of the BLOB.
The <a href="../c3ref/blob_bytes.html">sqlite3_blob_bytes()</a> interface returns the size of the BLOB in bytes.
</p><p>Constructor: <a href="../c3ref/blob_open.html">sqlite3_blob_open()</a></p>
<p>Destructor: <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a></p>
<p>Methods:
<a href="../c3ref/blob_bytes.html">sqlite3_blob_bytes()</a>,
<a href="../c3ref/blob_read.html">sqlite3_blob_read()</a>,
<a href="../c3ref/blob_reopen.html">sqlite3_blob_reopen()</a>,
<a href="../c3ref/blob_write.html">sqlite3_blob_write()</a></p>
<p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Return The Size Of An Open BLOB</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_blob_bytes -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Return The Size Of An Open BLOB</h2>
</div>
<blockquote><pre>
int sqlite3_blob_bytes(sqlite3_blob *);
</pre></blockquote>
<p>
Returns the size in bytes of the BLOB accessible via the
successfully opened <a href="../c3ref/blob.html">BLOB handle</a> in its only argument. The
incremental blob I/O routines can only read or overwriting existing
blob content; they cannot change the size of a blob.</p>
<p>This routine only works on a <a href="../c3ref/blob.html">BLOB handle</a> which has been created
by a prior successful call to <a href="../c3ref/blob_open.html">sqlite3_blob_open()</a> and which has not
been closed by <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a>. Passing any other pointer in
to this routine results in undefined and probably undesirable behavior.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,122 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Close A BLOB Handle</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_blob_close -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Close A BLOB Handle</h2>
</div>
<blockquote><pre>
int sqlite3_blob_close(sqlite3_blob *);
</pre></blockquote>
<p>
This function closes an open <a href="../c3ref/blob.html">BLOB handle</a>. The BLOB handle is closed
unconditionally. Even if this routine returns an error code, the
handle is still closed.</p>
<p>If the blob handle being closed was opened for read-write access, and if
the database is in auto-commit mode and there are no other open read-write
blob handles or active write statements, the current transaction is
committed. If an error occurs while committing the transaction, an error
code is returned and the transaction rolled back.</p>
<p>Calling this function with an argument that is not a NULL pointer or an
open blob handle results in undefined behaviour. Calling this routine
with a null pointer (such as would be returned by a failed call to
<a href="../c3ref/blob_open.html">sqlite3_blob_open()</a>) is a harmless no-op. Otherwise, if this function
is passed a valid open blob handle, the values returned by the
sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,191 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Open A BLOB For Incremental I/O</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_blob_open -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Open A BLOB For Incremental I/O</h2>
</div>
<blockquote><pre>
int sqlite3_blob_open(
sqlite3*,
const char *zDb,
const char *zTable,
const char *zColumn,
sqlite3_int64 iRow,
int flags,
sqlite3_blob **ppBlob
);
</pre></blockquote>
<p>
This interfaces opens a <a href="../c3ref/blob.html">handle</a> to the BLOB located
in row iRow, column zColumn, table zTable in database zDb;
in other words, the same BLOB that would be selected by:</p>
<p><pre>
SELECT zColumn FROM zDb.zTable WHERE <a href="../lang_createtable.html#rowid">rowid</a> = iRow;
</pre></p>
<p>Parameter zDb is not the filename that contains the database, but
rather the symbolic name of the database. For attached databases, this is
the name that appears after the AS keyword in the <a href="../lang_attach.html">ATTACH</a> statement.
For the main database file, the database name is "main". For TEMP
tables, the database name is "temp".</p>
<p>If the flags parameter is non-zero, then the BLOB is opened for read
and write access. If the flags parameter is zero, the BLOB is opened for
read-only access.</p>
<p>On success, <a href="../rescode.html#ok">SQLITE_OK</a> is returned and the new <a href="../c3ref/blob.html">BLOB handle</a> is stored
in *ppBlob. Otherwise an <a href="../rescode.html">error code</a> is returned and, unless the error
code is SQLITE_MISUSE, *ppBlob is set to NULL. This means that, provided
the API is not misused, it is always safe to call <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a>
on *ppBlob after this function it returns.</p>
<p>This function fails with SQLITE_ERROR if any of the following are true:
<ul>
<li> Database zDb does not exist,
<li> Table zTable does not exist within database zDb,
<li> Table zTable is a WITHOUT ROWID table,
<li> Column zColumn does not exist,
<li> Row iRow is not present in the table,
<li> The specified column of row iRow contains a value that is not
a TEXT or BLOB value,
<li> Column zColumn is part of an index, PRIMARY KEY or UNIQUE
constraint and the blob is being opened for read/write access,
<li> <a href="../foreignkeys.html">Foreign key constraints</a> are enabled,
column zColumn is part of a <a href="../foreignkeys.html#parentchild">child key</a> definition and the blob is
being opened for read/write access.
</ul></p>
<p>Unless it returns SQLITE_MISUSE, this function sets the
<a href="../c3ref/sqlite3.html">database connection</a> error code and message accessible via
<a href="../c3ref/errcode.html">sqlite3_errcode()</a> and <a href="../c3ref/errcode.html">sqlite3_errmsg()</a> and related functions.</p>
<p>A BLOB referenced by sqlite3_blob_open() may be read using the
<a href="../c3ref/blob_read.html">sqlite3_blob_read()</a> interface and modified by using
<a href="../c3ref/blob_write.html">sqlite3_blob_write()</a>. The <a href="../c3ref/blob.html">BLOB handle</a> can be moved to a
different row of the same table using the <a href="../c3ref/blob_reopen.html">sqlite3_blob_reopen()</a>
interface. However, the column, table, or database of a <a href="../c3ref/blob.html">BLOB handle</a>
cannot be changed after the <a href="../c3ref/blob.html">BLOB handle</a> is opened.</p>
<p>If the row that a BLOB handle points to is modified by an
<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
then the BLOB handle is marked as "expired".
This is true if any column of the row is changed, even a column
other than the one the BLOB handle is open on.
Calls to <a href="../c3ref/blob_read.html">sqlite3_blob_read()</a> and <a href="../c3ref/blob_write.html">sqlite3_blob_write()</a> for
an expired BLOB handle fail with a return code of <a href="../rescode.html#abort">SQLITE_ABORT</a>.
Changes written into a BLOB prior to the BLOB expiring are not
rolled back by the expiration of the BLOB. Such changes will eventually
commit if the transaction continues to completion.</p>
<p>Use the <a href="../c3ref/blob_bytes.html">sqlite3_blob_bytes()</a> interface to determine the size of
the opened blob. The size of a blob may not be changed by this
interface. Use the <a href="../lang_update.html">UPDATE</a> SQL command to change the size of a
blob.</p>
<p>The <a href="../c3ref/bind_blob.html">sqlite3_bind_zeroblob()</a> and <a href="../c3ref/result_blob.html">sqlite3_result_zeroblob()</a> interfaces
and the built-in <a href="../lang_corefunc.html#zeroblob">zeroblob</a> SQL function may be used to create a
zero-filled blob to read or write using the incremental-blob interface.</p>
<p>To avoid a resource leak, every open <a href="../c3ref/blob.html">BLOB handle</a> should eventually
be released by a call to <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a>.</p>
<p>See also: <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a>,
<a href="../c3ref/blob_reopen.html">sqlite3_blob_reopen()</a>, <a href="../c3ref/blob_read.html">sqlite3_blob_read()</a>,
<a href="../c3ref/blob_bytes.html">sqlite3_blob_bytes()</a>, <a href="../c3ref/blob_write.html">sqlite3_blob_write()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,128 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Read Data From A BLOB Incrementally</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_blob_read -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Read Data From A BLOB Incrementally</h2>
</div>
<blockquote><pre>
int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
</pre></blockquote>
<p>
This function is used to read data from an open <a href="../c3ref/blob.html">BLOB handle</a> into a
caller-supplied buffer. N bytes of data are copied into buffer Z
from the open BLOB, starting at offset iOffset.</p>
<p>If offset iOffset is less than N bytes from the end of the BLOB,
<a href="../rescode.html#error">SQLITE_ERROR</a> is returned and no data is read. If N or iOffset is
less than zero, <a href="../rescode.html#error">SQLITE_ERROR</a> is returned and no data is read.
The size of the blob (and hence the maximum value of N+iOffset)
can be determined using the <a href="../c3ref/blob_bytes.html">sqlite3_blob_bytes()</a> interface.</p>
<p>An attempt to read from an expired <a href="../c3ref/blob.html">BLOB handle</a> fails with an
error code of <a href="../rescode.html#abort">SQLITE_ABORT</a>.</p>
<p>On success, sqlite3_blob_read() returns SQLITE_OK.
Otherwise, an <a href="../rescode.html">error code</a> or an <a href="../rescode.html#extrc">extended error code</a> is returned.</p>
<p>This routine only works on a <a href="../c3ref/blob.html">BLOB handle</a> which has been created
by a prior successful call to <a href="../c3ref/blob_open.html">sqlite3_blob_open()</a> and which has not
been closed by <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a>. Passing any other pointer in
to this routine results in undefined and probably undesirable behavior.</p>
<p>See also: <a href="../c3ref/blob_write.html">sqlite3_blob_write()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Move a BLOB Handle to a New Row</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_blob_reopen -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Move a BLOB Handle to a New Row</h2>
</div>
<blockquote><pre>
int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
</pre></blockquote>
<p>
This function is used to move an existing <a href="../c3ref/blob.html">BLOB handle</a> so that it points
to a different row of the same database table. The new row is identified
by the rowid value passed as the second argument. Only the row can be
changed. The database, table and column on which the blob handle is open
remain the same. Moving an existing <a href="../c3ref/blob.html">BLOB handle</a> to a new row is
faster than closing the existing handle and opening a new one.</p>
<p>The new row must meet the same criteria as for <a href="../c3ref/blob_open.html">sqlite3_blob_open()</a> -
it must exist and there must be either a blob or text value stored in
the nominated column. If the new row is not present in the table, or if
it does not contain a blob or text value, or if another error occurs, an
SQLite error code is returned and the blob handle is considered aborted.
All subsequent calls to <a href="../c3ref/blob_read.html">sqlite3_blob_read()</a>, <a href="../c3ref/blob_write.html">sqlite3_blob_write()</a> or
<a href="../c3ref/blob_reopen.html">sqlite3_blob_reopen()</a> on an aborted blob handle immediately return
SQLITE_ABORT. Calling <a href="../c3ref/blob_bytes.html">sqlite3_blob_bytes()</a> on an aborted blob handle
always returns zero.</p>
<p>This function sets the database handle error code and message.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,141 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Write Data Into A BLOB Incrementally</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_blob_write -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Write Data Into A BLOB Incrementally</h2>
</div>
<blockquote><pre>
int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
</pre></blockquote>
<p>
This function is used to write data into an open <a href="../c3ref/blob.html">BLOB handle</a> from a
caller-supplied buffer. N bytes of data are copied from the buffer Z
into the open BLOB, starting at offset iOffset.</p>
<p>On success, sqlite3_blob_write() returns SQLITE_OK.
Otherwise, an <a href="../rescode.html">error code</a> or an <a href="../rescode.html#extrc">extended error code</a> is returned.
Unless SQLITE_MISUSE is returned, this function sets the
<a href="../c3ref/sqlite3.html">database connection</a> error code and message accessible via
<a href="../c3ref/errcode.html">sqlite3_errcode()</a> and <a href="../c3ref/errcode.html">sqlite3_errmsg()</a> and related functions.</p>
<p>If the <a href="../c3ref/blob.html">BLOB handle</a> passed as the first argument was not opened for
writing (the flags parameter to <a href="../c3ref/blob_open.html">sqlite3_blob_open()</a> was zero),
this function returns <a href="../rescode.html#readonly">SQLITE_READONLY</a>.</p>
<p>This function may only modify the contents of the BLOB; it is
not possible to increase the size of a BLOB using this API.
If offset iOffset is less than N bytes from the end of the BLOB,
<a href="../rescode.html#error">SQLITE_ERROR</a> is returned and no data is written. The size of the
BLOB (and hence the maximum value of N+iOffset) can be determined
using the <a href="../c3ref/blob_bytes.html">sqlite3_blob_bytes()</a> interface. If N or iOffset are less
than zero <a href="../rescode.html#error">SQLITE_ERROR</a> is returned and no data is written.</p>
<p>An attempt to write to an expired <a href="../c3ref/blob.html">BLOB handle</a> fails with an
error code of <a href="../rescode.html#abort">SQLITE_ABORT</a>. Writes to the BLOB that occurred
before the <a href="../c3ref/blob.html">BLOB handle</a> expired are not rolled back by the
expiration of the handle, though of course those changes might
have been overwritten by the statement that expired the BLOB handle
or by other independent statements.</p>
<p>This routine only works on a <a href="../c3ref/blob.html">BLOB handle</a> which has been created
by a prior successful call to <a href="../c3ref/blob_open.html">sqlite3_blob_open()</a> and which has not
been closed by <a href="../c3ref/blob_close.html">sqlite3_blob_close()</a>. Passing any other pointer in
to this routine results in undefined and probably undesirable behavior.</p>
<p>See also: <a href="../c3ref/blob_read.html">sqlite3_blob_read()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,159 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Register A Callback To Handle SQLITE_BUSY Errors</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {busy handler} {busy-handler callback} sqlite3_busy_handler -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Register A Callback To Handle SQLITE_BUSY Errors</h2>
</div>
<blockquote><pre>
int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
</pre></blockquote>
<p>
The sqlite3_busy_handler(D,X,P) routine sets a callback function X
that might be invoked with argument P whenever
an attempt is made to access a database table associated with
<a href="../c3ref/sqlite3.html">database connection</a> D when another thread
or process has the table locked.
The sqlite3_busy_handler() interface is used to implement
<a href="../c3ref/busy_timeout.html">sqlite3_busy_timeout()</a> and <a href="../pragma.html#pragma_busy_timeout">PRAGMA busy_timeout</a>.</p>
<p>If the busy callback is NULL, then <a href="../rescode.html#busy">SQLITE_BUSY</a>
is returned immediately upon encountering the lock. If the busy callback
is not NULL, then the callback might be invoked with two arguments.</p>
<p>The first argument to the busy handler is a copy of the void* pointer which
is the third argument to sqlite3_busy_handler(). The second argument to
the busy handler callback is the number of times that the busy handler has
been invoked previously for the same locking event. If the
busy callback returns 0, then no additional attempts are made to
access the database and <a href="../rescode.html#busy">SQLITE_BUSY</a> is returned
to the application.
If the callback returns non-zero, then another attempt
is made to access the database and the cycle repeats.</p>
<p>The presence of a busy handler does not guarantee that it will be invoked
when there is lock contention. If SQLite determines that invoking the busy
handler could result in a deadlock, it will go ahead and return <a href="../rescode.html#busy">SQLITE_BUSY</a>
to the application instead of invoking the
busy handler.
Consider a scenario where one process is holding a read lock that
it is trying to promote to a reserved lock and
a second process is holding a reserved lock that it is trying
to promote to an exclusive lock. The first process cannot proceed
because it is blocked by the second and the second process cannot
proceed because it is blocked by the first. If both processes
invoke the busy handlers, neither will make any progress. Therefore,
SQLite returns <a href="../rescode.html#busy">SQLITE_BUSY</a> for the first process, hoping that this
will induce the first process to release its read lock and allow
the second process to proceed.</p>
<p>The default busy callback is NULL.</p>
<p>There can only be a single busy handler defined for each
<a href="../c3ref/sqlite3.html">database connection</a>. Setting a new busy handler clears any
previously set handler. Note that calling <a href="../c3ref/busy_timeout.html">sqlite3_busy_timeout()</a>
or evaluating <a href="../pragma.html#pragma_busy_timeout">PRAGMA busy_timeout=N</a> will change the
busy handler and thus clear any previously set busy handler.</p>
<p>The busy callback should not take any actions which modify the
database connection that invoked the busy handler. In other words,
the busy handler is not reentrant. Any such actions
result in undefined behavior.</p>
<p>A busy handler must not close the database connection
or <a href="../c3ref/stmt.html">prepared statement</a> that invoked the busy handler.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,122 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Set A Busy Timeout</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_busy_timeout -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Set A Busy Timeout</h2>
</div>
<blockquote><pre>
int sqlite3_busy_timeout(sqlite3*, int ms);
</pre></blockquote>
<p>
This routine sets a <a href="../c3ref/busy_handler.html">busy handler</a> that sleeps
for a specified amount of time when a table is locked. The handler
will sleep multiple times until at least "ms" milliseconds of sleeping
have accumulated. After at least "ms" milliseconds of sleeping,
the handler returns 0 which causes <a href="../c3ref/step.html">sqlite3_step()</a> to return
<a href="../rescode.html#busy">SQLITE_BUSY</a>.</p>
<p>Calling this routine with an argument less than or equal to zero
turns off all busy handlers.</p>
<p>There can only be a single busy handler for a particular
<a href="../c3ref/sqlite3.html">database connection</a> at any given moment. If another busy handler
was defined (using <a href="../c3ref/busy_handler.html">sqlite3_busy_handler()</a>) prior to calling
this routine, that other busy handler is cleared.</p>
<p>See also: <a href="../pragma.html#pragma_busy_timeout">PRAGMA busy_timeout</a>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,144 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Result Codes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_ABORT SQLITE_AUTH SQLITE_BUSY SQLITE_CANTOPEN SQLITE_CONSTRAINT SQLITE_CORRUPT SQLITE_DONE SQLITE_EMPTY SQLITE_ERROR SQLITE_FORMAT SQLITE_FULL SQLITE_INTERNAL SQLITE_INTERRUPT SQLITE_IOERR SQLITE_LOCKED SQLITE_MISMATCH SQLITE_MISUSE SQLITE_NOLFS SQLITE_NOMEM SQLITE_NOTADB SQLITE_NOTFOUND SQLITE_NOTICE SQLITE_OK SQLITE_PERM SQLITE_PROTOCOL SQLITE_RANGE SQLITE_READONLY SQLITE_ROW SQLITE_SCHEMA SQLITE_TOOBIG SQLITE_WARNING {result code definitions} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Result Codes</h2>
</div>
<blockquote><pre>
#define SQLITE_OK 0 /* Successful result */
/* beginning-of-error-codes */
#define SQLITE_ERROR 1 /* Generic error */
#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
#define SQLITE_PERM 3 /* Access permission denied */
#define SQLITE_ABORT 4 /* Callback routine requested an abort */
#define SQLITE_BUSY 5 /* The database file is locked */
#define SQLITE_LOCKED 6 /* A table in the database is locked */
#define SQLITE_NOMEM 7 /* A malloc() failed */
#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
#define SQLITE_FULL 13 /* Insertion failed because database is full */
#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
#define SQLITE_EMPTY 16 /* Internal use only */
#define SQLITE_SCHEMA 17 /* The database schema changed */
#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
#define SQLITE_MISMATCH 20 /* Data type mismatch */
#define SQLITE_MISUSE 21 /* Library used incorrectly */
#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
#define SQLITE_AUTH 23 /* Authorization denied */
#define SQLITE_FORMAT 24 /* Not used */
#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
#define SQLITE_NOTADB 26 /* File opened that is not a database file */
#define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
#define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
/* end-of-error-codes */
</pre></blockquote>
<p>
Many SQLite functions return an integer result code from the set shown
here in order to indicate success or failure.</p>
<p>New error codes may be added in future versions of SQLite.</p>
<p>See also: <a href="../c3ref/c_abort_rollback.html">extended result code definitions</a>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,190 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Extended Result Codes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_ABORT_ROLLBACK SQLITE_AUTH_USER SQLITE_BUSY_RECOVERY SQLITE_BUSY_SNAPSHOT SQLITE_BUSY_TIMEOUT SQLITE_CANTOPEN_CONVPATH SQLITE_CANTOPEN_DIRTYWAL SQLITE_CANTOPEN_FULLPATH SQLITE_CANTOPEN_ISDIR SQLITE_CANTOPEN_NOTEMPDIR SQLITE_CANTOPEN_SYMLINK SQLITE_CONSTRAINT_CHECK SQLITE_CONSTRAINT_COMMITHOOK SQLITE_CONSTRAINT_FOREIGNKEY SQLITE_CONSTRAINT_FUNCTION SQLITE_CONSTRAINT_NOTNULL SQLITE_CONSTRAINT_PINNED SQLITE_CONSTRAINT_PRIMARYKEY SQLITE_CONSTRAINT_ROWID SQLITE_CONSTRAINT_TRIGGER SQLITE_CONSTRAINT_UNIQUE SQLITE_CONSTRAINT_VTAB SQLITE_CORRUPT_INDEX SQLITE_CORRUPT_SEQUENCE SQLITE_CORRUPT_VTAB SQLITE_ERROR_MISSING_COLLSEQ SQLITE_ERROR_RETRY SQLITE_ERROR_SNAPSHOT SQLITE_IOERR_ACCESS SQLITE_IOERR_AUTH SQLITE_IOERR_BEGIN_ATOMIC SQLITE_IOERR_BLOCKED SQLITE_IOERR_CHECKRESERVEDLOCK SQLITE_IOERR_CLOSE SQLITE_IOERR_COMMIT_ATOMIC SQLITE_IOERR_CONVPATH SQLITE_IOERR_DATA SQLITE_IOERR_DELETE SQLITE_IOERR_DELETE_NOENT SQLITE_IOERR_DIR_CLOSE SQLITE_IOERR_DIR_FSYNC SQLITE_IOERR_FSTAT SQLITE_IOERR_FSYNC SQLITE_IOERR_GETTEMPPATH SQLITE_IOERR_LOCK SQLITE_IOERR_MMAP SQLITE_IOERR_NOMEM SQLITE_IOERR_RDLOCK SQLITE_IOERR_READ SQLITE_IOERR_ROLLBACK_ATOMIC SQLITE_IOERR_SEEK SQLITE_IOERR_SHMLOCK SQLITE_IOERR_SHMMAP SQLITE_IOERR_SHMOPEN SQLITE_IOERR_SHMSIZE SQLITE_IOERR_SHORT_READ SQLITE_IOERR_TRUNCATE SQLITE_IOERR_UNLOCK SQLITE_IOERR_VNODE SQLITE_IOERR_WRITE SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_VTAB SQLITE_NOTICE_RECOVER_ROLLBACK SQLITE_NOTICE_RECOVER_WAL SQLITE_OK_LOAD_PERMANENTLY SQLITE_OK_SYMLINK SQLITE_READONLY_CANTINIT SQLITE_READONLY_CANTLOCK SQLITE_READONLY_DBMOVED SQLITE_READONLY_DIRECTORY SQLITE_READONLY_RECOVERY SQLITE_READONLY_ROLLBACK SQLITE_WARNING_AUTOINDEX {extended result code definitions} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Extended Result Codes</h2>
</div>
<blockquote><pre>
#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1&lt;&lt;8))
#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2&lt;&lt;8))
#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3&lt;&lt;8))
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1&lt;&lt;8))
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2&lt;&lt;8))
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3&lt;&lt;8))
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4&lt;&lt;8))
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5&lt;&lt;8))
#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6&lt;&lt;8))
#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7&lt;&lt;8))
#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8&lt;&lt;8))
#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9&lt;&lt;8))
#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10&lt;&lt;8))
#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11&lt;&lt;8))
#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12&lt;&lt;8))
#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13&lt;&lt;8))
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14&lt;&lt;8))
#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15&lt;&lt;8))
#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16&lt;&lt;8))
#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17&lt;&lt;8))
#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18&lt;&lt;8))
#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19&lt;&lt;8))
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20&lt;&lt;8))
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21&lt;&lt;8))
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22&lt;&lt;8))
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23&lt;&lt;8))
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24&lt;&lt;8))
#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25&lt;&lt;8))
#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26&lt;&lt;8))
#define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27&lt;&lt;8))
#define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28&lt;&lt;8))
#define SQLITE_IOERR_BEGIN_ATOMIC (SQLITE_IOERR | (29&lt;&lt;8))
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30&lt;&lt;8))
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31&lt;&lt;8))
#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32&lt;&lt;8))
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1&lt;&lt;8))
#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2&lt;&lt;8))
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1&lt;&lt;8))
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2&lt;&lt;8))
#define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3&lt;&lt;8))
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1&lt;&lt;8))
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2&lt;&lt;8))
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3&lt;&lt;8))
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4&lt;&lt;8))
#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5&lt;&lt;8)) /* Not Used */
#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6&lt;&lt;8))
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1&lt;&lt;8))
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2&lt;&lt;8))
#define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3&lt;&lt;8))
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1&lt;&lt;8))
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2&lt;&lt;8))
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3&lt;&lt;8))
#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4&lt;&lt;8))
#define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5&lt;&lt;8))
#define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6&lt;&lt;8))
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2&lt;&lt;8))
#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1&lt;&lt;8))
#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2&lt;&lt;8))
#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3&lt;&lt;8))
#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4&lt;&lt;8))
#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5&lt;&lt;8))
#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6&lt;&lt;8))
#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7&lt;&lt;8))
#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8&lt;&lt;8))
#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9&lt;&lt;8))
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10&lt;&lt;8))
#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11&lt;&lt;8))
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1&lt;&lt;8))
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2&lt;&lt;8))
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1&lt;&lt;8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1&lt;&lt;8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1&lt;&lt;8))
#define SQLITE_OK_SYMLINK (SQLITE_OK | (2&lt;&lt;8))
</pre></blockquote>
<p>
In its default configuration, SQLite API routines return one of 30 integer
<a href="../rescode.html">result codes</a>. However, experience has shown that many of
these result codes are too coarse-grained. They do not provide as
much information about problems as programmers might like. In an effort to
address this, newer versions of SQLite (version 3.3.8 2006-10-09
and later) include
support for additional result codes that provide more detailed information
about errors. These <a href="../rescode.html#extrc">extended result codes</a> are enabled or disabled
on a per database connection basis using the
<a href="../c3ref/extended_result_codes.html">sqlite3_extended_result_codes()</a> API. Or, the extended code for
the most recent error can be obtained using
<a href="../c3ref/errcode.html">sqlite3_extended_errcode()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Flags for the xAccess VFS method</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_ACCESS_EXISTS SQLITE_ACCESS_READ SQLITE_ACCESS_READWRITE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Flags for the xAccess VFS method</h2>
</div>
<blockquote><pre>
#define SQLITE_ACCESS_EXISTS 0
#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
#define SQLITE_ACCESS_READ 2 /* Unused */
</pre></blockquote>
<p>
These integer constants can be used as the third parameter to
the xAccess method of an <a href="../c3ref/vfs.html">sqlite3_vfs</a> object. They determine
what kind of permissions the xAccess method is looking for.
With SQLITE_ACCESS_EXISTS, the xAccess method
simply checks whether the file exists.
With SQLITE_ACCESS_READWRITE, the xAccess method
checks whether the named directory is both readable and writable
(in other words, if files can be added, removed, and renamed within
the directory).
The SQLITE_ACCESS_READWRITE constant is currently used only by the
<a href="../pragma.html#pragma_temp_store_directory">temp_store_directory pragma</a>, though this could change in a future
release of SQLite.
With SQLITE_ACCESS_READ, the xAccess method
checks whether the file is readable. The SQLITE_ACCESS_READ constant is
currently unused, though it might be used in a future release of
SQLite.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,155 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Authorizer Action Codes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_ALTER_TABLE SQLITE_ANALYZE SQLITE_ATTACH SQLITE_COPY SQLITE_CREATE_INDEX SQLITE_CREATE_TABLE SQLITE_CREATE_TEMP_INDEX SQLITE_CREATE_TEMP_TABLE SQLITE_CREATE_TEMP_TRIGGER SQLITE_CREATE_TEMP_VIEW SQLITE_CREATE_TRIGGER SQLITE_CREATE_VIEW SQLITE_CREATE_VTABLE SQLITE_DELETE SQLITE_DETACH SQLITE_DROP_INDEX SQLITE_DROP_TABLE SQLITE_DROP_TEMP_INDEX SQLITE_DROP_TEMP_TABLE SQLITE_DROP_TEMP_TRIGGER SQLITE_DROP_TEMP_VIEW SQLITE_DROP_TRIGGER SQLITE_DROP_VIEW SQLITE_DROP_VTABLE SQLITE_FUNCTION SQLITE_INSERT SQLITE_PRAGMA SQLITE_READ SQLITE_RECURSIVE SQLITE_REINDEX SQLITE_SAVEPOINT SQLITE_SELECT SQLITE_TRANSACTION SQLITE_UPDATE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Authorizer Action Codes</h2>
</div>
<blockquote><pre>
/******************************************* 3rd ************ 4th ***********/
#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */
#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
#define SQLITE_CREATE_VIEW 8 /* View Name NULL */
#define SQLITE_DELETE 9 /* Table Name NULL */
#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
#define SQLITE_DROP_TABLE 11 /* Table Name NULL */
#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */
#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
#define SQLITE_DROP_VIEW 17 /* View Name NULL */
#define SQLITE_INSERT 18 /* Table Name NULL */
#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */
#define SQLITE_READ 20 /* Table Name Column Name */
#define SQLITE_SELECT 21 /* NULL NULL */
#define SQLITE_TRANSACTION 22 /* Operation NULL */
#define SQLITE_UPDATE 23 /* Table Name Column Name */
#define SQLITE_ATTACH 24 /* Filename NULL */
#define SQLITE_DETACH 25 /* Database Name NULL */
#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
#define SQLITE_REINDEX 27 /* Index Name NULL */
#define SQLITE_ANALYZE 28 /* Table Name NULL */
#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
#define SQLITE_FUNCTION 31 /* NULL Function Name */
#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
#define SQLITE_COPY 0 /* No longer used */
#define SQLITE_RECURSIVE 33 /* NULL NULL */
</pre></blockquote>
<p>
The <a href="../c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> interface registers a callback function
that is invoked to authorize certain SQL statement actions. The
second parameter to the callback is an integer code that specifies
what action is being authorized. These are the integer action codes that
the authorizer callback may be passed.</p>
<p>These action code values signify what kind of operation is to be
authorized. The 3rd and 4th parameters to the authorization
callback function will be parameters or NULL depending on which of these
codes is used as the second parameter. The 5th parameter to the
authorizer callback is the name of the database ("main", "temp",
etc.) if applicable. The 6th parameter to the authorizer callback
is the name of the inner-most trigger or view that is responsible for
the access attempt or NULL if this access attempt is directly from
top-level SQL code.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,113 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Text Encodings</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_ANY SQLITE_UTF16 SQLITE_UTF16BE SQLITE_UTF16LE SQLITE_UTF16_ALIGNED SQLITE_UTF8 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Text Encodings</h2>
</div>
<blockquote><pre>
#define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
#define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
#define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */
#define SQLITE_UTF16 4 /* Use native byte order */
#define SQLITE_ANY 5 /* Deprecated */
#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
</pre></blockquote>
<p>
These constant define integer codes that represent the various
text encodings supported by SQLite.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,131 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Fundamental Datatypes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_BLOB SQLITE_FLOAT SQLITE_INTEGER SQLITE_NULL SQLITE_TEXT -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Fundamental Datatypes</h2>
</div>
<blockquote><pre>
#define SQLITE_INTEGER 1
#define SQLITE_FLOAT 2
#define SQLITE_BLOB 4
#define SQLITE_NULL 5
#ifdef SQLITE_TEXT
# undef SQLITE_TEXT
#else
# define SQLITE_TEXT 3
#endif
#define SQLITE3_TEXT 3
</pre></blockquote>
<p>
Every value in SQLite has one of five fundamental datatypes:</p>
<p><ul>
<li> 64-bit signed integer
<li> 64-bit IEEE floating point number
<li> string
<li> BLOB
<li> NULL
</ul></p>
<p>These constants are codes for each of those types.</p>
<p>Note that the SQLITE_TEXT constant was also used in SQLite version 2
for a completely different meaning. Software that links against both
SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not
SQLITE_TEXT.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,113 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Checkpoint Mode Values</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_CHECKPOINT_FULL SQLITE_CHECKPOINT_PASSIVE SQLITE_CHECKPOINT_RESTART SQLITE_CHECKPOINT_TRUNCATE {checkpoint mode} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Checkpoint Mode Values</h2>
</div>
<blockquote><pre>
#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
</pre></blockquote>
<p>
These constants define all valid values for the "checkpoint mode" passed
as the third parameter to the <a href="../c3ref/wal_checkpoint_v2.html">sqlite3_wal_checkpoint_v2()</a> interface.
See the <a href="../c3ref/wal_checkpoint_v2.html">sqlite3_wal_checkpoint_v2()</a> documentation for details on the
meaning of each of these checkpoint modes.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,510 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Configuration Options</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_CONFIG_COVERING_INDEX_SCAN SQLITE_CONFIG_GETMALLOC SQLITE_CONFIG_GETMUTEX SQLITE_CONFIG_GETPCACHE SQLITE_CONFIG_GETPCACHE2 SQLITE_CONFIG_HEAP SQLITE_CONFIG_LOG SQLITE_CONFIG_LOOKASIDE SQLITE_CONFIG_MALLOC SQLITE_CONFIG_MEMDB_MAXSIZE SQLITE_CONFIG_MEMSTATUS SQLITE_CONFIG_MMAP_SIZE SQLITE_CONFIG_MULTITHREAD SQLITE_CONFIG_MUTEX SQLITE_CONFIG_PAGECACHE SQLITE_CONFIG_PCACHE SQLITE_CONFIG_PCACHE2 SQLITE_CONFIG_PCACHE_HDRSZ SQLITE_CONFIG_PMASZ SQLITE_CONFIG_SCRATCH SQLITE_CONFIG_SERIALIZED SQLITE_CONFIG_SINGLETHREAD SQLITE_CONFIG_SMALL_MALLOC SQLITE_CONFIG_SORTERREF_SIZE SQLITE_CONFIG_SQLLOG SQLITE_CONFIG_STMTJRNL_SPILL SQLITE_CONFIG_URI SQLITE_CONFIG_WIN32_HEAPSIZE {configuration option} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Configuration Options</h2>
</div>
<blockquote><pre>
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */
#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
#define SQLITE_CONFIG_PCACHE 14 /* no-op */
#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
#define SQLITE_CONFIG_URI 17 /* int */
#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */
</pre></blockquote>
<p>
These constants are the available integer configuration options that
can be passed as the first argument to the <a href="../c3ref/config.html">sqlite3_config()</a> interface.</p>
<p>New configuration options may be added in future releases of SQLite.
Existing configuration options might be discontinued. Applications
should check the return code from <a href="../c3ref/config.html">sqlite3_config()</a> to make sure that
the call worked. The <a href="../c3ref/config.html">sqlite3_config()</a> interface will return a
non-zero <a href="../rescode.html">error code</a> if a discontinued or unsupported configuration option
is invoked.</p>
<p><dl>
<a name="sqliteconfigsinglethread"></a>
<dt>SQLITE_CONFIG_SINGLETHREAD</dt>
<dd>There are no arguments to this option. This option sets the
<a href="../threadsafe.html">threading mode</a> to Single-thread. In other words, it disables
all mutexing and puts SQLite into a mode where it can only be used
by a single thread. If SQLite is compiled with
the <a href="../compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
it is not possible to change the <a href="../threadsafe.html">threading mode</a> from its default
value of Single-thread and so <a href="../c3ref/config.html">sqlite3_config()</a> will return
<a href="../rescode.html#error">SQLITE_ERROR</a> if called with the SQLITE_CONFIG_SINGLETHREAD
configuration option.</dd></p>
<p><a name="sqliteconfigmultithread"></a>
<dt>SQLITE_CONFIG_MULTITHREAD</dt>
<dd>There are no arguments to this option. This option sets the
<a href="../threadsafe.html">threading mode</a> to Multi-thread. In other words, it disables
mutexing on <a href="../c3ref/sqlite3.html">database connection</a> and <a href="../c3ref/stmt.html">prepared statement</a> objects.
The application is responsible for serializing access to
<a href="../c3ref/sqlite3.html">database connections</a> and <a href="../c3ref/stmt.html">prepared statements</a>. But other mutexes
are enabled so that SQLite will be safe to use in a multi-threaded
environment as long as no two threads attempt to use the same
<a href="../c3ref/sqlite3.html">database connection</a> at the same time. If SQLite is compiled with
the <a href="../compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
it is not possible to set the Multi-thread <a href="../threadsafe.html">threading mode</a> and
<a href="../c3ref/config.html">sqlite3_config()</a> will return <a href="../rescode.html#error">SQLITE_ERROR</a> if called with the
SQLITE_CONFIG_MULTITHREAD configuration option.</dd></p>
<p><a name="sqliteconfigserialized"></a>
<dt>SQLITE_CONFIG_SERIALIZED</dt>
<dd>There are no arguments to this option. This option sets the
<a href="../threadsafe.html">threading mode</a> to Serialized. In other words, this option enables
all mutexes including the recursive
mutexes on <a href="../c3ref/sqlite3.html">database connection</a> and <a href="../c3ref/stmt.html">prepared statement</a> objects.
In this mode (which is the default when SQLite is compiled with
<a href="../compile.html#threadsafe">SQLITE_THREADSAFE=1</a>) the SQLite library will itself serialize access
to <a href="../c3ref/sqlite3.html">database connections</a> and <a href="../c3ref/stmt.html">prepared statements</a> so that the
application is free to use the same <a href="../c3ref/sqlite3.html">database connection</a> or the
same <a href="../c3ref/stmt.html">prepared statement</a> in different threads at the same time.
If SQLite is compiled with
the <a href="../compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
it is not possible to set the Serialized <a href="../threadsafe.html">threading mode</a> and
<a href="../c3ref/config.html">sqlite3_config()</a> will return <a href="../rescode.html#error">SQLITE_ERROR</a> if called with the
SQLITE_CONFIG_SERIALIZED configuration option.</dd></p>
<p><a name="sqliteconfigmalloc"></a>
<dt>SQLITE_CONFIG_MALLOC</dt>
<dd> The SQLITE_CONFIG_MALLOC option takes a single argument which is
a pointer to an instance of the <a href="../c3ref/mem_methods.html">sqlite3_mem_methods</a> structure.
The argument specifies
alternative low-level memory allocation routines to be used in place of
the memory allocation routines built into SQLite. SQLite makes
its own private copy of the content of the <a href="../c3ref/mem_methods.html">sqlite3_mem_methods</a> structure
before the <a href="../c3ref/config.html">sqlite3_config()</a> call returns.</dd></p>
<p><a name="sqliteconfiggetmalloc"></a>
<dt>SQLITE_CONFIG_GETMALLOC</dt>
<dd> The SQLITE_CONFIG_GETMALLOC option takes a single argument which
is a pointer to an instance of the <a href="../c3ref/mem_methods.html">sqlite3_mem_methods</a> structure.
The <a href="../c3ref/mem_methods.html">sqlite3_mem_methods</a>
structure is filled with the currently defined memory allocation routines.
This option can be used to overload the default memory allocation
routines with a wrapper that simulations memory allocation failure or
tracks memory usage, for example. </dd></p>
<p><a name="sqliteconfigsmallmalloc"></a>
<dt>SQLITE_CONFIG_SMALL_MALLOC</dt>
<dd> The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of
type int, interpreted as a boolean, which if true provides a hint to
SQLite that it should avoid large memory allocations if possible.
SQLite will run faster if it is free to make large memory allocations,
but some application might prefer to run slower in exchange for
guarantees about memory fragmentation that are possible if large
allocations are avoided. This hint is normally off.
</dd></p>
<p><a name="sqliteconfigmemstatus"></a>
<dt>SQLITE_CONFIG_MEMSTATUS</dt>
<dd> The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
interpreted as a boolean, which enables or disables the collection of
memory allocation statistics. When memory allocation statistics are
disabled, the following SQLite interfaces become non-operational:
<ul>
<li> <a href="../c3ref/hard_heap_limit64.html">sqlite3_hard_heap_limit64()</a>
<li> <a href="../c3ref/memory_highwater.html">sqlite3_memory_used()</a>
<li> <a href="../c3ref/memory_highwater.html">sqlite3_memory_highwater()</a>
<li> <a href="../c3ref/hard_heap_limit64.html">sqlite3_soft_heap_limit64()</a>
<li> <a href="../c3ref/status.html">sqlite3_status64()</a>
</ul>
Memory allocation statistics are enabled by default unless SQLite is
compiled with <a href="../compile.html#default_memstatus">SQLITE_DEFAULT_MEMSTATUS</a>=0 in which case memory
allocation statistics are disabled by default.
</dd></p>
<p><a name="sqliteconfigscratch"></a>
<dt>SQLITE_CONFIG_SCRATCH</dt>
<dd> The SQLITE_CONFIG_SCRATCH option is no longer used.
</dd></p>
<p><a name="sqliteconfigpagecache"></a>
<dt>SQLITE_CONFIG_PAGECACHE</dt>
<dd> The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
that SQLite can use for the database page cache with the default page
cache implementation.
This configuration option is a no-op if an application-defined page
cache implementation is loaded using the <a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpcache2">SQLITE_CONFIG_PCACHE2</a>.
There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
8-byte aligned memory (pMem), the size of each page cache line (sz),
and the number of cache lines (N).
The sz argument should be the size of the largest database page
(a power of two between 512 and 65536) plus some extra bytes for each
page header. The number of extra bytes needed by the page header
can be determined using <a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpcachehdrsz">SQLITE_CONFIG_PCACHE_HDRSZ</a>.
It is harmless, apart from the wasted memory,
for the sz parameter to be larger than necessary. The pMem
argument must be either a NULL pointer or a pointer to an 8-byte
aligned block of memory of at least sz*N bytes, otherwise
subsequent behavior is undefined.
When pMem is not NULL, SQLite will strive to use the memory provided
to satisfy page cache needs, falling back to <a href="../c3ref/free.html">sqlite3_malloc()</a> if
a page cache line is larger than sz bytes or if all of the pMem buffer
is exhausted.
If pMem is NULL and N is non-zero, then each database connection
does an initial bulk allocation for page cache memory
from <a href="../c3ref/free.html">sqlite3_malloc()</a> sufficient for N cache lines if N is positive or
of -1024*N bytes if N is negative, . If additional
page cache memory is needed beyond what is provided by the initial
allocation, then SQLite goes to <a href="../c3ref/free.html">sqlite3_malloc()</a> separately for each
additional cache line. </dd></p>
<p><a name="sqliteconfigheap"></a>
<dt>SQLITE_CONFIG_HEAP</dt>
<dd> The SQLITE_CONFIG_HEAP option specifies a static memory buffer
that SQLite will use for all of its dynamic memory allocation needs
beyond those provided for by <a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>.
The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
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
<a href="../rescode.html#error">SQLITE_ERROR</a> if invoked otherwise.
There are three arguments to SQLITE_CONFIG_HEAP:
An 8-byte aligned pointer to the memory,
the number of bytes in the memory buffer, and the minimum allocation size.
If the first pointer (the memory pointer) is NULL, then SQLite reverts
to using its default memory allocator (the system malloc() implementation),
undoing any prior invocation of <a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigmalloc">SQLITE_CONFIG_MALLOC</a>. If the
memory pointer is not NULL then the alternative memory
allocator is engaged to handle all of SQLites memory allocation needs.
The first pointer (the memory pointer) must be aligned to an 8-byte
boundary or subsequent behavior of SQLite will be undefined.
The minimum allocation size is capped at 2**12. Reasonable values
for the minimum allocation size are 2**5 through 2**8.</dd></p>
<p><a name="sqliteconfigmutex"></a>
<dt>SQLITE_CONFIG_MUTEX</dt>
<dd> The SQLITE_CONFIG_MUTEX option takes a single argument which is a
pointer to an instance of the <a href="../c3ref/mutex_methods.html">sqlite3_mutex_methods</a> structure.
The argument specifies alternative low-level mutex routines to be used
in place the mutex routines built into SQLite. SQLite makes a copy of
the content of the <a href="../c3ref/mutex_methods.html">sqlite3_mutex_methods</a> structure before the call to
<a href="../c3ref/config.html">sqlite3_config()</a> returns. If SQLite is compiled with
the <a href="../compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
the entire mutexing subsystem is omitted from the build and hence calls to
<a href="../c3ref/config.html">sqlite3_config()</a> with the SQLITE_CONFIG_MUTEX configuration option will
return <a href="../rescode.html#error">SQLITE_ERROR</a>.</dd></p>
<p><a name="sqliteconfiggetmutex"></a>
<dt>SQLITE_CONFIG_GETMUTEX</dt>
<dd> The SQLITE_CONFIG_GETMUTEX option takes a single argument which
is a pointer to an instance of the <a href="../c3ref/mutex_methods.html">sqlite3_mutex_methods</a> structure. The
<a href="../c3ref/mutex_methods.html">sqlite3_mutex_methods</a>
structure is filled with the currently defined mutex routines.
This option can be used to overload the default mutex allocation
routines with a wrapper used to track mutex usage for performance
profiling or testing, for example. If SQLite is compiled with
the <a href="../compile.html#threadsafe">SQLITE_THREADSAFE=0</a> compile-time option then
the entire mutexing subsystem is omitted from the build and hence calls to
<a href="../c3ref/config.html">sqlite3_config()</a> with the SQLITE_CONFIG_GETMUTEX configuration option will
return <a href="../rescode.html#error">SQLITE_ERROR</a>.</dd></p>
<p><a name="sqliteconfiglookaside"></a>
<dt>SQLITE_CONFIG_LOOKASIDE</dt>
<dd> The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
the default size of lookaside memory on each <a href="../c3ref/sqlite3.html">database connection</a>.
The first argument is the
size of each lookaside buffer slot and the second is the number of
slots allocated to each database connection. SQLITE_CONFIG_LOOKASIDE
sets the <i>default</i> lookaside size. The <a href="../c3ref/c_dbconfig_defensive.html#sqlitedbconfiglookaside">SQLITE_DBCONFIG_LOOKASIDE</a>
option to <a href="../c3ref/db_config.html">sqlite3_db_config()</a> can be used to change the lookaside
configuration on individual connections. </dd></p>
<p><a name="sqliteconfigpcache2"></a>
<dt>SQLITE_CONFIG_PCACHE2</dt>
<dd> The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
a pointer to an <a href="../c3ref/pcache_methods2.html">sqlite3_pcache_methods2</a> object. This object specifies
the interface to a custom page cache implementation.
SQLite makes a copy of the <a href="../c3ref/pcache_methods2.html">sqlite3_pcache_methods2</a> object.</dd></p>
<p><a name="sqliteconfiggetpcache2"></a>
<dt>SQLITE_CONFIG_GETPCACHE2</dt>
<dd> The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
is a pointer to an <a href="../c3ref/pcache_methods2.html">sqlite3_pcache_methods2</a> object. SQLite copies of
the current page cache implementation into that object. </dd></p>
<p><a name="sqliteconfiglog"></a>
<dt>SQLITE_CONFIG_LOG</dt>
<dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
global <a href="../errlog.html">error log</a>.
(The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
function with a call signature of void(*)(void*,int,const char*),
and a pointer to void. If the function pointer is not NULL, it is
invoked by <a href="../c3ref/log.html">sqlite3_log()</a> to process each logging event. If the
function pointer is NULL, the <a href="../c3ref/log.html">sqlite3_log()</a> interface becomes a no-op.
The void pointer that is the second argument to SQLITE_CONFIG_LOG is
passed through as the first parameter to the application-defined logger
function whenever that function is invoked. The second parameter to
the logger function is a copy of the first parameter to the corresponding
<a href="../c3ref/log.html">sqlite3_log()</a> call and is intended to be a <a href="../rescode.html">result code</a> or an
<a href="../rescode.html#extrc">extended result code</a>. The third parameter passed to the logger is
log message after formatting via <a href="../c3ref/mprintf.html">sqlite3_snprintf()</a>.
The SQLite logging interface is not reentrant; the logger function
supplied by the application must not invoke any SQLite interface.
In a multi-threaded application, the application-defined logger
function must be threadsafe. </dd></p>
<p><a name="sqliteconfiguri"></a>
<dt>SQLITE_CONFIG_URI
<dd>The SQLITE_CONFIG_URI option takes a single argument of type int.
If non-zero, then URI handling is globally enabled. If the parameter is zero,
then URI handling is globally disabled. If URI handling is globally
enabled, all filenames passed to <a href="../c3ref/open.html">sqlite3_open()</a>, <a href="../c3ref/open.html">sqlite3_open_v2()</a>,
<a href="../c3ref/open.html">sqlite3_open16()</a> or
specified as part of <a href="../lang_attach.html">ATTACH</a> commands are interpreted as URIs, regardless
of whether or not the <a href="../c3ref/c_open_autoproxy.html">SQLITE_OPEN_URI</a> flag is set when the database
connection is opened. If it is globally disabled, filenames are
only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
database connection is opened. By default, URI handling is globally
disabled. The default value may be changed by compiling with the
<a href="../compile.html#use_uri">SQLITE_USE_URI</a> symbol defined.</p>
<p><a name="sqliteconfigcoveringindexscan"></a>
<dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
<dd>The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
argument which is interpreted as a boolean in order to enable or disable
the use of covering indices for full table scans in the query optimizer.
The default setting is determined
by the <a href="../compile.html#allow_covering_index_scan">SQLITE_ALLOW_COVERING_INDEX_SCAN</a> compile-time option, or is "on"
if that compile-time option is omitted.
The ability to disable the use of covering indices for full table scans
is because some incorrectly coded legacy applications might malfunction
when the optimization is enabled. Providing the ability to
disable the optimization allows the older, buggy application code to work
without change even with newer versions of SQLite.</p>
<p><a name="sqliteconfigpcache"></a>
<a name="sqliteconfiggetpcache"></a>
<dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
<dd> These options are obsolete and should not be used by new code.
They are retained for backwards compatibility but are now no-ops.
</dd></p>
<p><a name="sqliteconfigsqllog"></a>
<dt>SQLITE_CONFIG_SQLLOG
<dd>This option is only available if sqlite is compiled with the
<a href="../compile.html#enable_sqllog">SQLITE_ENABLE_SQLLOG</a> pre-processor macro defined. The first argument should
be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
The second should be of type (void*). The callback is invoked by the library
in three separate circumstances, identified by the value passed as the
fourth parameter. If the fourth parameter is 0, then the database connection
passed as the second argument has just been opened. The third argument
points to a buffer containing the name of the main database file. If the
fourth parameter is 1, then the SQL statement that the third parameter
points to has just been executed. Or, if the fourth parameter is 2, then
the connection being passed as the second parameter is being closed. The
third parameter is passed NULL In this case. An example of using this
configuration option can be seen in the "test_sqllog.c" source file in
the canonical SQLite source tree.</dd></p>
<p><a name="sqliteconfigmmapsize"></a>
<dt>SQLITE_CONFIG_MMAP_SIZE
<dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
that are the default mmap size limit (the default setting for
<a href="../pragma.html#pragma_mmap_size">PRAGMA mmap_size</a>) and the maximum allowed mmap size limit.
The default setting can be overridden by each database connection using
either the <a href="../pragma.html#pragma_mmap_size">PRAGMA mmap_size</a> command, or by using the
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlmmapsize">SQLITE_FCNTL_MMAP_SIZE</a> file control. The maximum allowed mmap size
will be silently truncated if necessary so that it does not exceed the
compile-time maximum mmap size set by the
<a href="../compile.html#max_mmap_size">SQLITE_MAX_MMAP_SIZE</a> compile-time option.
If either argument to this option is negative, then that argument is
changed to its compile-time default.</p>
<p><a name="sqliteconfigwin32heapsize"></a>
<dt>SQLITE_CONFIG_WIN32_HEAPSIZE
<dd>The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
compiled for Windows with the <a href="../compile.html#win32_malloc">SQLITE_WIN32_MALLOC</a> pre-processor macro
defined. SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
that specifies the maximum size of the created heap.</p>
<p><a name="sqliteconfigpcachehdrsz"></a>
<dt>SQLITE_CONFIG_PCACHE_HDRSZ
<dd>The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
is a pointer to an integer and writes into that integer the number of extra
bytes per page required for each page in <a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>.
The amount of extra space required can change depending on the compiler,
target platform, and SQLite version.</p>
<p><a name="sqliteconfigpmasz"></a>
<dt>SQLITE_CONFIG_PMASZ
<dd>The SQLITE_CONFIG_PMASZ option takes a single parameter which
is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
sorter to that integer. The default minimum PMA Size is set by the
<a href="../compile.html#sorter_pmasz">SQLITE_SORTER_PMASZ</a> compile-time option. New threads are launched
to help with sort operations when multithreaded sorting
is enabled (using the <a href="../pragma.html#pragma_threads">PRAGMA threads</a> command) and the amount of content
to be sorted exceeds the page size times the minimum of the
<a href="../pragma.html#pragma_cache_size">PRAGMA cache_size</a> setting and this value.</p>
<p><a name="sqliteconfigstmtjrnlspill"></a>
<dt>SQLITE_CONFIG_STMTJRNL_SPILL
<dd>The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which
becomes the <a href="../tempfiles.html#stmtjrnl">statement journal</a> spill-to-disk threshold.
<a href="../tempfiles.html#stmtjrnl">Statement journals</a> are held in memory until their size (in bytes)
exceeds this threshold, at which point they are written to disk.
Or if the threshold is -1, statement journals are always held
exclusively in memory.
Since many statement journals never become large, setting the spill
threshold to a value such as 64KiB can greatly reduce the amount of
I/O required to support statement rollback.
The default value for this setting is controlled by the
<a href="../compile.html#stmtjrnl_spill">SQLITE_STMTJRNL_SPILL</a> compile-time option.</p>
<p><a name="sqliteconfigsorterrefsize"></a>
<dt>SQLITE_CONFIG_SORTERREF_SIZE
<dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
of type (int) - the new value of the sorter-reference size threshold.
Usually, when SQLite uses an external sort to order records according
to an ORDER BY clause, all fields required by the caller are present in the
sorted records. However, if SQLite determines based on the declared type
of a table column that its values are likely to be very large - larger
than the configured sorter-reference size threshold - then a reference
is stored in each sorted record and the required column values loaded
from the database as records are returned in sorted order. The default
value for this option is to never use this optimization. Specifying a
negative value for this option restores the default behaviour.
This option is only available if SQLite is compiled with the
<a href="../compile.html#enable_sorter_references">SQLITE_ENABLE_SORTER_REFERENCES</a> compile-time option.</p>
<p><a name="sqliteconfigmemdbmaxsize"></a>
<dt>SQLITE_CONFIG_MEMDB_MAXSIZE
<dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter
<a href="../c3ref/int64.html">sqlite3_int64</a> parameter which is the default maximum size for an in-memory
database created using <a href="../c3ref/deserialize.html">sqlite3_deserialize()</a>. This default maximum
size can be adjusted up or down for individual databases using the
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizelimit">SQLITE_FCNTL_SIZE_LIMIT</a> <a href="../c3ref/file_control.html">file-control</a>. If this
configuration setting is never used, then the default maximum is determined
by the <a href="../compile.html#memdb_default_maxsize">SQLITE_MEMDB_DEFAULT_MAXSIZE</a> compile-time option. If that
compile-time option is not set, then the default maximum is 1073741824.
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,407 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Database Connection Configuration Options</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_DBCONFIG_DEFENSIVE SQLITE_DBCONFIG_DQS_DDL SQLITE_DBCONFIG_DQS_DML SQLITE_DBCONFIG_ENABLE_FKEY SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION SQLITE_DBCONFIG_ENABLE_QPSG SQLITE_DBCONFIG_ENABLE_TRIGGER SQLITE_DBCONFIG_ENABLE_VIEW SQLITE_DBCONFIG_LEGACY_ALTER_TABLE SQLITE_DBCONFIG_LEGACY_FILE_FORMAT SQLITE_DBCONFIG_LOOKASIDE SQLITE_DBCONFIG_MAINDBNAME SQLITE_DBCONFIG_MAX SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE SQLITE_DBCONFIG_RESET_DATABASE SQLITE_DBCONFIG_TRIGGER_EQP SQLITE_DBCONFIG_TRUSTED_SCHEMA SQLITE_DBCONFIG_WRITABLE_SCHEMA -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Database Connection Configuration Options</h2>
</div>
<blockquote><pre>
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
#define SQLITE_DBCONFIG_MAX 1017 /* Largest DBCONFIG */
</pre></blockquote>
<p>
These constants are the available integer configuration options that
can be passed as the second argument to the <a href="../c3ref/db_config.html">sqlite3_db_config()</a> interface.</p>
<p>New configuration options may be added in future releases of SQLite.
Existing configuration options might be discontinued. Applications
should check the return code from <a href="../c3ref/db_config.html">sqlite3_db_config()</a> to make sure that
the call worked. The <a href="../c3ref/db_config.html">sqlite3_db_config()</a> interface will return a
non-zero <a href="../rescode.html">error code</a> if a discontinued or unsupported configuration option
is invoked.</p>
<p><dl>
<a name="sqlitedbconfiglookaside"></a>
<dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
<dd> This option takes three additional arguments that determine the
<a href="../malloc.html#lookaside">lookaside memory allocator</a> configuration for the <a href="../c3ref/sqlite3.html">database connection</a>.
The first argument (the third parameter to <a href="../c3ref/db_config.html">sqlite3_db_config()</a> is a
pointer to a memory buffer to use for lookaside memory.
The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
may be NULL in which case SQLite will allocate the
lookaside buffer itself using <a href="../c3ref/free.html">sqlite3_malloc()</a>. The second argument is the
size of each lookaside buffer slot. The third argument is the number of
slots. The size of the buffer in the first argument must be greater than
or equal to the product of the second and third arguments. The buffer
must be aligned to an 8-byte boundary. If the second argument to
SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
rounded down to the next smaller multiple of 8. The lookaside memory
configuration for a database connection can only be changed when that
connection is not currently using lookaside memory, or in other words
when the "current value" returned by
<a href="../c3ref/db_status.html">sqlite3_db_status</a>(D,<a href="../c3ref/c_config_covering_index_scan.html#sqliteconfiglookaside">SQLITE_CONFIG_LOOKASIDE</a>,...) is zero.
Any attempt to change the lookaside memory configuration when lookaside
memory is in use leaves the configuration unchanged and returns
<a href="../rescode.html#busy">SQLITE_BUSY</a>.</dd></p>
<p><a name="sqlitedbconfigenablefkey"></a>
<dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
<dd> This option is used to enable or disable the enforcement of
<a href="../foreignkeys.html">foreign key constraints</a>. There should be two additional arguments.
The first argument is an integer which is 0 to disable FK enforcement,
positive to enable FK enforcement or negative to leave FK enforcement
unchanged. The second parameter is a pointer to an integer into which
is written 0 or 1 to indicate whether FK enforcement is off or on
following this call. The second parameter may be a NULL pointer, in
which case the FK enforcement setting is not reported back. </dd></p>
<p><a name="sqlitedbconfigenabletrigger"></a>
<dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
<dd> This option is used to enable or disable <a href="../lang_createtrigger.html">triggers</a>.
There should be two additional arguments.
The first argument is an integer which is 0 to disable triggers,
positive to enable triggers or negative to leave the setting unchanged.
The second parameter is a pointer to an integer into which
is written 0 or 1 to indicate whether triggers are disabled or enabled
following this call. The second parameter may be a NULL pointer, in
which case the trigger setting is not reported back. </dd></p>
<p><a name="sqlitedbconfigenableview"></a>
<dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
<dd> This option is used to enable or disable <a href="../lang_createview.html">views</a>.
There should be two additional arguments.
The first argument is an integer which is 0 to disable views,
positive to enable views or negative to leave the setting unchanged.
The second parameter is a pointer to an integer into which
is written 0 or 1 to indicate whether views are disabled or enabled
following this call. The second parameter may be a NULL pointer, in
which case the view setting is not reported back. </dd></p>
<p><a name="sqlitedbconfigenablefts3tokenizer"></a>
<dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
<dd> This option is used to enable or disable the
<a href="../fts3.html#f3tknzr">fts3_tokenizer()</a> function which is part of the
<a href="../fts3.html">FTS3</a> full-text search engine extension.
There should be two additional arguments.
The first argument is an integer which is 0 to disable fts3_tokenizer() or
positive to enable fts3_tokenizer() or negative to leave the setting
unchanged.
The second parameter is a pointer to an integer into which
is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
following this call. The second parameter may be a NULL pointer, in
which case the new setting is not reported back. </dd></p>
<p><a name="sqlitedbconfigenableloadextension"></a>
<dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
<dd> This option is used to enable or disable the <a href="../c3ref/load_extension.html">sqlite3_load_extension()</a>
interface independently of the <a href="../lang_corefunc.html#load_extension">load_extension()</a> SQL function.
The <a href="../c3ref/enable_load_extension.html">sqlite3_enable_load_extension()</a> API enables or disables both the
C-API <a href="../c3ref/load_extension.html">sqlite3_load_extension()</a> and the SQL function <a href="../lang_corefunc.html#load_extension">load_extension()</a>.
There should be two additional arguments.
When the first argument to this interface is 1, then only the C-API is
enabled and the SQL function remains disabled. If the first argument to
this interface is 0, then both the C-API and the SQL function are disabled.
If the first argument is -1, then no changes are made to state of either the
C-API or the SQL function.
The second parameter is a pointer to an integer into which
is written 0 or 1 to indicate whether <a href="../c3ref/load_extension.html">sqlite3_load_extension()</a> interface
is disabled or enabled following this call. The second parameter may
be a NULL pointer, in which case the new setting is not reported back.
</dd></p>
<p><a name="sqlitedbconfigmaindbname"></a>
<dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
<dd> This option is used to change the name of the "main" database
schema. The sole argument is a pointer to a constant UTF8 string
which will become the new schema name in place of "main". SQLite
does not make a copy of the new main schema name string, so the application
must ensure that the argument passed into this DBCONFIG option is unchanged
until after the database connection closes.
</dd></p>
<p><a name="sqlitedbconfignockptonclose"></a>
<dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
<dd> Usually, when a database in wal mode is closed or detached from a
database handle, SQLite checks if this will mean that there are now no
connections at all to the database. If so, it performs a checkpoint
operation before closing the connection. This option may be used to
override this behaviour. The first parameter passed to this operation
is an integer - positive to disable checkpoints-on-close, or zero (the
default) to enable them, and negative to leave the setting unchanged.
The second parameter is a pointer to an integer
into which is written 0 or 1 to indicate whether checkpoints-on-close
have been disabled - 0 if they are not disabled, 1 if they are.
</dd></p>
<p><a name="sqlitedbconfigenableqpsg"></a>
<dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
<dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
the <a href="../queryplanner-ng.html#qpstab">query planner stability guarantee</a> (QPSG). When the QPSG is active,
a single SQL query statement will always use the same algorithm regardless
of values of <a href="../lang_expr.html#varparam">bound parameters</a>. The QPSG disables some query optimizations
that look at the values of bound parameters, which can make some queries
slower. But the QPSG has the advantage of more predictable behavior. With
the QPSG active, SQLite will always use the same query plan in the field as
was used during testing in the lab.
The first argument to this setting is an integer which is 0 to disable
the QPSG, positive to enable QPSG, or negative to leave the setting
unchanged. The second parameter is a pointer to an integer into which
is written 0 or 1 to indicate whether the QPSG is disabled or enabled
following this call.
</dd></p>
<p><a name="sqlitedbconfigtriggereqp"></a>
<dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
<dd> By default, the output of EXPLAIN QUERY PLAN commands does not
include output for any operations performed by trigger programs. This
option is used to set or clear (the default) a flag that governs this
behavior. The first parameter passed to this operation is an integer -
positive to enable output for trigger programs, or zero to disable it,
or negative to leave the setting unchanged.
The second parameter is a pointer to an integer into which is written
0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
it is not disabled, 1 if it is.
</dd></p>
<p><a name="sqlitedbconfigresetdatabase"></a>
<dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
<dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
<a href="../lang_vacuum.html">VACUUM</a> in order to reset a database back to an empty database
with no schema and no content. The following process works even for
a badly corrupted database file:
<ol>
<li> If the database connection is newly opened, make sure it has read the
database schema by preparing then discarding some query against the
database, or calling sqlite3_table_column_metadata(), ignoring any
errors. This step is only necessary if the application desires to keep
the database in WAL mode after the reset if it was in WAL mode before
the reset.
<li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
<li> <a href="../c3ref/exec.html">sqlite3_exec</a>(db, "<a href="../lang_vacuum.html">VACUUM</a>", 0, 0, 0);
<li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
</ol>
Because resetting a database is destructive and irreversible, the
process requires the use of this obscure API and multiple steps to help
ensure that it does not happen by accident.</p>
<p><a name="sqlitedbconfigdefensive"></a>
<dt>SQLITE_DBCONFIG_DEFENSIVE</dt>
<dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the
"defensive" flag for a database connection. When the defensive
flag is enabled, language features that allow ordinary SQL to
deliberately corrupt the database file are disabled. The disabled
features include but are not limited to the following:
<ul>
<li> The <a href="../pragma.html#pragma_writable_schema">PRAGMA writable_schema=ON</a> statement.
<li> The <a href="../pragma.html#pragma_journal_mode">PRAGMA journal_mode=OFF</a> statement.
<li> Writes to the <a href="../dbpage.html">sqlite_dbpage</a> virtual table.
<li> Direct writes to <a href="../vtab.html#xshadowname">shadow tables</a>.
</ul>
</dd></p>
<p><a name="sqlitedbconfigwritableschema"></a>
<dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt>
<dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the
"writable_schema" flag. This has the same effect and is logically equivalent
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>.
The first argument to this setting is an integer which is 0 to disable
the writable_schema, positive to enable writable_schema, or negative to
leave the setting unchanged. The second parameter is a pointer to an
integer into which is written 0 or 1 to indicate whether the writable_schema
is enabled or disabled following this call.
</dd></p>
<p><a name="sqlitedbconfiglegacyaltertable"></a>
<dt>SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</dt>
<dd>The SQLITE_DBCONFIG_LEGACY_ALTER_TABLE option activates or deactivates
the legacy behavior of the <a href="../lang_altertable.html#altertabrename">ALTER TABLE RENAME</a> command such it
behaves as it did prior to <a href="../releaselog/3_24_0.html">version 3.24.0</a> (2018-06-04). See the
"Compatibility Notice" on the <a href="../lang_altertable.html#altertabrename">ALTER TABLE RENAME documentation</a> for
additional information. This feature can also be turned on and off
using the <a href="../pragma.html#pragma_legacy_alter_table">PRAGMA legacy_alter_table</a> statement.
</dd></p>
<p><a name="sqlitedbconfigdqsdml"></a>
<dt>SQLITE_DBCONFIG_DQS_DML</td>
<dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
the legacy <a href="../quirks.html#dblquote">double-quoted string literal</a> misfeature for DML statements
only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
default value of this setting is determined by the <a href="../compile.html#dqs">-DSQLITE_DQS</a>
compile-time option.
</dd></p>
<p><a name="sqlitedbconfigdqsddl"></a>
<dt>SQLITE_DBCONFIG_DQS_DDL</td>
<dd>The SQLITE_DBCONFIG_DQS option activates or deactivates
the legacy <a href="../quirks.html#dblquote">double-quoted string literal</a> misfeature for DDL statements,
such as CREATE TABLE and CREATE INDEX. The
default value of this setting is determined by the <a href="../compile.html#dqs">-DSQLITE_DQS</a>
compile-time option.
</dd></p>
<p><a name="sqlitedbconfigtrustedschema"></a>
<dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</td>
<dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to
assume that database schemas are untainted by malicious content.
When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite
takes additional defensive steps to protect the application from harm
including:
<ul>
<li> Prohibit the use of SQL functions inside triggers, views,
CHECK constraints, DEFAULT clauses, expression indexes,
partial indexes, or generated columns
unless those functions are tagged with <a href="../c3ref/c_deterministic.html#sqliteinnocuous">SQLITE_INNOCUOUS</a>.
<li> Prohibit the use of virtual tables inside of triggers or views
unless those virtual tables are tagged with <a href="../c3ref/c_vtab_constraint_support.html#sqlitevtabinnocuous">SQLITE_VTAB_INNOCUOUS</a>.
</ul>
This setting defaults to "on" for legacy compatibility, however
all applications are advised to turn it off if possible. This setting
can also be controlled using the <a href="../pragma.html#pragma_trusted_schema">PRAGMA trusted_schema</a> statement.
</dd></p>
<p><a name="sqlitedbconfiglegacyfileformat"></a>
<dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td>
<dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
the legacy file format flag. When activated, this flag causes all newly
created database file to have a schema format version number (the 4-byte
integer found at offset 44 into the database header) of 1. This in turn
means that the resulting database file will be readable and writable by
any SQLite version back to 3.0.0 (2004-06-18). Without this setting,
newly created databases are generally not understandable by SQLite versions
prior to 3.3.0 (2006-01-11). As these words are written, there
is now scarcely any need to generated database files that are compatible
all the way back to version 3.0.0, and so this setting is of little
practical use, but is provided so that SQLite can continue to claim the
ability to generate new database files that are compatible with version
3.0.0.
<p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on,
the <a href="../lang_vacuum.html">VACUUM</a> command will fail with an obscure error when attempting to
process a table with generated columns and a descending index. This is
not considered a bug since SQLite versions 3.3.0 and earlier do not support
either generated columns or decending indexes.
</dd>
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,238 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Status Parameters for database connections</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {SQLITE_DBSTATUS options} SQLITE_DBSTATUS_CACHE_HIT SQLITE_DBSTATUS_CACHE_MISS SQLITE_DBSTATUS_CACHE_SPILL SQLITE_DBSTATUS_CACHE_USED SQLITE_DBSTATUS_CACHE_USED_SHARED SQLITE_DBSTATUS_CACHE_WRITE SQLITE_DBSTATUS_DEFERRED_FKS SQLITE_DBSTATUS_LOOKASIDE_HIT SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE SQLITE_DBSTATUS_LOOKASIDE_USED SQLITE_DBSTATUS_MAX SQLITE_DBSTATUS_SCHEMA_USED SQLITE_DBSTATUS_STMT_USED -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Status Parameters for database connections</h2>
</div>
<blockquote><pre>
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
#define SQLITE_DBSTATUS_CACHE_USED 1
#define SQLITE_DBSTATUS_SCHEMA_USED 2
#define SQLITE_DBSTATUS_STMT_USED 3
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
#define SQLITE_DBSTATUS_CACHE_HIT 7
#define SQLITE_DBSTATUS_CACHE_MISS 8
#define SQLITE_DBSTATUS_CACHE_WRITE 9
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
#define SQLITE_DBSTATUS_CACHE_SPILL 12
#define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */
</pre></blockquote>
<p>
These constants are the available integer "verbs" that can be passed as
the second argument to the <a href="../c3ref/db_status.html">sqlite3_db_status()</a> interface.</p>
<p>New verbs may be added in future releases of SQLite. Existing verbs
might be discontinued. Applications should check the return code from
<a href="../c3ref/db_status.html">sqlite3_db_status()</a> to make sure that the call worked.
The <a href="../c3ref/db_status.html">sqlite3_db_status()</a> interface will return a non-zero error code
if a discontinued or unsupported verb is invoked.</p>
<p><dl>
<a name="sqlitedbstatuslookasideused"></a>
<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
<dd>This parameter returns the number of lookaside memory slots currently
checked out.</dd></p>
<p><a name="sqlitedbstatuslookasidehit"></a>
<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
<dd>This parameter returns the number of malloc attempts that were
satisfied using lookaside memory. Only the high-water value is meaningful;
the current value is always zero.</p>
<p><a name="sqlitedbstatuslookasidemisssize"></a>
<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
<dd>This parameter returns the number malloc attempts that might have
been satisfied using lookaside memory but failed due to the amount of
memory requested being larger than the lookaside slot size.
Only the high-water value is meaningful;
the current value is always zero.</p>
<p><a name="sqlitedbstatuslookasidemissfull"></a>
<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
<dd>This parameter returns the number malloc attempts that might have
been satisfied using lookaside memory but failed due to all lookaside
memory already being in use.
Only the high-water value is meaningful;
the current value is always zero.</p>
<p><a name="sqlitedbstatuscacheused"></a>
<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
<dd>This parameter returns the approximate number of bytes of heap
memory used by all pager caches associated with the database connection.
The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.</p>
<p><a name="sqlitedbstatuscacheusedshared"></a>
<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
<dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
pager cache is shared between two or more connections the bytes of heap
memory used by that pager cache is divided evenly between the attached
connections. In other words, if none of the pager caches associated
with the database connection are shared, this request returns the same
value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
shared, the value returned by this call will be smaller than that returned
by DBSTATUS_CACHE_USED. The highwater mark associated with
SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.</p>
<p><a name="sqlitedbstatusschemaused"></a>
<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
<dd>This parameter returns the approximate number of bytes of heap
memory used to store the schema for all databases associated
with the connection - main, temp, and any <a href="../lang_attach.html">ATTACH</a>-ed databases.
The full amount of memory used by the schemas is reported, even if the
schema memory is shared with other database connections due to
<a href="../sharedcache.html">shared cache mode</a> being enabled.
The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.</p>
<p><a name="sqlitedbstatusstmtused"></a>
<dt>SQLITE_DBSTATUS_STMT_USED</dt>
<dd>This parameter returns the approximate number of bytes of heap
and lookaside memory used by all prepared statements associated with
the database connection.
The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
</dd></p>
<p><a name="sqlitedbstatuscachehit"></a>
<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>
<dd>This parameter returns the number of pager cache hits that have
occurred. The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT
is always 0.
</dd></p>
<p><a name="sqlitedbstatuscachemiss"></a>
<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
<dd>This parameter returns the number of pager cache misses that have
occurred. The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
is always 0.
</dd></p>
<p><a name="sqlitedbstatuscachewrite"></a>
<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
<dd>This parameter returns the number of dirty cache entries that have
been written to disk. Specifically, the number of pages written to the
wal file in wal mode databases, or the number of pages written to the
database file in rollback mode databases. Any pages written as part of
transaction rollback or database recovery operations are not included.
If an IO or other error occurs while writing a page to disk, the effect
on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined. The
highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
</dd></p>
<p><a name="sqlitedbstatuscachespill"></a>
<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
<dd>This parameter returns the number of dirty cache entries that have
been written to disk in the middle of a transaction due to the page
cache overflowing. Transactions are more efficient if they are written
to disk all at once. When pages spill mid-transaction, that introduces
additional overhead. This parameter can be used help identify
inefficiencies that can be resolved by increasing the cache size.
</dd></p>
<p><a name="sqlitedbstatusdeferredfks"></a>
<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
<dd>This parameter returns zero for the current value if and only if
all foreign key constraints (deferred or immediate) have been
resolved. The highwater mark is always 0.
</dd>
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Authorizer Return Codes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_DENY SQLITE_IGNORE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Authorizer Return Codes</h2>
</div>
<blockquote><pre>
#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
</pre></blockquote>
<p>
The <a href="../c3ref/set_authorizer.html">authorizer callback function</a> must
return either <a href="../rescode.html#ok">SQLITE_OK</a> or one of these two constants in order
to signal SQLite whether or not the action is permitted. See the
<a href="../c3ref/set_authorizer.html">authorizer documentation</a> for additional
information.</p>
<p>Note that SQLITE_IGNORE is also used as a <a href="../c3ref/c_fail.html">conflict resolution mode</a>
returned from the <a href="../c3ref/vtab_on_conflict.html">sqlite3_vtab_on_conflict()</a> interface.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,125 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Flags for sqlite3_deserialize()</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_DESERIALIZE_FREEONCLOSE SQLITE_DESERIALIZE_READONLY SQLITE_DESERIALIZE_RESIZEABLE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Flags for sqlite3_deserialize()</h2>
</div>
<blockquote><pre>
#define SQLITE_DESERIALIZE_FREEONCLOSE 1 /* Call sqlite3_free() on close */
#define SQLITE_DESERIALIZE_RESIZEABLE 2 /* Resize using sqlite3_realloc64() */
#define SQLITE_DESERIALIZE_READONLY 4 /* Database is read-only */
</pre></blockquote>
<p>
The following are allowed values for 6th argument (the F argument) to
the <a href="../c3ref/deserialize.html">sqlite3_deserialize(D,S,P,N,M,F)</a> interface.</p>
<p>The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization
in the P argument is held in memory obtained from <a href="../c3ref/free.html">sqlite3_malloc64()</a>
and that SQLite should take ownership of this memory and automatically
free it when it has finished using it. Without this flag, the caller
is responsible for freeing any dynamically allocated memory.</p>
<p>The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to
grow the size of the database using calls to <a href="../c3ref/free.html">sqlite3_realloc64()</a>. This
flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used.
Without this flag, the deserialized database cannot increase in size beyond
the number of bytes specified by the M parameter.</p>
<p>The SQLITE_DESERIALIZE_READONLY flag means that the deserialized database
should be treated as read-only.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,174 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Function Flags</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_DETERMINISTIC SQLITE_DIRECTONLY SQLITE_INNOCUOUS SQLITE_SUBTYPE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Function Flags</h2>
</div>
<blockquote><pre>
#define SQLITE_DETERMINISTIC 0x000000800
#define SQLITE_DIRECTONLY 0x000080000
#define SQLITE_SUBTYPE 0x000100000
#define SQLITE_INNOCUOUS 0x000200000
</pre></blockquote>
<p>
These constants may be ORed together with the
<a href="../c3ref/c_any.html">preferred text encoding</a> as the fourth argument
to <a href="../c3ref/create_function.html">sqlite3_create_function()</a>, <a href="../c3ref/create_function.html">sqlite3_create_function16()</a>, or
<a href="../c3ref/create_function.html">sqlite3_create_function_v2()</a>.</p>
<p><dl>
<a name="sqlitedeterministic"></a>
<dt>SQLITE_DETERMINISTIC</dt><dd>
The SQLITE_DETERMINISTIC flag means that the new function always gives
the same output when the input parameters are the same.
The <a href="../lang_corefunc.html#abs">abs() function</a> is deterministic, for example, but
<a href="../lang_corefunc.html#randomblob">randomblob()</a> is not. Functions must
be deterministic in order to be used in certain contexts such as
with the WHERE clause of <a href="../partialindex.html">partial indexes</a> or in <a href="../gencol.html">generated columns</a>.
SQLite might also optimize deterministic functions by factoring them
out of inner loops.
</dd></p>
<p><a name="sqlitedirectonly"></a>
<dt>SQLITE_DIRECTONLY</dt><dd>
The SQLITE_DIRECTONLY flag means that the function may only be invoked
from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in
schema structures such as <a href="../lang_createtable.html#ckconst">CHECK constraints</a>, <a href="../lang_createtable.html#dfltval">DEFAULT clauses</a>,
<a href="../expridx.html">expression indexes</a>, <a href="../partialindex.html">partial indexes</a>, or <a href="../gencol.html">generated columns</a>.
The SQLITE_DIRECTONLY flags is a security feature which is recommended
for all <a href="../appfunc.html">application-defined SQL functions</a>, and especially for functions
that have side-effects or that could potentially leak sensitive
information.
</dd></p>
<p><a name="sqliteinnocuous"></a>
<dt>SQLITE_INNOCUOUS</dt><dd>
The SQLITE_INNOCUOUS flag means that the function is unlikely
to cause problems even if misused. An innocuous function should have
no side effects and should not depend on any values other than its
input parameters. The <a href="../lang_corefunc.html#abs">abs() function</a> is an example of an
innocuous function.
The <a href="../lang_corefunc.html#load_extension">load_extension() SQL function</a> is not innocuous because of its
side effects.
<p> SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not
exactly the same. The <a href="../lang_corefunc.html#random">random() function</a> is an example of a
function that is innocuous but not deterministic.
<p>Some heightened security settings
(<a href="../c3ref/c_dbconfig_defensive.html#sqlitedbconfigtrustedschema">SQLITE_DBCONFIG_TRUSTED_SCHEMA</a> and <a href="../pragma.html#pragma_trusted_schema">PRAGMA trusted_schema=OFF</a>)
disable the use of SQL functions inside views and triggers and in
schema structures such as <a href="../lang_createtable.html#ckconst">CHECK constraints</a>, <a href="../lang_createtable.html#dfltval">DEFAULT clauses</a>,
<a href="../expridx.html">expression indexes</a>, <a href="../partialindex.html">partial indexes</a>, and <a href="../gencol.html">generated columns</a> unless
the function is tagged with SQLITE_INNOCUOUS. Most built-in functions
are innocuous. Developers are advised to avoid using the
SQLITE_INNOCUOUS flag for application-defined functions unless the
function has been carefully audited and found to be free of potentially
security-adverse side-effects and information-leaks.
</dd></p>
<p><a name="sqlitesubtype"></a>
<dt>SQLITE_SUBTYPE</dt><dd>
The SQLITE_SUBTYPE flag indicates to SQLite that a function may call
<a href="../c3ref/value_subtype.html">sqlite3_value_subtype()</a> to inspect the sub-types of its arguments.
Specifying this flag makes no difference for scalar or aggregate user
functions. However, if it is not specified for a user-defined window
function, then any sub-types belonging to arguments passed to the window
function may be discarded before the window function is called (i.e.
sqlite3_value_subtype() will always return 0).
</dd>
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,117 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Conflict resolution modes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_FAIL SQLITE_REPLACE SQLITE_ROLLBACK {conflict resolution mode} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Conflict resolution modes</h2>
</div>
<blockquote><pre>
#define SQLITE_ROLLBACK 1
/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */
#define SQLITE_FAIL 3
/* #define SQLITE_ABORT 4 // Also an error code */
#define SQLITE_REPLACE 5
</pre></blockquote>
<p>
These constants are returned by <a href="../c3ref/vtab_on_conflict.html">sqlite3_vtab_on_conflict()</a> to
inform a <a href="../vtab.html">virtual table</a> implementation what the <a href="../lang_conflict.html">ON CONFLICT</a> mode
is for the SQL statement being evaluated.</p>
<p>Note that the <a href="../c3ref/c_deny.html">SQLITE_IGNORE</a> constant is also used as a potential
return value from the <a href="../c3ref/set_authorizer.html">sqlite3_set_authorizer()</a> callback and that
<a href="../rescode.html#abort">SQLITE_ABORT</a> is also a <a href="../rescode.html">result code</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,493 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Standard File Control Opcodes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_FCNTL_BEGIN_ATOMIC_WRITE SQLITE_FCNTL_BUSYHANDLER SQLITE_FCNTL_CHUNK_SIZE SQLITE_FCNTL_CKPT_DONE SQLITE_FCNTL_CKPT_START SQLITE_FCNTL_COMMIT_ATOMIC_WRITE SQLITE_FCNTL_COMMIT_PHASETWO SQLITE_FCNTL_DATA_VERSION SQLITE_FCNTL_FILE_POINTER SQLITE_FCNTL_GET_LOCKPROXYFILE SQLITE_FCNTL_HAS_MOVED SQLITE_FCNTL_JOURNAL_POINTER SQLITE_FCNTL_LAST_ERRNO SQLITE_FCNTL_LOCKSTATE SQLITE_FCNTL_LOCK_TIMEOUT SQLITE_FCNTL_MMAP_SIZE SQLITE_FCNTL_OVERWRITE SQLITE_FCNTL_PDB SQLITE_FCNTL_PERSIST_WAL SQLITE_FCNTL_POWERSAFE_OVERWRITE SQLITE_FCNTL_PRAGMA SQLITE_FCNTL_RBU SQLITE_FCNTL_RESERVE_BYTES SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE SQLITE_FCNTL_SET_LOCKPROXYFILE SQLITE_FCNTL_SIZE_HINT SQLITE_FCNTL_SIZE_LIMIT SQLITE_FCNTL_SYNC SQLITE_FCNTL_SYNC_OMITTED SQLITE_FCNTL_TEMPFILENAME SQLITE_FCNTL_TRACE SQLITE_FCNTL_VFSNAME SQLITE_FCNTL_VFS_POINTER SQLITE_FCNTL_WAL_BLOCK SQLITE_FCNTL_WIN32_AV_RETRY SQLITE_FCNTL_WIN32_GET_HANDLE SQLITE_FCNTL_WIN32_SET_HANDLE SQLITE_FCNTL_ZIPVFS {file control opcode} {file control opcodes} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Standard File Control Opcodes</h2>
</div>
<blockquote><pre>
#define SQLITE_FCNTL_LOCKSTATE 1
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
#define SQLITE_FCNTL_LAST_ERRNO 4
#define SQLITE_FCNTL_SIZE_HINT 5
#define SQLITE_FCNTL_CHUNK_SIZE 6
#define SQLITE_FCNTL_FILE_POINTER 7
#define SQLITE_FCNTL_SYNC_OMITTED 8
#define SQLITE_FCNTL_WIN32_AV_RETRY 9
#define SQLITE_FCNTL_PERSIST_WAL 10
#define SQLITE_FCNTL_OVERWRITE 11
#define SQLITE_FCNTL_VFSNAME 12
#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
#define SQLITE_FCNTL_PRAGMA 14
#define SQLITE_FCNTL_BUSYHANDLER 15
#define SQLITE_FCNTL_TEMPFILENAME 16
#define SQLITE_FCNTL_MMAP_SIZE 18
#define SQLITE_FCNTL_TRACE 19
#define SQLITE_FCNTL_HAS_MOVED 20
#define SQLITE_FCNTL_SYNC 21
#define SQLITE_FCNTL_COMMIT_PHASETWO 22
#define SQLITE_FCNTL_WIN32_SET_HANDLE 23
#define SQLITE_FCNTL_WAL_BLOCK 24
#define SQLITE_FCNTL_ZIPVFS 25
#define SQLITE_FCNTL_RBU 26
#define SQLITE_FCNTL_VFS_POINTER 27
#define SQLITE_FCNTL_JOURNAL_POINTER 28
#define SQLITE_FCNTL_WIN32_GET_HANDLE 29
#define SQLITE_FCNTL_PDB 30
#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31
#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33
#define SQLITE_FCNTL_LOCK_TIMEOUT 34
#define SQLITE_FCNTL_DATA_VERSION 35
#define SQLITE_FCNTL_SIZE_LIMIT 36
#define SQLITE_FCNTL_CKPT_DONE 37
#define SQLITE_FCNTL_RESERVE_BYTES 38
#define SQLITE_FCNTL_CKPT_START 39
</pre></blockquote>
<p>
These integer constants are opcodes for the xFileControl method
of the <a href="../c3ref/io_methods.html">sqlite3_io_methods</a> object and for the <a href="../c3ref/file_control.html">sqlite3_file_control()</a>
interface.</p>
<p><ul>
<li><a name="sqlitefcntllockstate"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntllockstate">SQLITE_FCNTL_LOCKSTATE</a> opcode is used for debugging. This
opcode causes the xFileControl method to write the current state of
the lock (one of <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_NONE</a>, <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_SHARED</a>,
<a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_RESERVED</a>, <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_PENDING</a>, or <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_EXCLUSIVE</a>)
into an integer that the pArg argument points to. This capability
is used during testing and is only available when the SQLITE_TEST
compile-time option is used.</p>
<p><li><a name="sqlitefcntlsizehint"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizehint">SQLITE_FCNTL_SIZE_HINT</a> opcode is used by SQLite to give the VFS
layer a hint of how large the database file will grow to be during the
current transaction. This hint is not guaranteed to be accurate but it
is often close. The underlying VFS might choose to preallocate database
file space based on this hint in order to help writes to the database
file run faster.</p>
<p><li><a name="sqlitefcntlsizelimit"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizelimit">SQLITE_FCNTL_SIZE_LIMIT</a> opcode is used by in-memory VFS that
implements <a href="../c3ref/deserialize.html">sqlite3_deserialize()</a> to set an upper bound on the size
of the in-memory database. The argument is a pointer to a <a href="../c3ref/int64.html">sqlite3_int64</a>.
If the integer pointed to is negative, then it is filled in with the
current limit. Otherwise the limit is set to the larger of the value
of the integer pointed to and the current database size. The integer
pointed to is set to the new limit.</p>
<p><li><a name="sqlitefcntlchunksize"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlchunksize">SQLITE_FCNTL_CHUNK_SIZE</a> opcode is used to request that the VFS
extends and truncates the database file in chunks of a size specified
by the user. The fourth argument to <a href="../c3ref/file_control.html">sqlite3_file_control()</a> should
point to an integer (type int) containing the new chunk-size to use
for the nominated database. Allocating database file space in large
chunks (say 1MB at a time), may reduce file-system fragmentation and
improve performance on some systems.</p>
<p><li><a name="sqlitefcntlfilepointer"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlfilepointer">SQLITE_FCNTL_FILE_POINTER</a> opcode is used to obtain a pointer
to the <a href="../c3ref/file.html">sqlite3_file</a> object associated with a particular database
connection. See also <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntljournalpointer">SQLITE_FCNTL_JOURNAL_POINTER</a>.</p>
<p><li><a name="sqlitefcntljournalpointer"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntljournalpointer">SQLITE_FCNTL_JOURNAL_POINTER</a> opcode is used to obtain a pointer
to the <a href="../c3ref/file.html">sqlite3_file</a> object associated with the journal file (either
the <a href="../lockingv3.html#rollback">rollback journal</a> or the <a href="../wal.html">write-ahead log</a>) for a particular database
connection. See also <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlfilepointer">SQLITE_FCNTL_FILE_POINTER</a>.</p>
<p><li><a name="sqlitefcntlsyncomitted"></a>
No longer in use.</p>
<p><li><a name="sqlitefcntlsync"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsync">SQLITE_FCNTL_SYNC</a> opcode is generated internally by SQLite and
sent to the VFS immediately before the xSync method is invoked on a
database file descriptor. Or, if the xSync method is not invoked
because the user has configured SQLite with
<a href="../pragma.html#pragma_synchronous">PRAGMA synchronous=OFF</a> it is invoked in place
of the xSync method. In most cases, the pointer argument passed with
this file-control is NULL. However, if the database file is being synced
as part of a multi-database commit, the argument points to a nul-terminated
string containing the transactions super-journal file name. VFSes that
do not need this signal should silently ignore this opcode. Applications
should not call <a href="../c3ref/file_control.html">sqlite3_file_control()</a> with this opcode as doing so may
disrupt the operation of the specialized VFSes that do require it.</p>
<p><li><a name="sqlitefcntlcommitphasetwo"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitphasetwo">SQLITE_FCNTL_COMMIT_PHASETWO</a> opcode is generated internally by SQLite
and sent to the VFS after a transaction has been committed immediately
but before the database is unlocked. VFSes that do not need this signal
should silently ignore this opcode. Applications should not call
<a href="../c3ref/file_control.html">sqlite3_file_control()</a> with this opcode as doing so may disrupt the
operation of the specialized VFSes that do require it.</p>
<p><li><a name="sqlitefcntlwin32avretry"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwin32avretry">SQLITE_FCNTL_WIN32_AV_RETRY</a> opcode is used to configure automatic
retry counts and intervals for certain disk I/O operations for the
windows <a href="../vfs.html">VFS</a> in order to provide robustness in the presence of
anti-virus programs. By default, the windows VFS will retry file read,
file write, and file delete operations up to 10 times, with a delay
of 25 milliseconds before the first retry and with the delay increasing
by an additional 25 milliseconds with each subsequent retry. This
opcode allows these two values (10 retries and 25 milliseconds of delay)
to be adjusted. The values are changed for all database connections
within the same process. The argument is a pointer to an array of two
integers where the first integer is the new retry count and the second
integer is the delay. If either integer is negative, then the setting
is not changed but instead the prior value of that setting is written
into the array entry, allowing the current retry settings to be
interrogated. The zDbName parameter is ignored.</p>
<p><li><a name="sqlitefcntlpersistwal"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpersistwal">SQLITE_FCNTL_PERSIST_WAL</a> opcode is used to set or query the
persistent <a href="../wal.html">Write Ahead Log</a> setting. By default, the auxiliary
write ahead log (<a href="../wal.html#walfile">WAL file</a>) and shared memory
files used for transaction control
are automatically deleted when the latest connection to the database
closes. Setting persistent WAL mode causes those files to persist after
close. Persisting the files is useful when other processes that do not
have write permission on the directory containing the database file want
to read the database file, as the WAL and shared memory files must exist
in order for the database to be readable. The fourth parameter to
<a href="../c3ref/file_control.html">sqlite3_file_control()</a> for this opcode should be a pointer to an integer.
That integer is 0 to disable persistent WAL mode or 1 to enable persistent
WAL mode. If the integer is -1, then it is overwritten with the current
WAL persistence setting.</p>
<p><li><a name="sqlitefcntlpowersafeoverwrite"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpowersafeoverwrite">SQLITE_FCNTL_POWERSAFE_OVERWRITE</a> opcode is used to set or query the
persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting
determines the <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_POWERSAFE_OVERWRITE</a> bit of the
xDeviceCharacteristics methods. The fourth parameter to
<a href="../c3ref/file_control.html">sqlite3_file_control()</a> for this opcode should be a pointer to an integer.
That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
mode. If the integer is -1, then it is overwritten with the current
zero-damage mode setting.</p>
<p><li><a name="sqlitefcntloverwrite"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntloverwrite">SQLITE_FCNTL_OVERWRITE</a> opcode is invoked by SQLite after opening
a write transaction to indicate that, unless it is rolled back for some
reason, the entire database file will be overwritten by the current
transaction. This is used by VACUUM operations.</p>
<p><li><a name="sqlitefcntlvfsname"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlvfsname">SQLITE_FCNTL_VFSNAME</a> opcode can be used to obtain the names of
all <a href="../vfs.html">VFSes</a> in the VFS stack. The names are of all VFS shims and the
final bottom-level VFS are written into memory obtained from
<a href="../c3ref/free.html">sqlite3_malloc()</a> and the result is stored in the char* variable
that the fourth parameter of <a href="../c3ref/file_control.html">sqlite3_file_control()</a> points to.
The caller is responsible for freeing the memory when done. As with
all file-control actions, there is no guarantee that this will actually
do anything. Callers should initialize the char* variable to a NULL
pointer in case this file-control is not implemented. This file-control
is intended for diagnostic use only.</p>
<p><li><a name="sqlitefcntlvfspointer"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlvfspointer">SQLITE_FCNTL_VFS_POINTER</a> opcode finds a pointer to the top-level
<a href="../vfs.html">VFSes</a> currently in use. The argument X in
sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
of type "<a href="../c3ref/vfs.html">sqlite3_vfs</a> **". This opcodes will set *X
to a pointer to the top-level VFS.
When there are multiple VFS shims in the stack, this opcode finds the
upper-most shim only.</p>
<p><li><a name="sqlitefcntlpragma"></a>
Whenever a <a href="../pragma.html#syntax">PRAGMA</a> statement is parsed, an <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a>
file control is sent to the open <a href="../c3ref/file.html">sqlite3_file</a> object corresponding
to the database file to which the pragma statement refers. The argument
to the <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control is an array of
pointers to strings (char**) in which the second element of the array
is the name of the pragma and the third element is the argument to the
pragma or NULL if the pragma has no argument. The handler for an
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control can optionally make the first element
of the char** argument point to a string obtained from <a href="../c3ref/mprintf.html">sqlite3_mprintf()</a>
or the equivalent and that string will become the result of the pragma or
the error message if the pragma fails. If the
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control returns <a href="../rescode.html#notfound">SQLITE_NOTFOUND</a>, then normal
<a href="../pragma.html#syntax">PRAGMA</a> processing continues. If the <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a>
file control returns <a href="../rescode.html#ok">SQLITE_OK</a>, then the parser assumes that the
VFS has handled the PRAGMA itself and the parser generates a no-op
prepared statement if result string is NULL, or that returns a copy
of the result string if the string is non-NULL.
If the <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a> file control returns
any result code other than <a href="../rescode.html#ok">SQLITE_OK</a> or <a href="../rescode.html#notfound">SQLITE_NOTFOUND</a>, that means
that the VFS encountered an error while handling the <a href="../pragma.html#syntax">PRAGMA</a> and the
compilation of the PRAGMA fails with an error. The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma">SQLITE_FCNTL_PRAGMA</a>
file control occurs at the beginning of pragma statement analysis and so
it is able to override built-in <a href="../pragma.html#syntax">PRAGMA</a> statements.</p>
<p><li><a name="sqlitefcntlbusyhandler"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbusyhandler">SQLITE_FCNTL_BUSYHANDLER</a>
file-control may be invoked by SQLite on the database file handle
shortly after it is opened in order to provide a custom VFS with access
to the connection's busy-handler callback. The argument is of type (void**)
- an array of two (void *) values. The first (void *) actually points
to a function of type (int (*)(void *)). In order to invoke the connection's
busy-handler, this function should be invoked with the second (void *) in
the array as the only argument. If it returns non-zero, then the operation
should be retried. If it returns zero, the custom VFS should abandon the
current operation.</p>
<p><li><a name="sqlitefcntltempfilename"></a>
Applications can invoke the <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntltempfilename">SQLITE_FCNTL_TEMPFILENAME</a> file-control
to have SQLite generate a
temporary filename using the same algorithm that is followed to generate
temporary filenames for TEMP tables and other internal uses. The
argument should be a char** which will be filled with the filename
written into memory obtained from <a href="../c3ref/free.html">sqlite3_malloc()</a>. The caller should
invoke <a href="../c3ref/free.html">sqlite3_free()</a> on the result to avoid a memory leak.</p>
<p><li><a name="sqlitefcntlmmapsize"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlmmapsize">SQLITE_FCNTL_MMAP_SIZE</a> file control is used to query or set the
maximum number of bytes that will be used for memory-mapped I/O.
The argument is a pointer to a value of type sqlite3_int64 that
is an advisory maximum number of bytes in the file to memory map. The
pointer is overwritten with the old value. The limit is not changed if
the value originally pointed to is negative, and so the current limit
can be queried by passing in a pointer to a negative number. This
file-control is used internally to implement <a href="../pragma.html#pragma_mmap_size">PRAGMA mmap_size</a>.</p>
<p><li><a name="sqlitefcntltrace"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntltrace">SQLITE_FCNTL_TRACE</a> file control provides advisory information
to the VFS about what the higher layers of the SQLite stack are doing.
This file control is used by some VFS activity tracing <a href="../vfs.html#shim">shims</a>.
The argument is a zero-terminated string. Higher layers in the
SQLite stack may generate instances of this file control if
the <a href="../compile.html#use_fcntl_trace">SQLITE_USE_FCNTL_TRACE</a> compile-time option is enabled.</p>
<p><li><a name="sqlitefcntlhasmoved"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlhasmoved">SQLITE_FCNTL_HAS_MOVED</a> file control interprets its argument as a
pointer to an integer and it writes a boolean into that integer depending
on whether or not the file has been renamed, moved, or deleted since it
was first opened.</p>
<p><li><a name="sqlitefcntlwin32gethandle"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwin32gethandle">SQLITE_FCNTL_WIN32_GET_HANDLE</a> opcode can be used to obtain the
underlying native file handle associated with a file handle. This file
control interprets its argument as a pointer to a native file handle and
writes the resulting value there.</p>
<p><li><a name="sqlitefcntlwin32sethandle"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwin32sethandle">SQLITE_FCNTL_WIN32_SET_HANDLE</a> opcode is used for debugging. This
opcode causes the xFileControl method to swap the file handle with the one
pointed to by the pArg argument. This capability is used during testing
and only needs to be supported when SQLITE_TEST is defined.</p>
<p><li><a name="sqlitefcntlwalblock"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwalblock">SQLITE_FCNTL_WAL_BLOCK</a> is a signal to the VFS layer that it might
be advantageous to block on the next WAL lock if the lock is not immediately
available. The WAL subsystem issues this signal during rare
circumstances in order to fix a problem with priority inversion.
Applications should <em>not</em> use this file-control.</p>
<p><li><a name="sqlitefcntlzipvfs"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlzipvfs">SQLITE_FCNTL_ZIPVFS</a> opcode is implemented by zipvfs only. All other
VFS should return SQLITE_NOTFOUND for this opcode.</p>
<p><li><a name="sqlitefcntlrbu"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlrbu">SQLITE_FCNTL_RBU</a> opcode is implemented by the special VFS used by
the RBU extension only. All other VFS should return SQLITE_NOTFOUND for
this opcode.</p>
<p><li><a name="sqlitefcntlbeginatomicwrite"></a>
If the <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> opcode returns SQLITE_OK, then
the file descriptor is placed in "batch write mode", which
means all subsequent write operations will be deferred and done
atomically at the next <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a>. Systems
that do not support batch atomic writes will return SQLITE_NOTFOUND.
Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to
the closing <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a> or
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlrollbackatomicwrite">SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE</a>, SQLite will make
no VFS interface calls on the same <a href="../c3ref/file.html">sqlite3_file</a> file descriptor
except for calls to the xWrite method and the xFileControl method
with <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizehint">SQLITE_FCNTL_SIZE_HINT</a>.</p>
<p><li><a name="sqlitefcntlcommitatomicwrite"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a> opcode causes all write
operations since the previous successful call to
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> to be performed atomically.
This file control returns <a href="../rescode.html#ok">SQLITE_OK</a> if and only if the writes were
all performed successfully and have been committed to persistent storage.
Regardless of whether or not it is successful, this file control takes
the file descriptor out of batch write mode so that all subsequent
write operations are independent.
SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without
a prior successful call to <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a>.</p>
<p><li><a name="sqlitefcntlrollbackatomicwrite"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlrollbackatomicwrite">SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE</a> opcode causes all write
operations since the previous successful call to
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> to be rolled back.
This file control takes the file descriptor out of batch write mode
so that all subsequent write operations are independent.
SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
a prior successful call to <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a>.</p>
<p><li><a name="sqlitefcntllocktimeout"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntllocktimeout">SQLITE_FCNTL_LOCK_TIMEOUT</a> opcode is used to configure a VFS
to block for up to M milliseconds before failing when attempting to
obtain a file lock using the xLock or xShmLock methods of the VFS.
The parameter is a pointer to a 32-bit signed integer that contains
the value that M is to be set to. Before returning, the 32-bit signed
integer is overwritten with the previous value of M.</p>
<p><li><a name="sqlitefcntldataversion"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntldataversion">SQLITE_FCNTL_DATA_VERSION</a> opcode is used to detect changes to
a database file. The argument is a pointer to a 32-bit unsigned integer.
The "data version" for the pager is written into the pointer. The
"data version" changes whenever any change occurs to the corresponding
database file, either through SQL statements on the same database
connection or through transactions committed by separate database
connections possibly in other processes. The <a href="../c3ref/total_changes.html">sqlite3_total_changes()</a>
interface can be used to find if any database on the connection has changed,
but that interface responds to changes on TEMP as well as MAIN and does
not provide a mechanism to detect changes to MAIN only. Also, the
<a href="../c3ref/total_changes.html">sqlite3_total_changes()</a> interface responds to internal changes only and
omits changes made by other database connections. The
<a href="../pragma.html#pragma_data_version">PRAGMA data_version</a> command provides a mechanism to detect changes to
a single attached database that occur due to other database connections,
but omits changes implemented by the database connection on which it is
called. This file control is the only mechanism to detect changes that
happen either internally or externally and that are associated with
a particular attached database.</p>
<p><li><a name="sqlitefcntlckptstart"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlckptstart">SQLITE_FCNTL_CKPT_START</a> opcode is invoked from within a checkpoint
in wal mode before the client starts to copy pages from the wal
file to the database file.</p>
<p><li><a name="sqlitefcntlckptdone"></a>
The <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlckptdone">SQLITE_FCNTL_CKPT_DONE</a> opcode is invoked from within a checkpoint
in wal mode after the client has finished copying pages from the wal
file to the database file, but before the *-shm file is updated to
record the fact that the pages have been checkpointed.
</ul>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Virtual Table Constraint Operator Codes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_INDEX_CONSTRAINT_EQ SQLITE_INDEX_CONSTRAINT_FUNCTION SQLITE_INDEX_CONSTRAINT_GE SQLITE_INDEX_CONSTRAINT_GLOB SQLITE_INDEX_CONSTRAINT_GT SQLITE_INDEX_CONSTRAINT_IS SQLITE_INDEX_CONSTRAINT_ISNOT SQLITE_INDEX_CONSTRAINT_ISNOTNULL SQLITE_INDEX_CONSTRAINT_ISNULL SQLITE_INDEX_CONSTRAINT_LE SQLITE_INDEX_CONSTRAINT_LIKE SQLITE_INDEX_CONSTRAINT_LT SQLITE_INDEX_CONSTRAINT_MATCH SQLITE_INDEX_CONSTRAINT_NE SQLITE_INDEX_CONSTRAINT_REGEXP -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Virtual Table Constraint Operator Codes</h2>
</div>
<blockquote><pre>
#define SQLITE_INDEX_CONSTRAINT_EQ 2
#define SQLITE_INDEX_CONSTRAINT_GT 4
#define SQLITE_INDEX_CONSTRAINT_LE 8
#define SQLITE_INDEX_CONSTRAINT_LT 16
#define SQLITE_INDEX_CONSTRAINT_GE 32
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
#define SQLITE_INDEX_CONSTRAINT_LIKE 65
#define SQLITE_INDEX_CONSTRAINT_GLOB 66
#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
#define SQLITE_INDEX_CONSTRAINT_NE 68
#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
#define SQLITE_INDEX_CONSTRAINT_IS 72
#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
</pre></blockquote>
<p>
These macros define the allowed values for the
<a href="../c3ref/index_info.html">sqlite3_index_info</a>.aConstraint[].op field. Each value represents
an operator that is part of a constraint term in the wHERE clause of
a query that uses a <a href="../vtab.html">virtual table</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,109 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Virtual Table Scan Flags</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_INDEX_SCAN_UNIQUE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Virtual Table Scan Flags</h2>
</div>
<blockquote><pre>
#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
</pre></blockquote>
<p>
Virtual table implementations are allowed to set the
<a href="../c3ref/index_info.html">sqlite3_index_info</a>.idxFlags field to some combination of
these bits.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,149 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Device Characteristics</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_IOCAP_ATOMIC SQLITE_IOCAP_ATOMIC16K SQLITE_IOCAP_ATOMIC1K SQLITE_IOCAP_ATOMIC2K SQLITE_IOCAP_ATOMIC32K SQLITE_IOCAP_ATOMIC4K SQLITE_IOCAP_ATOMIC512 SQLITE_IOCAP_ATOMIC64K SQLITE_IOCAP_ATOMIC8K SQLITE_IOCAP_BATCH_ATOMIC SQLITE_IOCAP_IMMUTABLE SQLITE_IOCAP_POWERSAFE_OVERWRITE SQLITE_IOCAP_SAFE_APPEND SQLITE_IOCAP_SEQUENTIAL SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Device Characteristics</h2>
</div>
<blockquote><pre>
#define SQLITE_IOCAP_ATOMIC 0x00000001
#define SQLITE_IOCAP_ATOMIC512 0x00000002
#define SQLITE_IOCAP_ATOMIC1K 0x00000004
#define SQLITE_IOCAP_ATOMIC2K 0x00000008
#define SQLITE_IOCAP_ATOMIC4K 0x00000010
#define SQLITE_IOCAP_ATOMIC8K 0x00000020
#define SQLITE_IOCAP_ATOMIC16K 0x00000040
#define SQLITE_IOCAP_ATOMIC32K 0x00000080
#define SQLITE_IOCAP_ATOMIC64K 0x00000100
#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
#define SQLITE_IOCAP_IMMUTABLE 0x00002000
#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
</pre></blockquote>
<p>
The xDeviceCharacteristics method of the <a href="../c3ref/io_methods.html">sqlite3_io_methods</a>
object returns an integer which is a vector of these
bit values expressing I/O characteristics of the mass storage
device that holds the file that the <a href="../c3ref/io_methods.html">sqlite3_io_methods</a>
refers to.</p>
<p>The SQLITE_IOCAP_ATOMIC property means that all writes of
any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
mean that writes of blocks that are nnn bytes in size and
are aligned to an address which is an integer multiple of
nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
that when data is appended to a file, the data is appended
first then the size of the file is extended, never the other
way around. The SQLITE_IOCAP_SEQUENTIAL property means that
information is written to disk in the same order as calls
to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
after reboot following a crash or power loss, the only bytes in a
file that were written at the application level might have changed
and that adjacent bytes, even bytes within the same sector are
guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
flag indicates that a file cannot be deleted when open. The
SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
read-only media and cannot be changed even by processes with
elevated privileges.</p>
<p>The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying
filesystem supports doing multiple write operations atomically when those
write operations are bracketed by <a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite">SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a> and
<a href="../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitatomicwrite">SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,180 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Run-Time Limit Categories</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {*limit categories} SQLITE_LIMIT_ATTACHED SQLITE_LIMIT_COLUMN SQLITE_LIMIT_COMPOUND_SELECT SQLITE_LIMIT_EXPR_DEPTH SQLITE_LIMIT_FUNCTION_ARG SQLITE_LIMIT_LENGTH SQLITE_LIMIT_LIKE_PATTERN_LENGTH SQLITE_LIMIT_SQL_LENGTH SQLITE_LIMIT_TRIGGER_DEPTH SQLITE_LIMIT_VARIABLE_NUMBER SQLITE_LIMIT_VDBE_OP SQLITE_LIMIT_WORKER_THREADS {limit category} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Run-Time Limit Categories</h2>
</div>
<blockquote><pre>
#define SQLITE_LIMIT_LENGTH 0
#define SQLITE_LIMIT_SQL_LENGTH 1
#define SQLITE_LIMIT_COLUMN 2
#define SQLITE_LIMIT_EXPR_DEPTH 3
#define SQLITE_LIMIT_COMPOUND_SELECT 4
#define SQLITE_LIMIT_VDBE_OP 5
#define SQLITE_LIMIT_FUNCTION_ARG 6
#define SQLITE_LIMIT_ATTACHED 7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
#define SQLITE_LIMIT_WORKER_THREADS 11
</pre></blockquote>
<p>
These constants define various performance limits
that can be lowered at run-time using <a href="../c3ref/limit.html">sqlite3_limit()</a>.
The synopsis of the meanings of the various limits is shown below.
Additional information is available at <a href="../limits.html">Limits in SQLite</a>.</p>
<p><dl>
<a name="sqlitelimitlength"></a>
<dt>SQLITE_LIMIT_LENGTH</dt>
<dd>The maximum size of any string or BLOB or table row, in bytes.<dd></p>
<p><a name="sqlitelimitsqllength"></a>
<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
<dd>The maximum length of an SQL statement, in bytes.</dd></p>
<p><a name="sqlitelimitcolumn"></a>
<dt>SQLITE_LIMIT_COLUMN</dt>
<dd>The maximum number of columns in a table definition or in the
result set of a <a href="../lang_select.html">SELECT</a> or the maximum number of columns in an index
or in an ORDER BY or GROUP BY clause.</dd></p>
<p><a name="sqlitelimitexprdepth"></a>
<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
<dd>The maximum depth of the parse tree on any expression.</dd></p>
<p><a name="sqlitelimitcompoundselect"></a>
<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
<dd>The maximum number of terms in a compound SELECT statement.</dd></p>
<p><a name="sqlitelimitvdbeop"></a>
<dt>SQLITE_LIMIT_VDBE_OP</dt>
<dd>The maximum number of instructions in a virtual machine program
used to implement an SQL statement. If <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> or
the equivalent tries to allocate space for more than this many opcodes
in a single prepared statement, an SQLITE_NOMEM error is returned.</dd></p>
<p><a name="sqlitelimitfunctionarg"></a>
<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
<dd>The maximum number of arguments on a function.</dd></p>
<p><a name="sqlitelimitattached"></a>
<dt>SQLITE_LIMIT_ATTACHED</dt>
<dd>The maximum number of <a href="../lang_attach.html">attached databases</a>.</dd></p>
<p><a name="sqlitelimitlikepatternlength"></a>
<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
<dd>The maximum length of the pattern argument to the <a href="../lang_expr.html#like">LIKE</a> or
<a href="../lang_expr.html#glob">GLOB</a> operators.</dd></p>
<p><a name="sqlitelimitvariablenumber"></a>
<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
<dd>The maximum index number of any <a href="../lang_expr.html#varparam">parameter</a> in an SQL statement.</p>
<p><a name="sqlitelimittriggerdepth"></a>
<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
<dd>The maximum depth of recursion for triggers.</dd></p>
<p><a name="sqlitelimitworkerthreads"></a>
<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
<dd>The maximum number of auxiliary worker threads that a single
<a href="../c3ref/stmt.html">prepared statement</a> may start.</dd>
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,113 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>File Locking Levels</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_LOCK_EXCLUSIVE SQLITE_LOCK_NONE SQLITE_LOCK_PENDING SQLITE_LOCK_RESERVED SQLITE_LOCK_SHARED -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>File Locking Levels</h2>
</div>
<blockquote><pre>
#define SQLITE_LOCK_NONE 0
#define SQLITE_LOCK_SHARED 1
#define SQLITE_LOCK_RESERVED 2
#define SQLITE_LOCK_PENDING 3
#define SQLITE_LOCK_EXCLUSIVE 4
</pre></blockquote>
<p>
SQLite uses one of these integer values as the second
argument to calls it makes to the xLock() and xUnlock() methods
of an <a href="../c3ref/io_methods.html">sqlite3_io_methods</a> object.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Mutex Types</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_MUTEX_FAST SQLITE_MUTEX_RECURSIVE SQLITE_MUTEX_STATIC_APP1 SQLITE_MUTEX_STATIC_APP2 SQLITE_MUTEX_STATIC_APP3 SQLITE_MUTEX_STATIC_LRU SQLITE_MUTEX_STATIC_LRU2 SQLITE_MUTEX_STATIC_MAIN SQLITE_MUTEX_STATIC_MEM SQLITE_MUTEX_STATIC_MEM2 SQLITE_MUTEX_STATIC_OPEN SQLITE_MUTEX_STATIC_PMEM SQLITE_MUTEX_STATIC_PRNG SQLITE_MUTEX_STATIC_VFS1 SQLITE_MUTEX_STATIC_VFS2 SQLITE_MUTEX_STATIC_VFS3 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Mutex Types</h2>
</div>
<blockquote><pre>
#define SQLITE_MUTEX_FAST 0
#define SQLITE_MUTEX_RECURSIVE 1
#define SQLITE_MUTEX_STATIC_MAIN 2
#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */
#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */
#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */
#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_randomness() */
#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */
#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */
#define SQLITE_MUTEX_STATIC_APP1 8 /* For use by application */
#define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
#define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
#define SQLITE_MUTEX_STATIC_VFS1 11 /* For use by built-in VFS */
#define SQLITE_MUTEX_STATIC_VFS2 12 /* For use by extension VFS */
#define SQLITE_MUTEX_STATIC_VFS3 13 /* For use by application VFS */
</pre></blockquote>
<p>
The <a href="../c3ref/mutex_alloc.html">sqlite3_mutex_alloc()</a> interface takes a single argument
which is one of these integer constants.</p>
<p>The set of static mutexes may change from one SQLite release to the
next. Applications that override the built-in mutex logic must be
prepared to accommodate additional static mutexes.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,129 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Flags For File Open Operations</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_OPEN_AUTOPROXY SQLITE_OPEN_CREATE SQLITE_OPEN_DELETEONCLOSE SQLITE_OPEN_EXCLUSIVE SQLITE_OPEN_FULLMUTEX SQLITE_OPEN_MAIN_DB SQLITE_OPEN_MAIN_JOURNAL SQLITE_OPEN_MEMORY SQLITE_OPEN_NOFOLLOW SQLITE_OPEN_NOMUTEX SQLITE_OPEN_PRIVATECACHE SQLITE_OPEN_READONLY SQLITE_OPEN_READWRITE SQLITE_OPEN_SHAREDCACHE SQLITE_OPEN_SUBJOURNAL SQLITE_OPEN_SUPER_JOURNAL SQLITE_OPEN_TEMP_DB SQLITE_OPEN_TEMP_JOURNAL SQLITE_OPEN_TRANSIENT_DB SQLITE_OPEN_URI SQLITE_OPEN_WAL -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Flags For File Open Operations</h2>
</div>
<blockquote><pre>
#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */
#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */
#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */
#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */
#define SQLITE_OPEN_SUPER_JOURNAL 0x00004000 /* VFS only */
#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
</pre></blockquote>
<p>
These bit values are intended for use in the
3rd parameter to the <a href="../c3ref/open.html">sqlite3_open_v2()</a> interface and
in the 4th parameter to the <a href="../c3ref/vfs.html#sqlite3vfsxopen">sqlite3_vfs.xOpen</a> method.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,142 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Prepare Flags</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_PREPARE_NORMALIZE SQLITE_PREPARE_NO_VTAB SQLITE_PREPARE_PERSISTENT -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Prepare Flags</h2>
</div>
<blockquote><pre>
#define SQLITE_PREPARE_PERSISTENT 0x01
#define SQLITE_PREPARE_NORMALIZE 0x02
#define SQLITE_PREPARE_NO_VTAB 0x04
</pre></blockquote>
<p>
These constants define various flags that can be passed into
"prepFlags" parameter of the <a href="../c3ref/prepare.html">sqlite3_prepare_v3()</a> and
<a href="../c3ref/prepare.html">sqlite3_prepare16_v3()</a> interfaces.</p>
<p>New flags may be added in future releases of SQLite.</p>
<p><dl>
<a name="sqlitepreparepersistent"></a>
<dt>SQLITE_PREPARE_PERSISTENT</dt>
<dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
that the prepared statement will be retained for a long time and
probably reused many times. Without this flag, <a href="../c3ref/prepare.html">sqlite3_prepare_v3()</a>
and <a href="../c3ref/prepare.html">sqlite3_prepare16_v3()</a> assume that the prepared statement will
be used just once or at most a few times and then destroyed using
<a href="../c3ref/finalize.html">sqlite3_finalize()</a> relatively soon. The current implementation acts
on this hint by avoiding the use of <a href="../malloc.html#lookaside">lookaside memory</a> so as not to
deplete the limited store of lookaside memory. Future versions of
SQLite may act on this hint differently.</p>
<p><a name="sqlitepreparenormalize"></a>
<dt>SQLITE_PREPARE_NORMALIZE</dt>
<dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used
to be required for any prepared statement that wanted to use the
<a href="../c3ref/expanded_sql.html">sqlite3_normalized_sql()</a> interface. However, the
<a href="../c3ref/expanded_sql.html">sqlite3_normalized_sql()</a> interface is now available to all
prepared statements, regardless of whether or not they use this
flag.</p>
<p><a name="sqlitepreparenovtab"></a>
<dt>SQLITE_PREPARE_NO_VTAB</dt>
<dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
to return an error (error code SQLITE_ERROR) if the statement uses
any virtual tables.
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,159 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Prepared Statement Scan Status Opcodes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_SCANSTAT_EST SQLITE_SCANSTAT_EXPLAIN SQLITE_SCANSTAT_NAME SQLITE_SCANSTAT_NLOOP SQLITE_SCANSTAT_NVISIT SQLITE_SCANSTAT_SELECTID {scanstatus options} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Prepared Statement Scan Status Opcodes</h2>
</div>
<blockquote><pre>
#define SQLITE_SCANSTAT_NLOOP 0
#define SQLITE_SCANSTAT_NVISIT 1
#define SQLITE_SCANSTAT_EST 2
#define SQLITE_SCANSTAT_NAME 3
#define SQLITE_SCANSTAT_EXPLAIN 4
#define SQLITE_SCANSTAT_SELECTID 5
</pre></blockquote>
<p>
The following constants can be used for the T parameter to the
<a href="../c3ref/stmt_scanstatus.html">sqlite3_stmt_scanstatus(S,X,T,V)</a> interface. Each constant designates a
different metric for sqlite3_stmt_scanstatus() to return.</p>
<p>When the value returned to V is a string, space to hold that string is
managed by the prepared statement S and will be automatically freed when
S is finalized.</p>
<p><dl>
<a name="sqlitescanstatnloop"></a>
<dt>SQLITE_SCANSTAT_NLOOP</dt>
<dd>The <a href="../c3ref/int64.html">sqlite3_int64</a> variable pointed to by the V parameter will be
set to the total number of times that the X-th loop has run.</dd></p>
<p><a name="sqlitescanstatnvisit"></a>
<dt>SQLITE_SCANSTAT_NVISIT</dt>
<dd>The <a href="../c3ref/int64.html">sqlite3_int64</a> variable pointed to by the V parameter will be set
to the total number of rows examined by all iterations of the X-th loop.</dd></p>
<p><a name="sqlitescanstatest"></a>
<dt>SQLITE_SCANSTAT_EST</dt>
<dd>The "double" variable pointed to by the V parameter will be set to the
query planner's estimate for the average number of rows output from each
iteration of the X-th loop. If the query planner's estimates was accurate,
then this value will approximate the quotient NVISIT/NLOOP and the
product of this value for all prior loops with the same SELECTID will
be the NLOOP value for the current loop.</p>
<p><a name="sqlitescanstatname"></a>
<dt>SQLITE_SCANSTAT_NAME</dt>
<dd>The "const char *" variable pointed to by the V parameter will be set
to a zero-terminated UTF-8 string containing the name of the index or table
used for the X-th loop.</p>
<p><a name="sqlitescanstatexplain"></a>
<dt>SQLITE_SCANSTAT_EXPLAIN</dt>
<dd>The "const char *" variable pointed to by the V parameter will be set
to a zero-terminated UTF-8 string containing the <a href="../eqp.html">EXPLAIN QUERY PLAN</a>
description for the X-th loop.</p>
<p><a name="sqlitescanstatselectid"></a>
<dt>SQLITE_SCANSTAT_SELECT</dt>
<dd>The "int" variable pointed to by the V parameter will be set to the
"select-id" for the X-th loop. The select-id identifies which query or
subquery the loop is part of. The main query has a select-id of zero.
The select-id is the same value as is output in the first column
of an <a href="../eqp.html">EXPLAIN QUERY PLAN</a> query.
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Flags for sqlite3_serialize</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_SERIALIZE_NOCOPY -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Flags for sqlite3_serialize</h2>
</div>
<blockquote><pre>
#define SQLITE_SERIALIZE_NOCOPY 0x001 /* Do no memory allocations */
</pre></blockquote>
<p>
Zero or more of the following constants can be OR-ed together for
the F argument to <a href="../c3ref/serialize.html">sqlite3_serialize(D,S,P,F)</a>.</p>
<p>SQLITE_SERIALIZE_NOCOPY means that <a href="../c3ref/serialize.html">sqlite3_serialize()</a> will return
a pointer to contiguous in-memory database that it is currently using,
without making a copy of the database. If SQLite is not currently using
a contiguous in-memory database, then this option causes
<a href="../c3ref/serialize.html">sqlite3_serialize()</a> to return a NULL pointer. SQLite will only be
using a contiguous in-memory database if it has been initialized by a
prior call to <a href="../c3ref/deserialize.html">sqlite3_deserialize()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Flags for the xShmLock VFS method</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_SHM_EXCLUSIVE SQLITE_SHM_LOCK SQLITE_SHM_SHARED SQLITE_SHM_UNLOCK -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Flags for the xShmLock VFS method</h2>
</div>
<blockquote><pre>
#define SQLITE_SHM_UNLOCK 1
#define SQLITE_SHM_LOCK 2
#define SQLITE_SHM_SHARED 4
#define SQLITE_SHM_EXCLUSIVE 8
</pre></blockquote>
<p>
These integer constants define the various locking operations
allowed by the xShmLock method of <a href="../c3ref/io_methods.html">sqlite3_io_methods</a>. The
following are the only legal combinations of flags to the
xShmLock method:</p>
<p><ul>
<li> SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
<li> SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
<li> SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
<li> SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
</ul></p>
<p>When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
was given on the corresponding lock.</p>
<p>The xShmLock method can transition between unlocked and SHARED or
between unlocked and EXCLUSIVE. It cannot transition between SHARED
and EXCLUSIVE.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,110 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Maximum xShmLock index</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_SHM_NLOCK -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Maximum xShmLock index</h2>
</div>
<blockquote><pre>
#define SQLITE_SHM_NLOCK 8
</pre></blockquote>
<p>
The xShmLock method on <a href="../c3ref/io_methods.html">sqlite3_io_methods</a> may use values
between 0 and this upper bound as its "offset" argument.
The SQLite core will never attempt to acquire or release a
lock outside of this range
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,134 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Compile-Time Library Version Numbers</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_SOURCE_ID SQLITE_VERSION SQLITE_VERSION_NUMBER -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Compile-Time Library Version Numbers</h2>
</div>
<blockquote><pre>
#define SQLITE_VERSION "3.33.0"
#define SQLITE_VERSION_NUMBER 3033000
#define SQLITE_SOURCE_ID "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f"
</pre></blockquote>
<p>
The <a href="../c3ref/c_source_id.html">SQLITE_VERSION</a> C preprocessor macro in the sqlite3.h header
evaluates to a string literal that is the SQLite version in the
format "X.Y.Z" where X is the major version number (always 3 for
SQLite3) and Y is the minor version number and Z is the release number.
The <a href="../c3ref/c_source_id.html">SQLITE_VERSION_NUMBER</a> C preprocessor macro resolves to an integer
with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
numbers used in <a href="../c3ref/c_source_id.html">SQLITE_VERSION</a>.
The SQLITE_VERSION_NUMBER for any given release of SQLite will also
be larger than the release from which it is derived. Either Y will
be held constant and Z will be incremented or else Y will be incremented
and Z will be reset to zero.</p>
<p>Since <a href="../releaselog/3_6_18.html">version 3.6.18</a> (2009-09-11),
SQLite source code has been stored in the
<a href="http://www.fossil-scm.org/">Fossil configuration management
system</a>. The SQLITE_SOURCE_ID macro evaluates to
a string which identifies a particular check-in of SQLite
within its configuration management system. The SQLITE_SOURCE_ID
string contains the date and time of the check-in (UTC) and a SHA1
or SHA3-256 hash of the entire source tree. If the source code has
been edited in any way since it was last checked in, then the last
four hexadecimal digits of the hash may be modified.</p>
<p>See also: <a href="../c3ref/libversion.html">sqlite3_libversion()</a>,
<a href="../c3ref/libversion.html">sqlite3_libversion_number()</a>, <a href="../c3ref/libversion.html">sqlite3_sourceid()</a>,
<a href="../lang_corefunc.html#sqlite_version">sqlite_version()</a> and <a href="../lang_corefunc.html#sqlite_source_id">sqlite_source_id()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,118 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Constants Defining Special Destructor Behavior</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_STATIC SQLITE_TRANSIENT -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Constants Defining Special Destructor Behavior</h2>
</div>
<blockquote><pre>
typedef void (*sqlite3_destructor_type)(void*);
#define SQLITE_STATIC ((sqlite3_destructor_type)0)
#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
</pre></blockquote>
<p>
These are special values for the destructor that is passed in as the
final argument to routines like <a href="../c3ref/result_blob.html">sqlite3_result_blob()</a>. If the destructor
argument is SQLITE_STATIC, it means that the content pointer is constant
and will never change. It does not need to be destroyed. The
SQLITE_TRANSIENT value means that the content will likely change in
the near future and that SQLite should make its own private copy of
the content before returning.</p>
<p>The typedef is necessary to work around problems in certain
C++ compilers.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,187 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Status Parameters</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_STATUS_MALLOC_COUNT SQLITE_STATUS_MALLOC_SIZE SQLITE_STATUS_MEMORY_USED SQLITE_STATUS_PAGECACHE_OVERFLOW SQLITE_STATUS_PAGECACHE_SIZE SQLITE_STATUS_PAGECACHE_USED SQLITE_STATUS_PARSER_STACK SQLITE_STATUS_SCRATCH_OVERFLOW SQLITE_STATUS_SCRATCH_SIZE SQLITE_STATUS_SCRATCH_USED {status parameters} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Status Parameters</h2>
</div>
<blockquote><pre>
#define SQLITE_STATUS_MEMORY_USED 0
#define SQLITE_STATUS_PAGECACHE_USED 1
#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2
#define SQLITE_STATUS_SCRATCH_USED 3 /* NOT USED */
#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 /* NOT USED */
#define SQLITE_STATUS_MALLOC_SIZE 5
#define SQLITE_STATUS_PARSER_STACK 6
#define SQLITE_STATUS_PAGECACHE_SIZE 7
#define SQLITE_STATUS_SCRATCH_SIZE 8 /* NOT USED */
#define SQLITE_STATUS_MALLOC_COUNT 9
</pre></blockquote>
<p>
These integer constants designate various run-time status parameters
that can be returned by <a href="../c3ref/status.html">sqlite3_status()</a>.</p>
<p><dl>
<a name="sqlitestatusmemoryused"></a>
<dt>SQLITE_STATUS_MEMORY_USED</dt>
<dd>This parameter is the current amount of memory checked out
using <a href="../c3ref/free.html">sqlite3_malloc()</a>, either directly or indirectly. The
figure includes calls made to <a href="../c3ref/free.html">sqlite3_malloc()</a> by the application
and internal memory usage by the SQLite library. Auxiliary page-cache
memory controlled by <a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a> is not included in
this parameter. The amount returned is the sum of the allocation
sizes as reported by the xSize method in <a href="../c3ref/mem_methods.html">sqlite3_mem_methods</a>.</dd></p>
<p><a name="sqlitestatusmallocsize"></a>
<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
<dd>This parameter records the largest memory allocation request
handed to <a href="../c3ref/free.html">sqlite3_malloc()</a> or <a href="../c3ref/free.html">sqlite3_realloc()</a> (or their
internal equivalents). Only the value returned in the
*pHighwater parameter to <a href="../c3ref/status.html">sqlite3_status()</a> is of interest.
The value written into the *pCurrent parameter is undefined.</dd></p>
<p><a name="sqlitestatusmalloccount"></a>
<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
<dd>This parameter records the number of separate memory allocations
currently checked out.</dd></p>
<p><a name="sqlitestatuspagecacheused"></a>
<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
<dd>This parameter returns the number of pages used out of the
<a href="../malloc.html#pagecache">pagecache memory allocator</a> that was configured using
<a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>. The
value returned is in pages, not in bytes.</dd></p>
<p><a name="sqlitestatuspagecacheoverflow"></a>
<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
<dd>This parameter returns the number of bytes of page cache
allocation which could not be satisfied by the <a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>
buffer and where forced to overflow to <a href="../c3ref/free.html">sqlite3_malloc()</a>. The
returned value includes allocations that overflowed because they
where too large (they were larger than the "sz" parameter to
<a href="../c3ref/c_config_covering_index_scan.html#sqliteconfigpagecache">SQLITE_CONFIG_PAGECACHE</a>) and allocations that overflowed because
no space was left in the page cache.</dd></p>
<p><a name="sqlitestatuspagecachesize"></a>
<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
<dd>This parameter records the largest memory allocation request
handed to the <a href="../malloc.html#pagecache">pagecache memory allocator</a>. Only the value returned in the
*pHighwater parameter to <a href="../c3ref/status.html">sqlite3_status()</a> is of interest.
The value written into the *pCurrent parameter is undefined.</dd></p>
<p><a name="sqlitestatusscratchused"></a>
<dt>SQLITE_STATUS_SCRATCH_USED</dt>
<dd>No longer used.</dd></p>
<p><a name="sqlitestatusscratchoverflow"></a>
<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
<dd>No longer used.</dd></p>
<p><a name="sqlitestatusscratchsize"></a>
<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
<dd>No longer used.</dd></p>
<p><a name="sqlitestatusparserstack"></a>
<dt>SQLITE_STATUS_PARSER_STACK</dt>
<dd>The *pHighwater parameter records the deepest parser stack.
The *pCurrent value is undefined. The *pHighwater value is only
meaningful if SQLite is compiled with <a href="../compile.html#yytrackmaxstackdepth">YYTRACKMAXSTACKDEPTH</a>.</dd>
</dl></p>
<p>New status parameters may be added from time to time.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,169 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Status Parameters for prepared statements</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} SQLITE_STMTSTATUS_AUTOINDEX SQLITE_STMTSTATUS_FULLSCAN_STEP SQLITE_STMTSTATUS_MEMUSED SQLITE_STMTSTATUS_REPREPARE SQLITE_STMTSTATUS_RUN SQLITE_STMTSTATUS_SORT SQLITE_STMTSTATUS_VM_STEP -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Status Parameters for prepared statements</h2>
</div>
<blockquote><pre>
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
#define SQLITE_STMTSTATUS_SORT 2
#define SQLITE_STMTSTATUS_AUTOINDEX 3
#define SQLITE_STMTSTATUS_VM_STEP 4
#define SQLITE_STMTSTATUS_REPREPARE 5
#define SQLITE_STMTSTATUS_RUN 6
#define SQLITE_STMTSTATUS_MEMUSED 99
</pre></blockquote>
<p>
These preprocessor macros define integer codes that name counter
values associated with the <a href="../c3ref/stmt_status.html">sqlite3_stmt_status()</a> interface.
The meanings of the various counters are as follows:</p>
<p><dl>
<a name="sqlitestmtstatusfullscanstep"></a>
<dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
<dd>This is the number of times that SQLite has stepped forward in
a table as part of a full table scan. Large numbers for this counter
may indicate opportunities for performance improvement through
careful use of indices.</dd></p>
<p><a name="sqlitestmtstatussort"></a>
<dt>SQLITE_STMTSTATUS_SORT</dt>
<dd>This is the number of sort operations that have occurred.
A non-zero value in this counter may indicate an opportunity to
improvement performance through careful use of indices.</dd></p>
<p><a name="sqlitestmtstatusautoindex"></a>
<dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
<dd>This is the number of rows inserted into transient indices that
were created automatically in order to help joins run faster.
A non-zero value in this counter may indicate an opportunity to
improvement performance by adding permanent indices that do not
need to be reinitialized each time the statement is run.</dd></p>
<p><a name="sqlitestmtstatusvmstep"></a>
<dt>SQLITE_STMTSTATUS_VM_STEP</dt>
<dd>This is the number of virtual machine operations executed
by the prepared statement if that number is less than or equal
to 2147483647. The number of virtual machine operations can be
used as a proxy for the total work done by the prepared statement.
If the number of virtual machine operations exceeds 2147483647
then the value returned by this statement status code is undefined.</p>
<p><a name="sqlitestmtstatusreprepare"></a>
<dt>SQLITE_STMTSTATUS_REPREPARE</dt>
<dd>This is the number of times that the prepare statement has been
automatically regenerated due to schema changes or changes to
<a href="../lang_expr.html#varparam">bound parameters</a> that might affect the query plan.</p>
<p><a name="sqlitestmtstatusrun"></a>
<dt>SQLITE_STMTSTATUS_RUN</dt>
<dd>This is the number of times that the prepared statement has
been run. A single "run" for the purposes of this counter is one
or more calls to <a href="../c3ref/step.html">sqlite3_step()</a> followed by a call to <a href="../c3ref/reset.html">sqlite3_reset()</a>.
The counter is incremented on the first <a href="../c3ref/step.html">sqlite3_step()</a> call of each
cycle.</p>
<p><a name="sqlitestmtstatusmemused"></a>
<dt>SQLITE_STMTSTATUS_MEMUSED</dt>
<dd>This is the approximate number of bytes of heap memory
used to store the prepared statement. This value is not actually
a counter, and so the resetFlg parameter to sqlite3_stmt_status()
is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.
</dd>
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,130 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Synchronization Type Flags</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_SYNC_DATAONLY SQLITE_SYNC_FULL SQLITE_SYNC_NORMAL -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Synchronization Type Flags</h2>
</div>
<blockquote><pre>
#define SQLITE_SYNC_NORMAL 0x00002
#define SQLITE_SYNC_FULL 0x00003
#define SQLITE_SYNC_DATAONLY 0x00010
</pre></blockquote>
<p>
When SQLite invokes the xSync() method of an
<a href="../c3ref/io_methods.html">sqlite3_io_methods</a> object it uses a combination of
these integer values as the second argument.</p>
<p>When the SQLITE_SYNC_DATAONLY flag is used, it means that the
sync operation only needs to flush data to mass storage. Inode
information need not be flushed. If the lower four bits of the flag
equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
If the lower four bits equal SQLITE_SYNC_FULL, that means
to use Mac OS X style fullsync instead of fsync().</p>
<p>Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
with the <a href="../pragma.html#pragma_synchronous">PRAGMA synchronous</a>=NORMAL and <a href="../pragma.html#pragma_synchronous">PRAGMA synchronous</a>=FULL
settings. The <a href="../pragma.html#pragma_synchronous">synchronous pragma</a> determines when calls to the
xSync VFS method occur and applies uniformly across all platforms.
The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
energetic or rigorous or forceful the sync operations are and
only make a difference on Mac OSX for the default SQLite code.
(Third-party VFS implementations might also make the distinction
between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
operating systems natively supported by SQLite, only Mac OSX
cares about the difference.)
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,141 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Testing Interface Operation Codes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_TESTCTRL_ALWAYS SQLITE_TESTCTRL_ASSERT SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS SQLITE_TESTCTRL_BITVEC_TEST SQLITE_TESTCTRL_BYTEORDER SQLITE_TESTCTRL_EXPLAIN_STMT SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS SQLITE_TESTCTRL_FAULT_INSTALL SQLITE_TESTCTRL_FIRST SQLITE_TESTCTRL_IMPOSTER SQLITE_TESTCTRL_INTERNAL_FUNCTIONS SQLITE_TESTCTRL_ISINIT SQLITE_TESTCTRL_ISKEYWORD SQLITE_TESTCTRL_LAST SQLITE_TESTCTRL_LOCALTIME_FAULT SQLITE_TESTCTRL_NEVER_CORRUPT SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD SQLITE_TESTCTRL_OPTIMIZATIONS SQLITE_TESTCTRL_PARSER_COVERAGE SQLITE_TESTCTRL_PENDING_BYTE SQLITE_TESTCTRL_PRNG_RESET SQLITE_TESTCTRL_PRNG_RESTORE SQLITE_TESTCTRL_PRNG_SAVE SQLITE_TESTCTRL_PRNG_SEED SQLITE_TESTCTRL_RESERVE SQLITE_TESTCTRL_RESULT_INTREAL SQLITE_TESTCTRL_SCRATCHMALLOC SQLITE_TESTCTRL_SORTER_MMAP SQLITE_TESTCTRL_VDBE_COVERAGE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Testing Interface Operation Codes</h2>
</div>
<blockquote><pre>
#define SQLITE_TESTCTRL_FIRST 5
#define SQLITE_TESTCTRL_PRNG_SAVE 5
#define SQLITE_TESTCTRL_PRNG_RESTORE 6
#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
#define SQLITE_TESTCTRL_BITVEC_TEST 8
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
#define SQLITE_TESTCTRL_PENDING_BYTE 11
#define SQLITE_TESTCTRL_ASSERT 12
#define SQLITE_TESTCTRL_ALWAYS 13
#define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19
#define SQLITE_TESTCTRL_NEVER_CORRUPT 20
#define SQLITE_TESTCTRL_VDBE_COVERAGE 21
#define SQLITE_TESTCTRL_BYTEORDER 22
#define SQLITE_TESTCTRL_ISINIT 23
#define SQLITE_TESTCTRL_SORTER_MMAP 24
#define SQLITE_TESTCTRL_IMPOSTER 25
#define SQLITE_TESTCTRL_PARSER_COVERAGE 26
#define SQLITE_TESTCTRL_RESULT_INTREAL 27
#define SQLITE_TESTCTRL_PRNG_SEED 28
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
#define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */
</pre></blockquote>
<p>
These constants are the valid operation code parameters used
as the first argument to <a href="../c3ref/test_control.html">sqlite3_test_control()</a>.</p>
<p>These parameters and their meanings are subject to change
without notice. These values are for testing purposes only.
Applications should not use any of these parameters or the
<a href="../c3ref/test_control.html">sqlite3_test_control()</a> interface.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,160 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>SQL Trace Event Codes</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_TRACE SQLITE_TRACE_CLOSE SQLITE_TRACE_PROFILE SQLITE_TRACE_ROW SQLITE_TRACE_STMT -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>SQL Trace Event Codes</h2>
</div>
<blockquote><pre>
#define SQLITE_TRACE_STMT 0x01
#define SQLITE_TRACE_PROFILE 0x02
#define SQLITE_TRACE_ROW 0x04
#define SQLITE_TRACE_CLOSE 0x08
</pre></blockquote>
<p>
These constants identify classes of events that can be monitored
using the <a href="../c3ref/trace_v2.html">sqlite3_trace_v2()</a> tracing logic. The M argument
to <a href="../c3ref/trace_v2.html">sqlite3_trace_v2(D,M,X,P)</a> is an OR-ed combination of one or more of
the following constants. The first argument to the trace callback
is one of the following constants.</p>
<p>New tracing constants may be added in future releases.</p>
<p>A trace callback has four arguments: xCallback(T,C,P,X).
The T argument is one of the integer type codes above.
The C argument is a copy of the context pointer passed in as the
fourth argument to <a href="../c3ref/trace_v2.html">sqlite3_trace_v2()</a>.
The P and X arguments are pointers whose meanings depend on T.</p>
<p><dl>
<a name="sqlitetracestmt"></a>
<dt>SQLITE_TRACE_STMT</dt>
<dd>An SQLITE_TRACE_STMT callback is invoked when a prepared statement
first begins running and possibly at other times during the
execution of the prepared statement, such as at the start of each
trigger subprogram. The P argument is a pointer to the
<a href="../c3ref/stmt.html">prepared statement</a>. The X argument is a pointer to a string which
is the unexpanded SQL text of the prepared statement or an SQL comment
that indicates the invocation of a trigger. The callback can compute
the same text that would have been returned by the legacy <a href="../c3ref/profile.html">sqlite3_trace()</a>
interface by using the X argument when X begins with "--" and invoking
<a href="../c3ref/expanded_sql.html">sqlite3_expanded_sql(P)</a> otherwise.</p>
<p><a name="sqlitetraceprofile"></a>
<dt>SQLITE_TRACE_PROFILE</dt>
<dd>An SQLITE_TRACE_PROFILE callback provides approximately the same
information as is provided by the <a href="../c3ref/profile.html">sqlite3_profile()</a> callback.
The P argument is a pointer to the <a href="../c3ref/stmt.html">prepared statement</a> and the
X argument points to a 64-bit integer which is the estimated of
the number of nanosecond that the prepared statement took to run.
The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.</p>
<p><a name="sqlitetracerow"></a>
<dt>SQLITE_TRACE_ROW</dt>
<dd>An SQLITE_TRACE_ROW callback is invoked whenever a prepared
statement generates a single row of result.
The P argument is a pointer to the <a href="../c3ref/stmt.html">prepared statement</a> and the
X argument is unused.</p>
<p><a name="sqlitetraceclose"></a>
<dt>SQLITE_TRACE_CLOSE</dt>
<dd>An SQLITE_TRACE_CLOSE callback is invoked when a database
connection closes.
The P argument is a pointer to the <a href="../c3ref/sqlite3.html">database connection</a> object
and the X argument is unused.
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,167 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Virtual Table Configuration Options</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_VTAB_CONSTRAINT_SUPPORT SQLITE_VTAB_DIRECTONLY SQLITE_VTAB_INNOCUOUS {virtual table configuration option} {virtual table configuration options} -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Virtual Table Configuration Options</h2>
</div>
<blockquote><pre>
#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
#define SQLITE_VTAB_INNOCUOUS 2
#define SQLITE_VTAB_DIRECTONLY 3
</pre></blockquote>
<p>
These macros define the various options to the
<a href="../c3ref/vtab_config.html">sqlite3_vtab_config()</a> interface that <a href="../vtab.html">virtual table</a> implementations
can use to customize and optimize their behavior.</p>
<p><dl>
<a name="sqlitevtabconstraintsupport"></a>
<dt>SQLITE_VTAB_CONSTRAINT_SUPPORT</dt>
<dd>Calls of the form
<a href="../c3ref/vtab_config.html">sqlite3_vtab_config</a>(db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
where X is an integer. If X is zero, then the <a href="../vtab.html">virtual table</a> whose
<a href="../vtab.html#xcreate">xCreate</a> or <a href="../vtab.html#xconnect">xConnect</a> method invoked <a href="../c3ref/vtab_config.html">sqlite3_vtab_config()</a> does not
support constraints. In this configuration (which is the default) if
a call to the <a href="../vtab.html#xupdate">xUpdate</a> method returns <a href="../rescode.html#constraint">SQLITE_CONSTRAINT</a>, then the entire
statement is rolled back as if <a href="../lang_conflict.html">OR ABORT</a> had been
specified as part of the users SQL statement, regardless of the actual
ON CONFLICT mode specified.</p>
<p>If X is non-zero, then the virtual table implementation guarantees
that if <a href="../vtab.html#xupdate">xUpdate</a> returns <a href="../rescode.html#constraint">SQLITE_CONSTRAINT</a>, it will do so before
any modifications to internal or persistent data structures have been made.
If the <a href="../lang_conflict.html">ON CONFLICT</a> mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite
is able to roll back a statement or database transaction, and abandon
or continue processing the current SQL statement as appropriate.
If the ON CONFLICT mode is REPLACE and the <a href="../vtab.html#xupdate">xUpdate</a> method returns
<a href="../rescode.html#constraint">SQLITE_CONSTRAINT</a>, SQLite handles this as if the ON CONFLICT mode
had been ABORT.</p>
<p>Virtual table implementations that are required to handle OR REPLACE
must do so within the <a href="../vtab.html#xupdate">xUpdate</a> method. If a call to the
<a href="../c3ref/vtab_on_conflict.html">sqlite3_vtab_on_conflict()</a> function indicates that the current ON
CONFLICT policy is REPLACE, the virtual table implementation should
silently replace the appropriate rows within the xUpdate callback and
return SQLITE_OK. Or, if this is not possible, it may return
SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT
constraint handling.
</dd></p>
<p><a name="sqlitevtabdirectonly"></a>
<dt>SQLITE_VTAB_DIRECTONLY</dt>
<dd>Calls of the form
<a href="../c3ref/vtab_config.html">sqlite3_vtab_config</a>(db,SQLITE_VTAB_DIRECTONLY) from within the
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> implmentation
prohibits that virtual table from being used from within triggers and
views.
</dd></p>
<p><a name="sqlitevtabinnocuous"></a>
<dt>SQLITE_VTAB_INNOCUOUS</dt>
<dd>Calls of the form
<a href="../c3ref/vtab_config.html">sqlite3_vtab_config</a>(db,SQLITE_VTAB_INNOCUOUS) from within the
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> implmentation
identify that virtual table as being safe to use from within triggers
and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
virtual table can do no serious harm even if it is controlled by a
malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
flag unless absolutely necessary.
</dd>
</dl>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,109 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Win32 Directory Types</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: SQLITE_WIN32_DATA_DIRECTORY_TYPE SQLITE_WIN32_TEMP_DIRECTORY_TYPE -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Win32 Directory Types</h2>
</div>
<blockquote><pre>
#define SQLITE_WIN32_DATA_DIRECTORY_TYPE 1
#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2
</pre></blockquote>
<p>
These macros are only available on Windows. They define the allowed values
for the type argument to the <a href="../c3ref/win32_set_directory.html">sqlite3_win32_set_directory</a> interface.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,112 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Cancel Automatic Extension Loading</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_cancel_auto_extension -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Cancel Automatic Extension Loading</h2>
</div>
<blockquote><pre>
int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
</pre></blockquote>
<p>
The <a href="../c3ref/cancel_auto_extension.html">sqlite3_cancel_auto_extension(X)</a> interface unregisters the
initialization routine X that was registered using a prior call to
<a href="../c3ref/auto_extension.html">sqlite3_auto_extension(X)</a>. The <a href="../c3ref/cancel_auto_extension.html">sqlite3_cancel_auto_extension(X)</a>
routine returns 1 if initialization routine X was successfully
unregistered and it returns 0 if X was not on the list of initialization
routines.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,157 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Count The Number Of Rows Modified</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_changes -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Count The Number Of Rows Modified</h2>
</div>
<blockquote><pre>
int sqlite3_changes(sqlite3*);
</pre></blockquote>
<p>
This function returns the number of rows modified, inserted or
deleted by the most recently completed INSERT, UPDATE or DELETE
statement on the database connection specified by the only parameter.
Executing any other type of SQL statement does not modify the value
returned by this function.</p>
<p>Only changes made directly by the INSERT, UPDATE or DELETE statement are
considered - auxiliary changes caused by <a href="../lang_createtrigger.html">triggers</a>,
<a href="../foreignkeys.html#fk_actions">foreign key actions</a> or <a href="../lang_replace.html">REPLACE</a> constraint resolution are not counted.</p>
<p>Changes to a view that are intercepted by
<a href="../lang_createtrigger.html#instead_of_trigger">INSTEAD OF triggers</a> are not counted. The value
returned by sqlite3_changes() immediately after an INSERT, UPDATE or
DELETE statement run on a view is always zero. Only changes made to real
tables are counted.</p>
<p>Things are more complicated if the sqlite3_changes() function is
executed while a trigger program is running. This may happen if the
program uses the <a href="../lang_corefunc.html#changes">changes() SQL function</a>, or if some other callback
function invokes sqlite3_changes() directly. Essentially:</p>
<p><ul>
<li> Before entering a trigger program the value returned by
sqlite3_changes() function is saved. After the trigger program
has finished, the original value is restored.</p>
<p><li> Within a trigger program each INSERT, UPDATE and DELETE
statement sets the value returned by sqlite3_changes()
upon completion as normal. Of course, this value will not include
any changes performed by sub-triggers, as the sqlite3_changes()
value will be saved and restored after each sub-trigger has run.
</ul></p>
<p>This means that if the changes() SQL function (or similar) is used
by the first INSERT, UPDATE or DELETE statement within a trigger, it
returns the value as set when the calling statement began executing.
If it is used by the second or subsequent such statement within a trigger
program, the value returned reflects the number of rows modified by the
previous INSERT, UPDATE or DELETE statement within the same trigger.</p>
<p>If a separate thread makes changes on the same database connection
while <a href="../c3ref/changes.html">sqlite3_changes()</a> is running then the value returned
is unpredictable and not meaningful.</p>
<p>See also:
<ul>
<li> the <a href="../c3ref/total_changes.html">sqlite3_total_changes()</a> interface
<li> the <a href="../pragma.html#pragma_count_changes">count_changes pragma</a>
<li> the <a href="../lang_corefunc.html#changes">changes() SQL function</a>
<li> the <a href="../pragma.html#pragma_data_version">data_version pragma</a>
</ul>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,109 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Reset All Bindings On A Prepared Statement</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_clear_bindings -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Reset All Bindings On A Prepared Statement</h2>
</div>
<blockquote><pre>
int sqlite3_clear_bindings(sqlite3_stmt*);
</pre></blockquote>
<p>
Contrary to the intuition of many, <a href="../c3ref/reset.html">sqlite3_reset()</a> does not reset
the <a href="../c3ref/bind_blob.html">bindings</a> on a <a href="../c3ref/stmt.html">prepared statement</a>.
Use this routine to reset all host parameters to NULL.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,140 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Closing A Database Connection</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_close sqlite3_close_v2 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Closing A Database Connection</h2>
</div>
<blockquote><pre>
int sqlite3_close(sqlite3*);
int sqlite3_close_v2(sqlite3*);
</pre></blockquote>
<p>
The sqlite3_close() and sqlite3_close_v2() routines are destructors
for the <a href="../c3ref/sqlite3.html">sqlite3</a> object.
Calls to sqlite3_close() and sqlite3_close_v2() return <a href="../rescode.html#ok">SQLITE_OK</a> if
the <a href="../c3ref/sqlite3.html">sqlite3</a> object is successfully destroyed and all associated
resources are deallocated.</p>
<p>Ideally, applications should <a href="../c3ref/finalize.html">finalize</a> all
<a href="../c3ref/stmt.html">prepared statements</a>, <a href="../c3ref/blob_close.html">close</a> all <a href="../c3ref/blob.html">BLOB handles</a>, and
<a href="../c3ref/backup_finish.html#sqlite3backupfinish">finish</a> all <a href="../c3ref/backup.html">sqlite3_backup</a> objects associated
with the <a href="../c3ref/sqlite3.html">sqlite3</a> object prior to attempting to close the object.
If the database connection is associated with unfinalized prepared
statements, BLOB handlers, and/or unfinished sqlite3_backup objects then
sqlite3_close() will leave the database connection open and return
<a href="../rescode.html#busy">SQLITE_BUSY</a>. If sqlite3_close_v2() is called with unfinalized prepared
statements, unclosed BLOB handlers, and/or unfinished sqlite3_backups,
it returns <a href="../rescode.html#ok">SQLITE_OK</a> regardless, but instead of deallocating the database
connection immediately, it marks the database connection as an unusable
"zombie" and makes arrangements to automatically deallocate the database
connection after all prepared statements are finalized, all BLOB handles
are closed, and all backups have finished. The sqlite3_close_v2() interface
is intended for use with host languages that are garbage collected, and
where the order in which destructors are called is arbitrary.</p>
<p>If an <a href="../c3ref/sqlite3.html">sqlite3</a> object is destroyed while a transaction is open,
the transaction is automatically rolled back.</p>
<p>The C parameter to <a href="../c3ref/close.html">sqlite3_close(C)</a> and <a href="../c3ref/close.html">sqlite3_close_v2(C)</a>
must be either a NULL
pointer or an <a href="../c3ref/sqlite3.html">sqlite3</a> object pointer obtained
from <a href="../c3ref/open.html">sqlite3_open()</a>, <a href="../c3ref/open.html">sqlite3_open16()</a>, or
<a href="../c3ref/open.html">sqlite3_open_v2()</a>, and not previously closed.
Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
argument is a harmless no-op.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,137 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Collation Needed Callbacks</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_collation_needed sqlite3_collation_needed16 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Collation Needed Callbacks</h2>
</div>
<blockquote><pre>
int sqlite3_collation_needed(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const char*)
);
int sqlite3_collation_needed16(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const void*)
);
</pre></blockquote>
<p>
To avoid having to register all collation sequences before a database
can be used, a single callback function may be registered with the
<a href="../c3ref/sqlite3.html">database connection</a> to be invoked whenever an undefined collation
sequence is required.</p>
<p>If the function is registered using the sqlite3_collation_needed() API,
then it is passed the names of undefined collation sequences as strings
encoded in UTF-8. If sqlite3_collation_needed16() is used,
the names are passed as UTF-16 in machine native byte order.
A call to either function replaces the existing collation-needed callback.</p>
<p>When the callback is invoked, the first argument passed is a copy
of the second argument to sqlite3_collation_needed() or
sqlite3_collation_needed16(). The second argument is the database
connection. The third argument is one of <a href="../c3ref/c_any.html">SQLITE_UTF8</a>, <a href="../c3ref/c_any.html">SQLITE_UTF16BE</a>,
or <a href="../c3ref/c_any.html">SQLITE_UTF16LE</a>, indicating the most desirable form of the collation
sequence function required. The fourth parameter is the name of the
required collation sequence.</p>
<p>The callback function should register the desired collation using
<a href="../c3ref/create_collation.html">sqlite3_create_collation()</a>, <a href="../c3ref/create_collation.html">sqlite3_create_collation16()</a>, or
<a href="../c3ref/create_collation.html">sqlite3_create_collation_v2()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,318 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Result Values From A Query</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {column access functions} sqlite3_column_blob sqlite3_column_bytes sqlite3_column_bytes16 sqlite3_column_double sqlite3_column_int sqlite3_column_int64 sqlite3_column_text sqlite3_column_text16 sqlite3_column_type sqlite3_column_value -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Result Values From A Query</h2>
</div>
<blockquote><pre>
const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
double sqlite3_column_double(sqlite3_stmt*, int iCol);
int sqlite3_column_int(sqlite3_stmt*, int iCol);
sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
int sqlite3_column_type(sqlite3_stmt*, int iCol);
</pre></blockquote>
<p>
<b>Summary:</b>
<blockquote><table border=0 cellpadding=0 cellspacing=0>
<tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result
<tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result
<tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result
<tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result
<tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result
<tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result
<tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an
<a href="../c3ref/value.html">unprotected sqlite3_value</a> object.
<tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
<tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB
or a UTF-8 TEXT result in bytes
<tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>
<td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
TEXT in bytes
<tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default
datatype of the result
</table></blockquote></p>
<p><b>Details:</b></p>
<p>These routines return information about a single column of the current
result row of a query. In every case the first argument is a pointer
to the <a href="../c3ref/stmt.html">prepared statement</a> that is being evaluated (the <a href="../c3ref/stmt.html">sqlite3_stmt*</a>
that was returned from <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> or one of its variants)
and the second argument is the index of the column for which information
should be returned. The leftmost column of the result set has the index 0.
The number of columns in the result can be determined using
<a href="../c3ref/column_count.html">sqlite3_column_count()</a>.</p>
<p>If the SQL statement does not currently point to a valid row, or if the
column index is out of range, the result is undefined.
These routines may only be called when the most recent call to
<a href="../c3ref/step.html">sqlite3_step()</a> has returned <a href="../rescode.html#row">SQLITE_ROW</a> and neither
<a href="../c3ref/reset.html">sqlite3_reset()</a> nor <a href="../c3ref/finalize.html">sqlite3_finalize()</a> have been called subsequently.
If any of these routines are called after <a href="../c3ref/reset.html">sqlite3_reset()</a> or
<a href="../c3ref/finalize.html">sqlite3_finalize()</a> or after <a href="../c3ref/step.html">sqlite3_step()</a> has returned
something other than <a href="../rescode.html#row">SQLITE_ROW</a>, the results are undefined.
If <a href="../c3ref/step.html">sqlite3_step()</a> or <a href="../c3ref/reset.html">sqlite3_reset()</a> or <a href="../c3ref/finalize.html">sqlite3_finalize()</a>
are called from a different thread while any of these routines
are pending, then the results are undefined.</p>
<p>The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)
each return the value of a result column in a specific data format. If
the result column is not initially in the requested format (for example,
if the query returns an integer but the sqlite3_column_text() interface
is used to extract the value) then an automatic type conversion is performed.</p>
<p>The sqlite3_column_type() routine returns the
<a href="../c3ref/c_blob.html">datatype code</a> for the initial data type
of the result column. The returned value is one of <a href="../c3ref/c_blob.html">SQLITE_INTEGER</a>,
<a href="../c3ref/c_blob.html">SQLITE_FLOAT</a>, <a href="../c3ref/c_blob.html">SQLITE_TEXT</a>, <a href="../c3ref/c_blob.html">SQLITE_BLOB</a>, or <a href="../c3ref/c_blob.html">SQLITE_NULL</a>.
The return value of sqlite3_column_type() can be used to decide which
of the first six interface should be used to extract the column value.
The value returned by sqlite3_column_type() is only meaningful if no
automatic type conversions have occurred for the value in question.
After a type conversion, the result of calling sqlite3_column_type()
is undefined, though harmless. Future
versions of SQLite may change the behavior of sqlite3_column_type()
following a type conversion.</p>
<p>If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()
or sqlite3_column_bytes16() interfaces can be used to determine the size
of that BLOB or string.</p>
<p>If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
routine returns the number of bytes in that BLOB or string.
If the result is a UTF-16 string, then sqlite3_column_bytes() converts
the string to UTF-8 and then returns the number of bytes.
If the result is a numeric value then sqlite3_column_bytes() uses
<a href="../c3ref/mprintf.html">sqlite3_snprintf()</a> to convert that value to a UTF-8 string and returns
the number of bytes in that string.
If the result is NULL, then sqlite3_column_bytes() returns zero.</p>
<p>If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()
routine returns the number of bytes in that BLOB or string.
If the result is a UTF-8 string, then sqlite3_column_bytes16() converts
the string to UTF-16 and then returns the number of bytes.
If the result is a numeric value then sqlite3_column_bytes16() uses
<a href="../c3ref/mprintf.html">sqlite3_snprintf()</a> to convert that value to a UTF-16 string and returns
the number of bytes in that string.
If the result is NULL, then sqlite3_column_bytes16() returns zero.</p>
<p>The values returned by <a href="../c3ref/column_blob.html">sqlite3_column_bytes()</a> and
<a href="../c3ref/column_blob.html">sqlite3_column_bytes16()</a> do not include the zero terminators at the end
of the string. For clarity: the values returned by
<a href="../c3ref/column_blob.html">sqlite3_column_bytes()</a> and <a href="../c3ref/column_blob.html">sqlite3_column_bytes16()</a> are the number of
bytes in the string, not the number of characters.</p>
<p>Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
even empty strings, are always zero-terminated. The return
value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.</p>
<p><b>Warning:</b> The object returned by <a href="../c3ref/column_blob.html">sqlite3_column_value()</a> is an
<a href="../c3ref/value.html">unprotected sqlite3_value</a> object. In a multithreaded environment,
an unprotected sqlite3_value object may only be used safely with
<a href="../c3ref/bind_blob.html">sqlite3_bind_value()</a> and <a href="../c3ref/result_blob.html">sqlite3_result_value()</a>.
If the <a href="../c3ref/value.html">unprotected sqlite3_value</a> object returned by
<a href="../c3ref/column_blob.html">sqlite3_column_value()</a> is used in any other way, including calls
to routines like <a href="../c3ref/value_blob.html">sqlite3_value_int()</a>, <a href="../c3ref/value_blob.html">sqlite3_value_text()</a>,
or <a href="../c3ref/value_blob.html">sqlite3_value_bytes()</a>, the behavior is not threadsafe.
Hence, the sqlite3_column_value() interface
is normally only useful within the implementation of
<a href="../appfunc.html">application-defined SQL functions</a> or <a href="../vtab.html">virtual tables</a>, not within
top-level application code.</p>
<p>The these routines may attempt to convert the datatype of the result.
For example, if the internal representation is FLOAT and a text result
is requested, <a href="../c3ref/mprintf.html">sqlite3_snprintf()</a> is used internally to perform the
conversion automatically. The following table details the conversions
that are applied:</p>
<p><blockquote>
<table border="1">
<tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion</p>
<p><tr><td> NULL <td> INTEGER <td> Result is 0
<tr><td> NULL <td> FLOAT <td> Result is 0.0
<tr><td> NULL <td> TEXT <td> Result is a NULL pointer
<tr><td> NULL <td> BLOB <td> Result is a NULL pointer
<tr><td> INTEGER <td> FLOAT <td> Convert from integer to float
<tr><td> INTEGER <td> TEXT <td> ASCII rendering of the integer
<tr><td> INTEGER <td> BLOB <td> Same as INTEGER->TEXT
<tr><td> FLOAT <td> INTEGER <td> <a href="../lang_expr.html#castexpr">CAST</a> to INTEGER
<tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float
<tr><td> FLOAT <td> BLOB <td> <a href="../lang_expr.html#castexpr">CAST</a> to BLOB
<tr><td> TEXT <td> INTEGER <td> <a href="../lang_expr.html#castexpr">CAST</a> to INTEGER
<tr><td> TEXT <td> FLOAT <td> <a href="../lang_expr.html#castexpr">CAST</a> to REAL
<tr><td> TEXT <td> BLOB <td> No change
<tr><td> BLOB <td> INTEGER <td> <a href="../lang_expr.html#castexpr">CAST</a> to INTEGER
<tr><td> BLOB <td> FLOAT <td> <a href="../lang_expr.html#castexpr">CAST</a> to REAL
<tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
</table>
</blockquote></p>
<p>Note that when type conversions occur, pointers returned by prior
calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
sqlite3_column_text16() may be invalidated.
Type conversions and pointer invalidations might occur
in the following cases:</p>
<p><ul>
<li> The initial content is a BLOB and sqlite3_column_text() or
sqlite3_column_text16() is called. A zero-terminator might
need to be added to the string.</li>
<li> The initial content is UTF-8 text and sqlite3_column_bytes16() or
sqlite3_column_text16() is called. The content must be converted
to UTF-16.</li>
<li> The initial content is UTF-16 text and sqlite3_column_bytes() or
sqlite3_column_text() is called. The content must be converted
to UTF-8.</li>
</ul></p>
<p>Conversions between UTF-16be and UTF-16le are always done in place and do
not invalidate a prior pointer, though of course the content of the buffer
that the prior pointer references will have been modified. Other kinds
of conversion are done in place when it is possible, but sometimes they
are not possible and in those cases prior pointers are invalidated.</p>
<p>The safest policy is to invoke these routines
in one of the following ways:</p>
<p><ul>
<li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
<li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
<li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
</ul></p>
<p>In other words, you should call sqlite3_column_text(),
sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
into the desired format, then invoke sqlite3_column_bytes() or
sqlite3_column_bytes16() to find the size of the result. Do not mix calls
to sqlite3_column_text() or sqlite3_column_blob() with calls to
sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
with calls to sqlite3_column_bytes().</p>
<p>The pointers returned are valid until a type conversion occurs as
described above, or until <a href="../c3ref/step.html">sqlite3_step()</a> or <a href="../c3ref/reset.html">sqlite3_reset()</a> or
<a href="../c3ref/finalize.html">sqlite3_finalize()</a> is called. The memory space used to hold strings
and BLOBs is freed automatically. Do not pass the pointers returned
from <a href="../c3ref/column_blob.html">sqlite3_column_blob()</a>, <a href="../c3ref/column_blob.html">sqlite3_column_text()</a>, etc. into
<a href="../c3ref/free.html">sqlite3_free()</a>.</p>
<p>As long as the input parameters are correct, these routines will only
fail if an out-of-memory error occurs during a format conversion.
Only the following subset of interfaces are subject to out-of-memory
errors:</p>
<p><ul>
<li> sqlite3_column_blob()
<li> sqlite3_column_text()
<li> sqlite3_column_text16()
<li> sqlite3_column_bytes()
<li> sqlite3_column_bytes16()
</ul></p>
<p>If an out-of-memory error occurs, then the return value from these
routines is the same as if the column had contained an SQL NULL value.
Valid SQL NULL returns can be distinguished from out-of-memory errors
by invoking the <a href="../c3ref/errcode.html">sqlite3_errcode()</a> immediately after the suspect
return value is obtained and before any
other SQLite interface is called on the same <a href="../c3ref/sqlite3.html">database connection</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Number Of Columns In A Result Set</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_column_count -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Number Of Columns In A Result Set</h2>
</div>
<blockquote><pre>
int sqlite3_column_count(sqlite3_stmt *pStmt);
</pre></blockquote>
<p>
Return the number of columns in the result set returned by the
<a href="../c3ref/stmt.html">prepared statement</a>. If this routine returns 0, that means the
<a href="../c3ref/stmt.html">prepared statement</a> returns no data (for example an <a href="../lang_update.html">UPDATE</a>).
However, just because this routine returns a positive number does not
mean that one or more rows of data will be returned. A SELECT statement
will always have a positive sqlite3_column_count() but depending on the
WHERE clause constraints and the table content, it might return no rows.</p>
<p>See also: <a href="../c3ref/data_count.html">sqlite3_data_count()</a>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,148 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Source Of Data In A Query Result</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_column_database_name sqlite3_column_database_name16 sqlite3_column_origin_name sqlite3_column_origin_name16 sqlite3_column_table_name sqlite3_column_table_name16 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Source Of Data In A Query Result</h2>
</div>
<blockquote><pre>
const char *sqlite3_column_database_name(sqlite3_stmt*,int);
const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
const char *sqlite3_column_table_name(sqlite3_stmt*,int);
const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
</pre></blockquote>
<p>
These routines provide a means to determine the database, table, and
table column that is the origin of a particular result column in
<a href="../lang_select.html">SELECT</a> statement.
The name of the database or table or column can be returned as
either a UTF-8 or UTF-16 string. The _database_ routines return
the database name, the _table_ routines return the table name, and
the origin_ routines return the column name.
The returned string is valid until the <a href="../c3ref/stmt.html">prepared statement</a> is destroyed
using <a href="../c3ref/finalize.html">sqlite3_finalize()</a> or until the statement is automatically
reprepared by the first call to <a href="../c3ref/step.html">sqlite3_step()</a> for a particular run
or until the same information is requested
again in a different encoding.</p>
<p>The names returned are the original un-aliased names of the
database, table, and column.</p>
<p>The first argument to these interfaces is a <a href="../c3ref/stmt.html">prepared statement</a>.
These functions return information about the Nth result column returned by
the statement, where N is the second function argument.
The left-most column is column 0 for these routines.</p>
<p>If the Nth column returned by the statement is an expression or
subquery and is not a column value, then all of these functions return
NULL. These routines might also return NULL if a memory allocation error
occurs. Otherwise, they return the name of the attached database, table,
or column that query result column was extracted from.</p>
<p>As with all other SQLite APIs, those whose names end with "16" return
UTF-16 encoded strings and the other functions return UTF-8.</p>
<p>These APIs are only available if the library was compiled with the
<a href="../compile.html#enable_column_metadata">SQLITE_ENABLE_COLUMN_METADATA</a> C-preprocessor symbol.</p>
<p>If two or more threads call one or more
<a href="../c3ref/column_database_name.html">column metadata interfaces</a>
for the same <a href="../c3ref/stmt.html">prepared statement</a> and result column
at the same time then the results are undefined.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Declared Datatype Of A Query Result</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_column_decltype sqlite3_column_decltype16 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Declared Datatype Of A Query Result</h2>
</div>
<blockquote><pre>
const char *sqlite3_column_decltype(sqlite3_stmt*,int);
const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
</pre></blockquote>
<p>
The first parameter is a <a href="../c3ref/stmt.html">prepared statement</a>.
If this statement is a <a href="../lang_select.html">SELECT</a> statement and the Nth column of the
returned result set of that <a href="../lang_select.html">SELECT</a> is a table column (not an
expression or subquery) then the declared type of the table
column is returned. If the Nth column of the result set is an
expression or subquery, then a NULL pointer is returned.
The returned string is always UTF-8 encoded.</p>
<p>For example, given the database schema:</p>
<p>CREATE TABLE t1(c1 VARIANT);</p>
<p>and the following statement to be compiled:</p>
<p>SELECT c1 + 1, c1 FROM t1;</p>
<p>this routine would return the string "VARIANT" for the second result
column (i==1), and a NULL pointer for the first result column (i==0).</p>
<p>SQLite uses dynamic run-time typing. So just because a column
is declared to contain a particular type does not mean that the
data stored in that column is of the declared type. SQLite is
strongly typed, but the typing is dynamic not static. Type
is associated with individual values, not with the containers
used to hold those values.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,129 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Column Names In A Result Set</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_column_name sqlite3_column_name16 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Column Names In A Result Set</h2>
</div>
<blockquote><pre>
const char *sqlite3_column_name(sqlite3_stmt*, int N);
const void *sqlite3_column_name16(sqlite3_stmt*, int N);
</pre></blockquote>
<p>
These routines return the name assigned to a particular column
in the result set of a <a href="../lang_select.html">SELECT</a> statement. The sqlite3_column_name()
interface returns a pointer to a zero-terminated UTF-8 string
and sqlite3_column_name16() returns a pointer to a zero-terminated
UTF-16 string. The first parameter is the <a href="../c3ref/stmt.html">prepared statement</a>
that implements the <a href="../lang_select.html">SELECT</a> statement. The second parameter is the
column number. The leftmost column is number 0.</p>
<p>The returned string pointer is valid until either the <a href="../c3ref/stmt.html">prepared statement</a>
is destroyed by <a href="../c3ref/finalize.html">sqlite3_finalize()</a> or until the statement is automatically
reprepared by the first call to <a href="../c3ref/step.html">sqlite3_step()</a> for a particular run
or until the next call to
sqlite3_column_name() or sqlite3_column_name16() on the same column.</p>
<p>If sqlite3_malloc() fails during the processing of either routine
(for example during a conversion from UTF-8 to UTF-16) then a
NULL pointer is returned.</p>
<p>The name of a result column is the value of the "AS" clause for
that column, if there is an AS clause. If there is no AS clause
then the name of the column is unspecified and may change from
one release of SQLite to the next.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,149 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Commit And Rollback Notification Callbacks</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_commit_hook sqlite3_rollback_hook -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Commit And Rollback Notification Callbacks</h2>
</div>
<blockquote><pre>
void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
</pre></blockquote>
<p>
The sqlite3_commit_hook() interface registers a callback
function to be invoked whenever a transaction is <a href="../lang_transaction.html">committed</a>.
Any callback set by a previous call to sqlite3_commit_hook()
for the same database connection is overridden.
The sqlite3_rollback_hook() interface registers a callback
function to be invoked whenever a transaction is <a href="../lang_transaction.html">rolled back</a>.
Any callback set by a previous call to sqlite3_rollback_hook()
for the same database connection is overridden.
The pArg argument is passed through to the callback.
If the callback on a commit hook function returns non-zero,
then the commit is converted into a rollback.</p>
<p>The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
return the P argument from the previous call of the same function
on the same <a href="../c3ref/sqlite3.html">database connection</a> D, or NULL for
the first call for each function on D.</p>
<p>The commit and rollback hook callbacks are not reentrant.
The callback implementation must not do anything that will modify
the database connection that invoked the callback. Any actions
to modify the database connection must be deferred until after the
completion of the <a href="../c3ref/step.html">sqlite3_step()</a> call that triggered the commit
or rollback hook in the first place.
Note that running any other SQL statements, including SELECT statements,
or merely calling <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> and <a href="../c3ref/step.html">sqlite3_step()</a> will modify
the database connections for the meaning of "modify" in this paragraph.</p>
<p>Registering a NULL function disables the callback.</p>
<p>When the commit hook callback routine returns zero, the <a href="../lang_transaction.html">COMMIT</a>
operation is allowed to continue normally. If the commit hook
returns non-zero, then the <a href="../lang_transaction.html">COMMIT</a> is converted into a <a href="../lang_transaction.html">ROLLBACK</a>.
The rollback hook is invoked on a rollback that results from a commit
hook returning non-zero, just as it would be with any other rollback.</p>
<p>For the purposes of this API, a transaction is said to have been
rolled back if an explicit "ROLLBACK" statement is executed, or
an error or constraint causes an implicit rollback to occur.
The rollback callback is not invoked if a transaction is
automatically rolled back because the database connection is closed.</p>
<p>See also the <a href="../c3ref/update_hook.html">sqlite3_update_hook()</a> interface.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,130 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Run-Time Library Compilation Options Diagnostics</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_compileoption_get sqlite3_compileoption_used -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Run-Time Library Compilation Options Diagnostics</h2>
</div>
<blockquote><pre>
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
int sqlite3_compileoption_used(const char *zOptName);
const char *sqlite3_compileoption_get(int N);
#else
# define sqlite3_compileoption_used(X) 0
# define sqlite3_compileoption_get(X) ((void*)0)
#endif
</pre></blockquote>
<p>
The sqlite3_compileoption_used() function returns 0 or 1
indicating whether the specified option was defined at
compile time. The SQLITE_ prefix may be omitted from the
option name passed to sqlite3_compileoption_used().</p>
<p>The sqlite3_compileoption_get() function allows iterating
over the list of options that were defined at compile time by
returning the N-th compile time option string. If N is out of range,
sqlite3_compileoption_get() returns a NULL pointer. The SQLITE_
prefix is omitted from any strings returned by
sqlite3_compileoption_get().</p>
<p>Support for the diagnostic functions sqlite3_compileoption_used()
and sqlite3_compileoption_get() may be omitted by specifying the
<a href="../compile.html#omit_compileoption_diags">SQLITE_OMIT_COMPILEOPTION_DIAGS</a> option at compile time.</p>
<p>See also: SQL functions <a href="../lang_corefunc.html#sqlite_compileoption_used">sqlite_compileoption_used()</a> and
<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>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,136 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Determine If An SQL Statement Is Complete</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_complete sqlite3_complete16 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Determine If An SQL Statement Is Complete</h2>
</div>
<blockquote><pre>
int sqlite3_complete(const char *sql);
int sqlite3_complete16(const void *sql);
</pre></blockquote>
<p>
These routines are useful during command-line input to determine if the
currently entered text seems to form a complete SQL statement or
if additional input is needed before sending the text into
SQLite for parsing. These routines return 1 if the input string
appears to be a complete SQL statement. A statement is judged to be
complete if it ends with a semicolon token and is not a prefix of a
well-formed CREATE TRIGGER statement. Semicolons that are embedded within
string literals or quoted identifier names or comments are not
independent tokens (they are part of the token in which they are
embedded) and thus do not count as a statement terminator. Whitespace
and comments that follow the final semicolon are ignored.</p>
<p>These routines return 0 if the statement is incomplete. If a
memory allocation fails, then SQLITE_NOMEM is returned.</p>
<p>These routines do not parse the SQL statements thus
will not detect syntactically incorrect SQL.</p>
<p>If SQLite has not been initialized using <a href="../c3ref/initialize.html">sqlite3_initialize()</a> prior
to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
automatically by sqlite3_complete16(). If that initialization fails,
then the return value from sqlite3_complete16() will be non-zero
regardless of whether or not the input SQL is complete.</p>
<p>The input to <a href="../c3ref/complete.html">sqlite3_complete()</a> must be a zero-terminated
UTF-8 string.</p>
<p>The input to <a href="../c3ref/complete.html">sqlite3_complete16()</a> must be a zero-terminated
UTF-16 string in native byte order.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Configuring The SQLite Library</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_config -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Configuring The SQLite Library</h2>
</div>
<blockquote><pre>
int sqlite3_config(int, ...);
</pre></blockquote>
<p>
The sqlite3_config() interface is used to make global configuration
changes to SQLite in order to tune SQLite to the specific needs of
the application. The default configuration is recommended for most
applications and so this routine is usually not necessary. It is
provided to support rare applications with unusual needs.</p>
<p><b>The sqlite3_config() interface is not threadsafe. The application
must ensure that no other SQLite interfaces are invoked by other
threads while sqlite3_config() is running.</b></p>
<p>The sqlite3_config() interface
may only be invoked prior to library initialization using
<a href="../c3ref/initialize.html">sqlite3_initialize()</a> or after shutdown by <a href="../c3ref/initialize.html">sqlite3_shutdown()</a>.
If sqlite3_config() is called after <a href="../c3ref/initialize.html">sqlite3_initialize()</a> and before
<a href="../c3ref/initialize.html">sqlite3_shutdown()</a> then it will return SQLITE_MISUSE.
Note, however, that sqlite3_config() can be called as part of the
implementation of an application-defined <a href="../c3ref/initialize.html">sqlite3_os_init()</a>.</p>
<p>The first argument to sqlite3_config() is an integer
<a href="../c3ref/c_config_covering_index_scan.html">configuration option</a> that determines
what property of SQLite is to be configured. Subsequent arguments
vary depending on the <a href="../c3ref/c_config_covering_index_scan.html">configuration option</a>
in the first argument.</p>
<p>When a configuration option is set, sqlite3_config() returns <a href="../rescode.html#ok">SQLITE_OK</a>.
If the option is unknown or SQLite is unable to set the option
then this routine returns a non-zero <a href="../rescode.html">error code</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,537 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>List Of SQLite Constants</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>List Of Constants:</h2>
<p>Also available: <a href="../rescode.html">list of error codes</a></p>
<div class='columns' style='columns: 20em auto;'>
<ul style='padding-top:0;'>
<li><a href='../rescode.html#abort'>SQLITE_ABORT</a></li>
<li><a href='../rescode.html#abort_rollback'>SQLITE_ABORT_ROLLBACK</a></li>
<li><a href='../c3ref/c_access_exists.html'>SQLITE_ACCESS_EXISTS</a></li>
<li><a href='../c3ref/c_access_exists.html'>SQLITE_ACCESS_READ</a></li>
<li><a href='../c3ref/c_access_exists.html'>SQLITE_ACCESS_READWRITE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_ALTER_TABLE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_ANALYZE</a></li>
<li><a href='../c3ref/c_any.html'>SQLITE_ANY</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_ATTACH</a></li>
<li><a href='../rescode.html#auth'>SQLITE_AUTH</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_AUTH_USER</a></li>
<li><a href='../c3ref/c_blob.html'>SQLITE_BLOB</a></li>
<li><a href='../rescode.html#busy'>SQLITE_BUSY</a></li>
<li><a href='../rescode.html#busy_recovery'>SQLITE_BUSY_RECOVERY</a></li>
<li><a href='../rescode.html#busy_snapshot'>SQLITE_BUSY_SNAPSHOT</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_BUSY_TIMEOUT</a></li>
<li><a href='../rescode.html#cantopen'>SQLITE_CANTOPEN</a></li>
<li><a href='../rescode.html#cantopen_convpath'>SQLITE_CANTOPEN_CONVPATH</a></li>
<li><a href='../rescode.html#cantopen_dirtywal'>SQLITE_CANTOPEN_DIRTYWAL</a></li>
<li><a href='../rescode.html#cantopen_fullpath'>SQLITE_CANTOPEN_FULLPATH</a></li>
<li><a href='../rescode.html#cantopen_isdir'>SQLITE_CANTOPEN_ISDIR</a></li>
<li><a href='../rescode.html#cantopen_notempdir'>SQLITE_CANTOPEN_NOTEMPDIR</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_CANTOPEN_SYMLINK</a></li>
<li><a href='../c3ref/c_checkpoint_full.html'>SQLITE_CHECKPOINT_FULL</a></li>
<li><a href='../c3ref/c_checkpoint_full.html'>SQLITE_CHECKPOINT_PASSIVE</a></li>
<li><a href='../c3ref/c_checkpoint_full.html'>SQLITE_CHECKPOINT_RESTART</a></li>
<li><a href='../c3ref/c_checkpoint_full.html'>SQLITE_CHECKPOINT_TRUNCATE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigcoveringindexscan'>SQLITE_CONFIG_COVERING_INDEX_SCAN</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfiggetmalloc'>SQLITE_CONFIG_GETMALLOC</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfiggetmutex'>SQLITE_CONFIG_GETMUTEX</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfiggetpcache'>SQLITE_CONFIG_GETPCACHE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfiggetpcache2'>SQLITE_CONFIG_GETPCACHE2</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigheap'>SQLITE_CONFIG_HEAP</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfiglog'>SQLITE_CONFIG_LOG</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfiglookaside'>SQLITE_CONFIG_LOOKASIDE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigmalloc'>SQLITE_CONFIG_MALLOC</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigmemdbmaxsize'>SQLITE_CONFIG_MEMDB_MAXSIZE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigmemstatus'>SQLITE_CONFIG_MEMSTATUS</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigmmapsize'>SQLITE_CONFIG_MMAP_SIZE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigmultithread'>SQLITE_CONFIG_MULTITHREAD</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigmutex'>SQLITE_CONFIG_MUTEX</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigpagecache'>SQLITE_CONFIG_PAGECACHE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigpcache'>SQLITE_CONFIG_PCACHE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigpcache2'>SQLITE_CONFIG_PCACHE2</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigpcachehdrsz'>SQLITE_CONFIG_PCACHE_HDRSZ</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigpmasz'>SQLITE_CONFIG_PMASZ</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigscratch'>SQLITE_CONFIG_SCRATCH</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigserialized'>SQLITE_CONFIG_SERIALIZED</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigsinglethread'>SQLITE_CONFIG_SINGLETHREAD</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigsmallmalloc'>SQLITE_CONFIG_SMALL_MALLOC</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigsorterrefsize'>SQLITE_CONFIG_SORTERREF_SIZE</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigsqllog'>SQLITE_CONFIG_SQLLOG</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigstmtjrnlspill'>SQLITE_CONFIG_STMTJRNL_SPILL</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfiguri'>SQLITE_CONFIG_URI</a></li>
<li><a href='../c3ref/c_config_covering_index_scan.html#sqliteconfigwin32heapsize'>SQLITE_CONFIG_WIN32_HEAPSIZE</a></li>
<li><a href='../rescode.html#constraint'>SQLITE_CONSTRAINT</a></li>
<li><a href='../rescode.html#constraint_check'>SQLITE_CONSTRAINT_CHECK</a></li>
<li><a href='../rescode.html#constraint_commithook'>SQLITE_CONSTRAINT_COMMITHOOK</a></li>
<li><a href='../rescode.html#constraint_foreignkey'>SQLITE_CONSTRAINT_FOREIGNKEY</a></li>
<li><a href='../rescode.html#constraint_function'>SQLITE_CONSTRAINT_FUNCTION</a></li>
<li><a href='../rescode.html#constraint_notnull'>SQLITE_CONSTRAINT_NOTNULL</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_CONSTRAINT_PINNED</a></li>
<li><a href='../rescode.html#constraint_primarykey'>SQLITE_CONSTRAINT_PRIMARYKEY</a></li>
<li><a href='../rescode.html#constraint_rowid'>SQLITE_CONSTRAINT_ROWID</a></li>
<li><a href='../rescode.html#constraint_trigger'>SQLITE_CONSTRAINT_TRIGGER</a></li>
<li><a href='../rescode.html#constraint_unique'>SQLITE_CONSTRAINT_UNIQUE</a></li>
<li><a href='../rescode.html#constraint_vtab'>SQLITE_CONSTRAINT_VTAB</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_COPY</a></li>
<li><a href='../rescode.html#corrupt'>SQLITE_CORRUPT</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_CORRUPT_INDEX</a></li>
<li><a href='../rescode.html#corrupt_sequence'>SQLITE_CORRUPT_SEQUENCE</a></li>
<li><a href='../rescode.html#corrupt_vtab'>SQLITE_CORRUPT_VTAB</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_INDEX</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_TABLE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_TEMP_INDEX</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_TEMP_TABLE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_TEMP_TRIGGER</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_TEMP_VIEW</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_TRIGGER</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_VIEW</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_CREATE_VTABLE</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigdefensive'>SQLITE_DBCONFIG_DEFENSIVE</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigdqsddl'>SQLITE_DBCONFIG_DQS_DDL</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigdqsdml'>SQLITE_DBCONFIG_DQS_DML</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigenablefkey'>SQLITE_DBCONFIG_ENABLE_FKEY</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigenablefts3tokenizer'>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigenableloadextension'>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigenableqpsg'>SQLITE_DBCONFIG_ENABLE_QPSG</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigenabletrigger'>SQLITE_DBCONFIG_ENABLE_TRIGGER</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigenableview'>SQLITE_DBCONFIG_ENABLE_VIEW</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyaltertable'>SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfiglegacyfileformat'>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfiglookaside'>SQLITE_DBCONFIG_LOOKASIDE</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigmaindbname'>SQLITE_DBCONFIG_MAINDBNAME</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html'>SQLITE_DBCONFIG_MAX</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfignockptonclose'>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigresetdatabase'>SQLITE_DBCONFIG_RESET_DATABASE</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigtriggereqp'>SQLITE_DBCONFIG_TRIGGER_EQP</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigtrustedschema'>SQLITE_DBCONFIG_TRUSTED_SCHEMA</a></li>
<li><a href='../c3ref/c_dbconfig_defensive.html#sqlitedbconfigwritableschema'>SQLITE_DBCONFIG_WRITABLE_SCHEMA</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuscachehit'>SQLITE_DBSTATUS_CACHE_HIT</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuscachemiss'>SQLITE_DBSTATUS_CACHE_MISS</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuscachespill'>SQLITE_DBSTATUS_CACHE_SPILL</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuscacheused'>SQLITE_DBSTATUS_CACHE_USED</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuscacheusedshared'>SQLITE_DBSTATUS_CACHE_USED_SHARED</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuscachewrite'>SQLITE_DBSTATUS_CACHE_WRITE</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatusdeferredfks'>SQLITE_DBSTATUS_DEFERRED_FKS</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuslookasidehit'>SQLITE_DBSTATUS_LOOKASIDE_HIT</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuslookasidemissfull'>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuslookasidemisssize'>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatuslookasideused'>SQLITE_DBSTATUS_LOOKASIDE_USED</a></li>
<li><a href='../c3ref/c_dbstatus_options.html'>SQLITE_DBSTATUS_MAX</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatusschemaused'>SQLITE_DBSTATUS_SCHEMA_USED</a></li>
<li><a href='../c3ref/c_dbstatus_options.html#sqlitedbstatusstmtused'>SQLITE_DBSTATUS_STMT_USED</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DELETE</a></li>
<li><a href='../c3ref/c_deny.html'>SQLITE_DENY</a></li>
<li><a href='../c3ref/c_deserialize_freeonclose.html'>SQLITE_DESERIALIZE_FREEONCLOSE</a></li>
<li><a href='../c3ref/c_deserialize_freeonclose.html'>SQLITE_DESERIALIZE_READONLY</a></li>
<li><a href='../c3ref/c_deserialize_freeonclose.html'>SQLITE_DESERIALIZE_RESIZEABLE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DETACH</a></li>
<li><a href='../c3ref/c_deterministic.html#sqlitedeterministic'>SQLITE_DETERMINISTIC</a></li>
<li><a href='../c3ref/c_deterministic.html#sqlitedirectonly'>SQLITE_DIRECTONLY</a></li>
<li><a href='../rescode.html#done'>SQLITE_DONE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_INDEX</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_TABLE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_TEMP_INDEX</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_TEMP_TABLE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_TEMP_TRIGGER</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_TEMP_VIEW</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_TRIGGER</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_VIEW</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_DROP_VTABLE</a></li>
<li><a href='../rescode.html#empty'>SQLITE_EMPTY</a></li>
<li><a href='../rescode.html#error'>SQLITE_ERROR</a></li>
<li><a href='../rescode.html#error_missing_collseq'>SQLITE_ERROR_MISSING_COLLSEQ</a></li>
<li><a href='../rescode.html#error_retry'>SQLITE_ERROR_RETRY</a></li>
<li><a href='../rescode.html#error_snapshot'>SQLITE_ERROR_SNAPSHOT</a></li>
<li><a href='../c3ref/c_fail.html'>SQLITE_FAIL</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite'>SQLITE_FCNTL_BEGIN_ATOMIC_WRITE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbusyhandler'>SQLITE_FCNTL_BUSYHANDLER</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlchunksize'>SQLITE_FCNTL_CHUNK_SIZE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlckptdone'>SQLITE_FCNTL_CKPT_DONE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlckptstart'>SQLITE_FCNTL_CKPT_START</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitatomicwrite'>SQLITE_FCNTL_COMMIT_ATOMIC_WRITE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitphasetwo'>SQLITE_FCNTL_COMMIT_PHASETWO</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntldataversion'>SQLITE_FCNTL_DATA_VERSION</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlfilepointer'>SQLITE_FCNTL_FILE_POINTER</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html'>SQLITE_FCNTL_GET_LOCKPROXYFILE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlhasmoved'>SQLITE_FCNTL_HAS_MOVED</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntljournalpointer'>SQLITE_FCNTL_JOURNAL_POINTER</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html'>SQLITE_FCNTL_LAST_ERRNO</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntllockstate'>SQLITE_FCNTL_LOCKSTATE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntllocktimeout'>SQLITE_FCNTL_LOCK_TIMEOUT</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlmmapsize'>SQLITE_FCNTL_MMAP_SIZE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntloverwrite'>SQLITE_FCNTL_OVERWRITE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html'>SQLITE_FCNTL_PDB</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpersistwal'>SQLITE_FCNTL_PERSIST_WAL</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpowersafeoverwrite'>SQLITE_FCNTL_POWERSAFE_OVERWRITE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpragma'>SQLITE_FCNTL_PRAGMA</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlrbu'>SQLITE_FCNTL_RBU</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html'>SQLITE_FCNTL_RESERVE_BYTES</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlrollbackatomicwrite'>SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html'>SQLITE_FCNTL_SET_LOCKPROXYFILE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizehint'>SQLITE_FCNTL_SIZE_HINT</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizelimit'>SQLITE_FCNTL_SIZE_LIMIT</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsync'>SQLITE_FCNTL_SYNC</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsyncomitted'>SQLITE_FCNTL_SYNC_OMITTED</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntltempfilename'>SQLITE_FCNTL_TEMPFILENAME</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntltrace'>SQLITE_FCNTL_TRACE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlvfsname'>SQLITE_FCNTL_VFSNAME</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlvfspointer'>SQLITE_FCNTL_VFS_POINTER</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwalblock'>SQLITE_FCNTL_WAL_BLOCK</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwin32avretry'>SQLITE_FCNTL_WIN32_AV_RETRY</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwin32gethandle'>SQLITE_FCNTL_WIN32_GET_HANDLE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlwin32sethandle'>SQLITE_FCNTL_WIN32_SET_HANDLE</a></li>
<li><a href='../c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlzipvfs'>SQLITE_FCNTL_ZIPVFS</a></li>
<li><a href='../c3ref/c_blob.html'>SQLITE_FLOAT</a></li>
<li><a href='../rescode.html#format'>SQLITE_FORMAT</a></li>
<li><a href='../rescode.html#full'>SQLITE_FULL</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_FUNCTION</a></li>
<li><a href='../c3ref/c_deny.html'>SQLITE_IGNORE</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_EQ</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_FUNCTION</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_GE</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_GLOB</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_GT</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_IS</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_ISNOT</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_ISNOTNULL</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_ISNULL</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_LE</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_LIKE</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_LT</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_MATCH</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_NE</a></li>
<li><a href='../c3ref/c_index_constraint_eq.html'>SQLITE_INDEX_CONSTRAINT_REGEXP</a></li>
<li><a href='../c3ref/c_index_scan_unique.html'>SQLITE_INDEX_SCAN_UNIQUE</a></li>
<li><a href='../c3ref/c_deterministic.html#sqliteinnocuous'>SQLITE_INNOCUOUS</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_INSERT</a></li>
<li><a href='../c3ref/c_blob.html'>SQLITE_INTEGER</a></li>
<li><a href='../rescode.html#internal'>SQLITE_INTERNAL</a></li>
<li><a href='../rescode.html#interrupt'>SQLITE_INTERRUPT</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC16K</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC1K</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC2K</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC32K</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC4K</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC512</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC64K</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_ATOMIC8K</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_BATCH_ATOMIC</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_IMMUTABLE</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_POWERSAFE_OVERWRITE</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_SAFE_APPEND</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_SEQUENTIAL</a></li>
<li><a href='../c3ref/c_iocap_atomic.html'>SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN</a></li>
<li><a href='../rescode.html#ioerr'>SQLITE_IOERR</a></li>
<li><a href='../rescode.html#ioerr_access'>SQLITE_IOERR_ACCESS</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_IOERR_AUTH</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_IOERR_BEGIN_ATOMIC</a></li>
<li><a href='../rescode.html#ioerr_blocked'>SQLITE_IOERR_BLOCKED</a></li>
<li><a href='../rescode.html#ioerr_checkreservedlock'>SQLITE_IOERR_CHECKRESERVEDLOCK</a></li>
<li><a href='../rescode.html#ioerr_close'>SQLITE_IOERR_CLOSE</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_IOERR_COMMIT_ATOMIC</a></li>
<li><a href='../rescode.html#ioerr_convpath'>SQLITE_IOERR_CONVPATH</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_IOERR_DATA</a></li>
<li><a href='../rescode.html#ioerr_delete'>SQLITE_IOERR_DELETE</a></li>
<li><a href='../rescode.html#ioerr_delete_noent'>SQLITE_IOERR_DELETE_NOENT</a></li>
<li><a href='../rescode.html#ioerr_dir_close'>SQLITE_IOERR_DIR_CLOSE</a></li>
<li><a href='../rescode.html#ioerr_dir_fsync'>SQLITE_IOERR_DIR_FSYNC</a></li>
<li><a href='../rescode.html#ioerr_fstat'>SQLITE_IOERR_FSTAT</a></li>
<li><a href='../rescode.html#ioerr_fsync'>SQLITE_IOERR_FSYNC</a></li>
<li><a href='../rescode.html#ioerr_gettemppath'>SQLITE_IOERR_GETTEMPPATH</a></li>
<li><a href='../rescode.html#ioerr_lock'>SQLITE_IOERR_LOCK</a></li>
<li><a href='../rescode.html#ioerr_mmap'>SQLITE_IOERR_MMAP</a></li>
<li><a href='../rescode.html#ioerr_nomem'>SQLITE_IOERR_NOMEM</a></li>
<li><a href='../rescode.html#ioerr_rdlock'>SQLITE_IOERR_RDLOCK</a></li>
<li><a href='../rescode.html#ioerr_read'>SQLITE_IOERR_READ</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_IOERR_ROLLBACK_ATOMIC</a></li>
<li><a href='../rescode.html#ioerr_seek'>SQLITE_IOERR_SEEK</a></li>
<li><a href='../rescode.html#ioerr_shmlock'>SQLITE_IOERR_SHMLOCK</a></li>
<li><a href='../rescode.html#ioerr_shmmap'>SQLITE_IOERR_SHMMAP</a></li>
<li><a href='../rescode.html#ioerr_shmopen'>SQLITE_IOERR_SHMOPEN</a></li>
<li><a href='../rescode.html#ioerr_shmsize'>SQLITE_IOERR_SHMSIZE</a></li>
<li><a href='../rescode.html#ioerr_short_read'>SQLITE_IOERR_SHORT_READ</a></li>
<li><a href='../rescode.html#ioerr_truncate'>SQLITE_IOERR_TRUNCATE</a></li>
<li><a href='../rescode.html#ioerr_unlock'>SQLITE_IOERR_UNLOCK</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_IOERR_VNODE</a></li>
<li><a href='../rescode.html#ioerr_write'>SQLITE_IOERR_WRITE</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitattached'>SQLITE_LIMIT_ATTACHED</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitcolumn'>SQLITE_LIMIT_COLUMN</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitcompoundselect'>SQLITE_LIMIT_COMPOUND_SELECT</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitexprdepth'>SQLITE_LIMIT_EXPR_DEPTH</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitfunctionarg'>SQLITE_LIMIT_FUNCTION_ARG</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitlength'>SQLITE_LIMIT_LENGTH</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitlikepatternlength'>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitsqllength'>SQLITE_LIMIT_SQL_LENGTH</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimittriggerdepth'>SQLITE_LIMIT_TRIGGER_DEPTH</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitvariablenumber'>SQLITE_LIMIT_VARIABLE_NUMBER</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitvdbeop'>SQLITE_LIMIT_VDBE_OP</a></li>
<li><a href='../c3ref/c_limit_attached.html#sqlitelimitworkerthreads'>SQLITE_LIMIT_WORKER_THREADS</a></li>
<li><a href='../rescode.html#locked'>SQLITE_LOCKED</a></li>
<li><a href='../rescode.html#locked_sharedcache'>SQLITE_LOCKED_SHAREDCACHE</a></li>
<li><a href='../rescode.html#locked_vtab'>SQLITE_LOCKED_VTAB</a></li>
<li><a href='../c3ref/c_lock_exclusive.html'>SQLITE_LOCK_EXCLUSIVE</a></li>
<li><a href='../c3ref/c_lock_exclusive.html'>SQLITE_LOCK_NONE</a></li>
<li><a href='../c3ref/c_lock_exclusive.html'>SQLITE_LOCK_PENDING</a></li>
<li><a href='../c3ref/c_lock_exclusive.html'>SQLITE_LOCK_RESERVED</a></li>
<li><a href='../c3ref/c_lock_exclusive.html'>SQLITE_LOCK_SHARED</a></li>
<li><a href='../rescode.html#mismatch'>SQLITE_MISMATCH</a></li>
<li><a href='../rescode.html#misuse'>SQLITE_MISUSE</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_FAST</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_RECURSIVE</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_APP1</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_APP2</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_APP3</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_LRU</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_LRU2</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_MAIN</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_MEM</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_MEM2</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_OPEN</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_PMEM</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_PRNG</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_VFS1</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_VFS2</a></li>
<li><a href='../c3ref/c_mutex_fast.html'>SQLITE_MUTEX_STATIC_VFS3</a></li>
<li><a href='../rescode.html#nolfs'>SQLITE_NOLFS</a></li>
<li><a href='../rescode.html#nomem'>SQLITE_NOMEM</a></li>
<li><a href='../rescode.html#notadb'>SQLITE_NOTADB</a></li>
<li><a href='../rescode.html#notfound'>SQLITE_NOTFOUND</a></li>
<li><a href='../rescode.html#notice'>SQLITE_NOTICE</a></li>
<li><a href='../rescode.html#notice_recover_rollback'>SQLITE_NOTICE_RECOVER_ROLLBACK</a></li>
<li><a href='../rescode.html#notice_recover_wal'>SQLITE_NOTICE_RECOVER_WAL</a></li>
<li><a href='../c3ref/c_blob.html'>SQLITE_NULL</a></li>
<li><a href='../rescode.html#ok'>SQLITE_OK</a></li>
<li><a href='../rescode.html#ok_load_permanently'>SQLITE_OK_LOAD_PERMANENTLY</a></li>
<li><a href='../c3ref/c_abort_rollback.html'>SQLITE_OK_SYMLINK</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_AUTOPROXY</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_CREATE</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_DELETEONCLOSE</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_EXCLUSIVE</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_FULLMUTEX</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_MAIN_DB</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_MAIN_JOURNAL</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_MEMORY</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_NOFOLLOW</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_NOMUTEX</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_PRIVATECACHE</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_READONLY</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_READWRITE</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_SHAREDCACHE</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_SUBJOURNAL</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_SUPER_JOURNAL</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_TEMP_DB</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_TEMP_JOURNAL</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_TRANSIENT_DB</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_URI</a></li>
<li><a href='../c3ref/c_open_autoproxy.html'>SQLITE_OPEN_WAL</a></li>
<li><a href='../rescode.html#perm'>SQLITE_PERM</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_PRAGMA</a></li>
<li><a href='../c3ref/c_prepare_normalize.html#sqlitepreparenormalize'>SQLITE_PREPARE_NORMALIZE</a></li>
<li><a href='../c3ref/c_prepare_normalize.html#sqlitepreparenovtab'>SQLITE_PREPARE_NO_VTAB</a></li>
<li><a href='../c3ref/c_prepare_normalize.html#sqlitepreparepersistent'>SQLITE_PREPARE_PERSISTENT</a></li>
<li><a href='../rescode.html#protocol'>SQLITE_PROTOCOL</a></li>
<li><a href='../rescode.html#range'>SQLITE_RANGE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_READ</a></li>
<li><a href='../rescode.html#readonly'>SQLITE_READONLY</a></li>
<li><a href='../rescode.html#readonly_cantinit'>SQLITE_READONLY_CANTINIT</a></li>
<li><a href='../rescode.html#readonly_cantlock'>SQLITE_READONLY_CANTLOCK</a></li>
<li><a href='../rescode.html#readonly_dbmoved'>SQLITE_READONLY_DBMOVED</a></li>
<li><a href='../rescode.html#readonly_directory'>SQLITE_READONLY_DIRECTORY</a></li>
<li><a href='../rescode.html#readonly_recovery'>SQLITE_READONLY_RECOVERY</a></li>
<li><a href='../rescode.html#readonly_rollback'>SQLITE_READONLY_ROLLBACK</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_RECURSIVE</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_REINDEX</a></li>
<li><a href='../c3ref/c_fail.html'>SQLITE_REPLACE</a></li>
<li><a href='../c3ref/c_fail.html'>SQLITE_ROLLBACK</a></li>
<li><a href='../rescode.html#row'>SQLITE_ROW</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_SAVEPOINT</a></li>
<li><a href='../c3ref/c_scanstat_est.html#sqlitescanstatest'>SQLITE_SCANSTAT_EST</a></li>
<li><a href='../c3ref/c_scanstat_est.html#sqlitescanstatexplain'>SQLITE_SCANSTAT_EXPLAIN</a></li>
<li><a href='../c3ref/c_scanstat_est.html#sqlitescanstatname'>SQLITE_SCANSTAT_NAME</a></li>
<li><a href='../c3ref/c_scanstat_est.html#sqlitescanstatnloop'>SQLITE_SCANSTAT_NLOOP</a></li>
<li><a href='../c3ref/c_scanstat_est.html#sqlitescanstatnvisit'>SQLITE_SCANSTAT_NVISIT</a></li>
<li><a href='../c3ref/c_scanstat_est.html#sqlitescanstatselectid'>SQLITE_SCANSTAT_SELECTID</a></li>
<li><a href='../rescode.html#schema'>SQLITE_SCHEMA</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_SELECT</a></li>
<li><a href='../c3ref/c_serialize_nocopy.html'>SQLITE_SERIALIZE_NOCOPY</a></li>
<li><a href='../c3ref/c_shm_exclusive.html'>SQLITE_SHM_EXCLUSIVE</a></li>
<li><a href='../c3ref/c_shm_exclusive.html'>SQLITE_SHM_LOCK</a></li>
<li><a href='../c3ref/c_shm_nlock.html'>SQLITE_SHM_NLOCK</a></li>
<li><a href='../c3ref/c_shm_exclusive.html'>SQLITE_SHM_SHARED</a></li>
<li><a href='../c3ref/c_shm_exclusive.html'>SQLITE_SHM_UNLOCK</a></li>
<li><a href='../c3ref/c_source_id.html'>SQLITE_SOURCE_ID</a></li>
<li><a href='../c3ref/c_static.html'>SQLITE_STATIC</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatusmalloccount'>SQLITE_STATUS_MALLOC_COUNT</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatusmallocsize'>SQLITE_STATUS_MALLOC_SIZE</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatusmemoryused'>SQLITE_STATUS_MEMORY_USED</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatuspagecacheoverflow'>SQLITE_STATUS_PAGECACHE_OVERFLOW</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatuspagecachesize'>SQLITE_STATUS_PAGECACHE_SIZE</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatuspagecacheused'>SQLITE_STATUS_PAGECACHE_USED</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatusparserstack'>SQLITE_STATUS_PARSER_STACK</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatusscratchoverflow'>SQLITE_STATUS_SCRATCH_OVERFLOW</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatusscratchsize'>SQLITE_STATUS_SCRATCH_SIZE</a></li>
<li><a href='../c3ref/c_status_malloc_count.html#sqlitestatusscratchused'>SQLITE_STATUS_SCRATCH_USED</a></li>
<li><a href='../c3ref/c_stmtstatus_counter.html#sqlitestmtstatusautoindex'>SQLITE_STMTSTATUS_AUTOINDEX</a></li>
<li><a href='../c3ref/c_stmtstatus_counter.html#sqlitestmtstatusfullscanstep'>SQLITE_STMTSTATUS_FULLSCAN_STEP</a></li>
<li><a href='../c3ref/c_stmtstatus_counter.html#sqlitestmtstatusmemused'>SQLITE_STMTSTATUS_MEMUSED</a></li>
<li><a href='../c3ref/c_stmtstatus_counter.html#sqlitestmtstatusreprepare'>SQLITE_STMTSTATUS_REPREPARE</a></li>
<li><a href='../c3ref/c_stmtstatus_counter.html#sqlitestmtstatusrun'>SQLITE_STMTSTATUS_RUN</a></li>
<li><a href='../c3ref/c_stmtstatus_counter.html#sqlitestmtstatussort'>SQLITE_STMTSTATUS_SORT</a></li>
<li><a href='../c3ref/c_stmtstatus_counter.html#sqlitestmtstatusvmstep'>SQLITE_STMTSTATUS_VM_STEP</a></li>
<li><a href='../c3ref/c_deterministic.html#sqlitesubtype'>SQLITE_SUBTYPE</a></li>
<li><a href='../c3ref/c_sync_dataonly.html'>SQLITE_SYNC_DATAONLY</a></li>
<li><a href='../c3ref/c_sync_dataonly.html'>SQLITE_SYNC_FULL</a></li>
<li><a href='../c3ref/c_sync_dataonly.html'>SQLITE_SYNC_NORMAL</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_ALWAYS</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_ASSERT</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_BITVEC_TEST</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_BYTEORDER</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_EXPLAIN_STMT</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_FAULT_INSTALL</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_FIRST</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_IMPOSTER</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_INTERNAL_FUNCTIONS</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_ISINIT</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_ISKEYWORD</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_LAST</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_LOCALTIME_FAULT</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_NEVER_CORRUPT</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_OPTIMIZATIONS</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_PARSER_COVERAGE</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_PENDING_BYTE</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_PRNG_RESET</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_PRNG_RESTORE</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_PRNG_SAVE</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_PRNG_SEED</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_RESERVE</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_RESULT_INTREAL</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_SCRATCHMALLOC</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_SORTER_MMAP</a></li>
<li><a href='../c3ref/c_testctrl_always.html'>SQLITE_TESTCTRL_VDBE_COVERAGE</a></li>
<li><a href='../c3ref/c_blob.html'>SQLITE_TEXT</a></li>
<li><a href='../rescode.html#toobig'>SQLITE_TOOBIG</a></li>
<li><a href='../c3ref/c_trace.html'>SQLITE_TRACE</a></li>
<li><a href='../c3ref/c_trace.html#sqlitetraceclose'>SQLITE_TRACE_CLOSE</a></li>
<li><a href='../c3ref/c_trace.html#sqlitetraceprofile'>SQLITE_TRACE_PROFILE</a></li>
<li><a href='../c3ref/c_trace.html#sqlitetracerow'>SQLITE_TRACE_ROW</a></li>
<li><a href='../c3ref/c_trace.html#sqlitetracestmt'>SQLITE_TRACE_STMT</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_TRANSACTION</a></li>
<li><a href='../c3ref/c_static.html'>SQLITE_TRANSIENT</a></li>
<li><a href='../c3ref/c_alter_table.html'>SQLITE_UPDATE</a></li>
<li><a href='../c3ref/c_any.html'>SQLITE_UTF16</a></li>
<li><a href='../c3ref/c_any.html'>SQLITE_UTF16BE</a></li>
<li><a href='../c3ref/c_any.html'>SQLITE_UTF16LE</a></li>
<li><a href='../c3ref/c_any.html'>SQLITE_UTF16_ALIGNED</a></li>
<li><a href='../c3ref/c_any.html'>SQLITE_UTF8</a></li>
<li><a href='../c3ref/c_source_id.html'>SQLITE_VERSION</a></li>
<li><a href='../c3ref/c_source_id.html'>SQLITE_VERSION_NUMBER</a></li>
<li><a href='../c3ref/c_vtab_constraint_support.html#sqlitevtabconstraintsupport'>SQLITE_VTAB_CONSTRAINT_SUPPORT</a></li>
<li><a href='../c3ref/c_vtab_constraint_support.html#sqlitevtabdirectonly'>SQLITE_VTAB_DIRECTONLY</a></li>
<li><a href='../c3ref/c_vtab_constraint_support.html#sqlitevtabinnocuous'>SQLITE_VTAB_INNOCUOUS</a></li>
<li><a href='../rescode.html#warning'>SQLITE_WARNING</a></li>
<li><a href='../rescode.html#warning_autoindex'>SQLITE_WARNING_AUTOINDEX</a></li>
<li><a href='../c3ref/c_win32_data_directory_type.html'>SQLITE_WIN32_DATA_DIRECTORY_TYPE</a></li>
<li><a href='../c3ref/c_win32_data_directory_type.html'>SQLITE_WIN32_TEMP_DIRECTORY_TYPE</a></li>
</ul>
</div>
<p>Other lists:
<a href="objlist.html">Objects</a> and
<a href="funclist.html">Functions</a> and
<a href="../rescode.html">Result Codes</a>.</p>

View File

@ -0,0 +1,145 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>SQL Function Context Object</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_context -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>SQL Function Context Object</h2>
</div>
<blockquote><pre>
typedef struct sqlite3_context sqlite3_context;
</pre></blockquote>
<p>
The context in which an SQL function executes is stored in an
sqlite3_context object. A pointer to an sqlite3_context object
is always first parameter to <a href="../appfunc.html">application-defined SQL functions</a>.
The application-defined SQL function implementation will pass this
pointer through into calls to <a href="../c3ref/result_blob.html">sqlite3_result()</a>,
<a href="../c3ref/aggregate_context.html">sqlite3_aggregate_context()</a>, <a href="../c3ref/user_data.html">sqlite3_user_data()</a>,
<a href="../c3ref/context_db_handle.html">sqlite3_context_db_handle()</a>, <a href="../c3ref/get_auxdata.html">sqlite3_get_auxdata()</a>,
and/or <a href="../c3ref/get_auxdata.html">sqlite3_set_auxdata()</a>.
</p><div class='columns' style='columns: 17em auto;'>
<ul style='padding-top:0;'>
<li><a href='../c3ref/aggregate_context.html'>sqlite3_aggregate_context</a></li>
<li><a href='../c3ref/context_db_handle.html'>sqlite3_context_db_handle</a></li>
<li><a href='../c3ref/get_auxdata.html'>sqlite3_get_auxdata</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_blob</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_blob64</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_double</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_error</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_error16</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_error_code</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_error_nomem</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_error_toobig</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_int</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_int64</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_null</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_pointer</a></li>
<li><a href='../c3ref/result_subtype.html'>sqlite3_result_subtype</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_text</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_text16</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_text16be</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_text16le</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_text64</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_value</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_zeroblob</a></li>
<li><a href='../c3ref/result_blob.html'>sqlite3_result_zeroblob64</a></li>
<li><a href='../c3ref/get_auxdata.html'>sqlite3_set_auxdata</a></li>
<li><a href='../c3ref/user_data.html'>sqlite3_user_data</a></li>
</ul>
</div>
</p>
<p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Database Connection For Functions</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_context_db_handle -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Database Connection For Functions</h2>
</div>
<blockquote><pre>
sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
</pre></blockquote>
<p>
The sqlite3_context_db_handle() interface returns a copy of
the pointer to the <a href="../c3ref/sqlite3.html">database connection</a> (the 1st parameter)
of the <a href="../c3ref/create_function.html">sqlite3_create_function()</a>
and <a href="../c3ref/create_function.html">sqlite3_create_function16()</a> routines that originally
registered the application defined function.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,203 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Define New Collating Sequences</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_create_collation sqlite3_create_collation16 sqlite3_create_collation_v2 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Define New Collating Sequences</h2>
</div>
<blockquote><pre>
int sqlite3_create_collation(
sqlite3*,
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);
int sqlite3_create_collation_v2(
sqlite3*,
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*),
void(*xDestroy)(void*)
);
int sqlite3_create_collation16(
sqlite3*,
const void *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);
</pre></blockquote>
<p>
These functions add, remove, or modify a <a href="../datatype3.html#collation">collation</a> associated
with the <a href="../c3ref/sqlite3.html">database connection</a> specified as the first argument.</p>
<p>The name of the collation is a UTF-8 string
for sqlite3_create_collation() and sqlite3_create_collation_v2()
and a UTF-16 string in native byte order for sqlite3_create_collation16().
Collation names that compare equal according to <a href="../c3ref/stricmp.html">sqlite3_strnicmp()</a> are
considered to be the same name.</p>
<p>The third argument (eTextRep) must be one of the constants:
<ul>
<li> <a href="../c3ref/c_any.html">SQLITE_UTF8</a>,
<li> <a href="../c3ref/c_any.html">SQLITE_UTF16LE</a>,
<li> <a href="../c3ref/c_any.html">SQLITE_UTF16BE</a>,
<li> <a href="../c3ref/c_any.html">SQLITE_UTF16</a>, or
<li> <a href="../c3ref/c_any.html">SQLITE_UTF16_ALIGNED</a>.
</ul>
The eTextRep argument determines the encoding of strings passed
to the collating function callback, xCompare.
The <a href="../c3ref/c_any.html">SQLITE_UTF16</a> and <a href="../c3ref/c_any.html">SQLITE_UTF16_ALIGNED</a> values for eTextRep
force strings to be UTF16 with native byte order.
The <a href="../c3ref/c_any.html">SQLITE_UTF16_ALIGNED</a> value for eTextRep forces strings to begin
on an even byte address.</p>
<p>The fourth argument, pArg, is an application data pointer that is passed
through as the first argument to the collating function callback.</p>
<p>The fifth argument, xCompare, is a pointer to the collating function.
Multiple collating functions can be registered using the same name but
with different eTextRep parameters and SQLite will use whichever
function requires the least amount of data transformation.
If the xCompare argument is NULL then the collating function is
deleted. When all collating functions having the same name are deleted,
that collation is no longer usable.</p>
<p>The collating function callback is invoked with a copy of the pArg
application data pointer and with two strings in the encoding specified
by the eTextRep argument. The two integer parameters to the collating
function callback are the length of the two strings, in bytes. The collating
function must return an integer that is negative, zero, or positive
if the first string is less than, equal to, or greater than the second,
respectively. A collating function must always return the same answer
given the same inputs. If two or more collating functions are registered
to the same collation name (using different eTextRep values) then all
must give an equivalent answer when invoked with equivalent strings.
The collating function must obey the following properties for all
strings A, B, and C:</p>
<p><ol>
<li> If A==B then B==A.
<li> If A==B and B==C then A==C.
<li> If A&lt;B THEN B&gt;A.
<li> If A&lt;B and B&lt;C then A&lt;C.
</ol></p>
<p>If a collating function fails any of the above constraints and that
collating function is registered and used, then the behavior of SQLite
is undefined.</p>
<p>The sqlite3_create_collation_v2() works like sqlite3_create_collation()
with the addition that the xDestroy callback is invoked on pArg when
the collating function is deleted.
Collating functions are deleted when they are overridden by later
calls to the collation creation functions or when the
<a href="../c3ref/sqlite3.html">database connection</a> is closed using <a href="../c3ref/close.html">sqlite3_close()</a>.</p>
<p>The xDestroy callback is <u>not</u> called if the
sqlite3_create_collation_v2() function fails. Applications that invoke
sqlite3_create_collation_v2() with a non-NULL xDestroy argument should
check the return code and dispose of the application data pointer
themselves rather than expecting SQLite to deal with it for them.
This is different from every other SQLite interface. The inconsistency
is unfortunate but cannot be changed without breaking backwards
compatibility.</p>
<p>See also: <a href="../c3ref/collation_needed.html">sqlite3_collation_needed()</a> and <a href="../c3ref/collation_needed.html">sqlite3_collation_needed16()</a>.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,154 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Create and Destroy VFS Filenames</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_create_filename sqlite3_free_filename -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Create and Destroy VFS Filenames</h2>
</div>
<blockquote><pre>
char *sqlite3_create_filename(
const char *zDatabase,
const char *zJournal,
const char *zWal,
int nParam,
const char **azParam
);
void sqlite3_free_filename(char*);
</pre></blockquote>
<p>
These interfces are provided for use by <a href="../vfs.html#shim">VFS shim</a> implementations and
are not useful outside of that context.</p>
<p>The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of
database filename D with corresponding journal file J and WAL file W and
with N URI parameters key/values pairs in the array P. The result from
sqlite3_create_filename(D,J,W,N,P) is a pointer to a database filename that
is safe to pass to routines like:
<ul>
<li> <a href="../c3ref/uri_boolean.html">sqlite3_uri_parameter()</a>,
<li> <a href="../c3ref/uri_boolean.html">sqlite3_uri_boolean()</a>,
<li> <a href="../c3ref/uri_boolean.html">sqlite3_uri_int64()</a>,
<li> <a href="../c3ref/uri_boolean.html">sqlite3_uri_key()</a>,
<li> <a href="../c3ref/filename_database.html">sqlite3_filename_database()</a>,
<li> <a href="../c3ref/filename_database.html">sqlite3_filename_journal()</a>, or
<li> <a href="../c3ref/filename_database.html">sqlite3_filename_wal()</a>.
</ul>
If a memory allocation error occurs, sqlite3_create_filename() might
return a NULL pointer. The memory obtained from sqlite3_create_filename(X)
must be released by a corresponding call to sqlite3_free_filename(Y).</p>
<p>The P parameter in sqlite3_create_filename(D,J,W,N,P) should be an array
of 2*N pointers to strings. Each pair of pointers in this array corresponds
to a key and value for a query parameter. The P parameter may be a NULL
pointer if N is zero. None of the 2*N pointers in the P array may be
NULL pointers and key pointers should not be empty strings.
None of the D, J, or W parameters to sqlite3_create_filename(D,J,W,N,P) may
be NULL pointers, though they can be empty strings.</p>
<p>The sqlite3_free_filename(Y) routine releases a memory allocation
previously obtained from sqlite3_create_filename(). Invoking
sqlite3_free_filename(Y) where Y is a NULL pointer is a harmless no-op.</p>
<p>If the Y parameter to sqlite3_free_filename(Y) is anything other
than a NULL pointer or a pointer previously acquired from
sqlite3_create_filename(), then bad things such as heap
corruption or segfaults may occur. The value Y should be
used again after sqlite3_free_filename(Y) has been called. This means
that if the <a href="../c3ref/vfs.html#sqlite3vfsxopen">sqlite3_vfs.xOpen()</a> method of a VFS has been called using Y,
then the corresponding [sqlite3_module.xClose() method should also be
invoked prior to calling sqlite3_free_filename(Y).
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,267 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Create Or Redefine SQL Functions</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: {function creation routines} sqlite3_create_function sqlite3_create_function16 sqlite3_create_function_v2 sqlite3_create_window_function -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Create Or Redefine SQL Functions</h2>
</div>
<blockquote><pre>
int sqlite3_create_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
int sqlite3_create_function16(
sqlite3 *db,
const void *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
int sqlite3_create_function_v2(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void(*xDestroy)(void*)
);
int sqlite3_create_window_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void (*xValue)(sqlite3_context*),
void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
void(*xDestroy)(void*)
);
</pre></blockquote>
<p>
These functions (collectively known as "function creation routines")
are used to add SQL functions or aggregates or to redefine the behavior
of existing SQL functions or aggregates. The only differences between
the three "sqlite3_create_function*" routines are the text encoding
expected for the second parameter (the name of the function being
created) and the presence or absence of a destructor callback for
the application data pointer. Function sqlite3_create_window_function()
is similar, but allows the user to supply the extra callback functions
needed by <a href="../windowfunctions.html#aggwinfunc">aggregate window functions</a>.</p>
<p>The first parameter is the <a href="../c3ref/sqlite3.html">database connection</a> to which the SQL
function is to be added. If an application uses more than one database
connection then application-defined SQL functions must be added
to each database connection separately.</p>
<p>The second parameter is the name of the SQL function to be created or
redefined. The length of the name is limited to 255 bytes in a UTF-8
representation, exclusive of the zero-terminator. Note that the name
length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.
Any attempt to create a function with a longer name
will result in <a href="../rescode.html#misuse">SQLITE_MISUSE</a> being returned.</p>
<p>The third parameter (nArg)
is the number of arguments that the SQL function or
aggregate takes. If this parameter is -1, then the SQL function or
aggregate may take any number of arguments between 0 and the limit
set by <a href="../c3ref/limit.html">sqlite3_limit</a>(<a href="../c3ref/c_limit_attached.html#sqlitelimitfunctionarg">SQLITE_LIMIT_FUNCTION_ARG</a>). If the third
parameter is less than -1 or greater than 127 then the behavior is
undefined.</p>
<p>The fourth parameter, eTextRep, specifies what
<a href="../c3ref/c_any.html">text encoding</a> this SQL function prefers for
its parameters. The application should set this parameter to
<a href="../c3ref/c_any.html">SQLITE_UTF16LE</a> if the function implementation invokes
<a href="../c3ref/value_blob.html">sqlite3_value_text16le()</a> on an input, or <a href="../c3ref/c_any.html">SQLITE_UTF16BE</a> if the
implementation invokes <a href="../c3ref/value_blob.html">sqlite3_value_text16be()</a> on an input, or
<a href="../c3ref/c_any.html">SQLITE_UTF16</a> if <a href="../c3ref/value_blob.html">sqlite3_value_text16()</a> is used, or <a href="../c3ref/c_any.html">SQLITE_UTF8</a>
otherwise. The same SQL function may be registered multiple times using
different preferred text encodings, with different implementations for
each encoding.
When multiple implementations of the same function are available, SQLite
will pick the one that involves the least amount of data conversion.</p>
<p>The fourth parameter may optionally be ORed with <a href="../c3ref/c_deterministic.html#sqlitedeterministic">SQLITE_DETERMINISTIC</a>
to signal that the function will always return the same result given
the same inputs within a single SQL statement. Most SQL functions are
deterministic. The built-in <a href="../lang_corefunc.html#random">random()</a> SQL function is an example of a
function that is not deterministic. The SQLite query planner is able to
perform additional optimizations on deterministic functions, so use
of the <a href="../c3ref/c_deterministic.html#sqlitedeterministic">SQLITE_DETERMINISTIC</a> flag is recommended where possible.</p>
<p>The fourth parameter may also optionally include the <a href="../c3ref/c_deterministic.html#sqlitedirectonly">SQLITE_DIRECTONLY</a>
flag, which if present prevents the function from being invoked from
within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
index expressions, or the WHERE clause of partial indexes.</p>
<p><span style="background-color:#ffff90;">
For best security, the <a href="../c3ref/c_deterministic.html#sqlitedirectonly">SQLITE_DIRECTONLY</a> flag is recommended for
all application-defined SQL functions that do not need to be
used inside of triggers, view, CHECK constraints, or other elements of
the database schema. This flags is especially recommended for SQL
functions that have side effects or reveal internal application state.
Without this flag, an attacker might be able to modify the schema of
a database file to include invocations of the function with parameters
chosen by the attacker, which the application will then execute when
the database file is opened and read.
</span></p>
<p>The fifth parameter is an arbitrary pointer. The implementation of the
function can gain access to this pointer using <a href="../c3ref/user_data.html">sqlite3_user_data()</a>.</p>
<p>The sixth, seventh and eighth parameters passed to the three
"sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
pointers to C-language functions that implement the SQL function or
aggregate. A scalar SQL function requires an implementation of the xFunc
callback only; NULL pointers must be passed as the xStep and xFinal
parameters. An aggregate SQL function requires an implementation of xStep
and xFinal and NULL pointer must be passed for xFunc. To delete an existing
SQL function or aggregate, pass NULL pointers for all three function
callbacks.</p>
<p>The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
and xInverse) passed to sqlite3_create_window_function are pointers to
C-language callbacks that implement the new function. xStep and xFinal
must both be non-NULL. xValue and xInverse may either both be NULL, in
which case a regular aggregate function is created, or must both be
non-NULL, in which case the new function may be used as either an aggregate
or aggregate window function. More details regarding the implementation
of aggregate window functions are
<a href="../windowfunctions.html#udfwinfunc">available here</a>.</p>
<p>If the final parameter to sqlite3_create_function_v2() or
sqlite3_create_window_function() is not NULL, then it is destructor for
the application data pointer. The destructor is invoked when the function
is deleted, either by being overloaded or when the database connection
closes. The destructor is also invoked if the call to
sqlite3_create_function_v2() fails. When the destructor callback is
invoked, it is passed a single argument which is a copy of the application
data pointer which was the fifth parameter to sqlite3_create_function_v2().</p>
<p>It is permitted to register multiple implementations of the same
functions with the same name but with either differing numbers of
arguments or differing preferred text encodings. SQLite will use
the implementation that most closely matches the way in which the
SQL function is used. A function implementation with a non-negative
nArg parameter is a better match than a function implementation with
a negative nArg. A function where the preferred text encoding
matches the database encoding is a better
match than a function where the encoding is different.
A function where the encoding difference is between UTF16le and UTF16be
is a closer match than a function where the encoding difference is
between UTF8 and UTF16.</p>
<p>Built-in functions may be overloaded by new application-defined functions.</p>
<p>An application-defined function is permitted to call other
SQLite interfaces. However, such calls must not
close the database connection nor finalize or reset the prepared
statement in which the function is running.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,145 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Register A Virtual Table Implementation</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_create_module sqlite3_create_module_v2 -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Register A Virtual Table Implementation</h2>
</div>
<blockquote><pre>
int sqlite3_create_module(
sqlite3 *db, /* SQLite connection to register module with */
const char *zName, /* Name of the module */
const sqlite3_module *p, /* Methods for the module */
void *pClientData /* Client data for xCreate/xConnect */
);
int sqlite3_create_module_v2(
sqlite3 *db, /* SQLite connection to register module with */
const char *zName, /* Name of the module */
const sqlite3_module *p, /* Methods for the module */
void *pClientData, /* Client data for xCreate/xConnect */
void(*xDestroy)(void*) /* Module destructor function */
);
</pre></blockquote>
<p>
These routines are used to register a new <a href="../c3ref/module.html">virtual table module</a> name.
Module names must be registered before
creating a new <a href="../vtab.html">virtual table</a> using the module and before using a
preexisting <a href="../vtab.html">virtual table</a> for the module.</p>
<p>The module name is registered on the <a href="../c3ref/sqlite3.html">database connection</a> specified
by the first parameter. The name of the module is given by the
second parameter. The third parameter is a pointer to
the implementation of the <a href="../c3ref/module.html">virtual table module</a>. The fourth
parameter is an arbitrary client data pointer that is passed through
into the <a href="../vtab.html#xcreate">xCreate</a> and <a href="../vtab.html#xconnect">xConnect</a> methods of the virtual table module
when a new virtual table is be being created or reinitialized.</p>
<p>The sqlite3_create_module_v2() interface has a fifth parameter which
is a pointer to a destructor for the pClientData. SQLite will
invoke the destructor function (if it is not NULL) when SQLite
no longer needs the pClientData pointer. The destructor will also
be invoked if the call to sqlite3_create_module_v2() fails.
The sqlite3_create_module()
interface is equivalent to sqlite3_create_module_v2() with a NULL
destructor.</p>
<p>If the third parameter (the pointer to the sqlite3_module object) is
NULL then no new module is create and any existing modules with the
same name are dropped.</p>
<p>See also: <a href="../c3ref/drop_modules.html">sqlite3_drop_modules()</a>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Number of columns in a result set</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_data_count -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Number of columns in a result set</h2>
</div>
<blockquote><pre>
int sqlite3_data_count(sqlite3_stmt *pStmt);
</pre></blockquote>
<p>
The sqlite3_data_count(P) interface returns the number of columns in the
current row of the result set of <a href="../c3ref/stmt.html">prepared statement</a> P.
If prepared statement P does not have results ready to return
(via calls to the <a href="../c3ref/column_blob.html">sqlite3_column()</a> family of
interfaces) then sqlite3_data_count(P) returns 0.
The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
The sqlite3_data_count(P) routine returns 0 if the previous call to
<a href="../c3ref/step.html">sqlite3_step</a>(P) returned <a href="../rescode.html#done">SQLITE_DONE</a>. The sqlite3_data_count(P)
will return non-zero if previous call to <a href="../c3ref/step.html">sqlite3_step</a>(P) returned
<a href="../rescode.html#row">SQLITE_ROW</a>, except in the case of the <a href="../pragma.html#pragma_incremental_vacuum">PRAGMA incremental_vacuum</a>
where it always returns zero since each step of that multi-step
pragma returns 0 columns of data.</p>
<p>See also: <a href="../c3ref/column_count.html">sqlite3_column_count()</a>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,137 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Name Of The Folder Holding Database Files</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_data_directory -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Name Of The Folder Holding Database Files</h2>
</div>
<blockquote><pre>
SQLITE_EXTERN char *sqlite3_data_directory;
</pre></blockquote>
<p>
If this global variable is made to point to a string which is
the name of a folder (a.k.a. directory), then all database files
specified with a relative pathname and created or accessed by
SQLite when using a built-in windows <a href="../c3ref/vfs.html">VFS</a> will be assumed
to be relative to that directory. If this variable is a NULL
pointer, then SQLite assumes that all database files specified
with a relative pathname are relative to the current directory
for the process. Only the windows VFS makes use of this global
variable; it is ignored by the unix VFS.</p>
<p>Changing the value of this variable while a database connection is
open can result in a corrupt database.</p>
<p>It is not safe to read or modify this variable in more than one
thread at a time. It is not safe to read or modify this variable
if a <a href="../c3ref/sqlite3.html">database connection</a> is being used at the same time in a separate
thread.
It is intended that this variable be set once
as part of process initialization and before any SQLite interface
routines have been called and that this variable remain unchanged
thereafter.</p>
<p>The <a href="../pragma.html#pragma_data_store_directory">data_store_directory pragma</a> may modify this variable and cause
it to point to memory obtained from <a href="../c3ref/free.html">sqlite3_malloc</a>. Furthermore,
the <a href="../pragma.html#pragma_data_store_directory">data_store_directory pragma</a> always assumes that any string
that this variable points to is held in memory obtained from
<a href="../c3ref/free.html">sqlite3_malloc</a> and the pragma may attempt to free that memory
using <a href="../c3ref/free.html">sqlite3_free</a>.
Hence, if this variable is modified directly, either it should be
made NULL or made to point to memory obtained from <a href="../c3ref/free.html">sqlite3_malloc</a>
or else the use of the <a href="../pragma.html#pragma_data_store_directory">data_store_directory pragma</a> should be avoided.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,119 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Database File Corresponding To A Journal</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_database_file_object -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Database File Corresponding To A Journal</h2>
</div>
<blockquote><pre>
sqlite3_file *sqlite3_database_file_object(const char*);
</pre></blockquote>
<p>
If X is the name of a rollback or WAL-mode journal file that is
passed into the xOpen method of <a href="../c3ref/vfs.html">sqlite3_vfs</a>, then
sqlite3_database_file_object(X) returns a pointer to the <a href="../c3ref/file.html">sqlite3_file</a>
object that represents the main database file.</p>
<p>This routine is intended for use in custom <a href="../vfs.html">VFS</a> implementations
only. It is not a general-purpose interface.
The argument sqlite3_file_object(X) must be a filename pointer that
has been passed into <a href="../c3ref/vfs.html">sqlite3_vfs</a>.xOpen method where the
flags parameter to xOpen contains one of the bits
<a href="../c3ref/c_open_autoproxy.html">SQLITE_OPEN_MAIN_JOURNAL</a> or <a href="../c3ref/c_open_autoproxy.html">SQLITE_OPEN_WAL</a>. Any other use
of this routine results in undefined and probably undesirable
behavior.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Flush caches to disk mid-transaction</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_db_cacheflush -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Flush caches to disk mid-transaction</h2>
</div>
<blockquote><pre>
int sqlite3_db_cacheflush(sqlite3*);
</pre></blockquote>
<p>
If a write-transaction is open on <a href="../c3ref/sqlite3.html">database connection</a> D when the
<a href="../c3ref/db_cacheflush.html">sqlite3_db_cacheflush(D)</a> interface invoked, any dirty
pages in the pager-cache that are not currently in use are written out
to disk. A dirty page may be in use if a database cursor created by an
active SQL statement is reading from it, or if it is page 1 of a database
file (page 1 is always "in use"). The <a href="../c3ref/db_cacheflush.html">sqlite3_db_cacheflush(D)</a>
interface flushes caches for all schemas - "main", "temp", and
any <a href="../lang_attach.html">attached</a> databases.</p>
<p>If this function needs to obtain extra database locks before dirty pages
can be flushed to disk, it does so. If those locks cannot be obtained
immediately and there is a busy-handler callback configured, it is invoked
in the usual manner. If the required lock still cannot be obtained, then
the database is skipped and an attempt made to flush any dirty pages
belonging to the next (if any) database. If any databases are skipped
because locks cannot be obtained, but no other error occurs, this
function returns SQLITE_BUSY.</p>
<p>If any other error occurs while flushing dirty pages to disk (for
example an IO error or out-of-memory condition), then processing is
abandoned and an SQLite <a href="../rescode.html">error code</a> is returned to the caller immediately.</p>
<p>Otherwise, if no error occurs, <a href="../c3ref/db_cacheflush.html">sqlite3_db_cacheflush()</a> returns SQLITE_OK.</p>
<p>This function does not set the database handle error code or message
returned by the <a href="../c3ref/errcode.html">sqlite3_errcode()</a> and <a href="../c3ref/errcode.html">sqlite3_errmsg()</a> functions.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,118 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Configure database connections</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_db_config -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Configure database connections</h2>
</div>
<blockquote><pre>
int sqlite3_db_config(sqlite3*, int op, ...);
</pre></blockquote>
<p>
The sqlite3_db_config() interface is used to make configuration
changes to a <a href="../c3ref/sqlite3.html">database connection</a>. The interface is similar to
<a href="../c3ref/config.html">sqlite3_config()</a> except that the changes apply to a single
<a href="../c3ref/sqlite3.html">database connection</a> (specified in the first argument).</p>
<p>The second argument to sqlite3_db_config(D,V,...) is the
<a href="../c3ref/c_dbconfig_defensive.html#sqlitedbconfiglookaside">configuration verb</a> - an integer code
that indicates what aspect of the <a href="../c3ref/sqlite3.html">database connection</a> is being configured.
Subsequent arguments vary depending on the configuration verb.</p>
<p>Calls to sqlite3_db_config() return SQLITE_OK if and only if
the call is considered successful.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,131 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Return The Filename For A Database Connection</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_db_filename -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Return The Filename For A Database Connection</h2>
</div>
<blockquote><pre>
const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
</pre></blockquote>
<p>
The sqlite3_db_filename(D,N) interface returns a pointer to the filename
associated with database N of connection D.
If there is no attached database N on the database
connection D, or if database N is a temporary or in-memory database, then
this function will return either a NULL pointer or an empty string.</p>
<p>The string value returned by this routine is owned and managed by
the database connection. The value will be valid until the database N
is <a href="../lang_detach.html">DETACH</a>-ed or until the database connection closes.</p>
<p>The filename returned by this function is the output of the
xFullPathname method of the <a href="../vfs.html">VFS</a>. In other words, the filename
will be an absolute pathname, even if the filename used
to open the database originally was a URI or relative pathname.</p>
<p>If the filename pointer returned by this routine is not NULL, then it
can be used as the filename input parameter to these routines:
<ul>
<li> <a href="../c3ref/uri_boolean.html">sqlite3_uri_parameter()</a>
<li> <a href="../c3ref/uri_boolean.html">sqlite3_uri_boolean()</a>
<li> <a href="../c3ref/uri_boolean.html">sqlite3_uri_int64()</a>
<li> <a href="../c3ref/filename_database.html">sqlite3_filename_database()</a>
<li> <a href="../c3ref/filename_database.html">sqlite3_filename_journal()</a>
<li> <a href="../c3ref/filename_database.html">sqlite3_filename_wal()</a>
</ul>
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

View File

@ -0,0 +1,112 @@
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>Find The Database Handle Of A Prepared Statement</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
</div>
<!-- keywords: sqlite3_db_handle -->
<div class=nosearch>
<a href="intro.html"><h2>SQLite C Interface</h2></a>
<h2>Find The Database Handle Of A Prepared Statement</h2>
</div>
<blockquote><pre>
sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
</pre></blockquote>
<p>
The sqlite3_db_handle interface returns the <a href="../c3ref/sqlite3.html">database connection</a> handle
to which a <a href="../c3ref/stmt.html">prepared statement</a> belongs. The <a href="../c3ref/sqlite3.html">database connection</a>
returned by sqlite3_db_handle is the same <a href="../c3ref/sqlite3.html">database connection</a>
that was the first argument
to the <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> call (or its variants) that was used to
create the statement in the first place.
</p><p>See also lists of
<a href="objlist.html">Objects</a>,
<a href="constlist.html">Constants</a>, and
<a href="funclist.html">Functions</a>.</p>

Some files were not shown because too many files have changed in this diff Show More