| | @@ -1150,11 +1150,11 @@ |
| 1150 | 1150 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1151 | 1151 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1152 | 1152 | */ |
| 1153 | 1153 | #define SQLITE_VERSION "3.20.0" |
| 1154 | 1154 | #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" |
| 1156 | 1156 | |
| 1157 | 1157 | /* |
| 1158 | 1158 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1159 | 1159 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1160 | 1160 | ** |
| | @@ -1262,11 +1262,11 @@ |
| 1262 | 1262 | ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 |
| 1263 | 1263 | ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and |
| 1264 | 1264 | ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] |
| 1265 | 1265 | ** and [sqlite3_close_v2()] are its destructors. There are many other |
| 1266 | 1266 | ** interfaces (such as |
| 1267 | | -** [sqlite3_prepare_v3()], [sqlite3_create_function()], and |
| 1267 | +** [sqlite3_prepare_v2()], [sqlite3_create_function()], and |
| 1268 | 1268 | ** [sqlite3_busy_timeout()] to name but three) that are methods on an |
| 1269 | 1269 | ** sqlite3 object. |
| 1270 | 1270 | */ |
| 1271 | 1271 | typedef struct sqlite3 sqlite3; |
| 1272 | 1272 | |
| | @@ -1366,11 +1366,11 @@ |
| 1366 | 1366 | /* |
| 1367 | 1367 | ** CAPI3REF: One-Step Query Execution Interface |
| 1368 | 1368 | ** METHOD: sqlite3 |
| 1369 | 1369 | ** |
| 1370 | 1370 | ** 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()], |
| 1372 | 1372 | ** that allows an application to run multiple statements of SQL |
| 1373 | 1373 | ** without having to use a lot of C code. |
| 1374 | 1374 | ** |
| 1375 | 1375 | ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, |
| 1376 | 1376 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| | @@ -3035,14 +3035,14 @@ |
| 3035 | 3035 | ** into which is written 0 or 1 to indicate whether checkpoints-on-close |
| 3036 | 3036 | ** have been disabled - 0 if they are not disabled, 1 if they are. |
| 3037 | 3037 | ** </dd> |
| 3038 | 3038 | ** |
| 3039 | 3039 | ** <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 |
| 3041 | 3041 | ** the [query planner stability guarantee] (QPSG). When the QPSG is active, |
| 3042 | 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 |
| 3043 | +** of values of [bound parameters].)^ The QPSG disables some query optimizations |
| 3044 | 3044 | ** that look at the values of bound parameters, which can make some queries |
| 3045 | 3045 | ** slower. But the QPSG has the advantage of more predictable behavior. With |
| 3046 | 3046 | ** the QPSG active, SQLite will always use the same query plan in the field as |
| 3047 | 3047 | ** was used during testing in the lab. |
| 3048 | 3048 | ** </dd> |
| | @@ -3728,16 +3728,16 @@ |
| 3728 | 3728 | ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the |
| 3729 | 3729 | ** specific action but allow the SQL statement to continue to be |
| 3730 | 3730 | ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be |
| 3731 | 3731 | ** rejected with an error. ^If the authorizer callback returns |
| 3732 | 3732 | ** 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 |
| 3734 | 3734 | ** the authorizer will fail with an error message. |
| 3735 | 3735 | ** |
| 3736 | 3736 | ** When the callback returns [SQLITE_OK], that means the operation |
| 3737 | 3737 | ** 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 |
| 3739 | 3739 | ** authorizer will fail with an error message explaining that |
| 3740 | 3740 | ** access is denied. |
| 3741 | 3741 | ** |
| 3742 | 3742 | ** ^The first parameter to the authorizer callback is a copy of the third |
| 3743 | 3743 | ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter |
| | @@ -3784,23 +3784,23 @@ |
| 3784 | 3784 | ** previous call.)^ ^Disable the authorizer by installing a NULL callback. |
| 3785 | 3785 | ** The authorizer is disabled by default. |
| 3786 | 3786 | ** |
| 3787 | 3787 | ** The authorizer callback must not do anything that will modify |
| 3788 | 3788 | ** 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 |
| 3790 | 3790 | ** database connections for the meaning of "modify" in this paragraph. |
| 3791 | 3791 | ** |
| 3792 | | -** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the |
| 3792 | +** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the |
| 3793 | 3793 | ** statement might be re-prepared during [sqlite3_step()] due to a |
| 3794 | 3794 | ** schema change. Hence, the application should ensure that the |
| 3795 | 3795 | ** correct authorizer callback remains in place during the [sqlite3_step()]. |
| 3796 | 3796 | ** |
| 3797 | 3797 | ** ^Note that the authorizer callback is invoked only during |
| 3798 | 3798 | ** [sqlite3_prepare()] or its variants. Authorization is not |
| 3799 | 3799 | ** performed during statement evaluation in [sqlite3_step()], unless |
| 3800 | 3800 | ** 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. |
| 3802 | 3802 | */ |
| 3803 | 3803 | SQLITE_API int sqlite3_set_authorizer( |
| 3804 | 3804 | sqlite3*, |
| 3805 | 3805 | int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), |
| 3806 | 3806 | void *pUserData |
| | @@ -4032,11 +4032,11 @@ |
| 4032 | 4032 | ** interrupted. This feature can be used to implement a |
| 4033 | 4033 | ** "Cancel" button on a GUI progress dialog box. |
| 4034 | 4034 | ** |
| 4035 | 4035 | ** The progress handler callback must not do anything that will modify |
| 4036 | 4036 | ** 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 |
| 4038 | 4038 | ** database connections for the meaning of "modify" in this paragraph. |
| 4039 | 4039 | ** |
| 4040 | 4040 | */ |
| 4041 | 4041 | SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
| 4042 | 4042 | |
| | @@ -4386,11 +4386,11 @@ |
| 4386 | 4386 | ** prepared statement before it can be run. |
| 4387 | 4387 | ** |
| 4388 | 4388 | ** The life-cycle of a prepared statement object usually goes like this: |
| 4389 | 4389 | ** |
| 4390 | 4390 | ** <ol> |
| 4391 | | -** <li> Create the prepared statement object using [sqlite3_prepare_v3()]. |
| 4391 | +** <li> Create the prepared statement object using [sqlite3_prepare_v2()]. |
| 4392 | 4392 | ** <li> Bind values to [parameters] using the sqlite3_bind_*() |
| 4393 | 4393 | ** interfaces. |
| 4394 | 4394 | ** <li> Run the SQL by calling [sqlite3_step()] one or more times. |
| 4395 | 4395 | ** <li> Reset the prepared statement using [sqlite3_reset()] then go back |
| 4396 | 4396 | ** to step 2. Do this zero or more times. |
| | @@ -4468,11 +4468,11 @@ |
| 4468 | 4468 | ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt> |
| 4469 | 4469 | ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^ |
| 4470 | 4470 | ** |
| 4471 | 4471 | ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt> |
| 4472 | 4472 | ** <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 |
| 4474 | 4474 | ** the equivalent tries to allocate space for more than this many opcodes |
| 4475 | 4475 | ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^ |
| 4476 | 4476 | ** |
| 4477 | 4477 | ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt> |
| 4478 | 4478 | ** <dd>The maximum number of arguments on a function.</dd>)^ |
| | @@ -4519,17 +4519,19 @@ |
| 4519 | 4519 | ** |
| 4520 | 4520 | ** New flags may be added in future releases of SQLite. |
| 4521 | 4521 | ** |
| 4522 | 4522 | ** <dl> |
| 4523 | 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. |
| 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. |
| 4531 | 4533 | ** </dl> |
| 4532 | 4534 | */ |
| 4533 | 4535 | #define SQLITE_PREPARE_PERSISTENT 0x01 |
| 4534 | 4536 | |
| 4535 | 4537 | /* |
| | @@ -4828,11 +4830,11 @@ |
| 4828 | 4830 | ** CAPI3REF: Binding Values To Prepared Statements |
| 4829 | 4831 | ** KEYWORDS: {host parameter} {host parameters} {host parameter name} |
| 4830 | 4832 | ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} |
| 4831 | 4833 | ** METHOD: sqlite3_stmt |
| 4832 | 4834 | ** |
| 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, |
| 4834 | 4836 | ** literals may be replaced by a [parameter] that matches one of following |
| 4835 | 4837 | ** templates: |
| 4836 | 4838 | ** |
| 4837 | 4839 | ** <ul> |
| 4838 | 4840 | ** <li> ? |
| | @@ -4847,11 +4849,11 @@ |
| 4847 | 4849 | ** parameters (also called "host parameter names" or "SQL parameters") |
| 4848 | 4850 | ** can be set using the sqlite3_bind_*() routines defined here. |
| 4849 | 4851 | ** |
| 4850 | 4852 | ** ^The first argument to the sqlite3_bind_*() routines is always |
| 4851 | 4853 | ** a pointer to the [sqlite3_stmt] object returned from |
| 4852 | | -** [sqlite3_prepare_v3()] or its variants. |
| 4854 | +** [sqlite3_prepare_v2()] or its variants. |
| 4853 | 4855 | ** |
| 4854 | 4856 | ** ^The second argument is the index of the SQL parameter to be set. |
| 4855 | 4857 | ** ^The leftmost SQL parameter has an index of 1. ^When the same named |
| 4856 | 4858 | ** SQL parameter is used more than once, second and subsequent |
| 4857 | 4859 | ** occurrences have the same index as the first occurrence. |
| | @@ -4907,10 +4909,19 @@ |
| 4907 | 4909 | ** (just an integer to hold its size) while it is being processed. |
| 4908 | 4910 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 4909 | 4911 | ** content is later written using |
| 4910 | 4912 | ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| 4911 | 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()]. |
| 4912 | 4923 | ** |
| 4913 | 4924 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 4914 | 4925 | ** for the [prepared statement] or with a prepared statement for which |
| 4915 | 4926 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 4916 | 4927 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| | @@ -4941,10 +4952,11 @@ |
| 4941 | 4952 | SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 4942 | 4953 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 4943 | 4954 | SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 4944 | 4955 | void(*)(void*), unsigned char encoding); |
| 4945 | 4956 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 4957 | +SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*); |
| 4946 | 4958 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 4947 | 4959 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); |
| 4948 | 4960 | |
| 4949 | 4961 | /* |
| 4950 | 4962 | ** CAPI3REF: Number Of SQL Parameters |
| | @@ -5320,11 +5332,11 @@ |
| 5320 | 5332 | ** <b>Details:</b> |
| 5321 | 5333 | ** |
| 5322 | 5334 | ** ^These routines return information about a single column of the current |
| 5323 | 5335 | ** result row of a query. ^In every case the first argument is a pointer |
| 5324 | 5336 | ** 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) |
| 5326 | 5338 | ** and the second argument is the index of the column for which information |
| 5327 | 5339 | ** should be returned. ^The leftmost column of the result set has the index 0. |
| 5328 | 5340 | ** ^The number of columns in the result can be determined using |
| 5329 | 5341 | ** [sqlite3_column_count()]. |
| 5330 | 5342 | ** |
| | @@ -5734,10 +5746,11 @@ |
| 5734 | 5746 | ** <blockquote><table border=0 cellpadding=0 cellspacing=0> |
| 5735 | 5747 | ** <tr><td><b>sqlite3_value_blob</b><td>→<td>BLOB value |
| 5736 | 5748 | ** <tr><td><b>sqlite3_value_double</b><td>→<td>REAL value |
| 5737 | 5749 | ** <tr><td><b>sqlite3_value_int</b><td>→<td>32-bit INTEGER value |
| 5738 | 5750 | ** <tr><td><b>sqlite3_value_int64</b><td>→<td>64-bit INTEGER value |
| 5751 | +** <tr><td><b>sqlite3_value_pointer</b><td>→<td>Pointer value |
| 5739 | 5752 | ** <tr><td><b>sqlite3_value_text</b><td>→<td>UTF-8 TEXT value |
| 5740 | 5753 | ** <tr><td><b>sqlite3_value_text16</b><td>→<td>UTF-16 TEXT value in |
| 5741 | 5754 | ** the native byteorder |
| 5742 | 5755 | ** <tr><td><b>sqlite3_value_text16be</b><td>→<td>UTF-16be TEXT value |
| 5743 | 5756 | ** <tr><td><b>sqlite3_value_text16le</b><td>→<td>UTF-16le TEXT value |
| | @@ -5753,11 +5766,11 @@ |
| 5753 | 5766 | ** <td>→ <td>Best numeric datatype of the value |
| 5754 | 5767 | ** </table></blockquote> |
| 5755 | 5768 | ** |
| 5756 | 5769 | ** <b>Details:</b> |
| 5757 | 5770 | ** |
| 5758 | | -** This routine extract type, size, and content information from |
| 5771 | +** These routines extract type, size, and content information from |
| 5759 | 5772 | ** [protected sqlite3_value] objects. Protected sqlite3_value objects |
| 5760 | 5773 | ** are used to pass parameter information into implementation of |
| 5761 | 5774 | ** [application-defined SQL functions] and [virtual tables]. |
| 5762 | 5775 | ** |
| 5763 | 5776 | ** These routines work only with [protected sqlite3_value] objects. |
| | @@ -5770,10 +5783,15 @@ |
| 5770 | 5783 | ** |
| 5771 | 5784 | ** ^The sqlite3_value_text16() interface extracts a UTF-16 string |
| 5772 | 5785 | ** in the native byte-order of the host machine. ^The |
| 5773 | 5786 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 5774 | 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. |
| 5775 | 5793 | ** |
| 5776 | 5794 | ** ^(The sqlite3_value_type(V) interface returns the |
| 5777 | 5795 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 5778 | 5796 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 5779 | 5797 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| | @@ -5803,10 +5821,11 @@ |
| 5803 | 5821 | */ |
| 5804 | 5822 | SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); |
| 5805 | 5823 | SQLITE_API double sqlite3_value_double(sqlite3_value*); |
| 5806 | 5824 | SQLITE_API int sqlite3_value_int(sqlite3_value*); |
| 5807 | 5825 | SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); |
| 5826 | +SQLITE_API void *sqlite3_value_pointer(sqlite3_value*); |
| 5808 | 5827 | SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); |
| 5809 | 5828 | SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); |
| 5810 | 5829 | SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); |
| 5811 | 5830 | SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); |
| 5812 | 5831 | SQLITE_API int sqlite3_value_bytes(sqlite3_value*); |
| | @@ -5821,14 +5840,10 @@ |
| 5821 | 5840 | ** The sqlite3_value_subtype(V) function returns the subtype for |
| 5822 | 5841 | ** an [application-defined SQL function] argument V. The subtype |
| 5823 | 5842 | ** information can be used to pass a limited amount of context from |
| 5824 | 5843 | ** one SQL function to another. Use the [sqlite3_result_subtype()] |
| 5825 | 5844 | ** 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 | 5845 | */ |
| 5831 | 5846 | SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*); |
| 5832 | 5847 | |
| 5833 | 5848 | /* |
| 5834 | 5849 | ** CAPI3REF: Copy And Free SQL Values |
| | @@ -6094,11 +6109,11 @@ |
| 6094 | 6109 | ** assumes that the text or BLOB result is in constant space and does not |
| 6095 | 6110 | ** copy the content of the parameter nor call a destructor on the content |
| 6096 | 6111 | ** when it has finished using that result. |
| 6097 | 6112 | ** ^If the 4th parameter to the sqlite3_result_text* interfaces |
| 6098 | 6113 | ** 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 |
| 6100 | 6115 | ** from [sqlite3_malloc()] before it returns. |
| 6101 | 6116 | ** |
| 6102 | 6117 | ** ^The sqlite3_result_value() interface sets the result of |
| 6103 | 6118 | ** the application-defined function to be a copy of the |
| 6104 | 6119 | ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The |
| | @@ -6106,10 +6121,18 @@ |
| 6106 | 6121 | ** so that the [sqlite3_value] specified in the parameter may change or |
| 6107 | 6122 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 6108 | 6123 | ** ^A [protected sqlite3_value] object may always be used where an |
| 6109 | 6124 | ** [unprotected sqlite3_value] object is required, so either |
| 6110 | 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. |
| 6111 | 6134 | ** |
| 6112 | 6135 | ** If these routines are called from within the different thread |
| 6113 | 6136 | ** than the one containing the application-defined function that received |
| 6114 | 6137 | ** the [sqlite3_context] pointer, the results are undefined. |
| 6115 | 6138 | */ |
| | @@ -6130,10 +6153,11 @@ |
| 6130 | 6153 | void(*)(void*), unsigned char encoding); |
| 6131 | 6154 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 6132 | 6155 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6133 | 6156 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6134 | 6157 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 6158 | +SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*); |
| 6135 | 6159 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 6136 | 6160 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 6137 | 6161 | |
| 6138 | 6162 | |
| 6139 | 6163 | /* |
| | @@ -6490,11 +6514,11 @@ |
| 6490 | 6514 | ** |
| 6491 | 6515 | ** ^The sqlite3_db_handle interface returns the [database connection] handle |
| 6492 | 6516 | ** to which a [prepared statement] belongs. ^The [database connection] |
| 6493 | 6517 | ** returned by sqlite3_db_handle is the same [database connection] |
| 6494 | 6518 | ** 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 |
| 6496 | 6520 | ** create the statement in the first place. |
| 6497 | 6521 | */ |
| 6498 | 6522 | SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); |
| 6499 | 6523 | |
| 6500 | 6524 | /* |
| | @@ -6566,11 +6590,11 @@ |
| 6566 | 6590 | ** the database connection that invoked the callback. Any actions |
| 6567 | 6591 | ** to modify the database connection must be deferred until after the |
| 6568 | 6592 | ** completion of the [sqlite3_step()] call that triggered the commit |
| 6569 | 6593 | ** or rollback hook in the first place. |
| 6570 | 6594 | ** 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 |
| 6572 | 6596 | ** the database connections for the meaning of "modify" in this paragraph. |
| 6573 | 6597 | ** |
| 6574 | 6598 | ** ^Registering a NULL function disables the callback. |
| 6575 | 6599 | ** |
| 6576 | 6600 | ** ^When the commit hook callback routine returns zero, the [COMMIT] |
| | @@ -6626,11 +6650,11 @@ |
| 6626 | 6650 | ** |
| 6627 | 6651 | ** The update hook implementation must not do anything that will modify |
| 6628 | 6652 | ** the database connection that invoked the update hook. Any actions |
| 6629 | 6653 | ** to modify the database connection must be deferred until after the |
| 6630 | 6654 | ** 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 |
| 6632 | 6656 | ** database connections for the meaning of "modify" in this paragraph. |
| 6633 | 6657 | ** |
| 6634 | 6658 | ** ^The sqlite3_update_hook(D,C,P) function |
| 6635 | 6659 | ** returns the P argument from the previous call |
| 6636 | 6660 | ** on the same [database connection] D, or NULL for |
| | @@ -13595,28 +13619,30 @@ |
| 13595 | 13619 | typedef struct VdbeOpList VdbeOpList; |
| 13596 | 13620 | |
| 13597 | 13621 | /* |
| 13598 | 13622 | ** Allowed values of VdbeOp.p4type |
| 13599 | 13623 | */ |
| 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 */ |
| 13618 | 13644 | |
| 13619 | 13645 | /* Error message codes for OP_Halt */ |
| 13620 | 13646 | #define P5_ConstraintNotNull 1 |
| 13621 | 13647 | #define P5_ConstraintUnique 2 |
| 13622 | 13648 | #define P5_ConstraintCheck 3 |
| | @@ -18603,10 +18629,11 @@ |
| 18603 | 18629 | struct sqlite3_value { |
| 18604 | 18630 | union MemValue { |
| 18605 | 18631 | double r; /* Real value used when MEM_Real is set in flags */ |
| 18606 | 18632 | i64 i; /* Integer value used when MEM_Int is set in flags */ |
| 18607 | 18633 | int nZero; /* Used when bit MEM_Zero is set in flags */ |
| 18634 | + void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */ |
| 18608 | 18635 | FuncDef *pDef; /* Used only when flags==MEM_Agg */ |
| 18609 | 18636 | RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ |
| 18610 | 18637 | VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ |
| 18611 | 18638 | } u; |
| 18612 | 18639 | u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ |
| | @@ -18888,10 +18915,11 @@ |
| 18888 | 18915 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 18889 | 18916 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 |
| 18890 | 18917 | #else |
| 18891 | 18918 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 18892 | 18919 | #endif |
| 18920 | +SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*); |
| 18893 | 18921 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 18894 | 18922 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 18895 | 18923 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 18896 | 18924 | SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*); |
| 18897 | 18925 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| | @@ -70898,10 +70926,21 @@ |
| 70898 | 70926 | }else{ |
| 70899 | 70927 | pMem->u.i = val; |
| 70900 | 70928 | pMem->flags = MEM_Int; |
| 70901 | 70929 | } |
| 70902 | 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 | +} |
| 70903 | 70942 | |
| 70904 | 70943 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 70905 | 70944 | /* |
| 70906 | 70945 | ** Delete any previous value and set the value stored in *pMem to val, |
| 70907 | 70946 | ** manifest type REAL. |
| | @@ -72796,11 +72835,11 @@ |
| 72796 | 72835 | */ |
| 72797 | 72836 | static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){ |
| 72798 | 72837 | if( aOp ){ |
| 72799 | 72838 | Op *pOp; |
| 72800 | 72839 | 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); |
| 72802 | 72841 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 72803 | 72842 | sqlite3DbFree(db, pOp->zComment); |
| 72804 | 72843 | #endif |
| 72805 | 72844 | } |
| 72806 | 72845 | sqlite3DbFreeNN(db, aOp); |
| | @@ -76801,10 +76840,18 @@ |
| 76801 | 76840 | return sqlite3VdbeIntValue((Mem*)pVal); |
| 76802 | 76841 | } |
| 76803 | 76842 | SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){ |
| 76804 | 76843 | Mem *pMem = (Mem*)pVal; |
| 76805 | 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 | + } |
| 76806 | 76853 | } |
| 76807 | 76854 | SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ |
| 76808 | 76855 | return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8); |
| 76809 | 76856 | } |
| 76810 | 76857 | #ifndef SQLITE_OMIT_UTF16 |
| | @@ -76979,10 +77026,16 @@ |
| 76979 | 77026 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); |
| 76980 | 77027 | } |
| 76981 | 77028 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 76982 | 77029 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 76983 | 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); |
| 76984 | 77037 | } |
| 76985 | 77038 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 76986 | 77039 | Mem *pOut = pCtx->pOut; |
| 76987 | 77040 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 76988 | 77041 | pOut->eSubtype = eSubtype & 0xff; |
| | @@ -77982,10 +78035,20 @@ |
| 77982 | 78035 | rc = vdbeUnbind(p, i); |
| 77983 | 78036 | if( rc==SQLITE_OK ){ |
| 77984 | 78037 | sqlite3_mutex_leave(p->db->mutex); |
| 77985 | 78038 | } |
| 77986 | 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; |
| 77987 | 78050 | } |
| 77988 | 78051 | SQLITE_API int sqlite3_bind_text( |
| 77989 | 78052 | sqlite3_stmt *pStmt, |
| 77990 | 78053 | int i, |
| 77991 | 78054 | const char *zData, |
| | @@ -106211,10 +106274,14 @@ |
| 106211 | 106274 | assert( SQLITE_INTEGER==1 ); |
| 106212 | 106275 | assert( SQLITE_FLOAT==2 ); |
| 106213 | 106276 | assert( SQLITE_TEXT==3 ); |
| 106214 | 106277 | assert( SQLITE_BLOB==4 ); |
| 106215 | 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. */ |
| 106216 | 106283 | sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC); |
| 106217 | 106284 | } |
| 106218 | 106285 | |
| 106219 | 106286 | |
| 106220 | 106287 | /* |
| | @@ -112140,10 +112207,13 @@ |
| 112140 | 112207 | /* Version 3.20.0 and later */ |
| 112141 | 112208 | int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, |
| 112142 | 112209 | sqlite3_stmt**,const char**); |
| 112143 | 112210 | int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, |
| 112144 | 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*); |
| 112145 | 112215 | }; |
| 112146 | 112216 | |
| 112147 | 112217 | /* |
| 112148 | 112218 | ** This is the function signature used for all extension entry points. It |
| 112149 | 112219 | ** is also defined in the file "loadext.c". |
| | @@ -112403,10 +112473,13 @@ |
| 112403 | 112473 | /* Version 3.18.0 and later */ |
| 112404 | 112474 | #define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid |
| 112405 | 112475 | /* Version 3.20.0 and later */ |
| 112406 | 112476 | #define sqlite3_prepare_v3 sqlite3_api->prepare_v3 |
| 112407 | 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 |
| 112408 | 112481 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 112409 | 112482 | |
| 112410 | 112483 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 112411 | 112484 | /* This case when the file really is being compiled as a loadable |
| 112412 | 112485 | ** extension */ |
| | @@ -112834,11 +112907,14 @@ |
| 112834 | 112907 | sqlite3_expanded_sql, |
| 112835 | 112908 | /* Version 3.18.0 and later */ |
| 112836 | 112909 | sqlite3_set_last_insert_rowid, |
| 112837 | 112910 | /* Version 3.20.0 and later */ |
| 112838 | 112911 | sqlite3_prepare_v3, |
| 112839 | | - sqlite3_prepare16_v3 |
| 112912 | + sqlite3_prepare16_v3, |
| 112913 | + sqlite3_bind_pointer, |
| 112914 | + sqlite3_result_pointer, |
| 112915 | + sqlite3_value_pointer |
| 112840 | 112916 | }; |
| 112841 | 112917 | |
| 112842 | 112918 | /* |
| 112843 | 112919 | ** Attempt to load an SQLite extension library contained in the file |
| 112844 | 112920 | ** zFile. The entry point is zProc. zProc may be 0 in which case a |
| | @@ -117102,13 +117178,18 @@ |
| 117102 | 117178 | int nBytes, /* Length of zSql in bytes. */ |
| 117103 | 117179 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 117104 | 117180 | const char **pzTail /* OUT: End of parsed string */ |
| 117105 | 117181 | ){ |
| 117106 | 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 */ |
| 117107 | 117188 | rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0, |
| 117108 | 117189 | ppStmt,pzTail); |
| 117109 | | - assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */ |
| 117190 | + assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); |
| 117110 | 117191 | return rc; |
| 117111 | 117192 | } |
| 117112 | 117193 | SQLITE_API int sqlite3_prepare_v3( |
| 117113 | 117194 | sqlite3 *db, /* Database handle. */ |
| 117114 | 117195 | const char *zSql, /* UTF-8 encoded SQL statement. */ |
| | @@ -117116,14 +117197,21 @@ |
| 117116 | 117197 | unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */ |
| 117117 | 117198 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 117118 | 117199 | const char **pzTail /* OUT: End of parsed string */ |
| 117119 | 117200 | ){ |
| 117120 | 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. */ |
| 117121 | 117209 | rc = sqlite3LockAndPrepare(db,zSql,nBytes, |
| 117122 | 117210 | SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK), |
| 117123 | 117211 | 0,ppStmt,pzTail); |
| 117124 | | - assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */ |
| 117212 | + assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); |
| 117125 | 117213 | return rc; |
| 117126 | 117214 | } |
| 117127 | 117215 | |
| 117128 | 117216 | |
| 117129 | 117217 | #ifndef SQLITE_OMIT_UTF16 |
| | @@ -142215,10 +142303,12 @@ |
| 142215 | 142303 | va_list ap; |
| 142216 | 142304 | int rc; |
| 142217 | 142305 | va_start(ap, op); |
| 142218 | 142306 | switch( op ){ |
| 142219 | 142307 | case SQLITE_DBCONFIG_MAINDBNAME: { |
| 142308 | + /* IMP: R-06824-28531 */ |
| 142309 | + /* IMP: R-36257-52125 */ |
| 142220 | 142310 | db->aDb[0].zDbSName = va_arg(ap,char*); |
| 142221 | 142311 | rc = SQLITE_OK; |
| 142222 | 142312 | break; |
| 142223 | 142313 | } |
| 142224 | 142314 | case SQLITE_DBCONFIG_LOOKASIDE: { |
| | @@ -150188,12 +150278,11 @@ |
| 150188 | 150278 | assert( iCol>=0 && iCol<=p->nColumn+2 ); |
| 150189 | 150279 | |
| 150190 | 150280 | switch( iCol-p->nColumn ){ |
| 150191 | 150281 | case 0: |
| 150192 | 150282 | /* 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); |
| 150195 | 150284 | break; |
| 150196 | 150285 | |
| 150197 | 150286 | case 1: |
| 150198 | 150287 | /* The docid column */ |
| 150199 | 150288 | sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| | @@ -150407,13 +150496,14 @@ |
| 150407 | 150496 | sqlite3_context *pContext, /* SQL function call context */ |
| 150408 | 150497 | const char *zFunc, /* Function name */ |
| 150409 | 150498 | sqlite3_value *pVal, /* argv[0] passed to function */ |
| 150410 | 150499 | Fts3Cursor **ppCsr /* OUT: Store cursor handle here */ |
| 150411 | 150500 | ){ |
| 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; |
| 150415 | 150505 | }else{ |
| 150416 | 150506 | char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc); |
| 150417 | 150507 | sqlite3_result_error(pContext, zErr, -1); |
| 150418 | 150508 | sqlite3_free(zErr); |
| 150419 | 150509 | rc = SQLITE_ERROR; |
| | @@ -200127,11 +200217,11 @@ |
| 200127 | 200217 | int nArg, /* Number of args */ |
| 200128 | 200218 | sqlite3_value **apUnused /* Function arguments */ |
| 200129 | 200219 | ){ |
| 200130 | 200220 | assert( nArg==0 ); |
| 200131 | 200221 | 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); |
| 200133 | 200223 | } |
| 200134 | 200224 | |
| 200135 | 200225 | static int fts5Init(sqlite3 *db){ |
| 200136 | 200226 | static const sqlite3_module fts5Mod = { |
| 200137 | 200227 | /* iVersion */ 2, |
| | @@ -204014,27 +204104,10 @@ |
| 204014 | 204104 | SQLITE_EXTENSION_INIT1 |
| 204015 | 204105 | /* #include <assert.h> */ |
| 204016 | 204106 | /* #include <string.h> */ |
| 204017 | 204107 | |
| 204018 | 204108 | #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 | 204109 | |
| 204037 | 204110 | /* stmt_vtab is a subclass of sqlite3_vtab which will |
| 204038 | 204111 | ** serve as the underlying representation of a stmt virtual table |
| 204039 | 204112 | */ |
| 204040 | 204113 | typedef struct stmt_vtab stmt_vtab; |
| | @@ -204077,26 +204150,25 @@ |
| 204077 | 204150 | ){ |
| 204078 | 204151 | stmt_vtab *pNew; |
| 204079 | 204152 | int rc; |
| 204080 | 204153 | |
| 204081 | 204154 | /* 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 */ |
| 204094 | 204166 | |
| 204095 | 204167 | |
| 204096 | 204168 | 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," |
| 204098 | 204170 | "reprep,run,mem)"); |
| 204099 | 204171 | if( rc==SQLITE_OK ){ |
| 204100 | 204172 | pNew = sqlite3_malloc( sizeof(*pNew) ); |
| 204101 | 204173 | *ppVtab = (sqlite3_vtab*)pNew; |
| 204102 | 204174 | if( pNew==0 ) return SQLITE_NOMEM; |
| | @@ -204155,14 +204227,10 @@ |
| 204155 | 204227 | sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ |
| 204156 | 204228 | int i /* Which column to return */ |
| 204157 | 204229 | ){ |
| 204158 | 204230 | stmt_cursor *pCur = (stmt_cursor*)cur; |
| 204159 | 204231 | switch( i ){ |
| 204160 | | - case STMT_COLUMN_PTR: { |
| 204161 | | - sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt)); |
| 204162 | | - break; |
| 204163 | | - } |
| 204164 | 204232 | case STMT_COLUMN_SQL: { |
| 204165 | 204233 | sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT); |
| 204166 | 204234 | break; |
| 204167 | 204235 | } |
| 204168 | 204236 | case STMT_COLUMN_NCOL: { |
| | @@ -204280,11 +204348,11 @@ |
| 204280 | 204348 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 204281 | 204349 | |
| 204282 | 204350 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){ |
| 204283 | 204351 | int rc = SQLITE_OK; |
| 204284 | 204352 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 204285 | | - rc = sqlite3_create_module(db, "stmt", &stmtModule, 0); |
| 204353 | + rc = sqlite3_create_module(db, "sqlite_stmt", &stmtModule, 0); |
| 204286 | 204354 | #endif |
| 204287 | 204355 | return rc; |
| 204288 | 204356 | } |
| 204289 | 204357 | |
| 204290 | 204358 | #ifndef SQLITE_CORE |
| 204291 | 204359 | |