Fossil SCM

Update the built-in SQLite to the first 3.20.0 release candidate.

drh 2017-07-15 13:55 trunk
Commit 4872a58be2b6090383e014996df7a71f74b166073d789e11e984eb07441b4494
3 files changed +1 -2 +163 -95 +56 -32
+1 -2
--- src/shell.c
+++ src/shell.c
@@ -4264,19 +4264,18 @@
42644264
static char *readline_completion_generator(const char *text, int state){
42654265
static sqlite3_stmt *pStmt = 0;
42664266
char *zRet;
42674267
if( state==0 ){
42684268
char *zSql;
4269
- int rc;
42704269
sqlite3_finalize(pStmt);
42714270
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
42724271
" FROM completion(%Q) ORDER BY 1", text);
42734272
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
42744273
sqlite3_free(zSql);
42754274
}
42764275
if( sqlite3_step(pStmt)==SQLITE_ROW ){
4277
- zRet = strdup(sqlite3_column_text(pStmt, 0));
4276
+ zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));
42784277
}else{
42794278
sqlite3_finalize(pStmt);
42804279
pStmt = 0;
42814280
zRet = 0;
42824281
}
42834282
--- src/shell.c
+++ src/shell.c
@@ -4264,19 +4264,18 @@
4264 static char *readline_completion_generator(const char *text, int state){
4265 static sqlite3_stmt *pStmt = 0;
4266 char *zRet;
4267 if( state==0 ){
4268 char *zSql;
4269 int rc;
4270 sqlite3_finalize(pStmt);
4271 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
4272 " FROM completion(%Q) ORDER BY 1", text);
4273 sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
4274 sqlite3_free(zSql);
4275 }
4276 if( sqlite3_step(pStmt)==SQLITE_ROW ){
4277 zRet = strdup(sqlite3_column_text(pStmt, 0));
4278 }else{
4279 sqlite3_finalize(pStmt);
4280 pStmt = 0;
4281 zRet = 0;
4282 }
4283
--- src/shell.c
+++ src/shell.c
@@ -4264,19 +4264,18 @@
4264 static char *readline_completion_generator(const char *text, int state){
4265 static sqlite3_stmt *pStmt = 0;
4266 char *zRet;
4267 if( state==0 ){
4268 char *zSql;
 
4269 sqlite3_finalize(pStmt);
4270 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
4271 " FROM completion(%Q) ORDER BY 1", text);
4272 sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
4273 sqlite3_free(zSql);
4274 }
4275 if( sqlite3_step(pStmt)==SQLITE_ROW ){
4276 zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));
4277 }else{
4278 sqlite3_finalize(pStmt);
4279 pStmt = 0;
4280 zRet = 0;
4281 }
4282
+163 -95
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1150,11 +1150,11 @@
11501150
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11511151
** [sqlite_version()] and [sqlite_source_id()].
11521152
*/
11531153
#define SQLITE_VERSION "3.20.0"
11541154
#define SQLITE_VERSION_NUMBER 3020000
1155
-#define SQLITE_SOURCE_ID "2017-07-12 18:05:54 604c11d1a39f09e47b6fcee0f8b1c1054f9dbbc7b2c1cf93312aeaa4b7095018"
1155
+#define SQLITE_SOURCE_ID "2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6"
11561156
11571157
/*
11581158
** CAPI3REF: Run-Time Library Version Numbers
11591159
** KEYWORDS: sqlite3_version sqlite3_sourceid
11601160
**
@@ -1262,11 +1262,11 @@
12621262
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
12631263
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
12641264
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
12651265
** and [sqlite3_close_v2()] are its destructors. There are many other
12661266
** interfaces (such as
1267
-** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
1267
+** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
12681268
** [sqlite3_busy_timeout()] to name but three) that are methods on an
12691269
** sqlite3 object.
12701270
*/
12711271
typedef struct sqlite3 sqlite3;
12721272
@@ -1366,11 +1366,11 @@
13661366
/*
13671367
** CAPI3REF: One-Step Query Execution Interface
13681368
** METHOD: sqlite3
13691369
**
13701370
** The sqlite3_exec() interface is a convenience wrapper around
1371
-** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
1371
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
13721372
** that allows an application to run multiple statements of SQL
13731373
** without having to use a lot of C code.
13741374
**
13751375
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
13761376
** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3035,14 +3035,14 @@
30353035
** into which is written 0 or 1 to indicate whether checkpoints-on-close
30363036
** have been disabled - 0 if they are not disabled, 1 if they are.
30373037
** </dd>
30383038
**
30393039
** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3040
-** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3040
+** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
30413041
** the [query planner stability guarantee] (QPSG). When the QPSG is active,
30423042
** a single SQL query statement will always use the same algorithm regardless
3043
-** of values of [bound parameters]. The QPSG disables some query optimizations
3043
+** of values of [bound parameters].)^ The QPSG disables some query optimizations
30443044
** that look at the values of bound parameters, which can make some queries
30453045
** slower. But the QPSG has the advantage of more predictable behavior. With
30463046
** the QPSG active, SQLite will always use the same query plan in the field as
30473047
** was used during testing in the lab.
30483048
** </dd>
@@ -3728,16 +3728,16 @@
37283728
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
37293729
** specific action but allow the SQL statement to continue to be
37303730
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
37313731
** rejected with an error. ^If the authorizer callback returns
37323732
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3733
-** then the [sqlite3_prepare_v3()] or equivalent call that triggered
3733
+** then the [sqlite3_prepare_v2()] or equivalent call that triggered
37343734
** the authorizer will fail with an error message.
37353735
**
37363736
** When the callback returns [SQLITE_OK], that means the operation
37373737
** requested is ok. ^When the callback returns [SQLITE_DENY], the
3738
-** [sqlite3_prepare_v3()] or equivalent call that triggered the
3738
+** [sqlite3_prepare_v2()] or equivalent call that triggered the
37393739
** authorizer will fail with an error message explaining that
37403740
** access is denied.
37413741
**
37423742
** ^The first parameter to the authorizer callback is a copy of the third
37433743
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3784,23 +3784,23 @@
37843784
** previous call.)^ ^Disable the authorizer by installing a NULL callback.
37853785
** The authorizer is disabled by default.
37863786
**
37873787
** The authorizer callback must not do anything that will modify
37883788
** the database connection that invoked the authorizer callback.
3789
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3789
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
37903790
** database connections for the meaning of "modify" in this paragraph.
37913791
**
3792
-** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
3792
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
37933793
** statement might be re-prepared during [sqlite3_step()] due to a
37943794
** schema change. Hence, the application should ensure that the
37953795
** correct authorizer callback remains in place during the [sqlite3_step()].
37963796
**
37973797
** ^Note that the authorizer callback is invoked only during
37983798
** [sqlite3_prepare()] or its variants. Authorization is not
37993799
** performed during statement evaluation in [sqlite3_step()], unless
38003800
** as stated in the previous paragraph, sqlite3_step() invokes
3801
-** sqlite3_prepare_v3() to reprepare a statement after a schema change.
3801
+** sqlite3_prepare_v2() to reprepare a statement after a schema change.
38023802
*/
38033803
SQLITE_API int sqlite3_set_authorizer(
38043804
sqlite3*,
38053805
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
38063806
void *pUserData
@@ -4032,11 +4032,11 @@
40324032
** interrupted. This feature can be used to implement a
40334033
** "Cancel" button on a GUI progress dialog box.
40344034
**
40354035
** The progress handler callback must not do anything that will modify
40364036
** the database connection that invoked the progress handler.
4037
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
4037
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
40384038
** database connections for the meaning of "modify" in this paragraph.
40394039
**
40404040
*/
40414041
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
40424042
@@ -4386,11 +4386,11 @@
43864386
** prepared statement before it can be run.
43874387
**
43884388
** The life-cycle of a prepared statement object usually goes like this:
43894389
**
43904390
** <ol>
4391
-** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
4391
+** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
43924392
** <li> Bind values to [parameters] using the sqlite3_bind_*()
43934393
** interfaces.
43944394
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
43954395
** <li> Reset the prepared statement using [sqlite3_reset()] then go back
43964396
** to step 2. Do this zero or more times.
@@ -4468,11 +4468,11 @@
44684468
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
44694469
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
44704470
**
44714471
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
44724472
** <dd>The maximum number of instructions in a virtual machine program
4473
-** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
4473
+** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
44744474
** the equivalent tries to allocate space for more than this many opcodes
44754475
** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
44764476
**
44774477
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
44784478
** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4519,17 +4519,19 @@
45194519
**
45204520
** New flags may be added in future releases of SQLite.
45214521
**
45224522
** <dl>
45234523
** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
4524
-** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
4525
-** and [sqlite3_prepare16_v3()]
4526
-** to optimize the resulting prepared statement to be retained for a
4527
-** relatively long amount of time.)^ ^Without this flag,
4528
-** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
4529
-** the prepared statement will be used just once or at most a few times
4530
-** and then destroyed using [sqlite3_finalize()] relatively soon.
4524
+** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
4525
+** that the prepared statement will be retained for a long time and
4526
+** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]
4527
+** and [sqlite3_prepare16_v3()] assume that the prepared statement will
4528
+** be used just once or at most a few times and then destroyed using
4529
+** [sqlite3_finalize()] relatively soon. The current implementation acts
4530
+** on this hint by avoiding the use of [lookaside memory] so as not to
4531
+** deplete the limited store of lookaside memory. Future versions of
4532
+** SQLite may act on this hint differently.
45314533
** </dl>
45324534
*/
45334535
#define SQLITE_PREPARE_PERSISTENT 0x01
45344536
45354537
/*
@@ -4828,11 +4830,11 @@
48284830
** CAPI3REF: Binding Values To Prepared Statements
48294831
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
48304832
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
48314833
** METHOD: sqlite3_stmt
48324834
**
4833
-** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
4835
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
48344836
** literals may be replaced by a [parameter] that matches one of following
48354837
** templates:
48364838
**
48374839
** <ul>
48384840
** <li> ?
@@ -4847,11 +4849,11 @@
48474849
** parameters (also called "host parameter names" or "SQL parameters")
48484850
** can be set using the sqlite3_bind_*() routines defined here.
48494851
**
48504852
** ^The first argument to the sqlite3_bind_*() routines is always
48514853
** a pointer to the [sqlite3_stmt] object returned from
4852
-** [sqlite3_prepare_v3()] or its variants.
4854
+** [sqlite3_prepare_v2()] or its variants.
48534855
**
48544856
** ^The second argument is the index of the SQL parameter to be set.
48554857
** ^The leftmost SQL parameter has an index of 1. ^When the same named
48564858
** SQL parameter is used more than once, second and subsequent
48574859
** occurrences have the same index as the first occurrence.
@@ -4907,10 +4909,19 @@
49074909
** (just an integer to hold its size) while it is being processed.
49084910
** Zeroblobs are intended to serve as placeholders for BLOBs whose
49094911
** content is later written using
49104912
** [sqlite3_blob_open | incremental BLOB I/O] routines.
49114913
** ^A negative value for the zeroblob results in a zero-length BLOB.
4914
+**
4915
+** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
4916
+** [prepared statement] S to have an SQL value of NULL, but to also be
4917
+** associated with the pointer P.
4918
+** ^The sqlite3_bind_pointer() routine can be used to pass
4919
+** host-language pointers into [application-defined SQL functions].
4920
+** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
4921
+** to be an ordinary SQL NULL value to everything other than
4922
+** [sqlite3_value_pointer()].
49124923
**
49134924
** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
49144925
** for the [prepared statement] or with a prepared statement for which
49154926
** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
49164927
** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -4941,10 +4952,11 @@
49414952
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
49424953
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
49434954
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
49444955
void(*)(void*), unsigned char encoding);
49454956
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
4957
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
49464958
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
49474959
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
49484960
49494961
/*
49504962
** CAPI3REF: Number Of SQL Parameters
@@ -5320,11 +5332,11 @@
53205332
** <b>Details:</b>
53215333
**
53225334
** ^These routines return information about a single column of the current
53235335
** result row of a query. ^In every case the first argument is a pointer
53245336
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5325
-** that was returned from [sqlite3_prepare_v3()] or one of its variants)
5337
+** that was returned from [sqlite3_prepare_v2()] or one of its variants)
53265338
** and the second argument is the index of the column for which information
53275339
** should be returned. ^The leftmost column of the result set has the index 0.
53285340
** ^The number of columns in the result can be determined using
53295341
** [sqlite3_column_count()].
53305342
**
@@ -5734,10 +5746,11 @@
57345746
** <blockquote><table border=0 cellpadding=0 cellspacing=0>
57355747
** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
57365748
** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
57375749
** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
57385750
** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
5751
+** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value
57395752
** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
57405753
** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
57415754
** the native byteorder
57425755
** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
57435756
** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
@@ -5753,11 +5766,11 @@
57535766
** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
57545767
** </table></blockquote>
57555768
**
57565769
** <b>Details:</b>
57575770
**
5758
-** This routine extract type, size, and content information from
5771
+** These routines extract type, size, and content information from
57595772
** [protected sqlite3_value] objects. Protected sqlite3_value objects
57605773
** are used to pass parameter information into implementation of
57615774
** [application-defined SQL functions] and [virtual tables].
57625775
**
57635776
** These routines work only with [protected sqlite3_value] objects.
@@ -5770,10 +5783,15 @@
57705783
**
57715784
** ^The sqlite3_value_text16() interface extracts a UTF-16 string
57725785
** in the native byte-order of the host machine. ^The
57735786
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
57745787
** extract UTF-16 strings as big-endian and little-endian respectively.
5788
+**
5789
+** ^If [sqlite3_value] object V was initialized
5790
+** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
5791
+** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
5792
+** sqlite3_value_pointer(V) returns a NULL.
57755793
**
57765794
** ^(The sqlite3_value_type(V) interface returns the
57775795
** [SQLITE_INTEGER | datatype code] for the initial datatype of the
57785796
** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
57795797
** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -5803,10 +5821,11 @@
58035821
*/
58045822
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
58055823
SQLITE_API double sqlite3_value_double(sqlite3_value*);
58065824
SQLITE_API int sqlite3_value_int(sqlite3_value*);
58075825
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
5826
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
58085827
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
58095828
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
58105829
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
58115830
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
58125831
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -5821,14 +5840,10 @@
58215840
** The sqlite3_value_subtype(V) function returns the subtype for
58225841
** an [application-defined SQL function] argument V. The subtype
58235842
** information can be used to pass a limited amount of context from
58245843
** one SQL function to another. Use the [sqlite3_result_subtype()]
58255844
** routine to set the subtype for the return value of an SQL function.
5826
-**
5827
-** SQLite makes no use of subtype itself. It merely passes the subtype
5828
-** from the result of one [application-defined SQL function] into the
5829
-** input of another.
58305845
*/
58315846
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
58325847
58335848
/*
58345849
** CAPI3REF: Copy And Free SQL Values
@@ -6094,11 +6109,11 @@
60946109
** assumes that the text or BLOB result is in constant space and does not
60956110
** copy the content of the parameter nor call a destructor on the content
60966111
** when it has finished using that result.
60976112
** ^If the 4th parameter to the sqlite3_result_text* interfaces
60986113
** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
6099
-** then SQLite makes a copy of the result into space obtained from
6114
+** then SQLite makes a copy of the result into space obtained
61006115
** from [sqlite3_malloc()] before it returns.
61016116
**
61026117
** ^The sqlite3_result_value() interface sets the result of
61036118
** the application-defined function to be a copy of the
61046119
** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
@@ -6106,10 +6121,18 @@
61066121
** so that the [sqlite3_value] specified in the parameter may change or
61076122
** be deallocated after sqlite3_result_value() returns without harm.
61086123
** ^A [protected sqlite3_value] object may always be used where an
61096124
** [unprotected sqlite3_value] object is required, so either
61106125
** kind of [sqlite3_value] object can be used with this interface.
6126
+**
6127
+** ^The sqlite3_result_pointer(C,P) interface sets the result to an
6128
+** SQL NULL value, just like [sqlite3_result_null(C)], except that it
6129
+** also associates the host-language pointer P with that NULL value such
6130
+** that the pointer can be retrieved within an
6131
+** [application-defined SQL function] using [sqlite3_value_pointer()].
6132
+** This mechanism can be used to pass non-SQL values between
6133
+** application-defined functions.
61116134
**
61126135
** If these routines are called from within the different thread
61136136
** than the one containing the application-defined function that received
61146137
** the [sqlite3_context] pointer, the results are undefined.
61156138
*/
@@ -6130,10 +6153,11 @@
61306153
void(*)(void*), unsigned char encoding);
61316154
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
61326155
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
61336156
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
61346157
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
6158
+SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
61356159
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
61366160
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
61376161
61386162
61396163
/*
@@ -6490,11 +6514,11 @@
64906514
**
64916515
** ^The sqlite3_db_handle interface returns the [database connection] handle
64926516
** to which a [prepared statement] belongs. ^The [database connection]
64936517
** returned by sqlite3_db_handle is the same [database connection]
64946518
** that was the first argument
6495
-** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
6519
+** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
64966520
** create the statement in the first place.
64976521
*/
64986522
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
64996523
65006524
/*
@@ -6566,11 +6590,11 @@
65666590
** the database connection that invoked the callback. Any actions
65676591
** to modify the database connection must be deferred until after the
65686592
** completion of the [sqlite3_step()] call that triggered the commit
65696593
** or rollback hook in the first place.
65706594
** Note that running any other SQL statements, including SELECT statements,
6571
-** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
6595
+** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
65726596
** the database connections for the meaning of "modify" in this paragraph.
65736597
**
65746598
** ^Registering a NULL function disables the callback.
65756599
**
65766600
** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6626,11 +6650,11 @@
66266650
**
66276651
** The update hook implementation must not do anything that will modify
66286652
** the database connection that invoked the update hook. Any actions
66296653
** to modify the database connection must be deferred until after the
66306654
** completion of the [sqlite3_step()] call that triggered the update hook.
6631
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
6655
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
66326656
** database connections for the meaning of "modify" in this paragraph.
66336657
**
66346658
** ^The sqlite3_update_hook(D,C,P) function
66356659
** returns the P argument from the previous call
66366660
** on the same [database connection] D, or NULL for
@@ -13595,28 +13619,30 @@
1359513619
typedef struct VdbeOpList VdbeOpList;
1359613620
1359713621
/*
1359813622
** Allowed values of VdbeOp.p4type
1359913623
*/
13600
-#define P4_NOTUSED 0 /* The P4 parameter is not used */
13601
-#define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
13602
-#define P4_STATIC (-2) /* Pointer to a static string */
13603
-#define P4_COLLSEQ (-3) /* P4 is a pointer to a CollSeq structure */
13604
-#define P4_FUNCDEF (-4) /* P4 is a pointer to a FuncDef structure */
13605
-#define P4_KEYINFO (-5) /* P4 is a pointer to a KeyInfo structure */
13606
-#define P4_EXPR (-6) /* P4 is a pointer to an Expr tree */
13607
-#define P4_MEM (-7) /* P4 is a pointer to a Mem* structure */
13608
-#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
13609
-#define P4_VTAB (-8) /* P4 is a pointer to an sqlite3_vtab structure */
13610
-#define P4_REAL (-9) /* P4 is a 64-bit floating point value */
13611
-#define P4_INT64 (-10) /* P4 is a 64-bit signed integer */
13612
-#define P4_INT32 (-11) /* P4 is a 32-bit signed integer */
13613
-#define P4_INTARRAY (-12) /* P4 is a vector of 32-bit integers */
13614
-#define P4_SUBPROGRAM (-13) /* P4 is a pointer to a SubProgram structure */
13615
-#define P4_ADVANCE (-14) /* P4 is a pointer to BtreeNext() or BtreePrev() */
13616
-#define P4_TABLE (-15) /* P4 is a pointer to a Table structure */
13617
-#define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
13624
+#define P4_NOTUSED 0 /* The P4 parameter is not used */
13625
+#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
13626
+#define P4_STATIC (-1) /* Pointer to a static string */
13627
+#define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
13628
+#define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
13629
+#define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
13630
+#define P4_ADVANCE (-5) /* P4 is a pointer to BtreeNext() or BtreePrev() */
13631
+#define P4_TABLE (-6) /* P4 is a pointer to a Table structure */
13632
+/* Above do not own any resources. Must free those below */
13633
+#define P4_FREE_IF_LE (-7)
13634
+#define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */
13635
+#define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */
13636
+#define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */
13637
+#define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */
13638
+#define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */
13639
+#define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */
13640
+#define P4_REAL (-13) /* P4 is a 64-bit floating point value */
13641
+#define P4_INT64 (-14) /* P4 is a 64-bit signed integer */
13642
+#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
13643
+#define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
1361813644
1361913645
/* Error message codes for OP_Halt */
1362013646
#define P5_ConstraintNotNull 1
1362113647
#define P5_ConstraintUnique 2
1362213648
#define P5_ConstraintCheck 3
@@ -18603,10 +18629,11 @@
1860318629
struct sqlite3_value {
1860418630
union MemValue {
1860518631
double r; /* Real value used when MEM_Real is set in flags */
1860618632
i64 i; /* Integer value used when MEM_Int is set in flags */
1860718633
int nZero; /* Used when bit MEM_Zero is set in flags */
18634
+ void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */
1860818635
FuncDef *pDef; /* Used only when flags==MEM_Agg */
1860918636
RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
1861018637
VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
1861118638
} u;
1861218639
u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
@@ -18888,10 +18915,11 @@
1888818915
#ifdef SQLITE_OMIT_FLOATING_POINT
1888918916
# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
1889018917
#else
1889118918
SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
1889218919
#endif
18920
+SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*);
1889318921
SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
1889418922
SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
1889518923
SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
1889618924
SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);
1889718925
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
@@ -70898,10 +70926,21 @@
7089870926
}else{
7089970927
pMem->u.i = val;
7090070928
pMem->flags = MEM_Int;
7090170929
}
7090270930
}
70931
+
70932
+/*
70933
+** Set the value stored in *pMem should already be a NULL.
70934
+** Also store a pointer to go with it.
70935
+*/
70936
+SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
70937
+ assert( pMem->flags==MEM_Null );
70938
+ pMem->flags = MEM_Null|MEM_Subtype;
70939
+ pMem->u.pPtr = pPtr;
70940
+ pMem->eSubtype = 'p';
70941
+}
7090370942
7090470943
#ifndef SQLITE_OMIT_FLOATING_POINT
7090570944
/*
7090670945
** Delete any previous value and set the value stored in *pMem to val,
7090770946
** manifest type REAL.
@@ -72796,11 +72835,11 @@
7279672835
*/
7279772836
static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){
7279872837
if( aOp ){
7279972838
Op *pOp;
7280072839
for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){
72801
- if( pOp->p4type ) freeP4(db, pOp->p4type, pOp->p4.p);
72840
+ if( pOp->p4type <= P4_FREE_IF_LE ) freeP4(db, pOp->p4type, pOp->p4.p);
7280272841
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
7280372842
sqlite3DbFree(db, pOp->zComment);
7280472843
#endif
7280572844
}
7280672845
sqlite3DbFreeNN(db, aOp);
@@ -76801,10 +76840,18 @@
7680176840
return sqlite3VdbeIntValue((Mem*)pVal);
7680276841
}
7680376842
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
7680476843
Mem *pMem = (Mem*)pVal;
7680576844
return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
76845
+}
76846
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal){
76847
+ Mem *p = (Mem*)pVal;
76848
+ if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
76849
+ return p->u.pPtr;
76850
+ }else{
76851
+ return 0;
76852
+ }
7680676853
}
7680776854
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
7680876855
return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
7680976856
}
7681076857
#ifndef SQLITE_OMIT_UTF16
@@ -76979,10 +77026,16 @@
7697977026
sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
7698077027
}
7698177028
SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
7698277029
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
7698377030
sqlite3VdbeMemSetNull(pCtx->pOut);
77031
+}
77032
+SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
77033
+ Mem *pOut = pCtx->pOut;
77034
+ assert( sqlite3_mutex_held(pOut->db->mutex) );
77035
+ sqlite3VdbeMemSetNull(pOut);
77036
+ sqlite3VdbeMemSetPointer(pOut, pPtr);
7698477037
}
7698577038
SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
7698677039
Mem *pOut = pCtx->pOut;
7698777040
assert( sqlite3_mutex_held(pOut->db->mutex) );
7698877041
pOut->eSubtype = eSubtype & 0xff;
@@ -77982,10 +78035,20 @@
7798278035
rc = vdbeUnbind(p, i);
7798378036
if( rc==SQLITE_OK ){
7798478037
sqlite3_mutex_leave(p->db->mutex);
7798578038
}
7798678039
return rc;
78040
+}
78041
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
78042
+ int rc;
78043
+ Vdbe *p = (Vdbe*)pStmt;
78044
+ rc = vdbeUnbind(p, i);
78045
+ if( rc==SQLITE_OK ){
78046
+ sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
78047
+ sqlite3_mutex_leave(p->db->mutex);
78048
+ }
78049
+ return rc;
7798778050
}
7798878051
SQLITE_API int sqlite3_bind_text(
7798978052
sqlite3_stmt *pStmt,
7799078053
int i,
7799178054
const char *zData,
@@ -106211,10 +106274,14 @@
106211106274
assert( SQLITE_INTEGER==1 );
106212106275
assert( SQLITE_FLOAT==2 );
106213106276
assert( SQLITE_TEXT==3 );
106214106277
assert( SQLITE_BLOB==4 );
106215106278
assert( SQLITE_NULL==5 );
106279
+ /* EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns
106280
+ ** the datatype code for the initial datatype of the sqlite3_value object
106281
+ ** V. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT,
106282
+ ** SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */
106216106283
sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
106217106284
}
106218106285
106219106286
106220106287
/*
@@ -112140,10 +112207,13 @@
112140112207
/* Version 3.20.0 and later */
112141112208
int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
112142112209
sqlite3_stmt**,const char**);
112143112210
int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
112144112211
sqlite3_stmt**,const void**);
112212
+ int (*bind_pointer)(sqlite3_stmt*,int,void*);
112213
+ void (*result_pointer)(sqlite3_context*,void*);
112214
+ void *(*value_pointer)(sqlite3_value*);
112145112215
};
112146112216
112147112217
/*
112148112218
** This is the function signature used for all extension entry points. It
112149112219
** is also defined in the file "loadext.c".
@@ -112403,10 +112473,13 @@
112403112473
/* Version 3.18.0 and later */
112404112474
#define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
112405112475
/* Version 3.20.0 and later */
112406112476
#define sqlite3_prepare_v3 sqlite3_api->prepare_v3
112407112477
#define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
112478
+#define sqlite3_bind_pointer sqlite3_api->bind_pointer
112479
+#define sqlite3_result_pointer sqlite3_api->result_pointer
112480
+#define sqlite3_value_pointer sqlite3_api->value_pointer
112408112481
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
112409112482
112410112483
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
112411112484
/* This case when the file really is being compiled as a loadable
112412112485
** extension */
@@ -112834,11 +112907,14 @@
112834112907
sqlite3_expanded_sql,
112835112908
/* Version 3.18.0 and later */
112836112909
sqlite3_set_last_insert_rowid,
112837112910
/* Version 3.20.0 and later */
112838112911
sqlite3_prepare_v3,
112839
- sqlite3_prepare16_v3
112912
+ sqlite3_prepare16_v3,
112913
+ sqlite3_bind_pointer,
112914
+ sqlite3_result_pointer,
112915
+ sqlite3_value_pointer
112840112916
};
112841112917
112842112918
/*
112843112919
** Attempt to load an SQLite extension library contained in the file
112844112920
** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -117102,13 +117178,18 @@
117102117178
int nBytes, /* Length of zSql in bytes. */
117103117179
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117104117180
const char **pzTail /* OUT: End of parsed string */
117105117181
){
117106117182
int rc;
117183
+ /* EVIDENCE-OF: R-37923-12173 The sqlite3_prepare_v2() interface works
117184
+ ** exactly the same as sqlite3_prepare_v3() with a zero prepFlags
117185
+ ** parameter.
117186
+ **
117187
+ ** Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 */
117107117188
rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
117108117189
ppStmt,pzTail);
117109
- assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117190
+ assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );
117110117191
return rc;
117111117192
}
117112117193
SQLITE_API int sqlite3_prepare_v3(
117113117194
sqlite3 *db, /* Database handle. */
117114117195
const char *zSql, /* UTF-8 encoded SQL statement. */
@@ -117116,14 +117197,21 @@
117116117197
unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
117117117198
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117118117199
const char **pzTail /* OUT: End of parsed string */
117119117200
){
117120117201
int rc;
117202
+ /* EVIDENCE-OF: R-56861-42673 sqlite3_prepare_v3() differs from
117203
+ ** sqlite3_prepare_v2() only in having the extra prepFlags parameter,
117204
+ ** which is a bit array consisting of zero or more of the
117205
+ ** SQLITE_PREPARE_* flags.
117206
+ **
117207
+ ** Proof by comparison to the implementation of sqlite3_prepare_v2()
117208
+ ** directly above. */
117121117209
rc = sqlite3LockAndPrepare(db,zSql,nBytes,
117122117210
SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
117123117211
0,ppStmt,pzTail);
117124
- assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117212
+ assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );
117125117213
return rc;
117126117214
}
117127117215
117128117216
117129117217
#ifndef SQLITE_OMIT_UTF16
@@ -142215,10 +142303,12 @@
142215142303
va_list ap;
142216142304
int rc;
142217142305
va_start(ap, op);
142218142306
switch( op ){
142219142307
case SQLITE_DBCONFIG_MAINDBNAME: {
142308
+ /* IMP: R-06824-28531 */
142309
+ /* IMP: R-36257-52125 */
142220142310
db->aDb[0].zDbSName = va_arg(ap,char*);
142221142311
rc = SQLITE_OK;
142222142312
break;
142223142313
}
142224142314
case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -150188,12 +150278,11 @@
150188150278
assert( iCol>=0 && iCol<=p->nColumn+2 );
150189150279
150190150280
switch( iCol-p->nColumn ){
150191150281
case 0:
150192150282
/* The special 'table-name' column */
150193
- sqlite3_result_blob(pCtx, &pCsr, sizeof(Fts3Cursor*), SQLITE_TRANSIENT);
150194
- sqlite3_result_subtype(pCtx, SQLITE_BLOB);
150283
+ sqlite3_result_pointer(pCtx, pCsr);
150195150284
break;
150196150285
150197150286
case 1:
150198150287
/* The docid column */
150199150288
sqlite3_result_int64(pCtx, pCsr->iPrevId);
@@ -150407,13 +150496,14 @@
150407150496
sqlite3_context *pContext, /* SQL function call context */
150408150497
const char *zFunc, /* Function name */
150409150498
sqlite3_value *pVal, /* argv[0] passed to function */
150410150499
Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
150411150500
){
150412
- int rc = SQLITE_OK;
150413
- if( sqlite3_value_subtype(pVal)==SQLITE_BLOB ){
150414
- *ppCsr = *(Fts3Cursor**)sqlite3_value_blob(pVal);
150501
+ int rc;
150502
+ *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal);
150503
+ if( (*ppCsr)!=0 ){
150504
+ rc = SQLITE_OK;
150415150505
}else{
150416150506
char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
150417150507
sqlite3_result_error(pContext, zErr, -1);
150418150508
sqlite3_free(zErr);
150419150509
rc = SQLITE_ERROR;
@@ -200127,11 +200217,11 @@
200127200217
int nArg, /* Number of args */
200128200218
sqlite3_value **apUnused /* Function arguments */
200129200219
){
200130200220
assert( nArg==0 );
200131200221
UNUSED_PARAM2(nArg, apUnused);
200132
- sqlite3_result_text(pCtx, "fts5: 2017-07-12 18:05:54 604c11d1a39f09e47b6fcee0f8b1c1054f9dbbc7b2c1cf93312aeaa4b7095018", -1, SQLITE_TRANSIENT);
200222
+ sqlite3_result_text(pCtx, "fts5: 2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6", -1, SQLITE_TRANSIENT);
200133200223
}
200134200224
200135200225
static int fts5Init(sqlite3 *db){
200136200226
static const sqlite3_module fts5Mod = {
200137200227
/* iVersion */ 2,
@@ -204014,27 +204104,10 @@
204014204104
SQLITE_EXTENSION_INIT1
204015204105
/* #include <assert.h> */
204016204106
/* #include <string.h> */
204017204107
204018204108
#ifndef SQLITE_OMIT_VIRTUALTABLE
204019
-
204020
-/*
204021
-** The following macros are used to cast pointers to integers.
204022
-** The way you do this varies from one compiler
204023
-** to the next, so we have developed the following set of #if statements
204024
-** to generate appropriate macros for a wide range of compilers.
204025
-*/
204026
-#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
204027
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))
204028
-#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
204029
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(((char*)X)-(char*)0))
204030
-#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
204031
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(intptr_t)(X))
204032
-#else /* Generates a warning - but it always works */
204033
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(X))
204034
-#endif
204035
-
204036204109
204037204110
/* stmt_vtab is a subclass of sqlite3_vtab which will
204038204111
** serve as the underlying representation of a stmt virtual table
204039204112
*/
204040204113
typedef struct stmt_vtab stmt_vtab;
@@ -204077,26 +204150,25 @@
204077204150
){
204078204151
stmt_vtab *pNew;
204079204152
int rc;
204080204153
204081204154
/* Column numbers */
204082
-#define STMT_COLUMN_PTR 0 /* Numeric value of the statement pointer */
204083
-#define STMT_COLUMN_SQL 1 /* SQL for the statement */
204084
-#define STMT_COLUMN_NCOL 2 /* Number of result columns */
204085
-#define STMT_COLUMN_RO 3 /* True if read-only */
204086
-#define STMT_COLUMN_BUSY 4 /* True if currently busy */
204087
-#define STMT_COLUMN_NSCAN 5 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
204088
-#define STMT_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */
204089
-#define STMT_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */
204090
-#define STMT_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */
204091
-#define STMT_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */
204092
-#define STMT_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */
204093
-#define STMT_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */
204155
+#define STMT_COLUMN_SQL 0 /* SQL for the statement */
204156
+#define STMT_COLUMN_NCOL 1 /* Number of result columns */
204157
+#define STMT_COLUMN_RO 2 /* True if read-only */
204158
+#define STMT_COLUMN_BUSY 3 /* True if currently busy */
204159
+#define STMT_COLUMN_NSCAN 4 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
204160
+#define STMT_COLUMN_NSORT 5 /* SQLITE_STMTSTATUS_SORT */
204161
+#define STMT_COLUMN_NAIDX 6 /* SQLITE_STMTSTATUS_AUTOINDEX */
204162
+#define STMT_COLUMN_NSTEP 7 /* SQLITE_STMTSTATUS_VM_STEP */
204163
+#define STMT_COLUMN_REPREP 8 /* SQLITE_STMTSTATUS_REPREPARE */
204164
+#define STMT_COLUMN_RUN 9 /* SQLITE_STMTSTATUS_RUN */
204165
+#define STMT_COLUMN_MEM 10 /* SQLITE_STMTSTATUS_MEMUSED */
204094204166
204095204167
204096204168
rc = sqlite3_declare_vtab(db,
204097
- "CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
204169
+ "CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
204098204170
"reprep,run,mem)");
204099204171
if( rc==SQLITE_OK ){
204100204172
pNew = sqlite3_malloc( sizeof(*pNew) );
204101204173
*ppVtab = (sqlite3_vtab*)pNew;
204102204174
if( pNew==0 ) return SQLITE_NOMEM;
@@ -204155,14 +204227,10 @@
204155204227
sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
204156204228
int i /* Which column to return */
204157204229
){
204158204230
stmt_cursor *pCur = (stmt_cursor*)cur;
204159204231
switch( i ){
204160
- case STMT_COLUMN_PTR: {
204161
- sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt));
204162
- break;
204163
- }
204164204232
case STMT_COLUMN_SQL: {
204165204233
sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
204166204234
break;
204167204235
}
204168204236
case STMT_COLUMN_NCOL: {
@@ -204280,11 +204348,11 @@
204280204348
#endif /* SQLITE_OMIT_VIRTUALTABLE */
204281204349
204282204350
SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
204283204351
int rc = SQLITE_OK;
204284204352
#ifndef SQLITE_OMIT_VIRTUALTABLE
204285
- rc = sqlite3_create_module(db, "stmt", &stmtModule, 0);
204353
+ rc = sqlite3_create_module(db, "sqlite_stmt", &stmtModule, 0);
204286204354
#endif
204287204355
return rc;
204288204356
}
204289204357
204290204358
#ifndef SQLITE_CORE
204291204359
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1150,11 +1150,11 @@
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.20.0"
1154 #define SQLITE_VERSION_NUMBER 3020000
1155 #define SQLITE_SOURCE_ID "2017-07-12 18:05:54 604c11d1a39f09e47b6fcee0f8b1c1054f9dbbc7b2c1cf93312aeaa4b7095018"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1262,11 +1262,11 @@
1262 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
1263 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
1264 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
1265 ** and [sqlite3_close_v2()] are its destructors. There are many other
1266 ** interfaces (such as
1267 ** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
1268 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
1269 ** sqlite3 object.
1270 */
1271 typedef struct sqlite3 sqlite3;
1272
@@ -1366,11 +1366,11 @@
1366 /*
1367 ** CAPI3REF: One-Step Query Execution Interface
1368 ** METHOD: sqlite3
1369 **
1370 ** The sqlite3_exec() interface is a convenience wrapper around
1371 ** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
1372 ** that allows an application to run multiple statements of SQL
1373 ** without having to use a lot of C code.
1374 **
1375 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
1376 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3035,14 +3035,14 @@
3035 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
3036 ** have been disabled - 0 if they are not disabled, 1 if they are.
3037 ** </dd>
3038 **
3039 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3040 ** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3041 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3042 ** a single SQL query statement will always use the same algorithm regardless
3043 ** of values of [bound parameters]. The QPSG disables some query optimizations
3044 ** that look at the values of bound parameters, which can make some queries
3045 ** slower. But the QPSG has the advantage of more predictable behavior. With
3046 ** the QPSG active, SQLite will always use the same query plan in the field as
3047 ** was used during testing in the lab.
3048 ** </dd>
@@ -3728,16 +3728,16 @@
3728 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
3729 ** specific action but allow the SQL statement to continue to be
3730 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
3731 ** rejected with an error. ^If the authorizer callback returns
3732 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3733 ** then the [sqlite3_prepare_v3()] or equivalent call that triggered
3734 ** the authorizer will fail with an error message.
3735 **
3736 ** When the callback returns [SQLITE_OK], that means the operation
3737 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
3738 ** [sqlite3_prepare_v3()] or equivalent call that triggered the
3739 ** authorizer will fail with an error message explaining that
3740 ** access is denied.
3741 **
3742 ** ^The first parameter to the authorizer callback is a copy of the third
3743 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3784,23 +3784,23 @@
3784 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
3785 ** The authorizer is disabled by default.
3786 **
3787 ** The authorizer callback must not do anything that will modify
3788 ** the database connection that invoked the authorizer callback.
3789 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3790 ** database connections for the meaning of "modify" in this paragraph.
3791 **
3792 ** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
3793 ** statement might be re-prepared during [sqlite3_step()] due to a
3794 ** schema change. Hence, the application should ensure that the
3795 ** correct authorizer callback remains in place during the [sqlite3_step()].
3796 **
3797 ** ^Note that the authorizer callback is invoked only during
3798 ** [sqlite3_prepare()] or its variants. Authorization is not
3799 ** performed during statement evaluation in [sqlite3_step()], unless
3800 ** as stated in the previous paragraph, sqlite3_step() invokes
3801 ** sqlite3_prepare_v3() to reprepare a statement after a schema change.
3802 */
3803 SQLITE_API int sqlite3_set_authorizer(
3804 sqlite3*,
3805 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
3806 void *pUserData
@@ -4032,11 +4032,11 @@
4032 ** interrupted. This feature can be used to implement a
4033 ** "Cancel" button on a GUI progress dialog box.
4034 **
4035 ** The progress handler callback must not do anything that will modify
4036 ** the database connection that invoked the progress handler.
4037 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
4038 ** database connections for the meaning of "modify" in this paragraph.
4039 **
4040 */
4041 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
4042
@@ -4386,11 +4386,11 @@
4386 ** prepared statement before it can be run.
4387 **
4388 ** The life-cycle of a prepared statement object usually goes like this:
4389 **
4390 ** <ol>
4391 ** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
4392 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
4393 ** interfaces.
4394 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
4395 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
4396 ** to step 2. Do this zero or more times.
@@ -4468,11 +4468,11 @@
4468 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4469 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
4470 **
4471 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
4472 ** <dd>The maximum number of instructions in a virtual machine program
4473 ** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
4474 ** the equivalent tries to allocate space for more than this many opcodes
4475 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
4476 **
4477 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
4478 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4519,17 +4519,19 @@
4519 **
4520 ** New flags may be added in future releases of SQLite.
4521 **
4522 ** <dl>
4523 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
4524 ** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
4525 ** and [sqlite3_prepare16_v3()]
4526 ** to optimize the resulting prepared statement to be retained for a
4527 ** relatively long amount of time.)^ ^Without this flag,
4528 ** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
4529 ** the prepared statement will be used just once or at most a few times
4530 ** and then destroyed using [sqlite3_finalize()] relatively soon.
 
 
4531 ** </dl>
4532 */
4533 #define SQLITE_PREPARE_PERSISTENT 0x01
4534
4535 /*
@@ -4828,11 +4830,11 @@
4828 ** CAPI3REF: Binding Values To Prepared Statements
4829 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
4830 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
4831 ** METHOD: sqlite3_stmt
4832 **
4833 ** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
4834 ** literals may be replaced by a [parameter] that matches one of following
4835 ** templates:
4836 **
4837 ** <ul>
4838 ** <li> ?
@@ -4847,11 +4849,11 @@
4847 ** parameters (also called "host parameter names" or "SQL parameters")
4848 ** can be set using the sqlite3_bind_*() routines defined here.
4849 **
4850 ** ^The first argument to the sqlite3_bind_*() routines is always
4851 ** a pointer to the [sqlite3_stmt] object returned from
4852 ** [sqlite3_prepare_v3()] or its variants.
4853 **
4854 ** ^The second argument is the index of the SQL parameter to be set.
4855 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
4856 ** SQL parameter is used more than once, second and subsequent
4857 ** occurrences have the same index as the first occurrence.
@@ -4907,10 +4909,19 @@
4907 ** (just an integer to hold its size) while it is being processed.
4908 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
4909 ** content is later written using
4910 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
4911 ** ^A negative value for the zeroblob results in a zero-length BLOB.
 
 
 
 
 
 
 
 
 
4912 **
4913 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
4914 ** for the [prepared statement] or with a prepared statement for which
4915 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
4916 ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -4941,10 +4952,11 @@
4941 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
4942 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
4943 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
4944 void(*)(void*), unsigned char encoding);
4945 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
 
4946 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
4947 SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
4948
4949 /*
4950 ** CAPI3REF: Number Of SQL Parameters
@@ -5320,11 +5332,11 @@
5320 ** <b>Details:</b>
5321 **
5322 ** ^These routines return information about a single column of the current
5323 ** result row of a query. ^In every case the first argument is a pointer
5324 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5325 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
5326 ** and the second argument is the index of the column for which information
5327 ** should be returned. ^The leftmost column of the result set has the index 0.
5328 ** ^The number of columns in the result can be determined using
5329 ** [sqlite3_column_count()].
5330 **
@@ -5734,10 +5746,11 @@
5734 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5735 ** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
5736 ** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
5737 ** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
5738 ** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
 
5739 ** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
5740 ** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
5741 ** the native byteorder
5742 ** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
5743 ** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
@@ -5753,11 +5766,11 @@
5753 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
5754 ** </table></blockquote>
5755 **
5756 ** <b>Details:</b>
5757 **
5758 ** This routine extract type, size, and content information from
5759 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
5760 ** are used to pass parameter information into implementation of
5761 ** [application-defined SQL functions] and [virtual tables].
5762 **
5763 ** These routines work only with [protected sqlite3_value] objects.
@@ -5770,10 +5783,15 @@
5770 **
5771 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
5772 ** in the native byte-order of the host machine. ^The
5773 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
5774 ** extract UTF-16 strings as big-endian and little-endian respectively.
 
 
 
 
 
5775 **
5776 ** ^(The sqlite3_value_type(V) interface returns the
5777 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
5778 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
5779 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -5803,10 +5821,11 @@
5803 */
5804 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5805 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5806 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5807 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
 
5808 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
5809 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
5810 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
5811 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
5812 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -5821,14 +5840,10 @@
5821 ** The sqlite3_value_subtype(V) function returns the subtype for
5822 ** an [application-defined SQL function] argument V. The subtype
5823 ** information can be used to pass a limited amount of context from
5824 ** one SQL function to another. Use the [sqlite3_result_subtype()]
5825 ** routine to set the subtype for the return value of an SQL function.
5826 **
5827 ** SQLite makes no use of subtype itself. It merely passes the subtype
5828 ** from the result of one [application-defined SQL function] into the
5829 ** input of another.
5830 */
5831 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
5832
5833 /*
5834 ** CAPI3REF: Copy And Free SQL Values
@@ -6094,11 +6109,11 @@
6094 ** assumes that the text or BLOB result is in constant space and does not
6095 ** copy the content of the parameter nor call a destructor on the content
6096 ** when it has finished using that result.
6097 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
6098 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
6099 ** then SQLite makes a copy of the result into space obtained from
6100 ** from [sqlite3_malloc()] before it returns.
6101 **
6102 ** ^The sqlite3_result_value() interface sets the result of
6103 ** the application-defined function to be a copy of the
6104 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
@@ -6106,10 +6121,18 @@
6106 ** so that the [sqlite3_value] specified in the parameter may change or
6107 ** be deallocated after sqlite3_result_value() returns without harm.
6108 ** ^A [protected sqlite3_value] object may always be used where an
6109 ** [unprotected sqlite3_value] object is required, so either
6110 ** kind of [sqlite3_value] object can be used with this interface.
 
 
 
 
 
 
 
 
6111 **
6112 ** If these routines are called from within the different thread
6113 ** than the one containing the application-defined function that received
6114 ** the [sqlite3_context] pointer, the results are undefined.
6115 */
@@ -6130,10 +6153,11 @@
6130 void(*)(void*), unsigned char encoding);
6131 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
6132 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
6133 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
6134 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
 
6135 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
6136 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
6137
6138
6139 /*
@@ -6490,11 +6514,11 @@
6490 **
6491 ** ^The sqlite3_db_handle interface returns the [database connection] handle
6492 ** to which a [prepared statement] belongs. ^The [database connection]
6493 ** returned by sqlite3_db_handle is the same [database connection]
6494 ** that was the first argument
6495 ** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
6496 ** create the statement in the first place.
6497 */
6498 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
6499
6500 /*
@@ -6566,11 +6590,11 @@
6566 ** the database connection that invoked the callback. Any actions
6567 ** to modify the database connection must be deferred until after the
6568 ** completion of the [sqlite3_step()] call that triggered the commit
6569 ** or rollback hook in the first place.
6570 ** Note that running any other SQL statements, including SELECT statements,
6571 ** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
6572 ** the database connections for the meaning of "modify" in this paragraph.
6573 **
6574 ** ^Registering a NULL function disables the callback.
6575 **
6576 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6626,11 +6650,11 @@
6626 **
6627 ** The update hook implementation must not do anything that will modify
6628 ** the database connection that invoked the update hook. Any actions
6629 ** to modify the database connection must be deferred until after the
6630 ** completion of the [sqlite3_step()] call that triggered the update hook.
6631 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
6632 ** database connections for the meaning of "modify" in this paragraph.
6633 **
6634 ** ^The sqlite3_update_hook(D,C,P) function
6635 ** returns the P argument from the previous call
6636 ** on the same [database connection] D, or NULL for
@@ -13595,28 +13619,30 @@
13595 typedef struct VdbeOpList VdbeOpList;
13596
13597 /*
13598 ** Allowed values of VdbeOp.p4type
13599 */
13600 #define P4_NOTUSED 0 /* The P4 parameter is not used */
13601 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
13602 #define P4_STATIC (-2) /* Pointer to a static string */
13603 #define P4_COLLSEQ (-3) /* P4 is a pointer to a CollSeq structure */
13604 #define P4_FUNCDEF (-4) /* P4 is a pointer to a FuncDef structure */
13605 #define P4_KEYINFO (-5) /* P4 is a pointer to a KeyInfo structure */
13606 #define P4_EXPR (-6) /* P4 is a pointer to an Expr tree */
13607 #define P4_MEM (-7) /* P4 is a pointer to a Mem* structure */
13608 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
13609 #define P4_VTAB (-8) /* P4 is a pointer to an sqlite3_vtab structure */
13610 #define P4_REAL (-9) /* P4 is a 64-bit floating point value */
13611 #define P4_INT64 (-10) /* P4 is a 64-bit signed integer */
13612 #define P4_INT32 (-11) /* P4 is a 32-bit signed integer */
13613 #define P4_INTARRAY (-12) /* P4 is a vector of 32-bit integers */
13614 #define P4_SUBPROGRAM (-13) /* P4 is a pointer to a SubProgram structure */
13615 #define P4_ADVANCE (-14) /* P4 is a pointer to BtreeNext() or BtreePrev() */
13616 #define P4_TABLE (-15) /* P4 is a pointer to a Table structure */
13617 #define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
 
 
13618
13619 /* Error message codes for OP_Halt */
13620 #define P5_ConstraintNotNull 1
13621 #define P5_ConstraintUnique 2
13622 #define P5_ConstraintCheck 3
@@ -18603,10 +18629,11 @@
18603 struct sqlite3_value {
18604 union MemValue {
18605 double r; /* Real value used when MEM_Real is set in flags */
18606 i64 i; /* Integer value used when MEM_Int is set in flags */
18607 int nZero; /* Used when bit MEM_Zero is set in flags */
 
18608 FuncDef *pDef; /* Used only when flags==MEM_Agg */
18609 RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
18610 VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
18611 } u;
18612 u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
@@ -18888,10 +18915,11 @@
18888 #ifdef SQLITE_OMIT_FLOATING_POINT
18889 # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
18890 #else
18891 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
18892 #endif
 
18893 SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
18894 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
18895 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
18896 SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);
18897 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
@@ -70898,10 +70926,21 @@
70898 }else{
70899 pMem->u.i = val;
70900 pMem->flags = MEM_Int;
70901 }
70902 }
 
 
 
 
 
 
 
 
 
 
 
