|
|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
-** 2001 September 15
|
|
|
+** 2001-09-15
|
|
|
**
|
|
|
** The author disclaims copyright to this source code. In place of
|
|
|
** a legal notice, here is a blessing:
|
|
|
@@ -123,7 +123,7 @@ extern "C" {
|
|
|
*/
|
|
|
#define SQLITE_VERSION "3.20.0"
|
|
|
#define SQLITE_VERSION_NUMBER 3020000
|
|
|
-#define SQLITE_SOURCE_ID "2017-06-28 13:47:56 b362f0d8ed34839bf3b29d10ed0853ab94245fba135ccd28e619caa6ee6992d5"
|
|
|
+#define SQLITE_SOURCE_ID "2017-07-06 03:06:20 55ecd30304517acd23f89b3450fd6a5e18ac2f79aa24a4ff693f8d71a49f7837"
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Run-Time Library Version Numbers
|
|
|
@@ -235,7 +235,7 @@ SQLITE_API int sqlite3_threadsafe(void);
|
|
|
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
|
|
|
** and [sqlite3_close_v2()] are its destructors. There are many other
|
|
|
** interfaces (such as
|
|
|
-** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
|
|
|
+** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
|
|
|
** [sqlite3_busy_timeout()] to name but three) that are methods on an
|
|
|
** sqlite3 object.
|
|
|
*/
|
|
|
@@ -352,7 +352,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
|
|
|
** METHOD: sqlite3
|
|
|
**
|
|
|
** The sqlite3_exec() interface is a convenience wrapper around
|
|
|
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
|
|
|
+** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
|
|
|
** that allows an application to run multiple statements of SQL
|
|
|
** without having to use a lot of C code.
|
|
|
**
|
|
|
@@ -2722,7 +2722,8 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
|
|
|
** [database connection], supplied in the first argument.
|
|
|
** ^The authorizer callback is invoked as SQL statements are being compiled
|
|
|
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
|
|
|
-** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
|
|
|
+** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
|
|
|
+** and [sqlite3_prepare16_v3()]. ^At various
|
|
|
** points during the compilation process, as logic is being created
|
|
|
** to perform various actions, the authorizer callback is invoked to
|
|
|
** see if those actions are allowed. ^The authorizer callback should
|
|
|
@@ -2731,12 +2732,12 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
|
|
|
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
|
|
|
** rejected with an error. ^If the authorizer callback returns
|
|
|
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
|
|
|
-** then the [sqlite3_prepare_v2()] or equivalent call that triggered
|
|
|
+** then the [sqlite3_prepare_v3()] or equivalent call that triggered
|
|
|
** the authorizer will fail with an error message.
|
|
|
**
|
|
|
** When the callback returns [SQLITE_OK], that means the operation
|
|
|
** requested is ok. ^When the callback returns [SQLITE_DENY], the
|
|
|
-** [sqlite3_prepare_v2()] or equivalent call that triggered the
|
|
|
+** [sqlite3_prepare_v3()] or equivalent call that triggered the
|
|
|
** authorizer will fail with an error message explaining that
|
|
|
** access is denied.
|
|
|
**
|
|
|
@@ -2787,10 +2788,10 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
|
|
|
**
|
|
|
** The authorizer callback must not do anything that will modify
|
|
|
** the database connection that invoked the authorizer callback.
|
|
|
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
|
|
|
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
|
|
|
** database connections for the meaning of "modify" in this paragraph.
|
|
|
**
|
|
|
-** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
|
|
|
+** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
|
|
|
** statement might be re-prepared during [sqlite3_step()] due to a
|
|
|
** schema change. Hence, the application should ensure that the
|
|
|
** correct authorizer callback remains in place during the [sqlite3_step()].
|
|
|
@@ -2799,7 +2800,7 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
|
|
|
** [sqlite3_prepare()] or its variants. Authorization is not
|
|
|
** performed during statement evaluation in [sqlite3_step()], unless
|
|
|
** as stated in the previous paragraph, sqlite3_step() invokes
|
|
|
-** sqlite3_prepare_v2() to reprepare a statement after a schema change.
|
|
|
+** sqlite3_prepare_v3() to reprepare a statement after a schema change.
|
|
|
*/
|
|
|
SQLITE_API int sqlite3_set_authorizer(
|
|
|
sqlite3*,
|
|
|
@@ -3035,7 +3036,7 @@ SQLITE_API int sqlite3_trace_v2(
|
|
|
**
|
|
|
** The progress handler callback must not do anything that will modify
|
|
|
** the database connection that invoked the progress handler.
|
|
|
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
|
|
|
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
|
|
|
** database connections for the meaning of "modify" in this paragraph.
|
|
|
**
|
|
|
*/
|
|
|
@@ -3392,7 +3393,7 @@ SQLITE_API const char *sqlite3_errstr(int);
|
|
|
** The life-cycle of a prepared statement object usually goes like this:
|
|
|
**
|
|
|
** <ol>
|
|
|
-** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
|
|
|
+** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
|
|
|
** <li> Bind values to [parameters] using the sqlite3_bind_*()
|
|
|
** interfaces.
|
|
|
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
|
|
|
@@ -3474,7 +3475,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
|
|
|
**
|
|
|
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
|
|
|
** <dd>The maximum number of instructions in a virtual machine program
|
|
|
-** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
|
|
|
+** used to implement an SQL statement. If [sqlite3_prepare_v3()] 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>)^
|
|
|
**
|
|
|
@@ -3514,6 +3515,27 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
|
|
|
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
|
|
|
#define SQLITE_LIMIT_WORKER_THREADS 11
|
|
|
#define SQLITE_LIMIT_USE_ATTACHED_DBS 12
|
|
|
+/*
|
|
|
+** CAPI3REF: Prepare Flags
|
|
|
+**
|
|
|
+** These constants define various flags that can be passed into
|
|
|
+** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
|
|
|
+** [sqlite3_prepare16_v3()] interfaces.
|
|
|
+**
|
|
|
+** New flags may be added in future releases of SQLite.
|
|
|
+**
|
|
|
+** <dl>
|
|
|
+** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
|
|
|
+** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
|
|
|
+** and [sqlite3_prepare16_v3()]
|
|
|
+** to optimize the resulting prepared statement to be retained for a
|
|
|
+** relatively long amount of time.)^ ^Without this flag,
|
|
|
+** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
|
|
|
+** the prepared statement will be used just once or at most a few times
|
|
|
+** and then destroyed using [sqlite3_finalize()] relatively soon.
|
|
|
+** </dl>
|
|
|
+*/
|
|
|
+#define SQLITE_PREPARE_PERSISTENT 0x01
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Compiling An SQL Statement
|
|
|
@@ -3521,17 +3543,29 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
|
|
|
** METHOD: sqlite3
|
|
|
** CONSTRUCTOR: sqlite3_stmt
|
|
|
**
|
|
|
-** To execute an SQL query, it must first be compiled into a byte-code
|
|
|
-** program using one of these routines.
|
|
|
+** To execute an SQL statement, it must first be compiled into a byte-code
|
|
|
+** program using one of these routines. Or, in other words, these routines
|
|
|
+** are constructors for the [prepared statement] object.
|
|
|
+**
|
|
|
+** The preferred routine to use is [sqlite3_prepare_v2()]. The
|
|
|
+** [sqlite3_prepare()] interface is legacy and should be avoided.
|
|
|
+** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
|
|
|
+** for special purposes.
|
|
|
+**
|
|
|
+** The use of the UTF-8 interfaces is preferred, as SQLite currently
|
|
|
+** does all parsing using UTF-8. The UTF-16 interfaces are provided
|
|
|
+** as a convenience. The UTF-16 interfaces work by converting the
|
|
|
+** input text into UTF-8, then invoking the corresponding UTF-8 interface.
|
|
|
**
|
|
|
** The first argument, "db", is a [database connection] obtained from a
|
|
|
** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
|
|
|
** [sqlite3_open16()]. The database connection must not have been closed.
|
|
|
**
|
|
|
** The second argument, "zSql", is the statement to be compiled, encoded
|
|
|
-** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
|
|
|
-** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
|
|
|
-** use UTF-16.
|
|
|
+** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
|
|
|
+** and sqlite3_prepare_v3()
|
|
|
+** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
|
|
|
+** and sqlite3_prepare16_v3() use UTF-16.
|
|
|
**
|
|
|
** ^If the nByte argument is negative, then zSql is read up to the
|
|
|
** first zero terminator. ^If nByte is positive, then it is the
|
|
|
@@ -3558,10 +3592,11 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
|
|
|
** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
|
|
|
** otherwise an [error code] is returned.
|
|
|
**
|
|
|
-** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
|
|
|
-** recommended for all new programs. The two older interfaces are retained
|
|
|
-** for backwards compatibility, but their use is discouraged.
|
|
|
-** ^In the "v2" interfaces, the prepared statement
|
|
|
+** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
|
|
|
+** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
|
|
|
+** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
|
|
|
+** are retained for backwards compatibility, but their use is discouraged.
|
|
|
+** ^In the "vX" interfaces, the prepared statement
|
|
|
** that is returned (the [sqlite3_stmt] object) contains a copy of the
|
|
|
** original SQL text. This causes the [sqlite3_step()] interface to
|
|
|
** behave differently in three ways:
|
|
|
@@ -3594,6 +3629,12 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
|
|
|
** or [GLOB] operator or if the parameter is compared to an indexed column
|
|
|
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
|
|
|
** </li>
|
|
|
+**
|
|
|
+** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
|
|
|
+** the extra prepFlags parameter, which is a bit array consisting of zero or
|
|
|
+** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
|
|
|
+** sqlite3_prepare_v2() interface works exactly the same as
|
|
|
+** sqlite3_prepare_v3() with a zero prepFlags parameter.
|
|
|
** </ol>
|
|
|
*/
|
|
|
SQLITE_API int sqlite3_prepare(
|
|
|
@@ -3610,6 +3651,14 @@ SQLITE_API int sqlite3_prepare_v2(
|
|
|
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
|
|
|
const char **pzTail /* OUT: Pointer to unused portion of zSql */
|
|
|
);
|
|
|
+SQLITE_API int sqlite3_prepare_v3(
|
|
|
+ sqlite3 *db, /* Database handle */
|
|
|
+ const char *zSql, /* SQL statement, UTF-8 encoded */
|
|
|
+ int nByte, /* Maximum length of zSql in bytes. */
|
|
|
+ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
|
|
|
+ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
|
|
|
+ const char **pzTail /* OUT: Pointer to unused portion of zSql */
|
|
|
+);
|
|
|
SQLITE_API int sqlite3_prepare16(
|
|
|
sqlite3 *db, /* Database handle */
|
|
|
const void *zSql, /* SQL statement, UTF-16 encoded */
|
|
|
@@ -3624,6 +3673,14 @@ SQLITE_API int sqlite3_prepare16_v2(
|
|
|
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
|
|
|
const void **pzTail /* OUT: Pointer to unused portion of zSql */
|
|
|
);
|
|
|
+SQLITE_API int sqlite3_prepare16_v3(
|
|
|
+ sqlite3 *db, /* Database handle */
|
|
|
+ const void *zSql, /* SQL statement, UTF-16 encoded */
|
|
|
+ int nByte, /* Maximum length of zSql in bytes. */
|
|
|
+ unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
|
|
|
+ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
|
|
|
+ const void **pzTail /* OUT: Pointer to unused portion of zSql */
|
|
|
+);
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Retrieving Statement SQL
|
|
|
@@ -3631,7 +3688,8 @@ SQLITE_API int sqlite3_prepare16_v2(
|
|
|
**
|
|
|
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
|
|
|
** SQL text used to create [prepared statement] P if P was
|
|
|
-** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
|
|
|
+** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
|
|
|
+** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
|
|
|
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
|
|
|
** string containing the SQL text of prepared statement P with
|
|
|
** [bound parameters] expanded.
|
|
|
@@ -3777,7 +3835,7 @@ typedef struct sqlite3_context sqlite3_context;
|
|
|
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
|
|
|
** METHOD: sqlite3_stmt
|
|
|
**
|
|
|
-** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
|
|
|
+** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
|
|
|
** literals may be replaced by a [parameter] that matches one of following
|
|
|
** templates:
|
|
|
**
|
|
|
@@ -3796,7 +3854,7 @@ typedef struct sqlite3_context sqlite3_context;
|
|
|
**
|
|
|
** ^The first argument to the sqlite3_bind_*() routines is always
|
|
|
** a pointer to the [sqlite3_stmt] object returned from
|
|
|
-** [sqlite3_prepare_v2()] or its variants.
|
|
|
+** [sqlite3_prepare_v3()] or its variants.
|
|
|
**
|
|
|
** ^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
|
|
|
@@ -3933,8 +3991,8 @@ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
|
|
|
** ^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 [sqlite3_prepare16()] or
|
|
|
-** [sqlite3_prepare16_v2()].
|
|
|
+** originally specified as UTF-16 in [sqlite3_prepare16()],
|
|
|
+** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
|
|
|
**
|
|
|
** See also: [sqlite3_bind_blob|sqlite3_bind()],
|
|
|
** [sqlite3_bind_parameter_count()], and
|
|
|
@@ -3951,7 +4009,8 @@ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
|
|
|
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^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 [sqlite3_prepare16_v2()].
|
|
|
+** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
|
|
|
+** [sqlite3_prepare16_v3()].
|
|
|
**
|
|
|
** See also: [sqlite3_bind_blob|sqlite3_bind()],
|
|
|
** [sqlite3_bind_parameter_count()], and
|
|
|
@@ -4105,16 +4164,18 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
|
|
|
** CAPI3REF: Evaluate An SQL Statement
|
|
|
** METHOD: sqlite3_stmt
|
|
|
**
|
|
|
-** After a [prepared statement] has been prepared using either
|
|
|
-** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
|
|
|
+** After a [prepared statement] has been prepared using any of
|
|
|
+** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
|
|
|
+** or [sqlite3_prepare16_v3()] or one of the legacy
|
|
|
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
|
|
|
** must be called one or more times to evaluate the statement.
|
|
|
**
|
|
|
** The details of the behavior of the sqlite3_step() interface depend
|
|
|
-** on whether the statement was prepared using the newer "v2" interface
|
|
|
-** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
|
|
|
-** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
|
|
|
-** new "v2" interface is recommended for new applications but the legacy
|
|
|
+** on whether the statement was prepared using the newer "vX" interfaces
|
|
|
+** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
|
|
|
+** [sqlite3_prepare16_v2()] or the older legacy
|
|
|
+** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
|
|
|
+** new "vX" interface is recommended for new applications but the legacy
|
|
|
** interface will continue to be supported.
|
|
|
**
|
|
|
** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
|
|
|
@@ -4175,10 +4236,11 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
|
|
|
** specific [error codes] that better describes the error.
|
|
|
** We admit that this is a goofy design. The problem has been fixed
|
|
|
** with the "v2" interface. If you prepare all of your SQL statements
|
|
|
-** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
|
|
|
+** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
|
|
|
+** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
|
|
|
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
|
|
|
** then the more specific [error codes] are returned directly
|
|
|
-** by sqlite3_step(). The use of the "v2" interface is recommended.
|
|
|
+** by sqlite3_step(). The use of the "vX" interfaces is recommended.
|
|
|
*/
|
|
|
SQLITE_API int sqlite3_step(sqlite3_stmt*);
|
|
|
|
|
|
@@ -4240,10 +4302,32 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
|
** KEYWORDS: {column access functions}
|
|
|
** METHOD: sqlite3_stmt
|
|
|
**
|
|
|
+** <b>Summary:</b>
|
|
|
+** <blockquote><table border=0 cellpadding=0 cellspacing=0>
|
|
|
+** <tr><td><b>sqlite3_column_blob</b><td>→<td>BLOB result
|
|
|
+** <tr><td><b>sqlite3_column_double</b><td>→<td>REAL result
|
|
|
+** <tr><td><b>sqlite3_column_int</b><td>→<td>32-bit INTEGER result
|
|
|
+** <tr><td><b>sqlite3_column_int64</b><td>→<td>64-bit INTEGER result
|
|
|
+** <tr><td><b>sqlite3_column_text</b><td>→<td>UTF-8 TEXT result
|
|
|
+** <tr><td><b>sqlite3_column_text16</b><td>→<td>UTF-16 TEXT result
|
|
|
+** <tr><td><b>sqlite3_column_value</b><td>→<td>The result as an
|
|
|
+** [sqlite3_value|unprotected sqlite3_value] object.
|
|
|
+** <tr><td> <td> <td>
|
|
|
+** <tr><td><b>sqlite3_column_bytes</b><td>→<td>Size of a BLOB
|
|
|
+** or a UTF-8 TEXT result in bytes
|
|
|
+** <tr><td><b>sqlite3_column_bytes16 </b>
|
|
|
+** <td>→ <td>Size of UTF-16
|
|
|
+** TEXT in bytes
|
|
|
+** <tr><td><b>sqlite3_column_type</b><td>→<td>Default
|
|
|
+** datatype of the result
|
|
|
+** </table></blockquote>
|
|
|
+**
|
|
|
+** <b>Details:</b>
|
|
|
+**
|
|
|
** ^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 [prepared statement] that is being evaluated (the [sqlite3_stmt*]
|
|
|
-** that was returned from [sqlite3_prepare_v2()] or one of its variants)
|
|
|
+** that was returned from [sqlite3_prepare_v3()] 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
|
|
|
@@ -4261,16 +4345,29 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
|
** are called from a different thread while any of these routines
|
|
|
** are pending, then the results are undefined.
|
|
|
**
|
|
|
+** 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.
|
|
|
+**
|
|
|
** ^The sqlite3_column_type() routine returns the
|
|
|
** [SQLITE_INTEGER | datatype code] for the initial data type
|
|
|
** of the result column. ^The returned value is one of [SQLITE_INTEGER],
|
|
|
-** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
|
|
|
-** returned by sqlite3_column_type() is only meaningful if no type
|
|
|
-** conversions have occurred as described below. After a type conversion,
|
|
|
-** the value returned by sqlite3_column_type() is undefined. Future
|
|
|
+** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].
|
|
|
+** 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.
|
|
|
**
|
|
|
+** 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.
|
|
|
+**
|
|
|
** ^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
|
|
|
@@ -4307,9 +4404,13 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
|
** [sqlite3_column_value()] is used in any other way, including calls
|
|
|
** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
|
|
|
** or [sqlite3_value_bytes()], the behavior is not threadsafe.
|
|
|
+** Hence, the sqlite3_column_value() interface
|
|
|
+** is normally only useful within the implementation of
|
|
|
+** [application-defined SQL functions] or [virtual tables], not within
|
|
|
+** top-level application code.
|
|
|
**
|
|
|
-** These routines attempt to convert the value where appropriate. ^For
|
|
|
-** example, if the internal representation is FLOAT and a text result
|
|
|
+** 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, [sqlite3_snprintf()] is used internally to perform the
|
|
|
** conversion automatically. ^(The following table details the conversions
|
|
|
** that are applied:
|
|
|
@@ -4381,7 +4482,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
|
** ^The pointers returned are valid until a type conversion occurs as
|
|
|
** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
|
|
|
** [sqlite3_finalize()] is called. ^The memory space used to hold strings
|
|
|
-** and BLOBs is freed automatically. Do <em>not</em> pass the pointers returned
|
|
|
+** and BLOBs is freed automatically. Do not pass the pointers returned
|
|
|
** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
|
|
|
** [sqlite3_free()].
|
|
|
**
|
|
|
@@ -4392,15 +4493,15 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
|
** [SQLITE_NOMEM].)^
|
|
|
*/
|
|
|
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
|
|
|
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
|
|
|
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
|
|
|
SQLITE_API sqlite_double sqlite3_column_double(sqlite3_stmt*, int iCol);
|
|
|
SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
|
|
|
SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
|
|
|
SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
|
|
|
SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
|
|
|
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
|
|
|
SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
|
|
|
+SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
|
|
|
+SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
|
|
|
+SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Destroy A Prepared Statement Object
|
|
|
@@ -4634,21 +4735,39 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
|
|
|
** CAPI3REF: Obtaining SQL Values
|
|
|
** METHOD: sqlite3_value
|
|
|
**
|
|
|
-** The C-language implementation of SQL functions and aggregates uses
|
|
|
-** this set of interface routines to access the parameter values on
|
|
|
-** the function or aggregate.
|
|
|
-**
|
|
|
-** The xFunc (for scalar functions) or xStep (for aggregates) parameters
|
|
|
-** to [sqlite3_create_function()] and [sqlite3_create_function16()]
|
|
|
-** define callbacks that implement the SQL functions and aggregates.
|
|
|
-** The 3rd parameter to these callbacks is an array of pointers to
|
|
|
-** [protected sqlite3_value] objects. There is one [sqlite3_value] object for
|
|
|
-** each parameter to the SQL function. These routines are used to
|
|
|
-** extract values from the [sqlite3_value] objects.
|
|
|
+** <b>Summary:</b>
|
|
|
+** <blockquote><table border=0 cellpadding=0 cellspacing=0>
|
|
|
+** <tr><td><b>sqlite3_value_blob</b><td>→<td>BLOB value
|
|
|
+** <tr><td><b>sqlite3_value_double</b><td>→<td>REAL value
|
|
|
+** <tr><td><b>sqlite3_value_int</b><td>→<td>32-bit INTEGER value
|
|
|
+** <tr><td><b>sqlite3_value_int64</b><td>→<td>64-bit INTEGER value
|
|
|
+** <tr><td><b>sqlite3_value_text</b><td>→<td>UTF-8 TEXT value
|
|
|
+** <tr><td><b>sqlite3_value_text16</b><td>→<td>UTF-16 TEXT value in
|
|
|
+** the native byteorder
|
|
|
+** <tr><td><b>sqlite3_value_text16be</b><td>→<td>UTF-16be TEXT value
|
|
|
+** <tr><td><b>sqlite3_value_text16le</b><td>→<td>UTF-16le TEXT value
|
|
|
+** <tr><td> <td> <td>
|
|
|
+** <tr><td><b>sqlite3_value_bytes</b><td>→<td>Size of a BLOB
|
|
|
+** or a UTF-8 TEXT in bytes
|
|
|
+** <tr><td><b>sqlite3_value_bytes16 </b>
|
|
|
+** <td>→ <td>Size of UTF-16
|
|
|
+** TEXT in bytes
|
|
|
+** <tr><td><b>sqlite3_value_type</b><td>→<td>Default
|
|
|
+** datatype of the value
|
|
|
+** <tr><td><b>sqlite3_value_numeric_type </b>
|
|
|
+** <td>→ <td>Best numeric datatype of the value
|
|
|
+** </table></blockquote>
|
|
|
+**
|
|
|
+** <b>Details:</b>
|
|
|
+**
|
|
|
+** This routine extract type, size, and content information from
|
|
|
+** [protected sqlite3_value] objects. Protected sqlite3_value objects
|
|
|
+** are used to pass parameter information into implementation of
|
|
|
+** [application-defined SQL functions] and [virtual tables].
|
|
|
**
|
|
|
** These routines work only with [protected sqlite3_value] objects.
|
|
|
** Any attempt to use these routines on an [unprotected sqlite3_value]
|
|
|
-** object results in undefined behavior.
|
|
|
+** is not threadsafe.
|
|
|
**
|
|
|
** ^These routines work just like the corresponding [column access functions]
|
|
|
** except that these routines take a single [protected sqlite3_value] object
|
|
|
@@ -4659,6 +4778,17 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
|
|
|
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
|
|
|
** extract UTF-16 strings as big-endian and little-endian respectively.
|
|
|
**
|
|
|
+** ^(The sqlite3_value_type(V) interface returns the
|
|
|
+** [SQLITE_INTEGER | datatype code] for the initial datatype of the
|
|
|
+** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
|
|
|
+** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
|
|
|
+** Other interfaces might change the datatype for an sqlite3_value object.
|
|
|
+** For example, if the datatype is initially SQLITE_INTEGER and
|
|
|
+** sqlite3_value_text(V) is called to extract a text value for that
|
|
|
+** integer, then subsequent calls to sqlite3_value_type(V) might return
|
|
|
+** SQLITE_TEXT. Whether or not a persistent internal datatype conversion
|
|
|
+** occurs is undefined and may change from one release of SQLite to the next.
|
|
|
+**
|
|
|
** ^(The sqlite3_value_numeric_type() interface attempts to apply
|
|
|
** numeric affinity to the value. This means that an attempt is
|
|
|
** made to convert the value to an integer or floating point. If
|
|
|
@@ -4677,8 +4807,6 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
|
|
|
** the SQL function that supplied the [sqlite3_value*] parameters.
|
|
|
*/
|
|
|
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
|
|
|
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
|
|
|
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
|
|
|
SQLITE_API sqlite_double sqlite3_value_double(sqlite3_value*);
|
|
|
SQLITE_API int sqlite3_value_int(sqlite3_value*);
|
|
|
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
|
|
|
@@ -4686,6 +4814,8 @@ SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
|
|
|
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
|
|
|
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
|
|
|
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
|
|
|
+SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
|
|
|
+SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
|
|
|
SQLITE_API int sqlite3_value_type(sqlite3_value*);
|
|
|
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
|
|
|
|
|
|
@@ -5372,7 +5502,7 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*);
|
|
|
** to which a [prepared statement] belongs. ^The [database connection]
|
|
|
** returned by sqlite3_db_handle is the same [database connection]
|
|
|
** that was the first argument
|
|
|
-** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
|
|
|
+** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
|
|
|
** create the statement in the first place.
|
|
|
*/
|
|
|
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
|
|
|
@@ -5448,7 +5578,7 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
|
|
|
** completion of the [sqlite3_step()] 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 [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
|
|
|
+** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
|
|
|
** the database connections for the meaning of "modify" in this paragraph.
|
|
|
**
|
|
|
** ^Registering a NULL function disables the callback.
|
|
|
@@ -5508,7 +5638,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
|
|
|
** the database connection that invoked the update hook. Any actions
|
|
|
** to modify the database connection must be deferred until after the
|
|
|
** completion of the [sqlite3_step()] call that triggered the update hook.
|
|
|
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
|
|
|
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
|
|
|
** database connections for the meaning of "modify" in this paragraph.
|
|
|
**
|
|
|
** ^The sqlite3_update_hook(D,C,P) function
|
|
|
@@ -7187,6 +7317,18 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
|
|
|
** If the number of virtual machine operations exceeds 2147483647
|
|
|
** then the value returned by this statement status code is undefined.
|
|
|
**
|
|
|
+** [[SQLITE_STMTSTATUS_REPREPARE]] <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 change to
|
|
|
+** [bound parameters] that might affect the query plan.
|
|
|
+**
|
|
|
+** [[SQLITE_STMTSTATUS_RUN]] <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 [sqlite3_step()] followed by a call to [sqlite3_reset()].
|
|
|
+** The counter is incremented on the first [sqlite3_step()] call of each
|
|
|
+** cycle.
|
|
|
+**
|
|
|
** [[SQLITE_STMTSTATUS_MEMUSED]] <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
|
|
|
@@ -7199,7 +7341,9 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
|
|
|
#define SQLITE_STMTSTATUS_SORT 2
|
|
|
#define SQLITE_STMTSTATUS_AUTOINDEX 3
|
|
|
#define SQLITE_STMTSTATUS_VM_STEP 4
|
|
|
-#define SQLITE_STMTSTATUS_MEMUSED 5
|
|
|
+#define SQLITE_STMTSTATUS_REPREPARE 5
|
|
|
+#define SQLITE_STMTSTATUS_RUN 6
|
|
|
+#define SQLITE_STMTSTATUS_MEMUSED 99
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Custom Page Cache Object
|