70903
70904 #ifndef SQLITE_OMIT_FLOATING_POINT
70905 /*
70906 ** Delete any previous value and set the value stored in *pMem to val,
70907 ** manifest type REAL.
@@ -72796,11 +72835,11 @@
72796 */
72797 static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){
72798 if( aOp ){
72799 Op *pOp;
72800 for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){
72801 if( pOp->p4type ) freeP4(db, pOp->p4type, pOp->p4.p);
72802 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
72803 sqlite3DbFree(db, pOp->zComment);
72804 #endif
72805 }
72806 sqlite3DbFreeNN(db, aOp);
@@ -76801,10 +76840,18 @@
76801 return sqlite3VdbeIntValue((Mem*)pVal);
76802 }
76803 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
76804 Mem *pMem = (Mem*)pVal;
76805 return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
 
 
 
 
 
 
 
 
76806 }
76807 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
76808 return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
76809 }
76810 #ifndef SQLITE_OMIT_UTF16
@@ -76979,10 +77026,16 @@
76979 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
76980 }
76981 SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
76982 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
76983 sqlite3VdbeMemSetNull(pCtx->pOut);
 
 
 
 
 
 
76984 }
76985 SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
76986 Mem *pOut = pCtx->pOut;
76987 assert( sqlite3_mutex_held(pOut->db->mutex) );
76988 pOut->eSubtype = eSubtype & 0xff;
@@ -77982,10 +78035,20 @@
77982 rc = vdbeUnbind(p, i);
77983 if( rc==SQLITE_OK ){
77984 sqlite3_mutex_leave(p->db->mutex);
77985 }
77986 return rc;
 
 
 
 
 
 
 
 
 
 
77987 }
77988 SQLITE_API int sqlite3_bind_text(
77989 sqlite3_stmt *pStmt,
77990 int i,
77991 const char *zData,
@@ -106211,10 +106274,14 @@
106211 assert( SQLITE_INTEGER==1 );
106212 assert( SQLITE_FLOAT==2 );
106213 assert( SQLITE_TEXT==3 );
106214 assert( SQLITE_BLOB==4 );
106215 assert( SQLITE_NULL==5 );
 
 
 
 
106216 sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
106217 }
106218
106219
106220 /*
@@ -112140,10 +112207,13 @@
112140 /* Version 3.20.0 and later */
112141 int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
112142 sqlite3_stmt**,const char**);
112143 int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
112144 sqlite3_stmt**,const void**);
 
 
 
112145 };
112146
112147 /*
112148 ** This is the function signature used for all extension entry points. It
112149 ** is also defined in the file "loadext.c".
@@ -112403,10 +112473,13 @@
112403 /* Version 3.18.0 and later */
112404 #define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
112405 /* Version 3.20.0 and later */
112406 #define sqlite3_prepare_v3 sqlite3_api->prepare_v3
112407 #define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
 
 
 
112408 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
112409
112410 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
112411 /* This case when the file really is being compiled as a loadable
112412 ** extension */
@@ -112834,11 +112907,14 @@
112834 sqlite3_expanded_sql,
112835 /* Version 3.18.0 and later */
112836 sqlite3_set_last_insert_rowid,
112837 /* Version 3.20.0 and later */
112838 sqlite3_prepare_v3,
112839 sqlite3_prepare16_v3
 
 
 
112840 };
112841
112842 /*
112843 ** Attempt to load an SQLite extension library contained in the file
112844 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -117102,13 +117178,18 @@
117102 int nBytes, /* Length of zSql in bytes. */
117103 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117104 const char **pzTail /* OUT: End of parsed string */
117105 ){
117106 int rc;
 
 
 
 
 
117107 rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
117108 ppStmt,pzTail);
117109 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117110 return rc;
117111 }
117112 SQLITE_API int sqlite3_prepare_v3(
117113 sqlite3 *db, /* Database handle. */
117114 const char *zSql, /* UTF-8 encoded SQL statement. */
@@ -117116,14 +117197,21 @@
117116 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
117117 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117118 const char **pzTail /* OUT: End of parsed string */
117119 ){
117120 int rc;
 
 
 
 
 
 
 
117121 rc = sqlite3LockAndPrepare(db,zSql,nBytes,
117122 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
117123 0,ppStmt,pzTail);
117124 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117125 return rc;
117126 }
117127
117128
117129 #ifndef SQLITE_OMIT_UTF16
@@ -142215,10 +142303,12 @@
142215 va_list ap;
142216 int rc;
142217 va_start(ap, op);
142218 switch( op ){
142219 case SQLITE_DBCONFIG_MAINDBNAME: {
 
 
142220 db->aDb[0].zDbSName = va_arg(ap,char*);
142221 rc = SQLITE_OK;
142222 break;
142223 }
142224 case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -150188,12 +150278,11 @@
150188 assert( iCol>=0 && iCol<=p->nColumn+2 );
150189
150190 switch( iCol-p->nColumn ){
150191 case 0:
150192 /* The special 'table-name' column */
150193 sqlite3_result_blob(pCtx, &pCsr, sizeof(Fts3Cursor*), SQLITE_TRANSIENT);
150194 sqlite3_result_subtype(pCtx, SQLITE_BLOB);
150195 break;
150196
150197 case 1:
150198 /* The docid column */
150199 sqlite3_result_int64(pCtx, pCsr->iPrevId);
@@ -150407,13 +150496,14 @@
150407 sqlite3_context *pContext, /* SQL function call context */
150408 const char *zFunc, /* Function name */
150409 sqlite3_value *pVal, /* argv[0] passed to function */
150410 Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
150411 ){
150412 int rc = SQLITE_OK;
150413 if( sqlite3_value_subtype(pVal)==SQLITE_BLOB ){
150414 *ppCsr = *(Fts3Cursor**)sqlite3_value_blob(pVal);
 
150415 }else{
150416 char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
150417 sqlite3_result_error(pContext, zErr, -1);
150418 sqlite3_free(zErr);
150419 rc = SQLITE_ERROR;
@@ -200127,11 +200217,11 @@
200127 int nArg, /* Number of args */
200128 sqlite3_value **apUnused /* Function arguments */
200129 ){
200130 assert( nArg==0 );
200131 UNUSED_PARAM2(nArg, apUnused);
200132 sqlite3_result_text(pCtx, "fts5: 2017-07-12 18:05:54 604c11d1a39f09e47b6fcee0f8b1c1054f9dbbc7b2c1cf93312aeaa4b7095018", -1, SQLITE_TRANSIENT);
200133 }
200134
200135 static int fts5Init(sqlite3 *db){
200136 static const sqlite3_module fts5Mod = {
200137 /* iVersion */ 2,
@@ -204014,27 +204104,10 @@
204014 SQLITE_EXTENSION_INIT1
204015 /* #include <assert.h> */
204016 /* #include <string.h> */
204017
204018 #ifndef SQLITE_OMIT_VIRTUALTABLE
204019
204020 /*
204021 ** The following macros are used to cast pointers to integers.
204022 ** The way you do this varies from one compiler
204023 ** to the next, so we have developed the following set of #if statements
204024 ** to generate appropriate macros for a wide range of compilers.
204025 */
204026 #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
204027 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))
204028 #elif !defined(__GNUC__) /* Works for compilers other than LLVM */
204029 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(((char*)X)-(char*)0))
204030 #elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
204031 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(intptr_t)(X))
204032 #else /* Generates a warning - but it always works */
204033 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(X))
204034 #endif
204035
204036
204037 /* stmt_vtab is a subclass of sqlite3_vtab which will
204038 ** serve as the underlying representation of a stmt virtual table
204039 */
204040 typedef struct stmt_vtab stmt_vtab;
@@ -204077,26 +204150,25 @@
204077 ){
204078 stmt_vtab *pNew;
204079 int rc;
204080
204081 /* Column numbers */
204082 #define STMT_COLUMN_PTR 0 /* Numeric value of the statement pointer */
204083 #define STMT_COLUMN_SQL 1 /* SQL for the statement */
204084 #define STMT_COLUMN_NCOL 2 /* Number of result columns */
204085 #define STMT_COLUMN_RO 3 /* True if read-only */
204086 #define STMT_COLUMN_BUSY 4 /* True if currently busy */
204087 #define STMT_COLUMN_NSCAN 5 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
204088 #define STMT_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */
204089 #define STMT_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */
204090 #define STMT_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */
204091 #define STMT_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */
204092 #define STMT_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */
204093 #define STMT_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */
204094
204095
204096 rc = sqlite3_declare_vtab(db,
204097 "CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
204098 "reprep,run,mem)");
204099 if( rc==SQLITE_OK ){
204100 pNew = sqlite3_malloc( sizeof(*pNew) );
204101 *ppVtab = (sqlite3_vtab*)pNew;
204102 if( pNew==0 ) return SQLITE_NOMEM;
@@ -204155,14 +204227,10 @@
204155 sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
204156 int i /* Which column to return */
204157 ){
204158 stmt_cursor *pCur = (stmt_cursor*)cur;
204159 switch( i ){
204160 case STMT_COLUMN_PTR: {
204161 sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt));
204162 break;
204163 }
204164 case STMT_COLUMN_SQL: {
204165 sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
204166 break;
204167 }
204168 case STMT_COLUMN_NCOL: {
@@ -204280,11 +204348,11 @@
204280 #endif /* SQLITE_OMIT_VIRTUALTABLE */
204281
204282 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
204283 int rc = SQLITE_OK;
204284 #ifndef SQLITE_OMIT_VIRTUALTABLE
204285 rc = sqlite3_create_module(db, "stmt", &stmtModule, 0);
204286 #endif
204287 return rc;
204288 }
204289
204290 #ifndef SQLITE_CORE
204291
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1150,11 +1150,11 @@
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.20.0"
1154 #define SQLITE_VERSION_NUMBER 3020000
1155 #define SQLITE_SOURCE_ID "2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1262,11 +1262,11 @@
1262 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
1263 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
1264 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
1265 ** and [sqlite3_close_v2()] are its destructors. There are many other
1266 ** interfaces (such as
1267 ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
1268 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
1269 ** sqlite3 object.
1270 */
1271 typedef struct sqlite3 sqlite3;
1272
@@ -1366,11 +1366,11 @@
1366 /*
1367 ** CAPI3REF: One-Step Query Execution Interface
1368 ** METHOD: sqlite3
1369 **
1370 ** The sqlite3_exec() interface is a convenience wrapper around
1371 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
1372 ** that allows an application to run multiple statements of SQL
1373 ** without having to use a lot of C code.
1374 **
1375 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
1376 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3035,14 +3035,14 @@
3035 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
3036 ** have been disabled - 0 if they are not disabled, 1 if they are.
3037 ** </dd>
3038 **
3039 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3040 ** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3041 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3042 ** a single SQL query statement will always use the same algorithm regardless
3043 ** of values of [bound parameters].)^ The QPSG disables some query optimizations
3044 ** that look at the values of bound parameters, which can make some queries
3045 ** slower. But the QPSG has the advantage of more predictable behavior. With
3046 ** the QPSG active, SQLite will always use the same query plan in the field as
3047 ** was used during testing in the lab.
3048 ** </dd>
@@ -3728,16 +3728,16 @@
3728 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
3729 ** specific action but allow the SQL statement to continue to be
3730 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
3731 ** rejected with an error. ^If the authorizer callback returns
3732 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3733 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
3734 ** the authorizer will fail with an error message.
3735 **
3736 ** When the callback returns [SQLITE_OK], that means the operation
3737 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
3738 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
3739 ** authorizer will fail with an error message explaining that
3740 ** access is denied.
3741 **
3742 ** ^The first parameter to the authorizer callback is a copy of the third
3743 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3784,23 +3784,23 @@
3784 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
3785 ** The authorizer is disabled by default.
3786 **
3787 ** The authorizer callback must not do anything that will modify
3788 ** the database connection that invoked the authorizer callback.
3789 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3790 ** database connections for the meaning of "modify" in this paragraph.
3791 **
3792 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
3793 ** statement might be re-prepared during [sqlite3_step()] due to a
3794 ** schema change. Hence, the application should ensure that the
3795 ** correct authorizer callback remains in place during the [sqlite3_step()].
3796 **
3797 ** ^Note that the authorizer callback is invoked only during
3798 ** [sqlite3_prepare()] or its variants. Authorization is not
3799 ** performed during statement evaluation in [sqlite3_step()], unless
3800 ** as stated in the previous paragraph, sqlite3_step() invokes
3801 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
3802 */
3803 SQLITE_API int sqlite3_set_authorizer(
3804 sqlite3*,
3805 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
3806 void *pUserData
@@ -4032,11 +4032,11 @@
4032 ** interrupted. This feature can be used to implement a
4033 ** "Cancel" button on a GUI progress dialog box.
4034 **
4035 ** The progress handler callback must not do anything that will modify
4036 ** the database connection that invoked the progress handler.
4037 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4038 ** database connections for the meaning of "modify" in this paragraph.
4039 **
4040 */
4041 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
4042
@@ -4386,11 +4386,11 @@
4386 ** prepared statement before it can be run.
4387 **
4388 ** The life-cycle of a prepared statement object usually goes like this:
4389 **
4390 ** <ol>
4391 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
4392 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
4393 ** interfaces.
4394 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
4395 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
4396 ** to step 2. Do this zero or more times.
@@ -4468,11 +4468,11 @@
4468 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4469 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
4470 **
4471 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
4472 ** <dd>The maximum number of instructions in a virtual machine program
4473 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
4474 ** the equivalent tries to allocate space for more than this many opcodes
4475 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
4476 **
4477 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
4478 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4519,17 +4519,19 @@
4519 **
4520 ** New flags may be added in future releases of SQLite.
4521 **
4522 ** <dl>
4523 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
4524 ** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
4525 ** that the prepared statement will be retained for a long time and
4526 ** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]
4527 ** and [sqlite3_prepare16_v3()] assume that the prepared statement will
4528 ** be used just once or at most a few times and then destroyed using
4529 ** [sqlite3_finalize()] relatively soon. The current implementation acts
4530 ** on this hint by avoiding the use of [lookaside memory] so as not to
4531 ** deplete the limited store of lookaside memory. Future versions of
4532 ** SQLite may act on this hint differently.
4533 ** </dl>
4534 */
4535 #define SQLITE_PREPARE_PERSISTENT 0x01
4536
4537 /*
@@ -4828,11 +4830,11 @@
4830 ** CAPI3REF: Binding Values To Prepared Statements
4831 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
4832 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
4833 ** METHOD: sqlite3_stmt
4834 **
4835 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
4836 ** literals may be replaced by a [parameter] that matches one of following
4837 ** templates:
4838 **
4839 ** <ul>
4840 ** <li> ?
@@ -4847,11 +4849,11 @@
4849 ** parameters (also called "host parameter names" or "SQL parameters")
4850 ** can be set using the sqlite3_bind_*() routines defined here.
4851 **
4852 ** ^The first argument to the sqlite3_bind_*() routines is always
4853 ** a pointer to the [sqlite3_stmt] object returned from
4854 ** [sqlite3_prepare_v2()] or its variants.
4855 **
4856 ** ^The second argument is the index of the SQL parameter to be set.
4857 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
4858 ** SQL parameter is used more than once, second and subsequent
4859 ** occurrences have the same index as the first occurrence.
@@ -4907,10 +4909,19 @@
4909 ** (just an integer to hold its size) while it is being processed.
4910 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
4911 ** content is later written using
4912 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
4913 ** ^A negative value for the zeroblob results in a zero-length BLOB.
4914 **
4915 ** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
4916 ** [prepared statement] S to have an SQL value of NULL, but to also be
4917 ** associated with the pointer P.
4918 ** ^The sqlite3_bind_pointer() routine can be used to pass
4919 ** host-language pointers into [application-defined SQL functions].
4920 ** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
4921 ** to be an ordinary SQL NULL value to everything other than
4922 ** [sqlite3_value_pointer()].
4923 **
4924 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
4925 ** for the [prepared statement] or with a prepared statement for which
4926 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
4927 ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -4941,10 +4952,11 @@
4952 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
4953 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
4954 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
4955 void(*)(void*), unsigned char encoding);
4956 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
4957 SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
4958 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
4959 SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
4960
4961 /*
4962 ** CAPI3REF: Number Of SQL Parameters
@@ -5320,11 +5332,11 @@
5332 ** <b>Details:</b>
5333 **
5334 ** ^These routines return information about a single column of the current
5335 ** result row of a query. ^In every case the first argument is a pointer
5336 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5337 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
5338 ** and the second argument is the index of the column for which information
5339 ** should be returned. ^The leftmost column of the result set has the index 0.
5340 ** ^The number of columns in the result can be determined using
5341 ** [sqlite3_column_count()].
5342 **
@@ -5734,10 +5746,11 @@
5746 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5747 ** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
5748 ** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
5749 ** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
5750 ** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
5751 ** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value
5752 ** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
5753 ** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
5754 ** the native byteorder
5755 ** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
5756 ** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
@@ -5753,11 +5766,11 @@
5766 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
5767 ** </table></blockquote>
5768 **
5769 ** <b>Details:</b>
5770 **
5771 ** These routines extract type, size, and content information from
5772 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
5773 ** are used to pass parameter information into implementation of
5774 ** [application-defined SQL functions] and [virtual tables].
5775 **
5776 ** These routines work only with [protected sqlite3_value] objects.
@@ -5770,10 +5783,15 @@
5783 **
5784 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
5785 ** in the native byte-order of the host machine. ^The
5786 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
5787 ** extract UTF-16 strings as big-endian and little-endian respectively.
5788 **
5789 ** ^If [sqlite3_value] object V was initialized
5790 ** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
5791 ** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
5792 ** sqlite3_value_pointer(V) returns a NULL.
5793 **
5794 ** ^(The sqlite3_value_type(V) interface returns the
5795 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
5796 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
5797 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -5803,10 +5821,11 @@
5821 */
5822 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5823 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5824 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5825 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
5826 SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
5827 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
5828 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
5829 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
5830 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
5831 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -5821,14 +5840,10 @@
5840 ** The sqlite3_value_subtype(V) function returns the subtype for
5841 ** an [application-defined SQL function] argument V. The subtype
5842 ** information can be used to pass a limited amount of context from
5843 ** one SQL function to another. Use the [sqlite3_result_subtype()]
5844 ** routine to set the subtype for the return value of an SQL function.
 
 
 
 
5845 */
5846 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
5847
5848 /*
5849 ** CAPI3REF: Copy And Free SQL Values
@@ -6094,11 +6109,11 @@
6109 ** assumes that the text or BLOB result is in constant space and does not
6110 ** copy the content of the parameter nor call a destructor on the content
6111 ** when it has finished using that result.
6112 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
6113 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
6114 ** then SQLite makes a copy of the result into space obtained
6115 ** from [sqlite3_malloc()] before it returns.
6116 **
6117 ** ^The sqlite3_result_value() interface sets the result of
6118 ** the application-defined function to be a copy of the
6119 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
@@ -6106,10 +6121,18 @@
6121 ** so that the [sqlite3_value] specified in the parameter may change or
6122 ** be deallocated after sqlite3_result_value() returns without harm.
6123 ** ^A [protected sqlite3_value] object may always be used where an
6124 ** [unprotected sqlite3_value] object is required, so either
6125 ** kind of [sqlite3_value] object can be used with this interface.
6126 **
6127 ** ^The sqlite3_result_pointer(C,P) interface sets the result to an
6128 ** SQL NULL value, just like [sqlite3_result_null(C)], except that it
6129 ** also associates the host-language pointer P with that NULL value such
6130 ** that the pointer can be retrieved within an
6131 ** [application-defined SQL function] using [sqlite3_value_pointer()].
6132 ** This mechanism can be used to pass non-SQL values between
6133 ** application-defined functions.
6134 **
6135 ** If these routines are called from within the different thread
6136 ** than the one containing the application-defined function that received
6137 ** the [sqlite3_context] pointer, the results are undefined.
6138 */
@@ -6130,10 +6153,11 @@
6153 void(*)(void*), unsigned char encoding);
6154 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
6155 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
6156 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
6157 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
6158 SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
6159 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
6160 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
6161
6162
6163 /*
@@ -6490,11 +6514,11 @@
6514 **
6515 ** ^The sqlite3_db_handle interface returns the [database connection] handle
6516 ** to which a [prepared statement] belongs. ^The [database connection]
6517 ** returned by sqlite3_db_handle is the same [database connection]
6518 ** that was the first argument
6519 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
6520 ** create the statement in the first place.
6521 */
6522 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
6523
6524 /*
@@ -6566,11 +6590,11 @@
6590 ** the database connection that invoked the callback. Any actions
6591 ** to modify the database connection must be deferred until after the
6592 ** completion of the [sqlite3_step()] call that triggered the commit
6593 ** or rollback hook in the first place.
6594 ** Note that running any other SQL statements, including SELECT statements,
6595 ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
6596 ** the database connections for the meaning of "modify" in this paragraph.
6597 **
6598 ** ^Registering a NULL function disables the callback.
6599 **
6600 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6626,11 +6650,11 @@
6650 **
6651 ** The update hook implementation must not do anything that will modify
6652 ** the database connection that invoked the update hook. Any actions
6653 ** to modify the database connection must be deferred until after the
6654 ** completion of the [sqlite3_step()] call that triggered the update hook.
6655 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
6656 ** database connections for the meaning of "modify" in this paragraph.
6657 **
6658 ** ^The sqlite3_update_hook(D,C,P) function
6659 ** returns the P argument from the previous call
6660 ** on the same [database connection] D, or NULL for
@@ -13595,28 +13619,30 @@
13619 typedef struct VdbeOpList VdbeOpList;
13620
13621 /*
13622 ** Allowed values of VdbeOp.p4type
13623 */
13624 #define P4_NOTUSED 0 /* The P4 parameter is not used */
13625 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
13626 #define P4_STATIC (-1) /* Pointer to a static string */
13627 #define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
13628 #define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
13629 #define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
13630 #define P4_ADVANCE (-5) /* P4 is a pointer to BtreeNext() or BtreePrev() */
13631 #define P4_TABLE (-6) /* P4 is a pointer to a Table structure */
13632 /* Above do not own any resources. Must free those below */
13633 #define P4_FREE_IF_LE (-7)
13634 #define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */
13635 #define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */
13636 #define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */
13637 #define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */
13638 #define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */
13639 #define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */
13640 #define P4_REAL (-13) /* P4 is a 64-bit floating point value */
13641 #define P4_INT64 (-14) /* P4 is a 64-bit signed integer */
13642 #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
13643 #define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
13644
13645 /* Error message codes for OP_Halt */
13646 #define P5_ConstraintNotNull 1
13647 #define P5_ConstraintUnique 2
13648 #define P5_ConstraintCheck 3
@@ -18603,10 +18629,11 @@
18629 struct sqlite3_value {
18630 union MemValue {
18631 double r; /* Real value used when MEM_Real is set in flags */
18632 i64 i; /* Integer value used when MEM_Int is set in flags */
18633 int nZero; /* Used when bit MEM_Zero is set in flags */
18634 void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */
18635 FuncDef *pDef; /* Used only when flags==MEM_Agg */
18636 RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
18637 VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
18638 } u;
18639 u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
@@ -18888,10 +18915,11 @@
18915 #ifdef SQLITE_OMIT_FLOATING_POINT
18916 # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
18917 #else
18918 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
18919 #endif
18920 SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*);
18921 SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
18922 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
18923 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
18924 SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);
18925 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
@@ -70898,10 +70926,21 @@
70926 }else{
70927 pMem->u.i = val;
70928 pMem->flags = MEM_Int;
70929 }
70930 }
70931
70932 /*
70933 ** Set the value stored in *pMem should already be a NULL.
70934 ** Also store a pointer to go with it.
70935 */
70936 SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
70937 assert( pMem->flags==MEM_Null );
70938 pMem->flags = MEM_Null|MEM_Subtype;
70939 pMem->u.pPtr = pPtr;
70940 pMem->eSubtype = 'p';
70941 }
70942
70943 #ifndef SQLITE_OMIT_FLOATING_POINT
70944 /*
70945 ** Delete any previous value and set the value stored in *pMem to val,
70946 ** manifest type REAL.
@@ -72796,11 +72835,11 @@
72835 */
72836 static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){
72837 if( aOp ){
72838 Op *pOp;
72839 for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){
72840 if( pOp->p4type <= P4_FREE_IF_LE ) freeP4(db, pOp->p4type, pOp->p4.p);
72841 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
72842 sqlite3DbFree(db, pOp->zComment);
72843 #endif
72844 }
72845 sqlite3DbFreeNN(db, aOp);
@@ -76801,10 +76840,18 @@
76840 return sqlite3VdbeIntValue((Mem*)pVal);
76841 }
76842 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
76843 Mem *pMem = (Mem*)pVal;
76844 return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
76845 }
76846 SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal){
76847 Mem *p = (Mem*)pVal;
76848 if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
76849 return p->u.pPtr;
76850 }else{
76851 return 0;
76852 }
76853 }
76854 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
76855 return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
76856 }
76857 #ifndef SQLITE_OMIT_UTF16
@@ -76979,10 +77026,16 @@
77026 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
77027 }
77028 SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
77029 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
77030 sqlite3VdbeMemSetNull(pCtx->pOut);
77031 }
77032 SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
77033 Mem *pOut = pCtx->pOut;
77034 assert( sqlite3_mutex_held(pOut->db->mutex) );
77035 sqlite3VdbeMemSetNull(pOut);
77036 sqlite3VdbeMemSetPointer(pOut, pPtr);
77037 }
77038 SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
77039 Mem *pOut = pCtx->pOut;
77040 assert( sqlite3_mutex_held(pOut->db->mutex) );
77041 pOut->eSubtype = eSubtype & 0xff;
@@ -77982,10 +78035,20 @@
78035 rc = vdbeUnbind(p, i);
78036 if( rc==SQLITE_OK ){
78037 sqlite3_mutex_leave(p->db->mutex);
78038 }
78039 return rc;
78040 }
78041 SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
78042 int rc;
78043 Vdbe *p = (Vdbe*)pStmt;
78044 rc = vdbeUnbind(p, i);
78045 if( rc==SQLITE_OK ){
78046 sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
78047 sqlite3_mutex_leave(p->db->mutex);
78048 }
78049 return rc;
78050 }
78051 SQLITE_API int sqlite3_bind_text(
78052 sqlite3_stmt *pStmt,
78053 int i,
78054 const char *zData,
@@ -106211,10 +106274,14 @@
106274 assert( SQLITE_INTEGER==1 );
106275 assert( SQLITE_FLOAT==2 );
106276 assert( SQLITE_TEXT==3 );
106277 assert( SQLITE_BLOB==4 );
106278 assert( SQLITE_NULL==5 );
106279 /* EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns
106280 ** the datatype code for the initial datatype of the sqlite3_value object
106281 ** V. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT,
106282 ** SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */
106283 sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
106284 }
106285
106286
106287 /*
@@ -112140,10 +112207,13 @@
112207 /* Version 3.20.0 and later */
112208 int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
112209 sqlite3_stmt**,const char**);
112210 int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
112211 sqlite3_stmt**,const void**);
112212 int (*bind_pointer)(sqlite3_stmt*,int,void*);
112213 void (*result_pointer)(sqlite3_context*,void*);
112214 void *(*value_pointer)(sqlite3_value*);
112215 };
112216
112217 /*
112218 ** This is the function signature used for all extension entry points. It
112219 ** is also defined in the file "loadext.c".
@@ -112403,10 +112473,13 @@
112473 /* Version 3.18.0 and later */
112474 #define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
112475 /* Version 3.20.0 and later */
112476 #define sqlite3_prepare_v3 sqlite3_api->prepare_v3
112477 #define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
112478 #define sqlite3_bind_pointer sqlite3_api->bind_pointer
112479 #define sqlite3_result_pointer sqlite3_api->result_pointer
112480 #define sqlite3_value_pointer sqlite3_api->value_pointer
112481 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
112482
112483 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
112484 /* This case when the file really is being compiled as a loadable
112485 ** extension */
@@ -112834,11 +112907,14 @@
112907 sqlite3_expanded_sql,
112908 /* Version 3.18.0 and later */
112909 sqlite3_set_last_insert_rowid,
112910 /* Version 3.20.0 and later */
112911 sqlite3_prepare_v3,
112912 sqlite3_prepare16_v3,
112913 sqlite3_bind_pointer,
112914 sqlite3_result_pointer,
112915 sqlite3_value_pointer
112916 };
112917
112918 /*
112919 ** Attempt to load an SQLite extension library contained in the file
112920 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -117102,13 +117178,18 @@
117178 int nBytes, /* Length of zSql in bytes. */
117179 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117180 const char **pzTail /* OUT: End of parsed string */
117181 ){
117182 int rc;
117183 /* EVIDENCE-OF: R-37923-12173 The sqlite3_prepare_v2() interface works
117184 ** exactly the same as sqlite3_prepare_v3() with a zero prepFlags
117185 ** parameter.
117186 **
117187 ** Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 */
117188 rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
117189 ppStmt,pzTail);
117190 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );
117191 return rc;
117192 }
117193 SQLITE_API int sqlite3_prepare_v3(
117194 sqlite3 *db, /* Database handle. */
117195 const char *zSql, /* UTF-8 encoded SQL statement. */
@@ -117116,14 +117197,21 @@
117197 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
117198 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117199 const char **pzTail /* OUT: End of parsed string */
117200 ){
117201 int rc;
117202 /* EVIDENCE-OF: R-56861-42673 sqlite3_prepare_v3() differs from
117203 ** sqlite3_prepare_v2() only in having the extra prepFlags parameter,
117204 ** which is a bit array consisting of zero or more of the
117205 ** SQLITE_PREPARE_* flags.
117206 **
117207 ** Proof by comparison to the implementation of sqlite3_prepare_v2()
117208 ** directly above. */
117209 rc = sqlite3LockAndPrepare(db,zSql,nBytes,
117210 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
117211 0,ppStmt,pzTail);
117212 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );
117213 return rc;
117214 }
117215
117216
117217 #ifndef SQLITE_OMIT_UTF16
@@ -142215,10 +142303,12 @@
142303 va_list ap;
142304 int rc;
142305 va_start(ap, op);
142306 switch( op ){
142307 case SQLITE_DBCONFIG_MAINDBNAME: {
142308 /* IMP: R-06824-28531 */
142309 /* IMP: R-36257-52125 */
142310 db->aDb[0].zDbSName = va_arg(ap,char*);
142311 rc = SQLITE_OK;
142312 break;
142313 }
142314 case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -150188,12 +150278,11 @@
150278 assert( iCol>=0 && iCol<=p->nColumn+2 );
150279
150280 switch( iCol-p->nColumn ){
150281 case 0:
150282 /* The special 'table-name' column */
150283 sqlite3_result_pointer(pCtx, pCsr);
 
150284 break;
150285
150286 case 1:
150287 /* The docid column */
150288 sqlite3_result_int64(pCtx, pCsr->iPrevId);
@@ -150407,13 +150496,14 @@
150496 sqlite3_context *pContext, /* SQL function call context */
150497 const char *zFunc, /* Function name */
150498 sqlite3_value *pVal, /* argv[0] passed to function */
150499 Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
150500 ){
150501 int rc;
150502 *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal);
150503 if( (*ppCsr)!=0 ){
150504 rc = SQLITE_OK;
150505 }else{
150506 char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
150507 sqlite3_result_error(pContext, zErr, -1);
150508 sqlite3_free(zErr);
150509 rc = SQLITE_ERROR;
@@ -200127,11 +200217,11 @@
200217 int nArg, /* Number of args */
200218 sqlite3_value **apUnused /* Function arguments */
200219 ){
200220 assert( nArg==0 );
200221 UNUSED_PARAM2(nArg, apUnused);
200222 sqlite3_result_text(pCtx, "fts5: 2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6", -1, SQLITE_TRANSIENT);
200223 }
200224
200225 static int fts5Init(sqlite3 *db){
200226 static const sqlite3_module fts5Mod = {
200227 /* iVersion */ 2,
@@ -204014,27 +204104,10 @@
204104 SQLITE_EXTENSION_INIT1
204105 /* #include <assert.h> */
204106 /* #include <string.h> */
204107
204108 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204109
204110 /* stmt_vtab is a subclass of sqlite3_vtab which will
204111 ** serve as the underlying representation of a stmt virtual table
204112 */
204113 typedef struct stmt_vtab stmt_vtab;
@@ -204077,26 +204150,25 @@
204150 ){
204151 stmt_vtab *pNew;
204152 int rc;
204153
204154 /* Column numbers */
204155 #define STMT_COLUMN_SQL 0 /* SQL for the statement */
204156 #define STMT_COLUMN_NCOL 1 /* Number of result columns */
204157 #define STMT_COLUMN_RO 2 /* True if read-only */
204158 #define STMT_COLUMN_BUSY 3 /* True if currently busy */
204159 #define STMT_COLUMN_NSCAN 4 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
204160 #define STMT_COLUMN_NSORT 5 /* SQLITE_STMTSTATUS_SORT */
204161 #define STMT_COLUMN_NAIDX 6 /* SQLITE_STMTSTATUS_AUTOINDEX */
204162 #define STMT_COLUMN_NSTEP 7 /* SQLITE_STMTSTATUS_VM_STEP */
204163 #define STMT_COLUMN_REPREP 8 /* SQLITE_STMTSTATUS_REPREPARE */
204164 #define STMT_COLUMN_RUN 9 /* SQLITE_STMTSTATUS_RUN */
204165 #define STMT_COLUMN_MEM 10 /* SQLITE_STMTSTATUS_MEMUSED */
 
204166
204167
204168 rc = sqlite3_declare_vtab(db,
204169 "CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
204170 "reprep,run,mem)");
204171 if( rc==SQLITE_OK ){
204172 pNew = sqlite3_malloc( sizeof(*pNew) );
204173 *ppVtab = (sqlite3_vtab*)pNew;
204174 if( pNew==0 ) return SQLITE_NOMEM;
@@ -204155,14 +204227,10 @@
204227 sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
204228 int i /* Which column to return */
204229 ){
204230 stmt_cursor *pCur = (stmt_cursor*)cur;
204231 switch( i ){
 
 
 
 
204232 case STMT_COLUMN_SQL: {
204233 sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
204234 break;
204235 }
204236 case STMT_COLUMN_NCOL: {
@@ -204280,11 +204348,11 @@
204348 #endif /* SQLITE_OMIT_VIRTUALTABLE */
204349
204350 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
204351 int rc = SQLITE_OK;
204352 #ifndef SQLITE_OMIT_VIRTUALTABLE
204353 rc = sqlite3_create_module(db, "sqlite_stmt", &stmtModule, 0);
204354 #endif
204355 return rc;
204356 }
204357
204358 #ifndef SQLITE_CORE
204359
+56 -32
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.20.0"
125125
#define SQLITE_VERSION_NUMBER 3020000
126
-#define SQLITE_SOURCE_ID "2017-07-12 18:05:54 604c11d1a39f09e47b6fcee0f8b1c1054f9dbbc7b2c1cf93312aeaa4b7095018"
126
+#define SQLITE_SOURCE_ID "2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -233,11 +233,11 @@
233233
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234234
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235235
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236236
** and [sqlite3_close_v2()] are its destructors. There are many other
237237
** interfaces (such as
238
-** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
238
+** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
239239
** [sqlite3_busy_timeout()] to name but three) that are methods on an
240240
** sqlite3 object.
241241
*/
242242
typedef struct sqlite3 sqlite3;
243243
@@ -337,11 +337,11 @@
337337
/*
338338
** CAPI3REF: One-Step Query Execution Interface
339339
** METHOD: sqlite3
340340
**
341341
** The sqlite3_exec() interface is a convenience wrapper around
342
-** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
342
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
343343
** that allows an application to run multiple statements of SQL
344344
** without having to use a lot of C code.
345345
**
346346
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347347
** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2006,14 +2006,14 @@
20062006
** into which is written 0 or 1 to indicate whether checkpoints-on-close
20072007
** have been disabled - 0 if they are not disabled, 1 if they are.
20082008
** </dd>
20092009
**
20102010
** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2011
-** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2011
+** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
20122012
** the [query planner stability guarantee] (QPSG). When the QPSG is active,
20132013
** a single SQL query statement will always use the same algorithm regardless
2014
-** of values of [bound parameters]. The QPSG disables some query optimizations
2014
+** of values of [bound parameters].)^ The QPSG disables some query optimizations
20152015
** that look at the values of bound parameters, which can make some queries
20162016
** slower. But the QPSG has the advantage of more predictable behavior. With
20172017
** the QPSG active, SQLite will always use the same query plan in the field as
20182018
** was used during testing in the lab.
20192019
** </dd>
@@ -2699,16 +2699,16 @@
26992699
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
27002700
** specific action but allow the SQL statement to continue to be
27012701
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
27022702
** rejected with an error. ^If the authorizer callback returns
27032703
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2704
-** then the [sqlite3_prepare_v3()] or equivalent call that triggered
2704
+** then the [sqlite3_prepare_v2()] or equivalent call that triggered
27052705
** the authorizer will fail with an error message.
27062706
**
27072707
** When the callback returns [SQLITE_OK], that means the operation
27082708
** requested is ok. ^When the callback returns [SQLITE_DENY], the
2709
-** [sqlite3_prepare_v3()] or equivalent call that triggered the
2709
+** [sqlite3_prepare_v2()] or equivalent call that triggered the
27102710
** authorizer will fail with an error message explaining that
27112711
** access is denied.
27122712
**
27132713
** ^The first parameter to the authorizer callback is a copy of the third
27142714
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2755,23 +2755,23 @@
27552755
** previous call.)^ ^Disable the authorizer by installing a NULL callback.
27562756
** The authorizer is disabled by default.
27572757
**
27582758
** The authorizer callback must not do anything that will modify
27592759
** the database connection that invoked the authorizer callback.
2760
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
2760
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
27612761
** database connections for the meaning of "modify" in this paragraph.
27622762
**
2763
-** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
2763
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
27642764
** statement might be re-prepared during [sqlite3_step()] due to a
27652765
** schema change. Hence, the application should ensure that the
27662766
** correct authorizer callback remains in place during the [sqlite3_step()].
27672767
**
27682768
** ^Note that the authorizer callback is invoked only during
27692769
** [sqlite3_prepare()] or its variants. Authorization is not
27702770
** performed during statement evaluation in [sqlite3_step()], unless
27712771
** as stated in the previous paragraph, sqlite3_step() invokes
2772
-** sqlite3_prepare_v3() to reprepare a statement after a schema change.
2772
+** sqlite3_prepare_v2() to reprepare a statement after a schema change.
27732773
*/
27742774
SQLITE_API int sqlite3_set_authorizer(
27752775
sqlite3*,
27762776
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
27772777
void *pUserData
@@ -3003,11 +3003,11 @@
30033003
** interrupted. This feature can be used to implement a
30043004
** "Cancel" button on a GUI progress dialog box.
30053005
**
30063006
** The progress handler callback must not do anything that will modify
30073007
** the database connection that invoked the progress handler.
3008
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3008
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
30093009
** database connections for the meaning of "modify" in this paragraph.
30103010
**
30113011
*/
30123012
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
30133013
@@ -3357,11 +3357,11 @@
33573357
** prepared statement before it can be run.
33583358
**
33593359
** The life-cycle of a prepared statement object usually goes like this:
33603360
**
33613361
** <ol>
3362
-** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
3362
+** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
33633363
** <li> Bind values to [parameters] using the sqlite3_bind_*()
33643364
** interfaces.
33653365
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
33663366
** <li> Reset the prepared statement using [sqlite3_reset()] then go back
33673367
** to step 2. Do this zero or more times.
@@ -3439,11 +3439,11 @@
34393439
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
34403440
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
34413441
**
34423442
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
34433443
** <dd>The maximum number of instructions in a virtual machine program
3444
-** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
3444
+** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
34453445
** the equivalent tries to allocate space for more than this many opcodes
34463446
** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
34473447
**
34483448
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
34493449
** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3490,17 +3490,19 @@
34903490
**
34913491
** New flags may be added in future releases of SQLite.
34923492
**
34933493
** <dl>
34943494
** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
3495
-** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
3496
-** and [sqlite3_prepare16_v3()]
3497
-** to optimize the resulting prepared statement to be retained for a
3498
-** relatively long amount of time.)^ ^Without this flag,
3499
-** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
3500
-** the prepared statement will be used just once or at most a few times
3501
-** and then destroyed using [sqlite3_finalize()] relatively soon.
3495
+** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
3496
+** that the prepared statement will be retained for a long time and
3497
+** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]
3498
+** and [sqlite3_prepare16_v3()] assume that the prepared statement will
3499
+** be used just once or at most a few times and then destroyed using
3500
+** [sqlite3_finalize()] relatively soon. The current implementation acts
3501
+** on this hint by avoiding the use of [lookaside memory] so as not to
3502
+** deplete the limited store of lookaside memory. Future versions of
3503
+** SQLite may act on this hint differently.
35023504
** </dl>
35033505
*/
35043506
#define SQLITE_PREPARE_PERSISTENT 0x01
35053507
35063508
/*
@@ -3799,11 +3801,11 @@
37993801
** CAPI3REF: Binding Values To Prepared Statements
38003802
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
38013803
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
38023804
** METHOD: sqlite3_stmt
38033805
**
3804
-** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
3806
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
38053807
** literals may be replaced by a [parameter] that matches one of following
38063808
** templates:
38073809
**
38083810
** <ul>
38093811
** <li> ?
@@ -3818,11 +3820,11 @@
38183820
** parameters (also called "host parameter names" or "SQL parameters")
38193821
** can be set using the sqlite3_bind_*() routines defined here.
38203822
**
38213823
** ^The first argument to the sqlite3_bind_*() routines is always
38223824
** a pointer to the [sqlite3_stmt] object returned from
3823
-** [sqlite3_prepare_v3()] or its variants.
3825
+** [sqlite3_prepare_v2()] or its variants.
38243826
**
38253827
** ^The second argument is the index of the SQL parameter to be set.
38263828
** ^The leftmost SQL parameter has an index of 1. ^When the same named
38273829
** SQL parameter is used more than once, second and subsequent
38283830
** occurrences have the same index as the first occurrence.
@@ -3878,10 +3880,19 @@
38783880
** (just an integer to hold its size) while it is being processed.
38793881
** Zeroblobs are intended to serve as placeholders for BLOBs whose
38803882
** content is later written using
38813883
** [sqlite3_blob_open | incremental BLOB I/O] routines.
38823884
** ^A negative value for the zeroblob results in a zero-length BLOB.
3885
+**
3886
+** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
3887
+** [prepared statement] S to have an SQL value of NULL, but to also be
3888
+** associated with the pointer P.
3889
+** ^The sqlite3_bind_pointer() routine can be used to pass
3890
+** host-language pointers into [application-defined SQL functions].
3891
+** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
3892
+** to be an ordinary SQL NULL value to everything other than
3893
+** [sqlite3_value_pointer()].
38833894
**
38843895
** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
38853896
** for the [prepared statement] or with a prepared statement for which
38863897
** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
38873898
** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -3912,10 +3923,11 @@
39123923
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
39133924
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
39143925
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
39153926
void(*)(void*), unsigned char encoding);
39163927
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3928
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
39173929
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
39183930
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
39193931
39203932
/*
39213933
** CAPI3REF: Number Of SQL Parameters
@@ -4291,11 +4303,11 @@
42914303
** <b>Details:</b>
42924304
**
42934305
** ^These routines return information about a single column of the current
42944306
** result row of a query. ^In every case the first argument is a pointer
42954307
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4296
-** that was returned from [sqlite3_prepare_v3()] or one of its variants)
4308
+** that was returned from [sqlite3_prepare_v2()] or one of its variants)
42974309
** and the second argument is the index of the column for which information
42984310
** should be returned. ^The leftmost column of the result set has the index 0.
42994311
** ^The number of columns in the result can be determined using
43004312
** [sqlite3_column_count()].
43014313
**
@@ -4705,10 +4717,11 @@
47054717
** <blockquote><table border=0 cellpadding=0 cellspacing=0>
47064718
** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
47074719
** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
47084720
** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
47094721
** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
4722
+** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value
47104723
** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
47114724
** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
47124725
** the native byteorder
47134726
** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
47144727
** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
@@ -4724,11 +4737,11 @@
47244737
** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
47254738
** </table></blockquote>
47264739
**
47274740
** <b>Details:</b>
47284741
**
4729
-** This routine extract type, size, and content information from
4742
+** These routines extract type, size, and content information from
47304743
** [protected sqlite3_value] objects. Protected sqlite3_value objects
47314744
** are used to pass parameter information into implementation of
47324745
** [application-defined SQL functions] and [virtual tables].
47334746
**
47344747
** These routines work only with [protected sqlite3_value] objects.
@@ -4741,10 +4754,15 @@
47414754
**
47424755
** ^The sqlite3_value_text16() interface extracts a UTF-16 string
47434756
** in the native byte-order of the host machine. ^The
47444757
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
47454758
** extract UTF-16 strings as big-endian and little-endian respectively.
4759
+**
4760
+** ^If [sqlite3_value] object V was initialized
4761
+** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
4762
+** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
4763
+** sqlite3_value_pointer(V) returns a NULL.
47464764
**
47474765
** ^(The sqlite3_value_type(V) interface returns the
47484766
** [SQLITE_INTEGER | datatype code] for the initial datatype of the
47494767
** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
47504768
** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -4774,10 +4792,11 @@
47744792
*/
47754793
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
47764794
SQLITE_API double sqlite3_value_double(sqlite3_value*);
47774795
SQLITE_API int sqlite3_value_int(sqlite3_value*);
47784796
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4797
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
47794798
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
47804799
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
47814800
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
47824801
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
47834802
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -4792,14 +4811,10 @@
47924811
** The sqlite3_value_subtype(V) function returns the subtype for
47934812
** an [application-defined SQL function] argument V. The subtype
47944813
** information can be used to pass a limited amount of context from
47954814
** one SQL function to another. Use the [sqlite3_result_subtype()]
47964815
** routine to set the subtype for the return value of an SQL function.
4797
-**
4798
-** SQLite makes no use of subtype itself. It merely passes the subtype
4799
-** from the result of one [application-defined SQL function] into the
4800
-** input of another.
48014816
*/
48024817
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
48034818
48044819
/*
48054820
** CAPI3REF: Copy And Free SQL Values
@@ -5065,11 +5080,11 @@
50655080
** assumes that the text or BLOB result is in constant space and does not
50665081
** copy the content of the parameter nor call a destructor on the content
50675082
** when it has finished using that result.
50685083
** ^If the 4th parameter to the sqlite3_result_text* interfaces
50695084
** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
5070
-** then SQLite makes a copy of the result into space obtained from
5085
+** then SQLite makes a copy of the result into space obtained
50715086
** from [sqlite3_malloc()] before it returns.
50725087
**
50735088
** ^The sqlite3_result_value() interface sets the result of
50745089
** the application-defined function to be a copy of the
50755090
** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
@@ -5077,10 +5092,18 @@
50775092
** so that the [sqlite3_value] specified in the parameter may change or
50785093
** be deallocated after sqlite3_result_value() returns without harm.
50795094
** ^A [protected sqlite3_value] object may always be used where an
50805095
** [unprotected sqlite3_value] object is required, so either
50815096
** kind of [sqlite3_value] object can be used with this interface.
5097
+**
5098
+** ^The sqlite3_result_pointer(C,P) interface sets the result to an
5099
+** SQL NULL value, just like [sqlite3_result_null(C)], except that it
5100
+** also associates the host-language pointer P with that NULL value such
5101
+** that the pointer can be retrieved within an
5102
+** [application-defined SQL function] using [sqlite3_value_pointer()].
5103
+** This mechanism can be used to pass non-SQL values between
5104
+** application-defined functions.
50825105
**
50835106
** If these routines are called from within the different thread
50845107
** than the one containing the application-defined function that received
50855108
** the [sqlite3_context] pointer, the results are undefined.
50865109
*/
@@ -5101,10 +5124,11 @@
51015124
void(*)(void*), unsigned char encoding);
51025125
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
51035126
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
51045127
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
51055128
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
5129
+SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
51065130
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
51075131
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
51085132
51095133
51105134
/*
@@ -5461,11 +5485,11 @@
54615485
**
54625486
** ^The sqlite3_db_handle interface returns the [database connection] handle
54635487
** to which a [prepared statement] belongs. ^The [database connection]
54645488
** returned by sqlite3_db_handle is the same [database connection]
54655489
** that was the first argument
5466
-** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
5490
+** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
54675491
** create the statement in the first place.
54685492
*/
54695493
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
54705494
54715495
/*
@@ -5537,11 +5561,11 @@
55375561
** the database connection that invoked the callback. Any actions
55385562
** to modify the database connection must be deferred until after the
55395563
** completion of the [sqlite3_step()] call that triggered the commit
55405564
** or rollback hook in the first place.
55415565
** Note that running any other SQL statements, including SELECT statements,
5542
-** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
5566
+** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
55435567
** the database connections for the meaning of "modify" in this paragraph.
55445568
**
55455569
** ^Registering a NULL function disables the callback.
55465570
**
55475571
** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5597,11 +5621,11 @@
55975621
**
55985622
** The update hook implementation must not do anything that will modify
55995623
** the database connection that invoked the update hook. Any actions
56005624
** to modify the database connection must be deferred until after the
56015625
** completion of the [sqlite3_step()] call that triggered the update hook.
5602
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
5626
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
56035627
** database connections for the meaning of "modify" in this paragraph.
56045628
**
56055629
** ^The sqlite3_update_hook(D,C,P) function
56065630
** returns the P argument from the previous call
56075631
** on the same [database connection] D, or NULL for
56085632
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.20.0"
125 #define SQLITE_VERSION_NUMBER 3020000
126 #define SQLITE_SOURCE_ID "2017-07-12 18:05:54 604c11d1a39f09e47b6fcee0f8b1c1054f9dbbc7b2c1cf93312aeaa4b7095018"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -233,11 +233,11 @@
233 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236 ** and [sqlite3_close_v2()] are its destructors. There are many other
237 ** interfaces (such as
238 ** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
239 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
240 ** sqlite3 object.
241 */
242 typedef struct sqlite3 sqlite3;
243
@@ -337,11 +337,11 @@
337 /*
338 ** CAPI3REF: One-Step Query Execution Interface
339 ** METHOD: sqlite3
340 **
341 ** The sqlite3_exec() interface is a convenience wrapper around
342 ** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
343 ** that allows an application to run multiple statements of SQL
344 ** without having to use a lot of C code.
345 **
346 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2006,14 +2006,14 @@
2006 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2007 ** have been disabled - 0 if they are not disabled, 1 if they are.
2008 ** </dd>
2009 **
2010 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2011 ** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2012 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2013 ** a single SQL query statement will always use the same algorithm regardless
2014 ** of values of [bound parameters]. The QPSG disables some query optimizations
2015 ** that look at the values of bound parameters, which can make some queries
2016 ** slower. But the QPSG has the advantage of more predictable behavior. With
2017 ** the QPSG active, SQLite will always use the same query plan in the field as
2018 ** was used during testing in the lab.
2019 ** </dd>
@@ -2699,16 +2699,16 @@
2699 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2700 ** specific action but allow the SQL statement to continue to be
2701 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2702 ** rejected with an error. ^If the authorizer callback returns
2703 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2704 ** then the [sqlite3_prepare_v3()] or equivalent call that triggered
2705 ** the authorizer will fail with an error message.
2706 **
2707 ** When the callback returns [SQLITE_OK], that means the operation
2708 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2709 ** [sqlite3_prepare_v3()] or equivalent call that triggered the
2710 ** authorizer will fail with an error message explaining that
2711 ** access is denied.
2712 **
2713 ** ^The first parameter to the authorizer callback is a copy of the third
2714 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2755,23 +2755,23 @@
2755 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
2756 ** The authorizer is disabled by default.
2757 **
2758 ** The authorizer callback must not do anything that will modify
2759 ** the database connection that invoked the authorizer callback.
2760 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
2761 ** database connections for the meaning of "modify" in this paragraph.
2762 **
2763 ** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
2764 ** statement might be re-prepared during [sqlite3_step()] due to a
2765 ** schema change. Hence, the application should ensure that the
2766 ** correct authorizer callback remains in place during the [sqlite3_step()].
2767 **
2768 ** ^Note that the authorizer callback is invoked only during
2769 ** [sqlite3_prepare()] or its variants. Authorization is not
2770 ** performed during statement evaluation in [sqlite3_step()], unless
2771 ** as stated in the previous paragraph, sqlite3_step() invokes
2772 ** sqlite3_prepare_v3() to reprepare a statement after a schema change.
2773 */
2774 SQLITE_API int sqlite3_set_authorizer(
2775 sqlite3*,
2776 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2777 void *pUserData
@@ -3003,11 +3003,11 @@
3003 ** interrupted. This feature can be used to implement a
3004 ** "Cancel" button on a GUI progress dialog box.
3005 **
3006 ** The progress handler callback must not do anything that will modify
3007 ** the database connection that invoked the progress handler.
3008 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3009 ** database connections for the meaning of "modify" in this paragraph.
3010 **
3011 */
3012 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3013
@@ -3357,11 +3357,11 @@
3357 ** prepared statement before it can be run.
3358 **
3359 ** The life-cycle of a prepared statement object usually goes like this:
3360 **
3361 ** <ol>
3362 ** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
3363 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
3364 ** interfaces.
3365 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3366 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3367 ** to step 2. Do this zero or more times.
@@ -3439,11 +3439,11 @@
3439 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3440 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3441 **
3442 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3443 ** <dd>The maximum number of instructions in a virtual machine program
3444 ** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
3445 ** the equivalent tries to allocate space for more than this many opcodes
3446 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3447 **
3448 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3449 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3490,17 +3490,19 @@
3490 **
3491 ** New flags may be added in future releases of SQLite.
3492 **
3493 ** <dl>
3494 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
3495 ** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
3496 ** and [sqlite3_prepare16_v3()]
3497 ** to optimize the resulting prepared statement to be retained for a
3498 ** relatively long amount of time.)^ ^Without this flag,
3499 ** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
3500 ** the prepared statement will be used just once or at most a few times
3501 ** and then destroyed using [sqlite3_finalize()] relatively soon.
 
 
3502 ** </dl>
3503 */
3504 #define SQLITE_PREPARE_PERSISTENT 0x01
3505
3506 /*
@@ -3799,11 +3801,11 @@
3799 ** CAPI3REF: Binding Values To Prepared Statements
3800 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3801 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3802 ** METHOD: sqlite3_stmt
3803 **
3804 ** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
3805 ** literals may be replaced by a [parameter] that matches one of following
3806 ** templates:
3807 **
3808 ** <ul>
3809 ** <li> ?
@@ -3818,11 +3820,11 @@
3818 ** parameters (also called "host parameter names" or "SQL parameters")
3819 ** can be set using the sqlite3_bind_*() routines defined here.
3820 **
3821 ** ^The first argument to the sqlite3_bind_*() routines is always
3822 ** a pointer to the [sqlite3_stmt] object returned from
3823 ** [sqlite3_prepare_v3()] or its variants.
3824 **
3825 ** ^The second argument is the index of the SQL parameter to be set.
3826 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3827 ** SQL parameter is used more than once, second and subsequent
3828 ** occurrences have the same index as the first occurrence.
@@ -3878,10 +3880,19 @@
3878 ** (just an integer to hold its size) while it is being processed.
3879 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
3880 ** content is later written using
3881 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
3882 ** ^A negative value for the zeroblob results in a zero-length BLOB.
 
 
 
 
 
 
 
 
 
3883 **
3884 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
3885 ** for the [prepared statement] or with a prepared statement for which
3886 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
3887 ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -3912,10 +3923,11 @@
3912 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3913 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3914 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3915 void(*)(void*), unsigned char encoding);
3916 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
 
3917 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3918 SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
3919
3920 /*
3921 ** CAPI3REF: Number Of SQL Parameters
@@ -4291,11 +4303,11 @@
4291 ** <b>Details:</b>
4292 **
4293 ** ^These routines return information about a single column of the current
4294 ** result row of a query. ^In every case the first argument is a pointer
4295 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4296 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
4297 ** and the second argument is the index of the column for which information
4298 ** should be returned. ^The leftmost column of the result set has the index 0.
4299 ** ^The number of columns in the result can be determined using
4300 ** [sqlite3_column_count()].
4301 **
@@ -4705,10 +4717,11 @@
4705 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
4706 ** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
4707 ** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
4708 ** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
4709 ** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
 
4710 ** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
4711 ** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
4712 ** the native byteorder
4713 ** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
4714 ** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
@@ -4724,11 +4737,11 @@
4724 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
4725 ** </table></blockquote>
4726 **
4727 ** <b>Details:</b>
4728 **
4729 ** This routine extract type, size, and content information from
4730 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
4731 ** are used to pass parameter information into implementation of
4732 ** [application-defined SQL functions] and [virtual tables].
4733 **
4734 ** These routines work only with [protected sqlite3_value] objects.
@@ -4741,10 +4754,15 @@
4741 **
4742 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
4743 ** in the native byte-order of the host machine. ^The
4744 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
4745 ** extract UTF-16 strings as big-endian and little-endian respectively.
 
 
 
 
 
4746 **
4747 ** ^(The sqlite3_value_type(V) interface returns the
4748 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
4749 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
4750 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -4774,10 +4792,11 @@
4774 */
4775 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4776 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4777 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4778 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
 
4779 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4780 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4781 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4782 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4783 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -4792,14 +4811,10 @@
4792 ** The sqlite3_value_subtype(V) function returns the subtype for
4793 ** an [application-defined SQL function] argument V. The subtype
4794 ** information can be used to pass a limited amount of context from
4795 ** one SQL function to another. Use the [sqlite3_result_subtype()]
4796 ** routine to set the subtype for the return value of an SQL function.
4797 **
4798 ** SQLite makes no use of subtype itself. It merely passes the subtype
4799 ** from the result of one [application-defined SQL function] into the
4800 ** input of another.
4801 */
4802 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
4803
4804 /*
4805 ** CAPI3REF: Copy And Free SQL Values
@@ -5065,11 +5080,11 @@
5065 ** assumes that the text or BLOB result is in constant space and does not
5066 ** copy the content of the parameter nor call a destructor on the content
5067 ** when it has finished using that result.
5068 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
5069 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
5070 ** then SQLite makes a copy of the result into space obtained from
5071 ** from [sqlite3_malloc()] before it returns.
5072 **
5073 ** ^The sqlite3_result_value() interface sets the result of
5074 ** the application-defined function to be a copy of the
5075 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
@@ -5077,10 +5092,18 @@
5077 ** so that the [sqlite3_value] specified in the parameter may change or
5078 ** be deallocated after sqlite3_result_value() returns without harm.
5079 ** ^A [protected sqlite3_value] object may always be used where an
5080 ** [unprotected sqlite3_value] object is required, so either
5081 ** kind of [sqlite3_value] object can be used with this interface.
 
 
 
 
 
 
 
 
5082 **
5083 ** If these routines are called from within the different thread
5084 ** than the one containing the application-defined function that received
5085 ** the [sqlite3_context] pointer, the results are undefined.
5086 */
@@ -5101,10 +5124,11 @@
5101 void(*)(void*), unsigned char encoding);
5102 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
5103 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
5104 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
5105 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
 
5106 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
5107 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
5108
5109
5110 /*
@@ -5461,11 +5485,11 @@
5461 **
5462 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5463 ** to which a [prepared statement] belongs. ^The [database connection]
5464 ** returned by sqlite3_db_handle is the same [database connection]
5465 ** that was the first argument
5466 ** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
5467 ** create the statement in the first place.
5468 */
5469 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5470
5471 /*
@@ -5537,11 +5561,11 @@
5537 ** the database connection that invoked the callback. Any actions
5538 ** to modify the database connection must be deferred until after the
5539 ** completion of the [sqlite3_step()] call that triggered the commit
5540 ** or rollback hook in the first place.
5541 ** Note that running any other SQL statements, including SELECT statements,
5542 ** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
5543 ** the database connections for the meaning of "modify" in this paragraph.
5544 **
5545 ** ^Registering a NULL function disables the callback.
5546 **
5547 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5597,11 +5621,11 @@
5597 **
5598 ** The update hook implementation must not do anything that will modify
5599 ** the database connection that invoked the update hook. Any actions
5600 ** to modify the database connection must be deferred until after the
5601 ** completion of the [sqlite3_step()] call that triggered the update hook.
5602 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
5603 ** database connections for the meaning of "modify" in this paragraph.
5604 **
5605 ** ^The sqlite3_update_hook(D,C,P) function
5606 ** returns the P argument from the previous call
5607 ** on the same [database connection] D, or NULL for
5608
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.20.0"
125 #define SQLITE_VERSION_NUMBER 3020000
126 #define SQLITE_SOURCE_ID "2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -233,11 +233,11 @@
233 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236 ** and [sqlite3_close_v2()] are its destructors. There are many other
237 ** interfaces (such as
238 ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
239 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
240 ** sqlite3 object.
241 */
242 typedef struct sqlite3 sqlite3;
243
@@ -337,11 +337,11 @@
337 /*
338 ** CAPI3REF: One-Step Query Execution Interface
339 ** METHOD: sqlite3
340 **
341 ** The sqlite3_exec() interface is a convenience wrapper around
342 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
343 ** that allows an application to run multiple statements of SQL
344 ** without having to use a lot of C code.
345 **
346 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2006,14 +2006,14 @@
2006 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2007 ** have been disabled - 0 if they are not disabled, 1 if they are.
2008 ** </dd>
2009 **
2010 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2011 ** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2012 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2013 ** a single SQL query statement will always use the same algorithm regardless
2014 ** of values of [bound parameters].)^ The QPSG disables some query optimizations
2015 ** that look at the values of bound parameters, which can make some queries
2016 ** slower. But the QPSG has the advantage of more predictable behavior. With
2017 ** the QPSG active, SQLite will always use the same query plan in the field as
2018 ** was used during testing in the lab.
2019 ** </dd>
@@ -2699,16 +2699,16 @@
2699 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2700 ** specific action but allow the SQL statement to continue to be
2701 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2702 ** rejected with an error. ^If the authorizer callback returns
2703 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2704 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
2705 ** the authorizer will fail with an error message.
2706 **
2707 ** When the callback returns [SQLITE_OK], that means the operation
2708 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2709 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
2710 ** authorizer will fail with an error message explaining that
2711 ** access is denied.
2712 **
2713 ** ^The first parameter to the authorizer callback is a copy of the third
2714 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2755,23 +2755,23 @@
2755 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
2756 ** The authorizer is disabled by default.
2757 **
2758 ** The authorizer callback must not do anything that will modify
2759 ** the database connection that invoked the authorizer callback.
2760 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2761 ** database connections for the meaning of "modify" in this paragraph.
2762 **
2763 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
2764 ** statement might be re-prepared during [sqlite3_step()] due to a
2765 ** schema change. Hence, the application should ensure that the
2766 ** correct authorizer callback remains in place during the [sqlite3_step()].
2767 **
2768 ** ^Note that the authorizer callback is invoked only during
2769 ** [sqlite3_prepare()] or its variants. Authorization is not
2770 ** performed during statement evaluation in [sqlite3_step()], unless
2771 ** as stated in the previous paragraph, sqlite3_step() invokes
2772 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2773 */
2774 SQLITE_API int sqlite3_set_authorizer(
2775 sqlite3*,
2776 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2777 void *pUserData
@@ -3003,11 +3003,11 @@
3003 ** interrupted. This feature can be used to implement a
3004 ** "Cancel" button on a GUI progress dialog box.
3005 **
3006 ** The progress handler callback must not do anything that will modify
3007 ** the database connection that invoked the progress handler.
3008 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3009 ** database connections for the meaning of "modify" in this paragraph.
3010 **
3011 */
3012 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3013
@@ -3357,11 +3357,11 @@
3357 ** prepared statement before it can be run.
3358 **
3359 ** The life-cycle of a prepared statement object usually goes like this:
3360 **
3361 ** <ol>
3362 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3363 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
3364 ** interfaces.
3365 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3366 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3367 ** to step 2. Do this zero or more times.
@@ -3439,11 +3439,11 @@
3439 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3440 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3441 **
3442 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3443 ** <dd>The maximum number of instructions in a virtual machine program
3444 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3445 ** the equivalent tries to allocate space for more than this many opcodes
3446 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3447 **
3448 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3449 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3490,17 +3490,19 @@
3490 **
3491 ** New flags may be added in future releases of SQLite.
3492 **
3493 ** <dl>
3494 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
3495 ** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
3496 ** that the prepared statement will be retained for a long time and
3497 ** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]
3498 ** and [sqlite3_prepare16_v3()] assume that the prepared statement will
3499 ** be used just once or at most a few times and then destroyed using
3500 ** [sqlite3_finalize()] relatively soon. The current implementation acts
3501 ** on this hint by avoiding the use of [lookaside memory] so as not to
3502 ** deplete the limited store of lookaside memory. Future versions of
3503 ** SQLite may act on this hint differently.
3504 ** </dl>
3505 */
3506 #define SQLITE_PREPARE_PERSISTENT 0x01
3507
3508 /*
@@ -3799,11 +3801,11 @@
3801 ** CAPI3REF: Binding Values To Prepared Statements
3802 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3803 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3804 ** METHOD: sqlite3_stmt
3805 **
3806 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3807 ** literals may be replaced by a [parameter] that matches one of following
3808 ** templates:
3809 **
3810 ** <ul>
3811 ** <li> ?
@@ -3818,11 +3820,11 @@
3820 ** parameters (also called "host parameter names" or "SQL parameters")
3821 ** can be set using the sqlite3_bind_*() routines defined here.
3822 **
3823 ** ^The first argument to the sqlite3_bind_*() routines is always
3824 ** a pointer to the [sqlite3_stmt] object returned from
3825 ** [sqlite3_prepare_v2()] or its variants.
3826 **
3827 ** ^The second argument is the index of the SQL parameter to be set.
3828 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3829 ** SQL parameter is used more than once, second and subsequent
3830 ** occurrences have the same index as the first occurrence.
@@ -3878,10 +3880,19 @@
3880 ** (just an integer to hold its size) while it is being processed.
3881 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
3882 ** content is later written using
3883 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
3884 ** ^A negative value for the zeroblob results in a zero-length BLOB.
3885 **
3886 ** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
3887 ** [prepared statement] S to have an SQL value of NULL, but to also be
3888 ** associated with the pointer P.
3889 ** ^The sqlite3_bind_pointer() routine can be used to pass
3890 ** host-language pointers into [application-defined SQL functions].
3891 ** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
3892 ** to be an ordinary SQL NULL value to everything other than
3893 ** [sqlite3_value_pointer()].
3894 **
3895 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
3896 ** for the [prepared statement] or with a prepared statement for which
3897 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
3898 ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -3912,10 +3923,11 @@
3923 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3924 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3925 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3926 void(*)(void*), unsigned char encoding);
3927 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3928 SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
3929 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3930 SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
3931
3932 /*
3933 ** CAPI3REF: Number Of SQL Parameters
@@ -4291,11 +4303,11 @@
4303 ** <b>Details:</b>
4304 **
4305 ** ^These routines return information about a single column of the current
4306 ** result row of a query. ^In every case the first argument is a pointer
4307 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4308 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
4309 ** and the second argument is the index of the column for which information
4310 ** should be returned. ^The leftmost column of the result set has the index 0.
4311 ** ^The number of columns in the result can be determined using
4312 ** [sqlite3_column_count()].
4313 **
@@ -4705,10 +4717,11 @@
4717 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
4718 ** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
4719 ** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
4720 ** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
4721 ** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
4722 ** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value
4723 ** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
4724 ** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
4725 ** the native byteorder
4726 ** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
4727 ** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
@@ -4724,11 +4737,11 @@
4737 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
4738 ** </table></blockquote>
4739 **
4740 ** <b>Details:</b>
4741 **
4742 ** These routines extract type, size, and content information from
4743 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
4744 ** are used to pass parameter information into implementation of
4745 ** [application-defined SQL functions] and [virtual tables].
4746 **
4747 ** These routines work only with [protected sqlite3_value] objects.
@@ -4741,10 +4754,15 @@
4754 **
4755 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
4756 ** in the native byte-order of the host machine. ^The
4757 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
4758 ** extract UTF-16 strings as big-endian and little-endian respectively.
4759 **
4760 ** ^If [sqlite3_value] object V was initialized
4761 ** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
4762 ** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
4763 ** sqlite3_value_pointer(V) returns a NULL.
4764 **
4765 ** ^(The sqlite3_value_type(V) interface returns the
4766 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
4767 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
4768 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -4774,10 +4792,11 @@
4792 */
4793 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4794 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4795 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4796 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4797 SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
4798 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4799 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4800 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4801 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4802 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -4792,14 +4811,10 @@
4811 ** The sqlite3_value_subtype(V) function returns the subtype for
4812 ** an [application-defined SQL function] argument V. The subtype
4813 ** information can be used to pass a limited amount of context from
4814 ** one SQL function to another. Use the [sqlite3_result_subtype()]
4815 ** routine to set the subtype for the return value of an SQL function.
 
 
 
 
4816 */
4817 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
4818
4819 /*
4820 ** CAPI3REF: Copy And Free SQL Values
@@ -5065,11 +5080,11 @@
5080 ** assumes that the text or BLOB result is in constant space and does not
5081 ** copy the content of the parameter nor call a destructor on the content
5082 ** when it has finished using that result.
5083 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
5084 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
5085 ** then SQLite makes a copy of the result into space obtained
5086 ** from [sqlite3_malloc()] before it returns.
5087 **
5088 ** ^The sqlite3_result_value() interface sets the result of
5089 ** the application-defined function to be a copy of the
5090 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
@@ -5077,10 +5092,18 @@
5092 ** so that the [sqlite3_value] specified in the parameter may change or
5093 ** be deallocated after sqlite3_result_value() returns without harm.
5094 ** ^A [protected sqlite3_value] object may always be used where an
5095 ** [unprotected sqlite3_value] object is required, so either
5096 ** kind of [sqlite3_value] object can be used with this interface.
5097 **
5098 ** ^The sqlite3_result_pointer(C,P) interface sets the result to an
5099 ** SQL NULL value, just like [sqlite3_result_null(C)], except that it
5100 ** also associates the host-language pointer P with that NULL value such
5101 ** that the pointer can be retrieved within an
5102 ** [application-defined SQL function] using [sqlite3_value_pointer()].
5103 ** This mechanism can be used to pass non-SQL values between
5104 ** application-defined functions.
5105 **
5106 ** If these routines are called from within the different thread
5107 ** than the one containing the application-defined function that received
5108 ** the [sqlite3_context] pointer, the results are undefined.
5109 */
@@ -5101,10 +5124,11 @@
5124 void(*)(void*), unsigned char encoding);
5125 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
5126 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
5127 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
5128 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
5129 SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
5130 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
5131 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
5132
5133
5134 /*
@@ -5461,11 +5485,11 @@
5485 **
5486 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5487 ** to which a [prepared statement] belongs. ^The [database connection]
5488 ** returned by sqlite3_db_handle is the same [database connection]
5489 ** that was the first argument
5490 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5491 ** create the statement in the first place.
5492 */
5493 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5494
5495 /*
@@ -5537,11 +5561,11 @@
5561 ** the database connection that invoked the callback. Any actions
5562 ** to modify the database connection must be deferred until after the
5563 ** completion of the [sqlite3_step()] call that triggered the commit
5564 ** or rollback hook in the first place.
5565 ** Note that running any other SQL statements, including SELECT statements,
5566 ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
5567 ** the database connections for the meaning of "modify" in this paragraph.
5568 **
5569 ** ^Registering a NULL function disables the callback.
5570 **
5571 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5597,11 +5621,11 @@
5621 **
5622 ** The update hook implementation must not do anything that will modify
5623 ** the database connection that invoked the update hook. Any actions
5624 ** to modify the database connection must be deferred until after the
5625 ** completion of the [sqlite3_step()] call that triggered the update hook.
5626 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
5627 ** database connections for the meaning of "modify" in this paragraph.
5628 **
5629 ** ^The sqlite3_update_hook(D,C,P) function
5630 ** returns the P argument from the previous call
5631 ** on the same [database connection] D, or NULL for
5632

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button