From 2ad96f5880fd77919571477dc0302cf763e527ff Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Jun 2016 13:01:51 +0000 Subject: [PATCH 01/42] Add the json_quote() function to the JSON1 extension. FossilOrigin-Name: 2c3714aebf5e40e3728877a235b3c1f93defa33e --- ext/misc/json1.c | 20 ++++++++++++++++++++ manifest | 19 +++++++++++-------- manifest.uuid | 2 +- test/json101.test | 29 +++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 99d299c29c..a9452b0191 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -1211,6 +1211,25 @@ static void jsonTest1Func( ** Scalar SQL function implementations ****************************************************************************/ +/* +** Implementation of the json_QUOTE(VALUE) function. Return a JSON value +** corresponding to the SQL value input. Mostly this means putting +** double-quotes around strings and returning the unquoted string "null" +** when given a NULL input. +*/ +static void jsonQuoteFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString jx; + + jsonInit(&jx, ctx); + jsonAppendValue(&jx, argv[0]); + jsonResult(&jx); + sqlite3_result_subtype(ctx, JSON_SUBTYPE); +} + /* ** Implementation of the json_array(VALUE,...) function. Return a JSON ** array that contains all values given in arguments. Or if any argument @@ -2124,6 +2143,7 @@ int sqlite3Json1Init(sqlite3 *db){ { "json_extract", -1, 0, jsonExtractFunc }, { "json_insert", -1, 0, jsonSetFunc }, { "json_object", -1, 0, jsonObjectFunc }, + { "json_quote", 1, 0, jsonQuoteFunc }, { "json_remove", -1, 0, jsonRemoveFunc }, { "json_replace", -1, 0, jsonReplaceFunc }, { "json_set", -1, 1, jsonSetFunc }, diff --git a/manifest b/manifest index b6450cc841..cfd0f94004 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\sOP_ColumnsUsed\sopcode\sto\scode\sfor\sexpressions\slike\s"?\sIN\s(SELECT\s...)"\sin\scases\swhere\sexpression\scan\suse\san\sindex\sthat\smay\scontain\sNULL\svalues. -D 2016-06-16T17:14:02.375 +C Add\sthe\sjson_quote()\sfunction\sto\sthe\sJSON1\sextension. +D 2016-06-17T13:01:51.782 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -211,7 +211,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c -F ext/misc/json1.c b9c88d5c3b6ecd8c731ffdd7f5b3d902857f8c96 +F ext/misc/json1.c d51a764ba43a49e191bc3536238bfab3def258ca F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 @@ -874,7 +874,7 @@ F test/journal3.test ff8af941f9e06161d3db1b46bb9f965ff0e7f307 F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa -F test/json101.test ef42283f0b60d8bacbc2243448e7c84988578e52 +F test/json101.test 865776ed8580703e1684fe4b8ee2e473333bb121 F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff @@ -1501,7 +1501,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48b555c42de1cbc031fb6c2c93ef170e491c7d76 -R 7c056b92500e212b6fa7144618e1e6e0 -U dan -Z 6cf13efbb72ea4474e244da36e8952f1 +P 0b1579caf06a2c42433b8bc9dc28c9ad381aa07c +R d87f9b42ae99ac8ed32dd707e5951481 +T *branch * json_quote +T *sym-json_quote * +T -sym-trunk * +U drh +Z f05f5d0cd323376080196dc4fc41462d diff --git a/manifest.uuid b/manifest.uuid index 6347d15d5f..8de647c48f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b1579caf06a2c42433b8bc9dc28c9ad381aa07c \ No newline at end of file +2c3714aebf5e40e3728877a235b3c1f93defa33e \ No newline at end of file diff --git a/test/json101.test b/test/json101.test index 9b780a379b..3ee007c1cb 100644 --- a/test/json101.test +++ b/test/json101.test @@ -356,5 +356,34 @@ do_execsql_test json-8.2 { SELECT a=json_extract(b,'$[0]') FROM t8; } {1} +# The json_quote() function transforms an SQL value into a JSON value. +# String values are quoted and interior quotes are escaped. NULL values +# are rendered as the unquoted string "null". +# +do_execsql_test json-9.1 { + SELECT json_quote('abc"xyz'); +} {{"abc\"xyz"}} +do_execsql_test json-9.2 { + SELECT json_quote(3.14159); +} {3.14159} +do_execsql_test json-9.3 { + SELECT json_quote(12345); +} {12345} +do_execsql_test json-9.4 { + SELECT json_quote(null); +} {"null"} +do_catchsql_test json-9.5 { + SELECT json_quote(x'30313233'); +} {1 {JSON cannot hold BLOB values}} +do_catchsql_test json-9.6 { + SELECT json_quote(123,456) +} {1 {wrong number of arguments to function json_quote()}} +do_catchsql_test json-9.7 { + SELECT json_quote() +} {1 {wrong number of arguments to function json_quote()}} + + + + finish_test From ed916ba02514b2714e61e91eb478e4d2d6f243df Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 21:30:03 +0000 Subject: [PATCH 02/42] Interface design for a new sqlite3_trace_v2() method that supersedes sqlite3_trace() and sqlite3_profile(). FossilOrigin-Name: 0c569f759f6c4701321d7fea5e7ccb371743bb6b --- manifest | 15 ++++--- manifest.uuid | 2 +- src/sqlite.h.in | 108 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c9585f19cd..91d158c9f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sshell.c\sfor\sNetBSD. -D 2016-07-13T13:05:13.449 +C Interface\sdesign\sfor\sa\snew\ssqlite3_trace_v2()\smethod\sthat\ssupersedes\nsqlite3_trace()\sand\ssqlite3_profile(). +D 2016-07-13T21:30:03.340 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in b9ba728c1083b7a8ab5f6a628b25cd2a00325fbf +F src/sqlite.h.in 63774172623fe82336ad0757f373343a87bd0b36 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 2a170163d121095c6ab1ef05ed0413722f391d01 F src/sqliteInt.h dcf43b8abc5605b70f54ba80f42b6ad054b8ba95 @@ -1505,7 +1505,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 021d0fb8d85e44839d2b4fdb90b15f0e1f2442e6 -R f2c7097376b33c065f9732879605d098 +P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb +R eb1a84643390ea5aba50eced8805fb76 +T *branch * sqlite3_trace_v2 +T *sym-sqlite3_trace_v2 * +T -sym-trunk * U drh -Z e160e6d632f23e86ebc551e9950cc211 +Z 6025cf3e994164a26dea4fb0e96d3f78 diff --git a/manifest.uuid b/manifest.uuid index 6b7a74bfc9..42e31abf53 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -824b39e54fb9ba562be4d92cc9a54aee1cdf84cb \ No newline at end of file +0c569f759f6c4701321d7fea5e7ccb371743bb6b \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 12a07a9b4a..a3b8f31f07 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2755,6 +2755,9 @@ int sqlite3_set_authorizer( ** CAPI3REF: Tracing And Profiling Functions ** METHOD: sqlite3 ** +** These routines are deprecated. Use the [sqlite3_trace_v2()] interface +** instead of the routines described here. +** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** @@ -2780,10 +2783,111 @@ int sqlite3_set_authorizer( ** sqlite3_profile() function is considered experimental and is ** subject to change in future versions of SQLite. */ -void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); -SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, +SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*, + void(*xTrace)(void*,const char*), void*); +SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite3_uint64), void*); +/* +** CAPI3REF: SQL Trace Event Codes +** KEYWORDS: SQLITE_TRACE +** +** These constants identify classes of events that can be monitored +** using the [sqlite3_trace_v2()] tracing logic. The third argument +** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of +** the following constants. The first argument to the trace callback +** is one of the following constants. +** +** New tracing constants may be added in future releases. +** +** A trace callback has four arguments: xCallback(T,C,P,X). +** The T argument is one of the integer type codes above. +** The C argument is a copy of the context pointer passed in as the +** fourth argument to [sqlite3_trace_v2()]. +** The P argument is a pointer whose meaning depends on T. +** The X argument is an unsigned 64-bit integer whose meaning also +** depends on T. +** +**
+** [[SQLITE_TRACE_SQL]]
SQLITE_TRACE_SQL
+**
An SQLITE_TRACE_SQL callback provides the same functionality +** as the legacy [sqlite3_trace()] callback. +** The P argument is a pointer to the constant UTF-8 string that is text +** describing an SQL statement that is starting to run with all +** [bound parameter] expanded. The X argument is unused. The size +** of the expansion of [bound parameters] is limited by the +** [SQLITE_TRACE_SIZE_LIMIT] compile-time option. +** +** [[SQLITE_TRACE_STMT]]
SQLITE_TRACE_STMT
+**
An SQLITE_TRACE_STMT callback is invoked on the same occasions +** as SQLITE_TRACE_SQL. The difference is that the P argument is a +** pointer to the [prepared statement] rather than an SQL string. +** The X argument is unused. +** +** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
+**
An SQLITE_TRACE_PROFILE callback provides approximately the same +** information as is provided by the [sqlite3_profile()] callback. +** The P argument is a pointer to the [prepared statement] and the +** X argument is an estimate of the number of nanosecond for which +** the prepared statement ran. The SQLITE_TRACE_PROFILE callback is +** invoked when the statement finishes. +** +** [[SQLITE_TRACE_ROW]]
SQLITE_TRACE_ROW
+**
An SQLITE_TRACE_ROW callback is invoked whenever a prepared +** statement generates a single row of result. +** The P argument is a pointer to the [prepared statement] and the +** X argument is unused. +** +** [[SQLITE_TRACE_CLOSE]]
SQLITE_TRACE_CLOSE
+**
An SQLITE_TRACE_CLOSE callback is invoked when a database +** connection closes. +** The P argument is a pointer to the [database connection] object +** and the X argument is unused. +**
+*/ +#define SQLITE_TRACE_SQL 0x0001 +#define SQLITE_TRACE_STMT 0x0002 +#define SQLITE_TRACE_PROFILE 0x0004 +#define SQLITE_TRACE_ROW 0x0008 +#define SQLITE_TRACE_CLOSE 0x0010 + +/* +** CAPI3REF: SQL Trace Hook +** METHOD: sqlite3 +** +** The sqlite3_trace_v2(D,X,M,P) interface registers a trace callback +** function X against [database connection] D, using property mask M +** and context pointer P. If the X callback is +** NULL or if the M mask is zero, then tracing is disabled. The +** M argument must be one or more of the [SQLITE_TRACE] +** constants. +** +** Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides +** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). +** +** The X callback is invoked whenever any of the events identified by +** mask M occur. The integer return value from the callback is currently +** ignored, though this may change in future releases. Callback +** implementations should return zero to ensure future compatibility. +** +** A trace callback is invoked with four arguments: callback(T,C,P,X). +** The T argument is one of the [SQLITE_TRACE] +** constants to indicate why the callback was invoked. +** The C argument is a copy of the context pointer. +** The P and X arguments are a pointer and an unsigned 64-bit integer +** whose meanings depend on T. +** +** The sqlite3_trace_v2() interface is intended to replace the legacy +** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which +** are deprecated. +*/ +int sqlite3_trace_v2( + sqlite3*, + int(*xCallback)(unsigned,void*,void*,sqlite3_uint64), + unsigned uMask, + void *pCtx +); + /* ** CAPI3REF: Query Progress Callbacks ** METHOD: sqlite3 From 3d2a529df6ce9cc3e9a11e5a2214eabfb35e0b77 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 22:55:01 +0000 Subject: [PATCH 03/42] First cut at implementing the new sqlite3_trace_v2() interface. FossilOrigin-Name: cb0062feb018f52689938a58cb76886d431c33f0 --- manifest | 27 ++++++++++++--------------- manifest.uuid | 2 +- src/main.c | 31 ++++++++++++++++++++++++++++++- src/sqlite.h.in | 6 +++--- src/sqlite3ext.h | 5 +++++ src/sqliteInt.h | 12 +++++++++++- src/vacuum.c | 6 +++--- src/vdbe.c | 26 ++++++++++++++++++++++---- src/vdbeapi.c | 14 +++++++++++--- 9 files changed, 98 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index 91d158c9f4..bfca64b0a8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Interface\sdesign\sfor\sa\snew\ssqlite3_trace_v2()\smethod\sthat\ssupersedes\nsqlite3_trace()\sand\ssqlite3_profile(). -D 2016-07-13T21:30:03.340 +C First\scut\sat\simplementing\sthe\snew\ssqlite3_trace_v2()\sinterface. +D 2016-07-13T22:55:01.845 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c 405d13e3a4f7c5add9fb27702ae70ed0a6e32cca +F src/main.c 05658dfa4be5704e4d6542fe0f2452be5b9df09e F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -385,10 +385,10 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 63774172623fe82336ad0757f373343a87bd0b36 +F src/sqlite.h.in 0fde7379e6a9d900802976de51cb1256f0fdac59 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 2a170163d121095c6ab1ef05ed0413722f391d01 -F src/sqliteInt.h dcf43b8abc5605b70f54ba80f42b6ad054b8ba95 +F src/sqlite3ext.h 3875aa5b3c4bb5d8d14c387628c5fe852b2846bf +F src/sqliteInt.h 5b8a3e1dc92e7459b69954cce9f653bd2391deb8 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -448,11 +448,11 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 22b46c3b725e950e9f2760e2d76953d592600ad4 +F src/vacuum.c 459ff7cb3c589451111ff2d3b6eb31be83a46a54 +F src/vdbe.c c6bb62aa69a6faf1197eee36336c6de99bb4733f F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d -F src/vdbeapi.c 02bcbc2ca5d2004b029088b05b468b394881e103 +F src/vdbeapi.c a466743c8e6de100c11e044b693c9469d2cf598a F src/vdbeaux.c c90275b0e55a2b32c03dc09314194fe46f2429d8 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 @@ -1505,10 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb -R eb1a84643390ea5aba50eced8805fb76 -T *branch * sqlite3_trace_v2 -T *sym-sqlite3_trace_v2 * -T -sym-trunk * +P 0c569f759f6c4701321d7fea5e7ccb371743bb6b +R eeeb6e6908fe861e59edc045bbf20a73 U drh -Z 6025cf3e994164a26dea4fb0e96d3f78 +Z 1f8408ee484498502acfe0ea8cf0fbae diff --git a/manifest.uuid b/manifest.uuid index 42e31abf53..7db2593897 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c569f759f6c4701321d7fea5e7ccb371743bb6b \ No newline at end of file +cb0062feb018f52689938a58cb76886d431c33f0 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 30370f8cab..d2f8bf7996 100644 --- a/src/main.c +++ b/src/main.c @@ -1033,6 +1033,9 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){ return SQLITE_MISUSE_BKPT; } sqlite3_mutex_enter(db->mutex); + if( db->mTrace & SQLITE_TRACE_CLOSE ){ + db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0); + } /* Force xDisconnect calls on all virtual tables */ disconnectAllVtab(db); @@ -1801,6 +1804,7 @@ int sqlite3_overload_function( ** trace is a pointer to a function that is invoked at the start of each ** SQL statement. */ +#ifndef SQLITE_OMIT_DEPRECATED void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ void *pOld; @@ -1812,11 +1816,36 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ #endif sqlite3_mutex_enter(db->mutex); pOld = db->pTraceArg; - db->xTrace = xTrace; + db->mTrace = SQLITE_TRACE_LEGACY; + db->xTrace = (int(*)(u32,void*,void*,i64))xTrace; db->pTraceArg = pArg; sqlite3_mutex_leave(db->mutex); return pOld; } +#endif /* SQLITE_OMIT_DEPRECATED */ + +/* Register a trace callback using the version-2 interface. +*/ +int sqlite3_trace_v2( + sqlite3 *db, /* Trace this connection */ + int(*xTrace)(unsigned,void*,void*,sqlite3_int64), /* Callback to invoke */ + unsigned mTrace, /* OPs to be traced */ + void *pArg /* Context */ +){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + (void)SQLITE_MISUSE_BKPT; + return 0; + } +#endif + sqlite3_mutex_enter(db->mutex); + db->mTrace = mTrace; + db->xTrace = xTrace; + db->pTraceArg = pArg; + sqlite3_mutex_leave(db->mutex); + return SQLITE_OK; +} + /* ** Register a profile function. The pArg from the previously registered ** profile function is returned. diff --git a/src/sqlite.h.in b/src/sqlite.h.in index a3b8f31f07..07d85b254d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2805,7 +2805,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The C argument is a copy of the context pointer passed in as the ** fourth argument to [sqlite3_trace_v2()]. ** The P argument is a pointer whose meaning depends on T. -** The X argument is an unsigned 64-bit integer whose meaning also +** The X argument is an 64-bit integer whose meaning also ** depends on T. ** **
@@ -2874,7 +2874,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The T argument is one of the [SQLITE_TRACE] ** constants to indicate why the callback was invoked. ** The C argument is a copy of the context pointer. -** The P and X arguments are a pointer and an unsigned 64-bit integer +** The P and X arguments are a pointer and a 64-bit integer ** whose meanings depend on T. ** ** The sqlite3_trace_v2() interface is intended to replace the legacy @@ -2883,7 +2883,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, */ int sqlite3_trace_v2( sqlite3*, - int(*xCallback)(unsigned,void*,void*,sqlite3_uint64), + int(*xCallback)(unsigned,void*,void*,sqlite3_int64), unsigned uMask, void *pCtx ); diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 2d38e87ae7..8bcfc68521 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -281,6 +281,9 @@ struct sqlite3_api_routines { int (*db_cacheflush)(sqlite3*); /* Version 3.12.0 and later */ int (*system_errno)(sqlite3*); + /* Version 3.14.0 and later */ + int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,sqlite3_uint64), + unsigned,void*); }; /* @@ -526,6 +529,8 @@ struct sqlite3_api_routines { #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush /* Version 3.12.0 and later */ #define sqlite3_system_errno sqlite3_api->system_errno +/* Version 3.14.0 and later */ +#define sqlite3_trace_v2 sqlite3_api->trace_v2 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 998a17dac3..225d7b2872 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1241,6 +1241,15 @@ void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**); const char*); #endif +#ifndef SQLITE_OMIT_DEPRECATED +/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing +** in the style of sqlite3_trace() +*/ +#define SQLITE_TRACE_LEGACY 0x80 +#else +#define SQLITE_TRACE_LEGACY 0 +#endif /* SQLITE_OMIT_DEPRECATED */ + /* ** Each database connection is an instance of the following structure. @@ -1270,6 +1279,7 @@ struct sqlite3 { u8 suppressErr; /* Do not issue error messages if true */ u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ + u8 mTrace; /* zero or more SQLITE_TRACE flags */ int nextPagesize; /* Pagesize after VACUUM if >0 */ u32 magic; /* Magic number for detect library misuse */ int nChange; /* Value returned by sqlite3_changes() */ @@ -1290,7 +1300,7 @@ struct sqlite3 { int nVDestroy; /* Number of active OP_VDestroy operations */ int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared library handles */ - void (*xTrace)(void*,const char*); /* Trace function */ + int (*xTrace)(u32,void*,void*,i64); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ diff --git a/src/vacuum.c b/src/vacuum.c index bc7b5831b6..93b438fb1a 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -121,7 +121,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ int saved_flags; /* Saved value of the db->flags */ int saved_nChange; /* Saved value of db->nChange */ int saved_nTotalChange; /* Saved value of db->nTotalChange */ - void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ + u8 saved_mTrace; /* Saved trace settings */ Db *pDb = 0; /* Database to detach at end of vacuum */ int isMemDb; /* True if vacuuming a :memory: database */ int nRes; /* Bytes of reserved space at the end of each page */ @@ -142,7 +142,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ saved_flags = db->flags; saved_nChange = db->nChange; saved_nTotalChange = db->nTotalChange; - saved_xTrace = db->xTrace; + saved_mTrace = db->mTrace; db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder); db->xTrace = 0; @@ -345,7 +345,7 @@ end_of_vacuum: db->flags = saved_flags; db->nChange = saved_nChange; db->nTotalChange = saved_nTotalChange; - db->xTrace = saved_xTrace; + db->mTrace = saved_mTrace; sqlite3BtreeSetPageSize(pMain, -1, -1, 1); /* Currently there is an SQL level transaction open on the vacuum diff --git a/src/vdbe.c b/src/vdbe.c index 6adbcbbec1..7883536028 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1383,6 +1383,10 @@ case OP_ResultRow: { } if( db->mallocFailed ) goto no_mem; + if( db->mTrace & SQLITE_TRACE_ROW ){ + db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0); + } + /* Return SQLITE_ROW */ p->pc = (int)(pOp - aOp) + 1; @@ -6781,13 +6785,27 @@ case OP_Init: { /* jump */ char *z; #ifndef SQLITE_OMIT_TRACE - if( db->xTrace + if( (db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 ){ - z = sqlite3VdbeExpandSql(p, zTrace); - db->xTrace(db->pTraceArg, z); - sqlite3DbFree(db, z); + if( db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_LEGACY) ){ + z = sqlite3VdbeExpandSql(p, zTrace); +#ifndef SQLITE_OMIT_DEPRECATED + if( SQLITE_TRACE_LEGACY ){ + void (*x)(void*,const char*); + x = (void(*)(void*,const char*))db->xTrace; + x(db->pTraceArg, z); + }else +#endif + { + db->xTrace(SQLITE_TRACE_SQL,db->pTraceArg,z,0); + } + sqlite3DbFree(db, z); + } + if( db->mTrace & SQLITE_TRACE_STMT ){ + (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,0); + } } #ifdef SQLITE_USE_FCNTL_TRACE zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 83718eae39..a602fad383 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -60,12 +60,19 @@ static int vdbeSafetyNotNull(Vdbe *p){ */ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ sqlite3_int64 iNow; + sqlite3_int64 iElapse; assert( p->startTime>0 ); - assert( db->xProfile!=0 ); + assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 ); assert( db->init.busy==0 ); assert( p->zSql!=0 ); sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); - db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); + iElapse = (iNow - p->startTime)*1000000; + if( db->xProfile ){ + db->xProfile(db->pProfileArg, p->zSql, iElapse); + } + if( db->mTrace & SQLITE_TRACE_PROFILE ){ + db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, iElapse); + } p->startTime = 0; } /* @@ -569,7 +576,8 @@ static int sqlite3Step(Vdbe *p){ ); #ifndef SQLITE_OMIT_TRACE - if( db->xProfile && !db->init.busy && p->zSql ){ + if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0) + && !db->init.busy && p->zSql ){ sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime); }else{ assert( p->startTime==0 ); From 1637a5171f25bd6d5eb4e04dc855776c3af2c1da Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 23:18:27 +0000 Subject: [PATCH 04/42] Legacy tests now passing. FossilOrigin-Name: f33526a341132435cb4185149a784eef6b3a1a2d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 2 +- src/vacuum.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index bfca64b0a8..a7725c09a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C First\scut\sat\simplementing\sthe\snew\ssqlite3_trace_v2()\sinterface. -D 2016-07-13T22:55:01.845 +C Legacy\stests\snow\spassing. +D 2016-07-13T23:18:27.653 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c 05658dfa4be5704e4d6542fe0f2452be5b9df09e +F src/main.c a3be9a816c72fe658838e33e42afabfff93526f2 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -448,7 +448,7 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c 459ff7cb3c589451111ff2d3b6eb31be83a46a54 +F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 F src/vdbe.c c6bb62aa69a6faf1197eee36336c6de99bb4733f F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0c569f759f6c4701321d7fea5e7ccb371743bb6b -R eeeb6e6908fe861e59edc045bbf20a73 +P cb0062feb018f52689938a58cb76886d431c33f0 +R d7e93f0729616f164eba3e9e1862aa07 U drh -Z 1f8408ee484498502acfe0ea8cf0fbae +Z a0be5e80cc5b797f562ce4c096d88be2 diff --git a/manifest.uuid b/manifest.uuid index 7db2593897..5103610b4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cb0062feb018f52689938a58cb76886d431c33f0 \ No newline at end of file +f33526a341132435cb4185149a784eef6b3a1a2d \ No newline at end of file diff --git a/src/main.c b/src/main.c index d2f8bf7996..5969738f6b 100644 --- a/src/main.c +++ b/src/main.c @@ -1816,7 +1816,7 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ #endif sqlite3_mutex_enter(db->mutex); pOld = db->pTraceArg; - db->mTrace = SQLITE_TRACE_LEGACY; + db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0; db->xTrace = (int(*)(u32,void*,void*,i64))xTrace; db->pTraceArg = pArg; sqlite3_mutex_leave(db->mutex); diff --git a/src/vacuum.c b/src/vacuum.c index 93b438fb1a..9ab7f766ee 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -145,7 +145,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ saved_mTrace = db->mTrace; db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder); - db->xTrace = 0; + db->mTrace = 0; pMain = db->aDb[0].pBt; isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); From fca760c841227207bb8dd0dd43fb89a100ca18fb Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jul 2016 01:09:08 +0000 Subject: [PATCH 05/42] Add the sqlite3_expanded_sql() interface. Refinements to the sqlite3_trace_v2() interface to make it more useful. FossilOrigin-Name: 99ee7ee58d45b29a0000492306ddc0b90563ff51 --- manifest | 28 +++++++++---------- manifest.uuid | 2 +- src/main.c | 12 ++++---- src/sqlite.h.in | 71 +++++++++++++++++++++++++++--------------------- src/sqlite3ext.h | 5 ++-- src/sqliteInt.h | 2 +- src/test1.c | 21 ++++++++++++++ src/vdbe.c | 24 ++++++---------- src/vdbeapi.c | 2 +- src/vdbeaux.c | 15 ++++++++++ src/vdbetrace.c | 2 +- 11 files changed, 112 insertions(+), 72 deletions(-) diff --git a/manifest b/manifest index a7725c09a7..98c634e400 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Legacy\stests\snow\spassing. -D 2016-07-13T23:18:27.653 +C Add\sthe\ssqlite3_expanded_sql()\sinterface.\s\sRefinements\sto\sthe\nsqlite3_trace_v2()\sinterface\sto\smake\sit\smore\suseful. +D 2016-07-14T01:09:08.369 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c a3be9a816c72fe658838e33e42afabfff93526f2 +F src/main.c ade3b39f3bde9212b3fabcff2367d29052002df6 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -385,15 +385,15 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 0fde7379e6a9d900802976de51cb1256f0fdac59 +F src/sqlite.h.in 6ba80e88ee17b9071f35121271784ecef60df863 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 3875aa5b3c4bb5d8d14c387628c5fe852b2846bf -F src/sqliteInt.h 5b8a3e1dc92e7459b69954cce9f653bd2391deb8 +F src/sqlite3ext.h 6fb1639d41907544cb3905c69a348ee64c5da79e +F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 -F src/test1.c 640f862c490c8eee09a9d02d0d128c6a8a75336d +F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -449,15 +449,15 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 -F src/vdbe.c c6bb62aa69a6faf1197eee36336c6de99bb4733f +F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d -F src/vdbeapi.c a466743c8e6de100c11e044b693c9469d2cf598a -F src/vdbeaux.c c90275b0e55a2b32c03dc09314194fe46f2429d8 +F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b +F src/vdbeaux.c 6083ff395021ac8c40e1b53798ee6483037e3fb7 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 +F src/vdbetrace.c d0371769fe66fe4eb85bdcacf82b6f2af50feb9b F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cb0062feb018f52689938a58cb76886d431c33f0 -R d7e93f0729616f164eba3e9e1862aa07 +P f33526a341132435cb4185149a784eef6b3a1a2d +R b996b3134868ad007e1e44124ba2e740 U drh -Z a0be5e80cc5b797f562ce4c096d88be2 +Z 809ea44b43d6348d635e64228e5049a8 diff --git a/manifest.uuid b/manifest.uuid index 5103610b4f..6a7d48edff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f33526a341132435cb4185149a784eef6b3a1a2d \ No newline at end of file +99ee7ee58d45b29a0000492306ddc0b90563ff51 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 5969738f6b..2e996b5545 100644 --- a/src/main.c +++ b/src/main.c @@ -1805,7 +1805,7 @@ int sqlite3_overload_function( ** SQL statement. */ #ifndef SQLITE_OMIT_DEPRECATED -void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ +void *sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){ void *pOld; #ifdef SQLITE_ENABLE_API_ARMOR @@ -1817,7 +1817,7 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ sqlite3_mutex_enter(db->mutex); pOld = db->pTraceArg; db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0; - db->xTrace = (int(*)(u32,void*,void*,i64))xTrace; + db->xTrace = (int(*)(u32,void*,void*,void*))xTrace; db->pTraceArg = pArg; sqlite3_mutex_leave(db->mutex); return pOld; @@ -1827,10 +1827,10 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ /* Register a trace callback using the version-2 interface. */ int sqlite3_trace_v2( - sqlite3 *db, /* Trace this connection */ - int(*xTrace)(unsigned,void*,void*,sqlite3_int64), /* Callback to invoke */ - unsigned mTrace, /* OPs to be traced */ - void *pArg /* Context */ + sqlite3 *db, /* Trace this connection */ + unsigned mTrace, /* Mask of events to be traced */ + int(*xTrace)(unsigned,void*,void*,void*), /* Callback to invoke */ + void *pArg /* Context */ ){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ){ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 07d85b254d..8b9aa7402d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2804,33 +2804,25 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The T argument is one of the integer type codes above. ** The C argument is a copy of the context pointer passed in as the ** fourth argument to [sqlite3_trace_v2()]. -** The P argument is a pointer whose meaning depends on T. -** The X argument is an 64-bit integer whose meaning also -** depends on T. +** The P and X arguments are pointers whose meanings depend on T. ** **
-** [[SQLITE_TRACE_SQL]]
SQLITE_TRACE_SQL
-**
An SQLITE_TRACE_SQL callback provides the same functionality -** as the legacy [sqlite3_trace()] callback. -** The P argument is a pointer to the constant UTF-8 string that is text -** describing an SQL statement that is starting to run with all -** [bound parameter] expanded. The X argument is unused. The size -** of the expansion of [bound parameters] is limited by the -** [SQLITE_TRACE_SIZE_LIMIT] compile-time option. -** ** [[SQLITE_TRACE_STMT]]
SQLITE_TRACE_STMT
-**
An SQLITE_TRACE_STMT callback is invoked on the same occasions -** as SQLITE_TRACE_SQL. The difference is that the P argument is a -** pointer to the [prepared statement] rather than an SQL string. -** The X argument is unused. +**
An SQLITE_TRACE_STMT callback is invoked when a prepared statement +** first begins running and possibly at other times during the +** execution of the prepared statement, such as at the start of each +** trigger subprogram. The P argument is a pointer to the +** [prepared statement]. The X argument is a pointer to a string which +** is the expanded SQL text of the prepared statement or a comment that +** indicates the invocation of a trigger. ** ** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
**
An SQLITE_TRACE_PROFILE callback provides approximately the same ** information as is provided by the [sqlite3_profile()] callback. ** The P argument is a pointer to the [prepared statement] and the -** X argument is an estimate of the number of nanosecond for which -** the prepared statement ran. The SQLITE_TRACE_PROFILE callback is -** invoked when the statement finishes. +** X argument points to a 64-bit integer which is the estimated of +** the number of nanosecond that the prepared statement took to run. +** The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. ** ** [[SQLITE_TRACE_ROW]]
SQLITE_TRACE_ROW
**
An SQLITE_TRACE_ROW callback is invoked whenever a prepared @@ -2845,17 +2837,16 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** and the X argument is unused. **
*/ -#define SQLITE_TRACE_SQL 0x0001 -#define SQLITE_TRACE_STMT 0x0002 -#define SQLITE_TRACE_PROFILE 0x0004 -#define SQLITE_TRACE_ROW 0x0008 -#define SQLITE_TRACE_CLOSE 0x0010 +#define SQLITE_TRACE_STMT 0x01 +#define SQLITE_TRACE_PROFILE 0x02 +#define SQLITE_TRACE_ROW 0x04 +#define SQLITE_TRACE_CLOSE 0x08 /* ** CAPI3REF: SQL Trace Hook ** METHOD: sqlite3 ** -** The sqlite3_trace_v2(D,X,M,P) interface registers a trace callback +** The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback ** function X against [database connection] D, using property mask M ** and context pointer P. If the X callback is ** NULL or if the M mask is zero, then tracing is disabled. The @@ -2874,8 +2865,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The T argument is one of the [SQLITE_TRACE] ** constants to indicate why the callback was invoked. ** The C argument is a copy of the context pointer. -** The P and X arguments are a pointer and a 64-bit integer -** whose meanings depend on T. +** The P and X arguments are pointers whose meanings depend on T. ** ** The sqlite3_trace_v2() interface is intended to replace the legacy ** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which @@ -2883,8 +2873,8 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, */ int sqlite3_trace_v2( sqlite3*, - int(*xCallback)(unsigned,void*,void*,sqlite3_int64), unsigned uMask, + int(*xCallback)(unsigned,void*,void*,void*), void *pCtx ); @@ -3506,11 +3496,30 @@ int sqlite3_prepare16_v2( ** CAPI3REF: Retrieving Statement SQL ** METHOD: sqlite3_stmt ** -** ^This interface can be used to retrieve a saved copy of the original -** SQL text used to create a [prepared statement] if that statement was -** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. +** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 +** SQL text used to create [prepared statement] P if P was +** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. +** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 +** string containing the SQL text of prepared statement P with +** [bound parameters] expanded. +** +** For example, if a prepared statement is created using the SQL +** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 +** and parameter :xyz is unbound, then sqlite3_sql() will return +** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() +** will return "SELECT 2345,NULL". +** +** The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a +** bound parameter expansion. +** +** ^The string returned by sqlite3_sql(P) is managed by SQLite and is +** automatically freed when the prepared statement is finalized. +** ^The string returned by sqlite3_expanded_sql(P), on the other hand, +** is obtained from [sqlite3_malloc()] and must be free by the application +** by passing it to [sqlite3_free()]. */ const char *sqlite3_sql(sqlite3_stmt *pStmt); +char *sqlite3_expanded_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If An SQL Statement Writes The Database diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 8bcfc68521..4d5023292b 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -282,8 +282,8 @@ struct sqlite3_api_routines { /* Version 3.12.0 and later */ int (*system_errno)(sqlite3*); /* Version 3.14.0 and later */ - int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,sqlite3_uint64), - unsigned,void*); + int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,void*),unsigned,void*); + char *(*expanded_sql)(sqlite3_stmt*); }; /* @@ -531,6 +531,7 @@ struct sqlite3_api_routines { #define sqlite3_system_errno sqlite3_api->system_errno /* Version 3.14.0 and later */ #define sqlite3_trace_v2 sqlite3_api->trace_v2 +#define sqlite3_expanded_sql sqlite3_api->expanded_sql #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 225d7b2872..0be4947513 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1300,7 +1300,7 @@ struct sqlite3 { int nVDestroy; /* Number of active OP_VDestroy operations */ int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared library handles */ - int (*xTrace)(u32,void*,void*,i64); /* Trace function */ + int (*xTrace)(u32,void*,void*,void*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ diff --git a/src/test1.c b/src/test1.c index 5ce818bf74..a1fdcb5cfb 100644 --- a/src/test1.c +++ b/src/test1.c @@ -4386,6 +4386,26 @@ static int test_sql( Tcl_SetResult(interp, (char *)sqlite3_sql(pStmt), TCL_VOLATILE); return TCL_OK; } +static int test_ex_sql( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + char *z; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "STMT"); + return TCL_ERROR; + } + + if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; + z = sqlite3_expanded_sql(pStmt); + Tcl_SetResult(interp, z, TCL_VOLATILE); + sqlite3_free(z); + return TCL_OK; +} /* ** Usage: sqlite3_column_count STMT @@ -7276,6 +7296,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_changes", test_changes ,0 }, { "sqlite3_step", test_step ,0 }, { "sqlite3_sql", test_sql ,0 }, + { "sqlite3_expanded_sql", test_ex_sql ,0 }, { "sqlite3_next_stmt", test_next_stmt ,0 }, { "sqlite3_stmt_readonly", test_stmt_readonly ,0 }, { "sqlite3_stmt_busy", test_stmt_busy ,0 }, diff --git a/src/vdbe.c b/src/vdbe.c index 7883536028..cdbd7301b8 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6785,27 +6785,21 @@ case OP_Init: { /* jump */ char *z; #ifndef SQLITE_OMIT_TRACE - if( (db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 + if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 ){ - if( db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_LEGACY) ){ - z = sqlite3VdbeExpandSql(p, zTrace); + z = sqlite3VdbeExpandSql(p, zTrace); #ifndef SQLITE_OMIT_DEPRECATED - if( SQLITE_TRACE_LEGACY ){ - void (*x)(void*,const char*); - x = (void(*)(void*,const char*))db->xTrace; - x(db->pTraceArg, z); - }else + if( db->mTrace & SQLITE_TRACE_LEGACY ){ + void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; + x(db->pTraceArg, z); + }else #endif - { - db->xTrace(SQLITE_TRACE_SQL,db->pTraceArg,z,0); - } - sqlite3DbFree(db, z); - } - if( db->mTrace & SQLITE_TRACE_STMT ){ - (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,0); + { + (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,z); } + sqlite3_free(z); } #ifdef SQLITE_USE_FCNTL_TRACE zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index a602fad383..883e5c95bf 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -71,7 +71,7 @@ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ db->xProfile(db->pProfileArg, p->zSql, iElapse); } if( db->mTrace & SQLITE_TRACE_PROFILE ){ - db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, iElapse); + db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse); } p->startTime = 0; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 63609d72dd..355021e970 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -72,6 +72,21 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt){ return p ? p->zSql : 0; } +/* +** Return the SQL associated with a prepared statement with +** bound parameters expanded. Space to hold the returned string is +** obtained from sqlite3_malloc(). The caller is responsible for +** freeing the returned string by passing it to sqlite3_free(). +** +** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of +** expanded bound parameters. +*/ +char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ + Vdbe *p = (Vdbe *)pStmt; + return p ? sqlite3VdbeExpandSql(p, p->zSql) : 0; + if( p->zSql==0 ) return 0; +} + /* ** Swap all content between two VDBE structures. */ diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 07235c931b..7311bc35c6 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -84,7 +84,7 @@ char *sqlite3VdbeExpandSql( char zBase[100]; /* Initial working space */ db = p->db; - sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase), + sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), db->aLimit[SQLITE_LIMIT_LENGTH]); if( db->nVdbeExec>1 ){ while( *zRawSql ){ From c0e2203adb52051f623b6a3ef9a27511ca4ae8b3 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jul 2016 01:13:36 +0000 Subject: [PATCH 06/42] Fix a parameter misordering on sqlite3_trace_v2() in the loadable extension interface. FossilOrigin-Name: 989de2d5b5e7155654d3eebadb9651b23f422c58 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite3ext.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 98c634e400..8c007e6739 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_expanded_sql()\sinterface.\s\sRefinements\sto\sthe\nsqlite3_trace_v2()\sinterface\sto\smake\sit\smore\suseful. -D 2016-07-14T01:09:08.369 +C Fix\sa\sparameter\smisordering\son\ssqlite3_trace_v2()\sin\sthe\sloadable\sextension\ninterface. +D 2016-07-14T01:13:36.176 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -387,7 +387,7 @@ F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 F src/sqlite.h.in 6ba80e88ee17b9071f35121271784ecef60df863 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 6fb1639d41907544cb3905c69a348ee64c5da79e +F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f33526a341132435cb4185149a784eef6b3a1a2d -R b996b3134868ad007e1e44124ba2e740 +P 99ee7ee58d45b29a0000492306ddc0b90563ff51 +R 2e489e2cf495d4b07e42b94b658ce2d8 U drh -Z 809ea44b43d6348d635e64228e5049a8 +Z d214f48401d2ba878ebf65269a7b92c1 diff --git a/manifest.uuid b/manifest.uuid index 6a7d48edff..b1e5ac35c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99ee7ee58d45b29a0000492306ddc0b90563ff51 \ No newline at end of file +989de2d5b5e7155654d3eebadb9651b23f422c58 \ No newline at end of file diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 4d5023292b..338e1becd5 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -282,7 +282,7 @@ struct sqlite3_api_routines { /* Version 3.12.0 and later */ int (*system_errno)(sqlite3*); /* Version 3.14.0 and later */ - int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,void*),unsigned,void*); + int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*); char *(*expanded_sql)(sqlite3_stmt*); }; From 0129a54a167cd10f94cc5830890589e5138de7d5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 14 Jul 2016 09:22:16 +0000 Subject: [PATCH 07/42] Fix copy/paste typo in the new sqlite3_expanded_sql() function. FossilOrigin-Name: e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8c007e6739..0d6dec24f5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sparameter\smisordering\son\ssqlite3_trace_v2()\sin\sthe\sloadable\sextension\ninterface. -D 2016-07-14T01:13:36.176 +C Fix\scopy/paste\stypo\sin\sthe\snew\ssqlite3_expanded_sql()\sfunction. +D 2016-07-14T09:22:16.664 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -453,7 +453,7 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 6083ff395021ac8c40e1b53798ee6483037e3fb7 +F src/vdbeaux.c 08a459b6906dfcce0e921daba3a471a28ea65d41 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 99ee7ee58d45b29a0000492306ddc0b90563ff51 -R 2e489e2cf495d4b07e42b94b658ce2d8 -U drh -Z d214f48401d2ba878ebf65269a7b92c1 +P 989de2d5b5e7155654d3eebadb9651b23f422c58 +R 22fe35d8085a083776873f2a488c7041 +U mistachkin +Z 0cf3ee8d7f2e128326cc9e0cdcd59d22 diff --git a/manifest.uuid b/manifest.uuid index b1e5ac35c8..9a4a235af8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -989de2d5b5e7155654d3eebadb9651b23f422c58 \ No newline at end of file +e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 355021e970..72a882c176 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -83,8 +83,8 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt){ */ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe *)pStmt; - return p ? sqlite3VdbeExpandSql(p, p->zSql) : 0; - if( p->zSql==0 ) return 0; + if( p==0 || p->zSql==0 ) return 0; + return sqlite3VdbeExpandSql(p, p->zSql); } /* From 0b4c042b867e71bfd64a17e62d60ee2923707561 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jul 2016 19:48:08 +0000 Subject: [PATCH 08/42] Minor tweak the the b-tree balancer. FossilOrigin-Name: d2a0af7a37e390439c3001fedb5834f47fb24a1f --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 966b26fc0e..47fc104dda 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sALTER\sTABLE\sso\sthat\sit\sdoes\snot\spromote\sthe\sschema\sversion\spast\s3,\sas\nthat\swill\scause\sDESC\sindexes\sto\sgo\scorrupt.\nTicket\s[f68bf68513a1c]. -D 2016-07-14T19:13:11.812 +C Minor\stweak\sthe\sthe\sb-tree\sbalancer. +D 2016-07-14T19:48:08.366 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -327,7 +327,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c dc4e5f3e95fd57b610422e36e0913662ecd6814c +F src/btree.c 6a42efa461cf3a0c33e8755e9d236371ac80d1b3 F src/btree.h 075c45707c0f8f8af118f739f36df8098a08b7da F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 @@ -1505,7 +1505,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb -R 7d842c7254944c448483c1d7ddff9ad6 +P a7db6e45ad45be9b3003f61d4163f543498a7c9d +R cf8c76c330a7fe6ea73db33dfc44a97f +T *branch * btree-tuning +T *sym-btree-tuning * +T -sym-trunk * U drh -Z f6a6c237e43006b812e6af2a3e69c586 +Z 48948e5bf85e9b289f89aa7970884ba4 diff --git a/manifest.uuid b/manifest.uuid index 1fc14b81a9..467d7f99b2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7db6e45ad45be9b3003f61d4163f543498a7c9d \ No newline at end of file +d2a0af7a37e390439c3001fedb5834f47fb24a1f \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7fc9193dc8..8ea20b9ad0 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7340,7 +7340,7 @@ static int balance_nonroot( assert( r szLeft-(b.szCell[r]+2)) ){ + && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){ break; } szRight += b.szCell[d] + 2; From b56660f5a4bb4acdcdd21d0dcce6a90daa1e6ee7 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 14 Jul 2016 21:26:09 +0000 Subject: [PATCH 09/42] Initial work on the Tcl API interface to the new sqlite3_trace_v2() function. FossilOrigin-Name: 7b59fa40a01c89cc98414d90a798169c26e04256 --- manifest | 12 +- manifest.uuid | 2 +- src/tclsqlite.c | 303 ++++++++++++++++++++++++++++++++++-------------- 3 files changed, 223 insertions(+), 94 deletions(-) diff --git a/manifest b/manifest index 0d6dec24f5..b880ee391d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scopy/paste\stypo\sin\sthe\snew\ssqlite3_expanded_sql()\sfunction. -D 2016-07-14T09:22:16.664 +C Initial\swork\son\sthe\sTcl\sAPI\sinterface\sto\sthe\snew\ssqlite3_trace_v2()\sfunction. +D 2016-07-14T21:26:09.090 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -392,7 +392,7 @@ F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 +F src/tclsqlite.c 361167055f0d0d9883b729f1db698edcd3b46065 F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 989de2d5b5e7155654d3eebadb9651b23f422c58 -R 22fe35d8085a083776873f2a488c7041 +P e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 +R 85912bc13f3699d6087855b14808f819 U mistachkin -Z 0cf3ee8d7f2e128326cc9e0cdcd59d22 +Z 312d6409632132f635d6a5f40333e628 diff --git a/manifest.uuid b/manifest.uuid index 9a4a235af8..f5bb4e0461 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 \ No newline at end of file +7b59fa40a01c89cc98414d90a798169c26e04256 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 476bdf235e..bcae05d795 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -133,6 +133,7 @@ struct SqliteDb { char *zBusy; /* The busy callback routine */ char *zCommit; /* The commit hook callback routine */ char *zTrace; /* The trace callback routine */ + char *zTraceV2; /* The trace_v2 callback routine */ char *zProfile; /* The profile callback routine */ char *zProgress; /* The progress callback routine */ char *zAuth; /* The authorization callback routine */ @@ -192,7 +193,7 @@ static void closeIncrblobChannels(SqliteDb *pDb){ for(p=pDb->pIncrblob; p; p=pNext){ pNext = p->pNext; - /* Note: Calling unregister here call Tcl_Close on the incrblob channel, + /* Note: Calling unregister here call Tcl_Close on the incrblob channel, ** which deletes the IncrblobChannel structure at *p. So do not ** call Tcl_Free() here. */ @@ -233,8 +234,8 @@ static int incrblobClose(ClientData instanceData, Tcl_Interp *interp){ ** Read data from an incremental blob channel. */ static int incrblobInput( - ClientData instanceData, - char *buf, + ClientData instanceData, + char *buf, int bufSize, int *errorCodePtr ){ @@ -265,8 +266,8 @@ static int incrblobInput( ** Write data to an incremental blob channel. */ static int incrblobOutput( - ClientData instanceData, - CONST char *buf, + ClientData instanceData, + CONST char *buf, int toWrite, int *errorCodePtr ){ @@ -298,7 +299,7 @@ static int incrblobOutput( ** Seek an incremental blob channel. */ static int incrblobSeek( - ClientData instanceData, + ClientData instanceData, long offset, int seekMode, int *errorCodePtr @@ -323,8 +324,8 @@ static int incrblobSeek( } -static void incrblobWatch(ClientData instanceData, int mode){ - /* NO-OP */ +static void incrblobWatch(ClientData instanceData, int mode){ + /* NO-OP */ } static int incrblobHandle(ClientData instanceData, int dir, ClientData *hPtr){ return TCL_ERROR; @@ -352,11 +353,11 @@ static Tcl_ChannelType IncrblobChannelType = { ** Create a new incrblob channel. */ static int createIncrblobChannel( - Tcl_Interp *interp, - SqliteDb *pDb, + Tcl_Interp *interp, + SqliteDb *pDb, const char *zDb, - const char *zTable, - const char *zColumn, + const char *zTable, + const char *zColumn, sqlite_int64 iRow, int isReadonly ){ @@ -438,7 +439,7 @@ static SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){ pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + nName + 1 ); pNew->zName = (char*)&pNew[1]; memcpy(pNew->zName, zName, nName+1); - for(p=pDb->pFunc; p; p=p->pNext){ + for(p=pDb->pFunc; p; p=p->pNext){ if( sqlite3_stricmp(p->zName, pNew->zName)==0 ){ Tcl_Free((char*)pNew); return p; @@ -508,6 +509,9 @@ static void DbDeleteCmd(void *db){ if( pDb->zTrace ){ Tcl_Free(pDb->zTrace); } + if( pDb->zTraceV2 ){ + Tcl_Free(pDb->zTraceV2); + } if( pDb->zProfile ){ Tcl_Free(pDb->zProfile); } @@ -587,6 +591,82 @@ static void DbTraceHandler(void *cd, const char *zSql){ } #endif +#ifndef SQLITE_OMIT_TRACE +/* +** This routine is called by the SQLite trace_v2 handler whenever a new +** supported event is generated. Unsupported event types are ignored. +** The TCL script in pDb->zTraceV2 is executed, with the arguments for +** the event appended to it (as list elements). +*/ +static int DbTraceV2Handler( + unsigned type, /* One of the SQLITE_TRACE_* event types. */ + void *cd, /* The original context data pointer. */ + void *pd, /* Primary event data, depends on event type. */ + void *xd /* Extra event data, depends on event type. */ +){ + SqliteDb *pDb = (SqliteDb*)cd; + Tcl_Obj *pCmd; + + switch( type ){ + case SQLITE_TRACE_STMT: { + sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; + char *zSql = (char *)xd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewStringObj(zSql, -1)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + case SQLITE_TRACE_PROFILE: { + sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; + sqlite3_int64 ns = (sqlite3_int64)xd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)ns)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + case SQLITE_TRACE_ROW: { + sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + case SQLITE_TRACE_CLOSE: { + sqlite3 *db = (sqlite3 *)pd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)db)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + } + return SQLITE_OK; +} +#endif + #ifndef SQLITE_OMIT_TRACE /* ** This routine is called by the SQLite profile handler after a statement @@ -637,9 +717,9 @@ static void DbRollbackHandler(void *clientData){ ** This procedure handles wal_hook callbacks. */ static int DbWalHandler( - void *clientData, - sqlite3 *db, - const char *zDb, + void *clientData, + sqlite3 *db, + const char *zDb, int nEntry ){ int ret = SQLITE_OK; @@ -653,7 +733,7 @@ static int DbWalHandler( Tcl_IncrRefCount(p); Tcl_ListObjAppendElement(interp, p, Tcl_NewStringObj(zDb, -1)); Tcl_ListObjAppendElement(interp, p, Tcl_NewIntObj(nEntry)); - if( TCL_OK!=Tcl_EvalObjEx(interp, p, 0) + if( TCL_OK!=Tcl_EvalObjEx(interp, p, 0) || TCL_OK!=Tcl_GetIntFromObj(interp, Tcl_GetObjResult(interp), &ret) ){ Tcl_BackgroundError(interp); @@ -695,11 +775,11 @@ static void DbUnlockNotify(void **apArg, int nArg){ ** Pre-update hook callback. */ static void DbPreUpdateHandler( - void *p, + void *p, sqlite3 *db, int op, - const char *zDb, - const char *zTbl, + const char *zDb, + const char *zTbl, sqlite_int64 iKey1, sqlite_int64 iKey2 ){ @@ -727,10 +807,10 @@ static void DbPreUpdateHandler( #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ static void DbUpdateHandler( - void *p, + void *p, int op, - const char *zDb, - const char *zTbl, + const char *zDb, + const char *zTbl, sqlite_int64 rowid ){ SqliteDb *pDb = (SqliteDb *)p; @@ -815,7 +895,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ ** script object, lappend the arguments, then evaluate the copy. ** ** By "shallow" copy, we mean only the outer list Tcl_Obj is duplicated. - ** The new Tcl_Obj contains pointers to the original list elements. + ** The new Tcl_Obj contains pointers to the original list elements. ** That way, when Tcl_EvalObjv() is run and shimmers the first element ** of the list to tclCmdNameType, that alternate representation will ** be preserved and reused on the next invocation. @@ -823,15 +903,15 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ Tcl_Obj **aArg; int nArg; if( Tcl_ListObjGetElements(p->interp, p->pScript, &nArg, &aArg) ){ - sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); + sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); return; - } + } pCmd = Tcl_NewListObj(nArg, aArg); Tcl_IncrRefCount(pCmd); for(i=0; iinterp, pCmd, pVal); if( rc ){ Tcl_DecrRefCount(pCmd); - sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); + sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); return; } } @@ -881,7 +961,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ } if( rc && rc!=TCL_RETURN ){ - sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); + sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); }else{ Tcl_Obj *pVar = Tcl_GetObjResult(p->interp); int n; @@ -983,7 +1063,7 @@ static int auth_callback( Tcl_DStringAppendElement(&str, zArg4 ? zArg4 : ""); #ifdef SQLITE_USER_AUTHENTICATION Tcl_DStringAppendElement(&str, zArg5 ? zArg5 : ""); -#endif +#endif rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str)); Tcl_DStringFree(&str); zReply = rc==TCL_OK ? Tcl_GetStringResult(pDb->interp) : "SQLITE_DENY"; @@ -1075,12 +1155,12 @@ static int DbTransPostCmd( pDb->disableAuth++; if( sqlite3_exec(pDb->db, zEnd, 0, 0, 0) ){ /* This is a tricky scenario to handle. The most likely cause of an - ** error is that the exec() above was an attempt to commit the + ** error is that the exec() above was an attempt to commit the ** top-level transaction that returned SQLITE_BUSY. Or, less likely, ** that an IO-error has occurred. In either case, throw a Tcl exception ** and try to rollback the transaction. ** - ** But it could also be that the user executed one or more BEGIN, + ** But it could also be that the user executed one or more BEGIN, ** COMMIT, SAVEPOINT, RELEASE or ROLLBACK commands that are confusing ** this method's logic. Not clear how this would be best handled. */ @@ -1099,7 +1179,7 @@ static int DbTransPostCmd( ** Unless SQLITE_TEST is defined, this function is a simple wrapper around ** sqlite3_prepare_v2(). If SQLITE_TEST is defined, then it uses either ** sqlite3_prepare_v2() or legacy interface sqlite3_prepare(), depending -** on whether or not the [db_use_legacy_prepare] command has been used to +** on whether or not the [db_use_legacy_prepare] command has been used to ** configure the connection. */ static int dbPrepare( @@ -1155,7 +1235,7 @@ static int dbPrepareAndBind( for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pPreStmt->pNext){ int n = pPreStmt->nSql; - if( nSql>=n + if( nSql>=n && memcmp(pPreStmt->zSql, zSql, n)==0 && (zSql[n]==0 || zSql[n-1]==';') ){ @@ -1181,7 +1261,7 @@ static int dbPrepareAndBind( break; } } - + /* If no prepared statement was found. Compile the SQL text. Also allocate ** a new SqlPreparedStmt structure. */ if( pPreStmt==0 ){ @@ -1227,7 +1307,7 @@ static int dbPrepareAndBind( assert( strlen30(pPreStmt->zSql)==pPreStmt->nSql ); assert( 0==memcmp(pPreStmt->zSql, zSql, pPreStmt->nSql) ); - /* Bind values to parameters that begin with $ or : */ + /* Bind values to parameters that begin with $ or : */ for(i=1; i<=nVar; i++){ const char *zVar = sqlite3_bind_parameter_name(pStmt, i); if( zVar!=0 && (zVar[0]=='$' || zVar[0]==':' || zVar[0]=='@') ){ @@ -1315,8 +1395,8 @@ static void dbReleaseStmt( assert( pDb->nStmt>0 ); } pDb->nStmt++; - - /* If we have too many statement in cache, remove the surplus from + + /* If we have too many statement in cache, remove the surplus from ** the end of the cache list. */ while( pDb->nStmt>pDb->maxStmt ){ SqlPreparedStmt *pLast = pDb->stmtLast; @@ -1370,8 +1450,8 @@ static void dbReleaseColumnNames(DbEvalContext *p){ ** If pArray is not NULL, then it contains the name of a Tcl array ** variable. The "*" member of this array is set to a list containing ** the names of the columns returned by the statement as part of each -** call to dbEvalStep(), in order from left to right. e.g. if the names -** of the returned columns are a, b and c, it does the equivalent of the +** call to dbEvalStep(), in order from left to right. e.g. if the names +** of the returned columns are a, b and c, it does the equivalent of the ** tcl command: ** ** set ${pArray}(*) {a b c} @@ -1492,7 +1572,7 @@ static int dbEvalStep(DbEvalContext *p){ #if SQLITE_TEST if( p->pDb->bLegacyPrepare && rcs==SQLITE_SCHEMA && zPrevSql ){ /* If the runtime error was an SQLITE_SCHEMA, and the database - ** handle is configured to use the legacy sqlite3_prepare() + ** handle is configured to use the legacy sqlite3_prepare() ** interface, retry prepare()/step() on the same SQL statement. ** This only happens once. If there is a second SQLITE_SCHEMA ** error, the error will be returned to the caller. */ @@ -1580,11 +1660,11 @@ static int DbUseNre(void){ return( (major==8 && minor>=6) || major>8 ); } #else -/* +/* ** Compiling using headers earlier than 8.6. In this case NR cannot be ** used, so DbUseNre() to always return zero. Add #defines for the other ** Tcl_NRxxx() functions to prevent them from causing compilation errors, -** even though the only invocations of them are within conditional blocks +** even though the only invocations of them are within conditional blocks ** of the form: ** ** if( DbUseNre() ) { ... } @@ -1630,11 +1710,11 @@ static int DbEvalNextCmd( } } - /* The required interpreter variables are now populated with the data + /* The required interpreter variables are now populated with the data ** from the current row. If using NRE, schedule callbacks to evaluate ** script pScript, then to invoke this function again to fetch the next ** row (or clean up if there is no next row or the script throws an - ** exception). After scheduling the callbacks, return control to the + ** exception). After scheduling the callbacks, return control to the ** caller. ** ** If not using NRE, evaluate pScript directly and continue with the @@ -1659,7 +1739,7 @@ static int DbEvalNextCmd( } /* -** This function is used by the implementations of the following database +** This function is used by the implementations of the following database ** handle sub-commands: ** ** $db update_hook ?SCRIPT? @@ -1726,9 +1806,10 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ "preupdate", "profile", "progress", "rekey", "restore", "rollback_hook", "status", "timeout", "total_changes", - "trace", "transaction", "unlock_notify", - "update_hook", "version", "wal_hook", - 0 + "trace", "trace_v2", "transaction", + "unlock_notify", "update_hook", "version", + "wal_hook", + 0 }; enum DB_enum { DB_AUTHORIZER, DB_BACKUP, DB_BUSY, @@ -1741,8 +1822,9 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ DB_PREUPDATE, DB_PROFILE, DB_PROGRESS, DB_REKEY, DB_RESTORE, DB_ROLLBACK_HOOK, DB_STATUS, DB_TIMEOUT, DB_TOTAL_CHANGES, - DB_TRACE, DB_TRANSACTION, DB_UNLOCK_NOTIFY, - DB_UPDATE_HOOK, DB_VERSION, DB_WAL_HOOK, + DB_TRACE, DB_TRACE_V2, DB_TRANSACTION, + DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK, DB_VERSION, + DB_WAL_HOOK, }; /* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */ @@ -1928,7 +2010,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ return TCL_ERROR; }else{ if( TCL_ERROR==Tcl_GetIntFromObj(interp, objv[3], &n) ){ - Tcl_AppendResult( interp, "cannot convert \"", + Tcl_AppendResult( interp, "cannot convert \"", Tcl_GetStringFromObj(objv[3],0), "\" to integer", (char*)0); return TCL_ERROR; }else{ @@ -1942,7 +2024,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } } }else{ - Tcl_AppendResult( interp, "bad option \"", + Tcl_AppendResult( interp, "bad option \"", Tcl_GetStringFromObj(objv[2],0), "\": must be flush or size", (char*)0); return TCL_ERROR; @@ -1953,7 +2035,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* $db changes ** ** Return the number of rows that were modified, inserted, or deleted by - ** the most recent INSERT, UPDATE or DELETE statement, not including + ** the most recent INSERT, UPDATE or DELETE statement, not including ** any changes made by trigger programs. */ case DB_CHANGES: { @@ -2000,7 +2082,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ pCollate->zScript = (char*)&pCollate[1]; pDb->pCollate = pCollate; memcpy(pCollate->zScript, zScript, nScript+1); - if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, + if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, pCollate, tclSqlCollate) ){ Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE); return TCL_ERROR; @@ -2126,7 +2208,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ const char *zSep; const char *zNull; if( objc<5 || objc>7 ){ - Tcl_WrongNumArgs(interp, 2, objv, + Tcl_WrongNumArgs(interp, 2, objv, "CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?"); return TCL_ERROR; } @@ -2155,7 +2237,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ strcmp(zConflict, "fail" ) != 0 && strcmp(zConflict, "ignore" ) != 0 && strcmp(zConflict, "replace" ) != 0 ) { - Tcl_AppendResult(interp, "Error: \"", zConflict, + Tcl_AppendResult(interp, "Error: \"", zConflict, "\", conflict-algorithm must be one of: rollback, " "abort, fail, ignore, or replace", (char*)0); return TCL_ERROR; @@ -2244,7 +2326,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ for(i=0; i0 && strcmp(azCol[i], zNull)==0) - || strlen30(azCol[i])==0 + || strlen30(azCol[i])==0 ){ sqlite3_bind_null(pStmt, i+1); }else{ @@ -2323,7 +2405,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ ** The onecolumn method is the equivalent of: ** lindex [$db eval $sql] 0 */ - case DB_EXISTS: + case DB_EXISTS: case DB_ONECOLUMN: { Tcl_Obj *pResult = 0; DbEvalContext sEval; @@ -2351,7 +2433,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } break; } - + /* ** $db eval $sql ?array? ?{ ...code... }? ** @@ -2397,7 +2479,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } pScript = objv[objc-1]; Tcl_IncrRefCount(pScript); - + p = (DbEvalContext *)Tcl_Alloc(sizeof(DbEvalContext)); dbEvalInit(p, pDb, objv[2], pArray); @@ -2444,7 +2526,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ if( n>2 && strncmp(z, "-deterministic",n)==0 ){ flags |= SQLITE_DETERMINISTIC; }else{ - Tcl_AppendResult(interp, "bad option \"", z, + Tcl_AppendResult(interp, "bad option \"", z, "\": must be -argcount or -deterministic", 0 ); return TCL_ERROR; @@ -2553,7 +2635,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } /* - ** $db last_insert_rowid + ** $db last_insert_rowid ** ** Return an integer which is the ROWID for the most recent insert. */ @@ -2575,7 +2657,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ */ /* $db progress ?N CALLBACK? - ** + ** ** Invoke the given callback every N virtual machine opcodes while executing ** queries. */ @@ -2682,7 +2764,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* $db restore ?DATABASE? FILENAME ** - ** Open a database file named FILENAME. Transfer the content + ** Open a database file named FILENAME. Transfer the content ** of FILENAME into the local database DATABASE (default: "main"). */ case DB_RESTORE: { @@ -2743,7 +2825,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* ** $db status (step|sort|autoindex) ** - ** Display SQLITE_STMTSTATUS_FULLSCAN_STEP or + ** Display SQLITE_STMTSTATUS_FULLSCAN_STEP or ** SQLITE_STMTSTATUS_SORT for the most recent eval. */ case DB_STATUS: { @@ -2761,15 +2843,15 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ }else if( strcmp(zOp, "autoindex")==0 ){ v = pDb->nIndex; }else{ - Tcl_AppendResult(interp, - "bad argument: should be autoindex, step, or sort", + Tcl_AppendResult(interp, + "bad argument: should be autoindex, step, or sort", (char*)0); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(v)); break; } - + /* ** $db timeout MILLESECONDS ** @@ -2785,11 +2867,11 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ sqlite3_busy_timeout(pDb->db, ms); break; } - + /* ** $db total_changes ** - ** Return the number of rows that were modified, inserted, or deleted + ** Return the number of rows that were modified, inserted, or deleted ** since the database handle was created. */ case DB_TOTAL_CHANGES: { @@ -2842,6 +2924,53 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ break; } + /* $db trace_v2 ?CALLBACK? ?MASK? + ** + ** Make arrangements to invoke the CALLBACK routine for each trace event + ** matching the mask that is generated. The parameters are appended to + ** CALLBACK before it is executed. + */ + case DB_TRACE_V2: { + if( objc>4 ){ + Tcl_WrongNumArgs(interp, 2, objv, "?CALLBACK? ?MASK?"); + return TCL_ERROR; + }else if( objc==2 ){ + if( pDb->zTraceV2 ){ + Tcl_AppendResult(interp, pDb->zTraceV2, (char*)0); + } + }else{ + Tcl_WideInt wMask; + char *zTraceV2; + int len; + if( objc==4 ){ + if( TCL_OK!=Tcl_GetWideIntFromObj(interp, objv[3], &wMask) ){ + return TCL_ERROR; + } + }else{ + wMask = SQLITE_TRACE_STMT; + } + if( pDb->zTraceV2 ){ + Tcl_Free(pDb->zTraceV2); + } + zTraceV2 = Tcl_GetStringFromObj(objv[2], &len); + if( zTraceV2 && len>0 ){ + pDb->zTraceV2 = Tcl_Alloc( len + 1 ); + memcpy(pDb->zTraceV2, zTraceV2, len+1); + }else{ + pDb->zTraceV2 = 0; + } +#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) + if( pDb->zTraceV2 ){ + pDb->interp = interp; + sqlite3_trace_v2(pDb->db, (unsigned)wMask, DbTraceV2Handler, pDb); + }else{ + sqlite3_trace_v2(pDb->db, 0, 0, 0); + } +#endif + } + break; + } + /* $db transaction [-deferred|-immediate|-exclusive] SCRIPT ** ** Start a new transaction (if we are not already in the midst of a @@ -2894,7 +3023,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* If using NRE, schedule a callback to invoke the script pScript, then ** a second callback to commit (or rollback) the transaction or savepoint ** opened above. If not using NRE, evaluate the script directly, then - ** call function DbTransPostCmd() to commit (or rollback) the transaction + ** call function DbTransPostCmd() to commit (or rollback) the transaction ** or savepoint. */ if( DbUseNre() ){ Tcl_NRAddCallback(interp, DbTransPostCmd, cd, 0, 0, 0); @@ -2925,14 +3054,14 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_DecrRefCount(pDb->pUnlockNotify); pDb->pUnlockNotify = 0; } - + if( objc==3 ){ xNotify = DbUnlockNotify; pNotifyArg = (void *)pDb; pDb->pUnlockNotify = objv[2]; Tcl_IncrRefCount(pDb->pUnlockNotify); } - + if( sqlite3_unlock_notify(pDb->db, xNotify, pNotifyArg) ){ Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0); rc = TCL_ERROR; @@ -3031,13 +3160,13 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ ** $db update_hook ?script? ** $db rollback_hook ?script? */ - case DB_WAL_HOOK: - case DB_UPDATE_HOOK: + case DB_WAL_HOOK: + case DB_UPDATE_HOOK: case DB_ROLLBACK_HOOK: { - /* set ppHook to point at pUpdateHook or pRollbackHook, depending on + /* set ppHook to point at pUpdateHook or pRollbackHook, depending on ** whether [$db update_hook] or [$db rollback_hook] was invoked. */ - Tcl_Obj **ppHook = 0; + Tcl_Obj **ppHook = 0; if( choice==DB_WAL_HOOK ) ppHook = &pDb->pWalHook; if( choice==DB_UPDATE_HOOK ) ppHook = &pDb->pUpdateHook; if( choice==DB_ROLLBACK_HOOK ) ppHook = &pDb->pRollbackHook; @@ -3198,7 +3327,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } } if( objc<3 || (objc&1)!=1 ){ - Tcl_WrongNumArgs(interp, 1, objv, + Tcl_WrongNumArgs(interp, 1, objv, "HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?" " ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?" #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL) @@ -3490,7 +3619,7 @@ static void MD5Init(MD5Context *ctx){ * Update context to reflect the concatenation of another buffer full * of bytes. */ -static +static void MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len){ uint32 t; @@ -3536,7 +3665,7 @@ void MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len){ } /* - * Final wrapup - pad to 64-byte boundary with the bit pattern + * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ static void MD5Final(unsigned char digest[16], MD5Context *ctx){ @@ -3612,7 +3741,7 @@ static void MD5DigestToBase10x8(unsigned char digest[16], char zDigest[50]){ /* ** A TCL command for md5. The argument is the text to be hashed. The -** Result is the hash in base64. +** Result is the hash in base64. */ static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ MD5Context ctx; @@ -3621,7 +3750,7 @@ static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ void (*converter)(unsigned char*, char*); if( argc!=2 ){ - Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], + Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], " TEXT\"", (char*)0); return TCL_ERROR; } @@ -3646,13 +3775,13 @@ static int md5file_cmd(void*cd, Tcl_Interp*interp, int argc, const char **argv){ char zBuf[10240]; if( argc!=2 ){ - Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], + Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], " FILENAME\"", (char*)0); return TCL_ERROR; } in = fopen(argv[1],"rb"); if( in==0 ){ - Tcl_AppendResult(interp,"unable to open file \"", argv[1], + Tcl_AppendResult(interp,"unable to open file \"", argv[1], "\" for reading", (char*)0); return TCL_ERROR; } @@ -3719,7 +3848,7 @@ static void md5finalize(sqlite3_context *context){ sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } int Md5_Register(sqlite3 *db){ - int rc = sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, + int rc = sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, md5step, md5finalize); sqlite3_overload_function(db, "md5sum", -1); /* To exercise this API */ return rc; @@ -3870,7 +3999,7 @@ static int db_last_stmt_ptr( ** Configure the interpreter passed as the first argument to have access ** to the commands and linked variables that make up: ** -** * the [sqlite3] extension itself, +** * the [sqlite3] extension itself, ** ** * If SQLITE_TCLMD5 or SQLITE_TEST is defined, the Md5 commands, and ** From b52dcd898936ad3e397d3e696573c8768d8c2422 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 14 Jul 2016 23:17:03 +0000 Subject: [PATCH 10/42] More work on the Tcl interface and tests for the sqlite3_trace_v2() API. FossilOrigin-Name: f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 --- manifest | 13 ++--- manifest.uuid | 2 +- src/tclsqlite.c | 41 ++++++++++++++-- test/trace3.test | 124 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 test/trace3.test diff --git a/manifest b/manifest index b880ee391d..ae6c2d0353 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initial\swork\son\sthe\sTcl\sAPI\sinterface\sto\sthe\snew\ssqlite3_trace_v2()\sfunction. -D 2016-07-14T21:26:09.090 +C More\swork\son\sthe\sTcl\sinterface\sand\stests\sfor\sthe\ssqlite3_trace_v2()\sAPI. +D 2016-07-14T23:17:03.656 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -392,7 +392,7 @@ F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 361167055f0d0d9883b729f1db698edcd3b46065 +F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 @@ -1285,6 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 +F test/trace3.test bc598719949e59b8ba5152cc42fea75e99766478 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1505,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 -R 85912bc13f3699d6087855b14808f819 +P 7b59fa40a01c89cc98414d90a798169c26e04256 +R f3e8ed411550909534d86cfeab7a6746 U mistachkin -Z 312d6409632132f635d6a5f40333e628 +Z 5840e23d72dcfac70e0e20acc9abb290 diff --git a/manifest.uuid b/manifest.uuid index f5bb4e0461..0d1c4fc278 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7b59fa40a01c89cc98414d90a798169c26e04256 \ No newline at end of file +f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index bcae05d795..43dfedb727 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2939,15 +2939,50 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_AppendResult(interp, pDb->zTraceV2, (char*)0); } }else{ - Tcl_WideInt wMask; char *zTraceV2; int len; + Tcl_WideInt wMask = 0; if( objc==4 ){ - if( TCL_OK!=Tcl_GetWideIntFromObj(interp, objv[3], &wMask) ){ + static const char *TTYPE_strs[] = { + "statement", "profile", "row", "close", 0 + }; + enum TTYPE_enum { + TTYPE_STMT, TTYPE_PROFILE, TTYPE_ROW, TTYPE_CLOSE + }; + int i; + if( TCL_OK!=Tcl_ListObjLength(interp, objv[3], &len) ){ return TCL_ERROR; } + for(i=0; izTraceV2 ){ Tcl_Free(pDb->zTraceV2); diff --git a/test/trace3.test b/test/trace3.test new file mode 100644 index 0000000000..b9977178ad --- /dev/null +++ b/test/trace3.test @@ -0,0 +1,124 @@ +# 2016 July 14 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The focus +# of this test file is the "sqlite3_trace_v2()" API. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +ifcapable !trace { finish_test ; return } +set ::testprefix trace3 + +proc trace_v2_error { args } { + lappend ::stmtlist(error) [string trim $args] + error "trace error"; # this will be ignored. +} +proc trace_v2_record { args } { + lappend ::stmtlist(record) [string trim $args] +} +proc trace_v2_nop { args } {}; # do nothing. + +do_test trace3-1.0 { + execsql { + CREATE TABLE t1(a,b); + INSERT INTO t1 VALUES(1,NULL); + INSERT INTO t1 VALUES(2,-1); + INSERT INTO t1 VALUES(3,0); + INSERT INTO t1 VALUES(4,1); + INSERT INTO t1 VALUES(5,-2147483648); + INSERT INTO t1 VALUES(6,2147483647); + INSERT INTO t1 VALUES(7,-9223372036854775808); + INSERT INTO t1 VALUES(8,9223372036854775807); + INSERT INTO t1 VALUES(9,-1.0); + INSERT INTO t1 VALUES(10,0.0); + INSERT INTO t1 VALUES(11,1.0); + INSERT INTO t1 VALUES(12,''); + INSERT INTO t1 VALUES(13,'1'); + INSERT INTO t1 VALUES(14,'one'); + INSERT INTO t1 VALUES(15,x'abcd0123'); + INSERT INTO t1 VALUES(16,x'4567cdef'); + } +} {} + +do_test trace3-1.1 { + set rc [catch {db trace_v2 1 2 3} msg] + lappend rc $msg +} {1 {wrong # args: should be "db trace_v2 ?CALLBACK? ?MASK?"}} +do_test trace3-1.2 { + set rc [catch {db trace_v2 1 bad} msg] + lappend rc $msg +} {1 {bad trace type "bad": must be statement, profile, row, or close}} + +do_test trace3-2.1 { + db trace_v2 trace_v2_nop + db trace_v2 +} {trace_v2_nop} + +do_test trace3-3.1 { + unset -nocomplain ::stmtlist + db trace_v2 trace_v2_nop + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + array get ::stmtlist +} {} +do_test trace3-3.2 { + set ::stmtlist(error) {} + db trace_v2 trace_v2_error + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(error) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} +do_test trace3-3.3 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} + +do_test trace3-4.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record profile + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ -?\d+\}$/} + +do_test trace3-5.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record row + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^[string trim [string repeat {\d+ } 16]]\$/" + +do_test trace3-6.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record {profile row} + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^[string trim [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/" + +do_test trace3-7.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record close + db close + set ::stmtlist(record) +} {/^-?\d+$/} + +finish_test From e2f84b403c982d48ed4e9f49677ab40119c7db4b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:07:47 +0000 Subject: [PATCH 11/42] Add tests, including some for the sqlite3_expanded_sql() API. FossilOrigin-Name: 8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 --- manifest | 12 ++++----- manifest.uuid | 2 +- test/trace3.test | 64 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ae6c2d0353..1075a137e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\swork\son\sthe\sTcl\sinterface\sand\stests\sfor\sthe\ssqlite3_trace_v2()\sAPI. -D 2016-07-14T23:17:03.656 +C Add\stests,\sincluding\ssome\sfor\sthe\ssqlite3_expanded_sql()\sAPI. +D 2016-07-15T00:07:47.847 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test bc598719949e59b8ba5152cc42fea75e99766478 +F test/trace3.test fb9242446aeef4f6e559edb126b3d67185b9a1c0 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7b59fa40a01c89cc98414d90a798169c26e04256 -R f3e8ed411550909534d86cfeab7a6746 +P f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 +R 433ed72af7d798e30b744dbac703a881 U mistachkin -Z 5840e23d72dcfac70e0e20acc9abb290 +Z c19e7bc180fcaf3fc05253b5c21f7fa0 diff --git a/manifest.uuid b/manifest.uuid index 0d1c4fc278..d877fc43c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 \ No newline at end of file +8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 \ No newline at end of file diff --git a/test/trace3.test b/test/trace3.test index b9977178ad..760fd33fe5 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -8,8 +8,9 @@ # May you share freely, never taking more than you give. # #*********************************************************************** -# This file implements regression tests for SQLite library. The focus -# of this test file is the "sqlite3_trace_v2()" API. +# This file implements regression tests for SQLite library. The focus of +# this test file is the "sqlite3_trace_v2()" and "sqlite3_expanded_sql()" +# APIs. # set testdir [file dirname $argv0] @@ -113,8 +114,67 @@ do_test trace3-6.1 { } set ::stmtlist(record) } "/^[string trim [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/" +do_test trace3-6.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record {statement profile row} + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^\\\{-?\\d+ \\\{SELECT a, b FROM t1 ORDER BY a;\\\}\\\} [string trim \ +[string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/" do_test trace3-7.1 { + set DB [sqlite3_connection_pointer db] + + set STMT [sqlite3_prepare_v2 $DB \ + "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 TAIL] +} {/^[0-9A-F]+$/} + +do_test trace3-8.1 { + list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = NULL ORDER BY a;}} +do_test trace3-8.2 { + list [sqlite3_bind_int $STMT 1 123] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}} +do_test trace3-8.3 { + list [sqlite3_bind_int64 $STMT 1 123] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}} +do_test trace3-8.4 { + list [sqlite3_bind_text $STMT 1 "some string" 11] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 'some string' ORDER BY a;}} +do_test trace3-8.5 { + list [sqlite3_bind_text $STMT 1 "some 'bad' string" 17] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 'some ''bad'' string' ORDER BY a;}} +do_test trace3-8.6 { + list [sqlite3_bind_double $STMT 1 123] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 123.0 ORDER BY a;}} +do_test trace3-8.7 { + list [sqlite3_bind_text16 $STMT 1 \ + [encoding convertto unicode hi\000yall\000] 16] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 'hi' ORDER BY a;}} +do_test trace3-8.8 { + list [sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}} + +do_test trace3-9.1 { + db trace_v2 "" + db trace_v2 +} {} +do_test trace3-9.2 { + unset -nocomplain ::stmtlist + db trace_v2 "" {statement profile row} + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + array get ::stmtlist +} {} + +do_test trace3-10.1 { set ::stmtlist(record) {} db trace_v2 trace_v2_record close db close From a8f286a38a1c89bca1af69ff59a38d0cb1c412cc Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:09:53 +0000 Subject: [PATCH 12/42] Modify one test result to be case-insensitive. FossilOrigin-Name: 5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/trace3.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1075a137e4..4323ff299d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests,\sincluding\ssome\sfor\sthe\ssqlite3_expanded_sql()\sAPI. -D 2016-07-15T00:07:47.847 +C Modify\sone\stest\sresult\sto\sbe\scase-insensitive. +D 2016-07-15T00:09:53.145 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test fb9242446aeef4f6e559edb126b3d67185b9a1c0 +F test/trace3.test 0cb672483450fd430b24bc53eaddd13b2e69ffb7 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 -R 433ed72af7d798e30b744dbac703a881 +P 8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 +R 4595806197ce86b476490cbf571f56e0 U mistachkin -Z c19e7bc180fcaf3fc05253b5c21f7fa0 +Z b642433aedf1b36843816b1e93dd1f01 diff --git a/manifest.uuid b/manifest.uuid index d877fc43c8..c8129cd085 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 \ No newline at end of file +5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 \ No newline at end of file diff --git a/test/trace3.test b/test/trace3.test index 760fd33fe5..eef9198791 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -129,7 +129,7 @@ do_test trace3-7.1 { set STMT [sqlite3_prepare_v2 $DB \ "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 TAIL] -} {/^[0-9A-F]+$/} +} {/^[0-9A-Fa-f]+$/} do_test trace3-8.1 { list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT] From 170e9982369e9b80b70fd654003a86f22a79330f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:23:01 +0000 Subject: [PATCH 13/42] Corrections and enhancements for the new tests. FossilOrigin-Name: 20e74c638537aa207de41a4f3c932cc05024ea9a --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/trace3.test | 49 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4323ff299d..e0b98e55b5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sone\stest\sresult\sto\sbe\scase-insensitive. -D 2016-07-15T00:09:53.145 +C Corrections\sand\senhancements\sfor\sthe\snew\stests. +D 2016-07-15T00:23:01.539 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test 0cb672483450fd430b24bc53eaddd13b2e69ffb7 +F test/trace3.test 7d174e42aab63f528a0d04ea1ddf3b49497a9cf5 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 -R 4595806197ce86b476490cbf571f56e0 +P 5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 +R 614bfc4ccb78b65b369725b4f27e97e3 U mistachkin -Z b642433aedf1b36843816b1e93dd1f01 +Z a476d2a0aebfb671981b15fc2ac6c121 diff --git a/manifest.uuid b/manifest.uuid index c8129cd085..22e8d58574 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 \ No newline at end of file +20e74c638537aa207de41a4f3c932cc05024ea9a \ No newline at end of file diff --git a/test/trace3.test b/test/trace3.test index eef9198791..1149bea3f2 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -87,6 +87,22 @@ do_test trace3-3.3 { } set ::stmtlist(record) } {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} +do_test trace3-3.4 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record statement + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} +do_test trace3-3.5 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 1 + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} do_test trace3-4.1 { set ::stmtlist(record) {} @@ -96,6 +112,14 @@ do_test trace3-4.1 { } set ::stmtlist(record) } {/^\{-?\d+ -?\d+\}$/} +do_test trace3-4.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 2 + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ -?\d+\}$/} do_test trace3-5.1 { set ::stmtlist(record) {} @@ -105,6 +129,14 @@ do_test trace3-5.1 { } set ::stmtlist(record) } "/^[string trim [string repeat {\d+ } 16]]\$/" +do_test trace3-5.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 4 + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^[string trim [string repeat {\d+ } 16]]\$/" do_test trace3-6.1 { set ::stmtlist(record) {} @@ -162,10 +194,14 @@ do_test trace3-8.8 { } {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}} do_test trace3-9.1 { + sqlite3_finalize $STMT +} {SQLITE_OK} + +do_test trace3-10.1 { db trace_v2 "" db trace_v2 } {} -do_test trace3-9.2 { +do_test trace3-10.2 { unset -nocomplain ::stmtlist db trace_v2 "" {statement profile row} execsql { @@ -174,11 +210,20 @@ do_test trace3-9.2 { array get ::stmtlist } {} -do_test trace3-10.1 { +do_test trace3-11.1 { set ::stmtlist(record) {} db trace_v2 trace_v2_record close db close set ::stmtlist(record) } {/^-?\d+$/} +reset_db + +do_test trace3-11.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 8 + db close + set ::stmtlist(record) +} {/^-?\d+$/} + finish_test From 283a85ca212d4cc42a115c13011e7d88189d6dac Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:39:47 +0000 Subject: [PATCH 14/42] Fix typo in sqlite3_trace_v2(). FossilOrigin-Name: 97ccf15fb7e5103c8317d06a1985ba9c88544a60 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e0b98e55b5..72176f68e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Corrections\sand\senhancements\sfor\sthe\snew\stests. -D 2016-07-15T00:23:01.539 +C Fix\stypo\sin\ssqlite3_trace_v2(). +D 2016-07-15T00:39:47.683 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c ade3b39f3bde9212b3fabcff2367d29052002df6 +F src/main.c 2d3e62a971e7f169a74448e81af9ebde95b07381 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 -R 614bfc4ccb78b65b369725b4f27e97e3 +P 20e74c638537aa207de41a4f3c932cc05024ea9a +R 6a6c93d9b0435cebe88086cbb6537465 U mistachkin -Z a476d2a0aebfb671981b15fc2ac6c121 +Z 470459b5b02059a7c191e033bd2eea7f diff --git a/manifest.uuid b/manifest.uuid index 22e8d58574..8fa3e9fe97 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -20e74c638537aa207de41a4f3c932cc05024ea9a \ No newline at end of file +97ccf15fb7e5103c8317d06a1985ba9c88544a60 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 2e996b5545..5cd1ea7185 100644 --- a/src/main.c +++ b/src/main.c @@ -1834,8 +1834,7 @@ int sqlite3_trace_v2( ){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ){ - (void)SQLITE_MISUSE_BKPT; - return 0; + return SQLITE_MISUSE_BKPT; } #endif sqlite3_mutex_enter(db->mutex); From de6fde6af69f9ea2cc0e3a0180cf97a48a0dcb03 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 01:49:25 +0000 Subject: [PATCH 15/42] Modify the Tcl test command 'sqlite3_bind_blob' to make use of the Tcl_GetByteArrayFromObj() API. FossilOrigin-Name: e03c81895e52096ab055d8231841e9070602ca84 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test1.c | 13 +++++++++++-- test/trace3.test | 4 ++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 72176f68e4..42028828b3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\ssqlite3_trace_v2(). -D 2016-07-15T00:39:47.683 +C Modify\sthe\sTcl\stest\scommand\s'sqlite3_bind_blob'\sto\smake\suse\sof\sthe\sTcl_GetByteArrayFromObj()\sAPI. +D 2016-07-15T01:49:25.642 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -393,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e -F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e +F src/test1.c 4bdfccf93a33453b427fb01cf12dfe26a5dd2cbc F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test 7d174e42aab63f528a0d04ea1ddf3b49497a9cf5 +F test/trace3.test 01e4111d582c7b20ab1c63156169157d256bc3d5 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 20e74c638537aa207de41a4f3c932cc05024ea9a -R 6a6c93d9b0435cebe88086cbb6537465 +P 97ccf15fb7e5103c8317d06a1985ba9c88544a60 +R 23f12c56d57425cd5e6978d10e653771 U mistachkin -Z 470459b5b02059a7c191e033bd2eea7f +Z ce44a3acd6ed0a8254df88a4b23a0c52 diff --git a/manifest.uuid b/manifest.uuid index 8fa3e9fe97..4fc1c619aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -97ccf15fb7e5103c8317d06a1985ba9c88544a60 \ No newline at end of file +e03c81895e52096ab055d8231841e9070602ca84 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index a1fdcb5cfb..11cd17e722 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3633,7 +3633,7 @@ static int test_bind_blob( Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; - int idx; + int len, idx; int bytes; char *value; int rc; @@ -3652,9 +3652,18 @@ static int test_bind_blob( if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; - value = Tcl_GetString(objv[3]); + + value = Tcl_GetByteArrayFromObj(objv[3], &len); if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; + if( bytes>len ){ + char zBuf[200]; + sqlite3_snprintf(sizeof(zBuf), zBuf, + "cannot use %d blob bytes, have %d", bytes, len); + Tcl_AppendResult(interp, zBuf, -1); + return TCL_ERROR; + } + rc = sqlite3_bind_blob(pStmt, idx, value, bytes, xDestructor); if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ diff --git a/test/trace3.test b/test/trace3.test index 1149bea3f2..0809759d80 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -192,6 +192,10 @@ do_test trace3-8.8 { list [sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3] \ [sqlite3_expanded_sql $STMT] } {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}} +do_test trace3-8.9 { + list [sqlite3_bind_blob $STMT 1 "\xAB\xCD\xEF" 3] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = x'abcdef' ORDER BY a;}} do_test trace3-9.1 { sqlite3_finalize $STMT From 8d85364261a96a0e370bce1f1f6b858612e838f0 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 15 Jul 2016 10:01:06 +0000 Subject: [PATCH 16/42] The sqlite3_expanded_sql() function compiles, but always returns NULL, when the SQLITE_OMIT_TRACE compile-time option is used. FossilOrigin-Name: 53c25ebe34e6776a12260078852973b1d581d20f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 4 +++- src/test1.c | 2 +- src/vdbeaux.c | 4 ++++ 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 373a08e7de..fdc8e8e54c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sfixes\sfrom\strunk.\s\sFix\sthe\stclsqlite.test\sscript. -D 2016-07-15T02:55:51.860 +C The\ssqlite3_expanded_sql()\sfunction\scompiles,\sbut\salways\sreturns\sNULL,\swhen\nthe\sSQLITE_OMIT_TRACE\scompile-time\soption\sis\sused. +D 2016-07-15T10:01:06.596 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 6ba80e88ee17b9071f35121271784ecef60df863 +F src/sqlite.h.in aad252c428329522c4146a8da236e92496b15de5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -393,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e -F src/test1.c 4bdfccf93a33453b427fb01cf12dfe26a5dd2cbc +F src/test1.c 186e3b53c402b7a73bcb4ade2b77709675c39fe3 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -453,7 +453,7 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 08a459b6906dfcce0e921daba3a471a28ea65d41 +F src/vdbeaux.c 23df1e66e420a0e591bc877eace43be1f16f0f28 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e03c81895e52096ab055d8231841e9070602ca84 ec7180892ac737f0731cf61f2d095a5c1d18ad93 -R 8bd18a5122e19b3b0675d3bc2674a51e +P d2b1fa55e8809ffc25a25f256349b8d08beadab5 +R 62f79e8e18332d747e11f9ca2d1624d9 U drh -Z 68d53222f802b7ae8fc8a7f808e2ed8d +Z 83a3df8e5ff251b53fc0f846b015b7e8 diff --git a/manifest.uuid b/manifest.uuid index af07c18f62..84bd71ab4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2b1fa55e8809ffc25a25f256349b8d08beadab5 \ No newline at end of file +53c25ebe34e6776a12260078852973b1d581d20f \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8b9aa7402d..2a34fb8e9d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3510,7 +3510,9 @@ int sqlite3_prepare16_v2( ** will return "SELECT 2345,NULL". ** ** The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a -** bound parameter expansion. +** bound parameter expansion. If SQLite is built with the +** [SQLITE_OMIT_TRACE] compile-time option then the sqlite3_expanded_sql() +** interface is non-functional and always returns NULL. ** ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is ** automatically freed when the prepared statement is finalized. diff --git a/src/test1.c b/src/test1.c index 11cd17e722..7d83881139 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3653,7 +3653,7 @@ static int test_bind_blob( if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; - value = Tcl_GetByteArrayFromObj(objv[3], &len); + value = (char*)Tcl_GetByteArrayFromObj(objv[3], &len); if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; if( bytes>len ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 72a882c176..ec702b3c8c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -82,9 +82,13 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt){ ** expanded bound parameters. */ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ +#ifdef SQLITE_OMIT_TRACE + return 0; +#else Vdbe *p = (Vdbe *)pStmt; if( p==0 || p->zSql==0 ) return 0; return sqlite3VdbeExpandSql(p, p->zSql); +#endif } /* From dec8bc0eb49b5af519ead428296dbfce884ae1cb Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 Jul 2016 20:20:53 +0000 Subject: [PATCH 17/42] Add requirements marks to the sqlite3_expanded_sql() documentation. FossilOrigin-Name: 409535e6dfc307f26ea3d9f51be51c439b6d7b22 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index fdc8e8e54c..a198d7e20b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3_expanded_sql()\sfunction\scompiles,\sbut\salways\sreturns\sNULL,\swhen\nthe\sSQLITE_OMIT_TRACE\scompile-time\soption\sis\sused. -D 2016-07-15T10:01:06.596 +C Add\srequirements\smarks\sto\sthe\ssqlite3_expanded_sql()\sdocumentation. +D 2016-07-22T20:20:53.758 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in aad252c428329522c4146a8da236e92496b15de5 +F src/sqlite.h.in f1e866f8b789391ba7f77f71164e51b7f8b4b111 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d2b1fa55e8809ffc25a25f256349b8d08beadab5 -R 62f79e8e18332d747e11f9ca2d1624d9 +P 53c25ebe34e6776a12260078852973b1d581d20f +R d9d54b2d05c15d2014a2ffa7a3228fb1 U drh -Z 83a3df8e5ff251b53fc0f846b015b7e8 +Z 3464c79040c125df7d1b54a6ef5c52ad diff --git a/manifest.uuid b/manifest.uuid index 84bd71ab4a..5369a8751e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -53c25ebe34e6776a12260078852973b1d581d20f \ No newline at end of file +409535e6dfc307f26ea3d9f51be51c439b6d7b22 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2a34fb8e9d..5c4c373b80 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3503,14 +3503,14 @@ int sqlite3_prepare16_v2( ** string containing the SQL text of prepared statement P with ** [bound parameters] expanded. ** -** For example, if a prepared statement is created using the SQL +** ^(For example, if a prepared statement is created using the SQL ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 ** and parameter :xyz is unbound, then sqlite3_sql() will return ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() -** will return "SELECT 2345,NULL". +** will return "SELECT 2345,NULL".)^ ** -** The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a -** bound parameter expansion. If SQLite is built with the +** ^The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a +** bound parameter expansion. ^If SQLite is built with the ** [SQLITE_OMIT_TRACE] compile-time option then the sqlite3_expanded_sql() ** interface is non-functional and always returns NULL. ** From 9a8b9ec51c3cb0897d8a7311cf6216e9e34df480 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 Jul 2016 20:45:03 +0000 Subject: [PATCH 18/42] Be sure to hold the database connection mutex while calling sqlite3VdbeExpand() from within sqlite3_expanded_sql(). FossilOrigin-Name: 527b5ba68c0b0185958b945b197f9022951d9379 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a198d7e20b..cbb93bb180 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\srequirements\smarks\sto\sthe\ssqlite3_expanded_sql()\sdocumentation. -D 2016-07-22T20:20:53.758 +C Be\ssure\sto\shold\sthe\sdatabase\sconnection\smutex\swhile\scalling\ssqlite3VdbeExpand()\nfrom\swithin\ssqlite3_expanded_sql(). +D 2016-07-22T20:45:03.857 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -453,7 +453,7 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 23df1e66e420a0e591bc877eace43be1f16f0f28 +F src/vdbeaux.c 7a09b945ebc4893e3a15bd68c4634d4aff34ebd5 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 53c25ebe34e6776a12260078852973b1d581d20f -R d9d54b2d05c15d2014a2ffa7a3228fb1 +P 409535e6dfc307f26ea3d9f51be51c439b6d7b22 +R 2b4fbb49220ef1cdb35ff0cc787c0937 U drh -Z 3464c79040c125df7d1b54a6ef5c52ad +Z 1a401e59c5d6714d520ae3898a7c3c7e diff --git a/manifest.uuid b/manifest.uuid index 5369a8751e..8a31fb63f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -409535e6dfc307f26ea3d9f51be51c439b6d7b22 \ No newline at end of file +527b5ba68c0b0185958b945b197f9022951d9379 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index ec702b3c8c..6eeb325b1e 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -86,8 +86,12 @@ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ return 0; #else Vdbe *p = (Vdbe *)pStmt; + char *z; if( p==0 || p->zSql==0 ) return 0; - return sqlite3VdbeExpandSql(p, p->zSql); + sqlite3_mutex_enter(p->db->mutex); + z = sqlite3VdbeExpandSql(p, p->zSql); + sqlite3_mutex_leave(p->db->mutex); + return z; #endif } From 80f2b33a12214ca194babd468f2618ed805d2f95 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 22 Jul 2016 21:26:56 +0000 Subject: [PATCH 19/42] Fix harmless compiler warnings seen with MSVC. FossilOrigin-Name: 8bb6e6fcedf7d0ae796b8848593106c921ebf21a --- ext/misc/carray.c | 2 +- ext/misc/csv.c | 13 +++++++------ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ext/misc/carray.c b/ext/misc/carray.c index 6fdbecf575..3c2398ec45 100644 --- a/ext/misc/carray.c +++ b/ext/misc/carray.c @@ -247,7 +247,7 @@ static int carrayFilter( "unknown datatype: %Q", zType); return SQLITE_ERROR; }else{ - pCur->eType = i; + pCur->eType = (unsigned char)i; } } }else{ diff --git a/ext/misc/csv.c b/ext/misc/csv.c index a055a8df13..2a9463bd6e 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -232,7 +232,7 @@ static char *csv_read_one_field(CsvReader *p){ || (c==EOF && pc=='"') ){ do{ p->n--; }while( p->z[p->n]!='"' ); - p->cTerm = c; + p->cTerm = (char)c; break; } if( pc=='"' && c!='\r' ){ @@ -242,7 +242,7 @@ static char *csv_read_one_field(CsvReader *p){ if( c==EOF ){ csv_errmsg(p, "line %d: unterminated %c-quoted field\n", startLine, '"'); - p->cTerm = c; + p->cTerm = (char)c; break; } } @@ -259,7 +259,7 @@ static char *csv_read_one_field(CsvReader *p){ p->nLine++; if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--; } - p->cTerm = c; + p->cTerm = (char)c; } if( p->z ) p->z[p->n] = 0; return p->z; @@ -338,9 +338,9 @@ static void csv_trim_whitespace(char *z){ /* Dequote the string */ static void csv_dequote(char *z){ - int i, j; + int j; char cQuote = z[0]; - size_t n; + size_t i, n; if( cQuote!='\'' && cQuote!='"' ) return; n = strlen(z); @@ -725,7 +725,8 @@ static int csvtabFilter( pCur->iRowid = 0; if( pCur->rdr.in==0 ){ assert( pCur->rdr.zIn==pTab->zData ); - assert( pTab->iStart<=pCur->rdr.nIn ); + assert( pTab->iStart>=0 ); + assert( (size_t)pTab->iStart<=pCur->rdr.nIn ); pCur->rdr.iIn = pTab->iStart; }else{ fseek(pCur->rdr.in, pTab->iStart, SEEK_SET); diff --git a/manifest b/manifest index 15a467b95d..718e7796c0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\supper\scase\smodule\snames\sin\sthe\s"sqldiff\s--vtab"\scommand. -D 2016-07-22T10:09:26.990 +C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. +D 2016-07-22T21:26:56.199 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -204,10 +204,10 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/carray.c 214c9e9d909ceaae3b2f5f917cc2204deca85cc6 +F ext/misc/carray.c b0478416ab01368e40c4e9231c4e15c00a6c1c4c F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c f51b0566ea15e24cce871037e30a4db99ea6cf77 +F ext/misc/csv.c 816a3715356e4210dae2d242057745e937050896 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bf98a2de7ed41a8acca89d7369b353f12182cfb4 -R 21feff5d71e42b08ceb5cf54c6ef8c4f -U dan -Z 0597e24d7597ffc51d59928722cf37fa +P 87e25fc472604b3978811be53991104c665a95e7 +R 0235f59a00c54f640f61c277b29bcc69 +U mistachkin +Z 015e7c1f4d0390bbef94656d13220477 diff --git a/manifest.uuid b/manifest.uuid index a48b14490b..efdad925f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87e25fc472604b3978811be53991104c665a95e7 \ No newline at end of file +8bb6e6fcedf7d0ae796b8848593106c921ebf21a \ No newline at end of file From a4c07346b79cff61782e9bb6eb8812aea156f8ce Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 22 Jul 2016 21:35:38 +0000 Subject: [PATCH 20/42] Revise a warning fix from the previous check-in to improve clarity. Also, fix an incorrect test prefix (typo). FossilOrigin-Name: f50a3fd6606c14b82c9b938bfca284d54b6c650f --- ext/misc/carray.c | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- test/csv01.test | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/misc/carray.c b/ext/misc/carray.c index 3c2398ec45..025eb5db2c 100644 --- a/ext/misc/carray.c +++ b/ext/misc/carray.c @@ -237,7 +237,7 @@ static int carrayFilter( if( idxNum<3 ){ pCur->eType = CARRAY_INT32; }else{ - int i; + unsigned char i; const char *zType = (const char*)sqlite3_value_text(argv[2]); for(i=0; ieType = (unsigned char)i; + pCur->eType = i; } } }else{ diff --git a/manifest b/manifest index 718e7796c0..1a7b6fcb75 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. -D 2016-07-22T21:26:56.199 +C Revise\sa\swarning\sfix\sfrom\sthe\sprevious\scheck-in\sto\simprove\sclarity.\s\sAlso,\sfix\san\sincorrect\stest\sprefix\s(typo). +D 2016-07-22T21:35:38.430 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -204,7 +204,7 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/carray.c b0478416ab01368e40c4e9231c4e15c00a6c1c4c +F ext/misc/carray.c 40c27641010a4dc67e3690bdb7c9d36ca58b3c2d F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 816a3715356e4210dae2d242057745e937050896 @@ -616,7 +616,7 @@ F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c -F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f +F test/csv01.test e0ba3caaa57e4c667a0b45977689fb8082f14348 F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87e25fc472604b3978811be53991104c665a95e7 -R 0235f59a00c54f640f61c277b29bcc69 +P 8bb6e6fcedf7d0ae796b8848593106c921ebf21a +R 5b6ff2c3db1a5eba26e3cea3eedea20b U mistachkin -Z 015e7c1f4d0390bbef94656d13220477 +Z 074e5835acae805d82010c066036788b diff --git a/manifest.uuid b/manifest.uuid index efdad925f7..2171fc8fa7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bb6e6fcedf7d0ae796b8848593106c921ebf21a \ No newline at end of file +f50a3fd6606c14b82c9b938bfca284d54b6c650f \ No newline at end of file diff --git a/test/csv01.test b/test/csv01.test index a6fff81c3f..8151c47714 100644 --- a/test/csv01.test +++ b/test/csv01.test @@ -13,7 +13,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -set testprefix closure01 +set testprefix csv01 ifcapable !vtab||!cte { finish_test ; return } From cf1e395acb41d886d72aa77d7e49f08ed1d36317 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 00:43:14 +0000 Subject: [PATCH 21/42] Fix sqlite3VdbeExpandSql() so that it handles OOMs by always returning NULL. FossilOrigin-Name: 5a027fe4127d498e0dc0d9439131c6a29085cf0a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 14 ++++++++------ src/vdbetrace.c | 13 ++++++++++--- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index cbb93bb180..a844004956 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Be\ssure\sto\shold\sthe\sdatabase\sconnection\smutex\swhile\scalling\ssqlite3VdbeExpand()\nfrom\swithin\ssqlite3_expanded_sql(). -D 2016-07-22T20:45:03.857 +C Fix\ssqlite3VdbeExpandSql()\sso\sthat\sit\shandles\sOOMs\sby\salways\sreturning\sNULL. +D 2016-07-23T00:43:14.540 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -453,11 +453,11 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 7a09b945ebc4893e3a15bd68c4634d4aff34ebd5 +F src/vdbeaux.c 8557563e9b0fed6ba05b0ce42e3b3049d93f26fa F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c d0371769fe66fe4eb85bdcacf82b6f2af50feb9b +F src/vdbetrace.c bea16fb07070b33f6efdece3169c3c4b423894a8 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 409535e6dfc307f26ea3d9f51be51c439b6d7b22 -R 2b4fbb49220ef1cdb35ff0cc787c0937 +P 527b5ba68c0b0185958b945b197f9022951d9379 +R e119b9614fe99fd5a44e65f51db3182b U drh -Z 1a401e59c5d6714d520ae3898a7c3c7e +Z 16700eecfd0a8ed6af44720c8587b7e0 diff --git a/manifest.uuid b/manifest.uuid index 8a31fb63f9..7d4379e1ee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -527b5ba68c0b0185958b945b197f9022951d9379 \ No newline at end of file +5a027fe4127d498e0dc0d9439131c6a29085cf0a \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 6eeb325b1e..b04a1d23f2 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -85,12 +85,14 @@ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ #ifdef SQLITE_OMIT_TRACE return 0; #else - Vdbe *p = (Vdbe *)pStmt; - char *z; - if( p==0 || p->zSql==0 ) return 0; - sqlite3_mutex_enter(p->db->mutex); - z = sqlite3VdbeExpandSql(p, p->zSql); - sqlite3_mutex_leave(p->db->mutex); + char *z = 0; + const char *zSql = sqlite3_sql(pStmt); + if( zSql ){ + Vdbe *p = (Vdbe *)pStmt; + sqlite3_mutex_enter(p->db->mutex); + z = sqlite3VdbeExpandSql(p, zSql); + sqlite3_mutex_leave(p->db->mutex); + } return z; #endif } diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 7311bc35c6..8a1c23bc35 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -81,6 +81,9 @@ char *sqlite3VdbeExpandSql( int i; /* Loop counter */ Mem *pVar; /* Value of a host parameter */ StrAccum out; /* Accumulate the output here */ +#ifndef SQLITE_OMIT_UTF16 + Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */ +#endif char zBase[100]; /* Initial working space */ db = p->db; @@ -135,12 +138,16 @@ char *sqlite3VdbeExpandSql( int nOut; /* Number of bytes of the string text to include in output */ #ifndef SQLITE_OMIT_UTF16 u8 enc = ENC(db); - Mem utf8; if( enc!=SQLITE_UTF8 ){ memset(&utf8, 0, sizeof(utf8)); utf8.db = db; - sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC); - sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8); + if( SQLITE_NOMEM== sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) + || SQLITE_NOMEM== sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) + ){ + sqlite3StrAccumReset(&out); + sqlite3VdbeMemRelease(&utf8); + return 0; + } pVar = &utf8; } #endif From 557341e8fa72f03a35768a34c33cfb18645f95cd Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 02:07:26 +0000 Subject: [PATCH 22/42] Add requirements marks to the sqlite3_trace_v2() interface documentation. FossilOrigin-Name: ebd388e94da4a2b29c2a546f832d359619803ec5 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 46 +++++++++++++++++++++++----------------------- src/vdbeapi.c | 33 +++++++++++++++++++++++++++++++++ src/vdbeaux.c | 33 --------------------------------- src/vdbetrace.c | 4 ++-- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/manifest b/manifest index a844004956..631dae73d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssqlite3VdbeExpandSql()\sso\sthat\sit\shandles\sOOMs\sby\salways\sreturning\sNULL. -D 2016-07-23T00:43:14.540 +C Add\srequirements\smarks\sto\sthe\ssqlite3_trace_v2()\sinterface\sdocumentation. +D 2016-07-23T02:07:26.475 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in f1e866f8b789391ba7f77f71164e51b7f8b4b111 +F src/sqlite.h.in 35e253c3b408157a9edc3306d4f1b770af73a398 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -452,12 +452,12 @@ F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d -F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 8557563e9b0fed6ba05b0ce42e3b3049d93f26fa +F src/vdbeapi.c c3f6715a99995c11748ecad91d25e93fd9fc390b +F src/vdbeaux.c a32d79aeaa88dc2b97c261172d952d395254a055 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c bea16fb07070b33f6efdece3169c3c4b423894a8 +F src/vdbetrace.c 05d1f843117c4fdcc1f8b1e950011bbeef0cef84 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 527b5ba68c0b0185958b945b197f9022951d9379 -R e119b9614fe99fd5a44e65f51db3182b +P 5a027fe4127d498e0dc0d9439131c6a29085cf0a +R 424a44eb6e790a98bbdc6c3248de6bc5 U drh -Z 16700eecfd0a8ed6af44720c8587b7e0 +Z 5a7cc904a805d16230629029b0dc335a diff --git a/manifest.uuid b/manifest.uuid index 7d4379e1ee..4db50f7e69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a027fe4127d498e0dc0d9439131c6a29085cf0a \ No newline at end of file +ebd388e94da4a2b29c2a546f832d359619803ec5 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 5c4c373b80..1308a1122d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2795,45 +2795,45 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** These constants identify classes of events that can be monitored ** using the [sqlite3_trace_v2()] tracing logic. The third argument ** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of -** the following constants. The first argument to the trace callback +** the following constants. ^The first argument to the trace callback ** is one of the following constants. ** ** New tracing constants may be added in future releases. ** -** A trace callback has four arguments: xCallback(T,C,P,X). -** The T argument is one of the integer type codes above. -** The C argument is a copy of the context pointer passed in as the +** ^A trace callback has four arguments: xCallback(T,C,P,X). +** ^The T argument is one of the integer type codes above. +** ^The C argument is a copy of the context pointer passed in as the ** fourth argument to [sqlite3_trace_v2()]. ** The P and X arguments are pointers whose meanings depend on T. ** **
** [[SQLITE_TRACE_STMT]]
SQLITE_TRACE_STMT
-**
An SQLITE_TRACE_STMT callback is invoked when a prepared statement +**
^An SQLITE_TRACE_STMT callback is invoked when a prepared statement ** first begins running and possibly at other times during the ** execution of the prepared statement, such as at the start of each -** trigger subprogram. The P argument is a pointer to the -** [prepared statement]. The X argument is a pointer to a string which +** trigger subprogram. ^The P argument is a pointer to the +** [prepared statement]. ^The X argument is a pointer to a string which ** is the expanded SQL text of the prepared statement or a comment that ** indicates the invocation of a trigger. ** ** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
-**
An SQLITE_TRACE_PROFILE callback provides approximately the same +**
^An SQLITE_TRACE_PROFILE callback provides approximately the same ** information as is provided by the [sqlite3_profile()] callback. -** The P argument is a pointer to the [prepared statement] and the -** X argument points to a 64-bit integer which is the estimated of +** ^The P argument is a pointer to the [prepared statement] and the +** ^X argument points to a 64-bit integer which is the estimated of ** the number of nanosecond that the prepared statement took to run. -** The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. +** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. ** ** [[SQLITE_TRACE_ROW]]
SQLITE_TRACE_ROW
-**
An SQLITE_TRACE_ROW callback is invoked whenever a prepared +**
^An SQLITE_TRACE_ROW callback is invoked whenever a prepared ** statement generates a single row of result. -** The P argument is a pointer to the [prepared statement] and the +** ^The P argument is a pointer to the [prepared statement] and the ** X argument is unused. ** ** [[SQLITE_TRACE_CLOSE]]
SQLITE_TRACE_CLOSE
-**
An SQLITE_TRACE_CLOSE callback is invoked when a database +**
^An SQLITE_TRACE_CLOSE callback is invoked when a database ** connection closes. -** The P argument is a pointer to the [database connection] object +** ^The P argument is a pointer to the [database connection] object ** and the X argument is unused. **
*/ @@ -2846,25 +2846,25 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** CAPI3REF: SQL Trace Hook ** METHOD: sqlite3 ** -** The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback +** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback ** function X against [database connection] D, using property mask M -** and context pointer P. If the X callback is +** and context pointer P. ^If the X callback is ** NULL or if the M mask is zero, then tracing is disabled. The ** M argument must be one or more of the [SQLITE_TRACE] ** constants. ** -** Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides +** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). ** -** The X callback is invoked whenever any of the events identified by -** mask M occur. The integer return value from the callback is currently +** ^The X callback is invoked whenever any of the events identified by +** mask M occur. ^The integer return value from the callback is currently ** ignored, though this may change in future releases. Callback ** implementations should return zero to ensure future compatibility. ** -** A trace callback is invoked with four arguments: callback(T,C,P,X). -** The T argument is one of the [SQLITE_TRACE] +** ^A trace callback is invoked with four arguments: callback(T,C,P,X). +** ^The T argument is one of the [SQLITE_TRACE] ** constants to indicate why the callback was invoked. -** The C argument is a copy of the context pointer. +** ^The C argument is a copy of the context pointer. ** The P and X arguments are pointers whose meanings depend on T. ** ** The sqlite3_trace_v2() interface is intended to replace the legacy diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 883e5c95bf..b17c0e0a40 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1612,6 +1612,39 @@ int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){ return (int)v; } +/* +** Return the SQL associated with a prepared statement +*/ +const char *sqlite3_sql(sqlite3_stmt *pStmt){ + Vdbe *p = (Vdbe *)pStmt; + return p ? p->zSql : 0; +} + +/* +** Return the SQL associated with a prepared statement with +** bound parameters expanded. Space to hold the returned string is +** obtained from sqlite3_malloc(). The caller is responsible for +** freeing the returned string by passing it to sqlite3_free(). +** +** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of +** expanded bound parameters. +*/ +char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ +#ifdef SQLITE_OMIT_TRACE + return 0; +#else + char *z = 0; + const char *zSql = sqlite3_sql(pStmt); + if( zSql ){ + Vdbe *p = (Vdbe *)pStmt; + sqlite3_mutex_enter(p->db->mutex); + z = sqlite3VdbeExpandSql(p, zSql); + sqlite3_mutex_leave(p->db->mutex); + } + return z; +#endif +} + #ifdef SQLITE_ENABLE_PREUPDATE_HOOK /* ** Allocate and populate an UnpackedRecord structure based on the serialized diff --git a/src/vdbeaux.c b/src/vdbeaux.c index b04a1d23f2..992fa4db9e 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -64,39 +64,6 @@ void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){ p->isPrepareV2 = (u8)isPrepareV2; } -/* -** Return the SQL associated with a prepared statement -*/ -const char *sqlite3_sql(sqlite3_stmt *pStmt){ - Vdbe *p = (Vdbe *)pStmt; - return p ? p->zSql : 0; -} - -/* -** Return the SQL associated with a prepared statement with -** bound parameters expanded. Space to hold the returned string is -** obtained from sqlite3_malloc(). The caller is responsible for -** freeing the returned string by passing it to sqlite3_free(). -** -** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of -** expanded bound parameters. -*/ -char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ -#ifdef SQLITE_OMIT_TRACE - return 0; -#else - char *z = 0; - const char *zSql = sqlite3_sql(pStmt); - if( zSql ){ - Vdbe *p = (Vdbe *)pStmt; - sqlite3_mutex_enter(p->db->mutex); - z = sqlite3VdbeExpandSql(p, zSql); - sqlite3_mutex_leave(p->db->mutex); - } - return z; -#endif -} - /* ** Swap all content between two VDBE structures. */ diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 8a1c23bc35..d30cf3acd5 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -141,8 +141,8 @@ char *sqlite3VdbeExpandSql( if( enc!=SQLITE_UTF8 ){ memset(&utf8, 0, sizeof(utf8)); utf8.db = db; - if( SQLITE_NOMEM== sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) - || SQLITE_NOMEM== sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) + if( SQLITE_NOMEM==sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) + || SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){ sqlite3StrAccumReset(&out); sqlite3VdbeMemRelease(&utf8); From 8afffe7244c9e66c1667e92da35bb258b59ee170 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 04:58:57 +0000 Subject: [PATCH 23/42] Improvements to sqlite3_trace_v2() documentation. Fix the sqlite3VdbeExpandSql() routine to respond better to OOM conditions. FossilOrigin-Name: 0400f642d542e62bb428e0bf263964c65691368e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 17 ++++++++++------- src/vdbetrace.c | 11 +++++------ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 631dae73d0..1bd6c3bab6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\srequirements\smarks\sto\sthe\ssqlite3_trace_v2()\sinterface\sdocumentation. -D 2016-07-23T02:07:26.475 +C Improvements\sto\ssqlite3_trace_v2()\sdocumentation.\s\sFix\sthe\nsqlite3VdbeExpandSql()\sroutine\sto\srespond\sbetter\sto\sOOM\sconditions. +D 2016-07-23T04:58:57.202 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 35e253c3b408157a9edc3306d4f1b770af73a398 +F src/sqlite.h.in 3dc7317ded4bf66facd845705f45f21d03517940 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -457,7 +457,7 @@ F src/vdbeaux.c a32d79aeaa88dc2b97c261172d952d395254a055 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c 05d1f843117c4fdcc1f8b1e950011bbeef0cef84 +F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5a027fe4127d498e0dc0d9439131c6a29085cf0a -R 424a44eb6e790a98bbdc6c3248de6bc5 +P ebd388e94da4a2b29c2a546f832d359619803ec5 +R 19a6abe5f5ce376943dab16457333fb2 U drh -Z 5a7cc904a805d16230629029b0dc335a +Z 006f9291eaaf608f3169b0980f613014 diff --git a/manifest.uuid b/manifest.uuid index 4db50f7e69..06586e70c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ebd388e94da4a2b29c2a546f832d359619803ec5 \ No newline at end of file +0400f642d542e62bb428e0bf263964c65691368e \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 1308a1122d..ed68cf0a13 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2820,7 +2820,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, **
^An SQLITE_TRACE_PROFILE callback provides approximately the same ** information as is provided by the [sqlite3_profile()] callback. ** ^The P argument is a pointer to the [prepared statement] and the -** ^X argument points to a 64-bit integer which is the estimated of +** X argument points to a 64-bit integer which is the estimated of ** the number of nanosecond that the prepared statement took to run. ** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. ** @@ -2850,8 +2850,8 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** function X against [database connection] D, using property mask M ** and context pointer P. ^If the X callback is ** NULL or if the M mask is zero, then tracing is disabled. The -** M argument must be one or more of the [SQLITE_TRACE] -** constants. +** M argument should be the bitwise OR-ed combination of +** zero or more [SQLITE_TRACE] constants. ** ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). @@ -3509,10 +3509,13 @@ int sqlite3_prepare16_v2( ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() ** will return "SELECT 2345,NULL".)^ ** -** ^The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a -** bound parameter expansion. ^If SQLite is built with the -** [SQLITE_OMIT_TRACE] compile-time option then the sqlite3_expanded_sql() -** interface is non-functional and always returns NULL. +** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory +** is available to hold the result, or if the result would exceed the +** the maximum string length determined by the [SQLITE_LIMIT_LENGTH]. +** +** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of +** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time +** option causes sqlite3_expanded_sql() to always return NULL. ** ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is ** automatically freed when the prepared statement is finalized. diff --git a/src/vdbetrace.c b/src/vdbetrace.c index d30cf3acd5..7b47363991 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -141,12 +141,10 @@ char *sqlite3VdbeExpandSql( if( enc!=SQLITE_UTF8 ){ memset(&utf8, 0, sizeof(utf8)); utf8.db = db; - if( SQLITE_NOMEM==sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) - || SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) - ){ - sqlite3StrAccumReset(&out); - sqlite3VdbeMemRelease(&utf8); - return 0; + sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC); + if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){ + out.accError = STRACCUM_NOMEM; + out.nAlloc = 0; } pVar = &utf8; } @@ -189,6 +187,7 @@ char *sqlite3VdbeExpandSql( } } } + if( out.accError ) sqlite3StrAccumReset(&out); return sqlite3StrAccumFinish(&out); } From 49dcd79e7d2d759df3fbe7446b100dbd90cd4bd6 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 14:50:26 +0000 Subject: [PATCH 24/42] Fix recently added tests so that they work in all configurations. FossilOrigin-Name: d0bcaf0cd92ae5bbea7ad68537ba89437d5c39e8 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/dbstatus.test | 1 + test/vacuummem.test | 7 ++++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index feb1cf9a6e..412a1d98e5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_expanded_sql()\sand\ssqlite3_trace_v2()\sinterfaces. -D 2016-07-23T05:22:02.142 +C Fix\srecently\sadded\stests\sso\sthat\sthey\swork\sin\sall\sconfigurations. +D 2016-07-23T14:50:26.969 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 85833ba5bc95262749d080dcd40af87072ea8d5b +F test/dbstatus.test 2bb4d576f11c0f57f5633dad373ad1a57c2a7195 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1324,7 +1324,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 -F test/vacuummem.test 09c8b72a12405649ed84564367dad729bff88760 +F test/vacuummem.test ae20cc80a4960d3507d27cf0f2f4555988ceb6df F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test 765802c7a66d37fabd5ac8e2f2dbe572b43eb9ab @@ -1507,8 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f50a3fd6606c14b82c9b938bfca284d54b6c650f 0400f642d542e62bb428e0bf263964c65691368e -R 4a3af12ad9efd4d7dc81ee4ca45f95f6 -T +closed 0400f642d542e62bb428e0bf263964c65691368e +P 99a6c51887d9d78409944c5a028d5a3ac2e066a7 +R dcbad5b66668d4f45eebea8d8e4c4fc1 U drh -Z 2820f9890a85b78d1796850ebe9bb3ba +Z b2cb07cac2703599b169fabec6f383c3 diff --git a/manifest.uuid b/manifest.uuid index 288e6dc899..77b620836b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99a6c51887d9d78409944c5a028d5a3ac2e066a7 \ No newline at end of file +d0bcaf0cd92ae5bbea7ad68537ba89437d5c39e8 \ No newline at end of file diff --git a/test/dbstatus.test b/test/dbstatus.test index 00c5deabd5..fb4cbe04ba 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -390,6 +390,7 @@ ifcapable shared_cache { sqlite3 db file:test.db?cache=shared do_execsql_test 4.0 { + PRAGMA auto_vacuum=NONE; CREATE TABLE t1(a, b, c); INSERT INTO t1 VALUES(1, 2, 3); } diff --git a/test/vacuummem.test b/test/vacuummem.test index 967e28cec7..b0f5cf2038 100644 --- a/test/vacuummem.test +++ b/test/vacuummem.test @@ -17,6 +17,12 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix vacuummem +if {[permutation]=="memsubsys1"} { + finish_test + return +} + + proc memory_used {} { set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1] lindex $stat 1 @@ -51,4 +57,3 @@ do_test 1.5 { memory_used } {#/2300000/} finish_test - From 4b363a5130eeb67734da40007eeb46c48c268e9e Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 20:27:41 +0000 Subject: [PATCH 25/42] Use sqlite3_trace_v2() instead of sqlite3_trace() in the shell. FossilOrigin-Name: c8e0539b970585cbb3619461a53abb0c3b308a17 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/shell.c | 13 ++++++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 58ad849efb..882bad7357 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_quote()\sfunction\sto\sthe\sJSON1\sextension. -D 2016-07-23T19:34:53.707 +C Use\ssqlite3_trace_v2()\sinstead\sof\ssqlite3_trace()\sin\sthe\sshell. +D 2016-07-23T20:27:41.266 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -384,7 +384,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 -F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 +F src/shell.c ad6375a1cbfb13786bfc7ae28e00d822aedefd35 F src/sqlite.h.in 3dc7317ded4bf66facd845705f45f21d03517940 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 @@ -1507,8 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8817dedb75430e6c78ff527f7ded4abb35776cef 2c3714aebf5e40e3728877a235b3c1f93defa33e -R d8b644436fd0d857689e119dadae618e -T +closed 2c3714aebf5e40e3728877a235b3c1f93defa33e +P 269892abf6e59c417729669cc764d1f237e093fd +R 38c94a12899d68429eb06d66defc6359 U drh -Z e34798b2dc952c68e869c2ddf5f79301 +Z 4041e092b34c5d7817e039ca6e44ec6c diff --git a/manifest.uuid b/manifest.uuid index 49e513c3f7..771fe8bf2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -269892abf6e59c417729669cc764d1f237e093fd \ No newline at end of file +c8e0539b970585cbb3619461a53abb0c3b308a17 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 874782c5f1..4a546ccfef 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2543,13 +2543,20 @@ static FILE *output_file_open(const char *zFile){ /* ** A routine for handling output from sqlite3_trace(). */ -static void sql_trace_callback(void *pArg, const char *z){ +static int sql_trace_callback( + unsigned mType, + void *pArg, + void *pP, + void *pX +){ FILE *f = (FILE*)pArg; if( f ){ + const char *z = (const char*)pX; int i = (int)strlen(z); while( i>0 && z[i-1]==';' ){ i--; } utf8_printf(f, "%.*s;\n", i, z); } + return 0; } /* @@ -4655,9 +4662,9 @@ static int do_meta_command(char *zLine, ShellState *p){ p->traceOut = output_file_open(azArg[1]); #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) if( p->traceOut==0 ){ - sqlite3_trace(p->db, 0, 0); + sqlite3_trace_v2(p->db, 0, 0, 0); }else{ - sqlite3_trace(p->db, sql_trace_callback, p->traceOut); + sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut); } #endif }else From 087ec072ef45e9aaca031a4535cc93b4dbd530f3 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 00:05:56 +0000 Subject: [PATCH 26/42] Fix code so that the deprecated sqlite3_trace() and sqlite3_profile() interfaces are not called when SQLITE_OMIT_DEPRECATED is used. FossilOrigin-Name: 1c5baae3c545096a29a093f7d4387771f1db507c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/loadext.c | 2 +- src/main.c | 2 ++ src/tclsqlite.c | 3 ++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 882bad7357..da3ec9d304 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\ssqlite3_trace_v2()\sinstead\sof\ssqlite3_trace()\sin\sthe\sshell. -D 2016-07-23T20:27:41.266 +C Fix\scode\sso\sthat\sthe\sdeprecated\ssqlite3_trace()\sand\ssqlite3_profile()\s\ninterfaces\sare\snot\scalled\swhen\sSQLITE_OMIT_DEPRECATED\sis\sused. +D 2016-07-25T00:05:56.727 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -347,8 +347,8 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e -F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c 2d3e62a971e7f169a74448e81af9ebde95b07381 +F src/loadext.c 5dd8b5a67d32a98bb75657c2a9e48b2cedbf13a4 +F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -392,7 +392,7 @@ F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e +F src/tclsqlite.c 5c213bf5fee084390f632df2328cf0821d483799 F src/test1.c 186e3b53c402b7a73bcb4ade2b77709675c39fe3 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 269892abf6e59c417729669cc764d1f237e093fd -R 38c94a12899d68429eb06d66defc6359 +P c8e0539b970585cbb3619461a53abb0c3b308a17 +R d97169b5da173af1e8c3e0989fc5f73b U drh -Z 4041e092b34c5d7817e039ca6e44ec6c +Z 74b666fd406733750b5703b09cc23966 diff --git a/manifest.uuid b/manifest.uuid index 771fe8bf2c..5edb03d00b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c8e0539b970585cbb3619461a53abb0c3b308a17 \ No newline at end of file +1c5baae3c545096a29a093f7d4387771f1db507c \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index 718dae5777..ce1f5317c6 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -91,7 +91,7 @@ # define sqlite3_enable_shared_cache 0 #endif -#ifdef SQLITE_OMIT_TRACE +#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED) # define sqlite3_profile 0 # define sqlite3_trace 0 #endif diff --git a/src/main.c b/src/main.c index 5cd1ea7185..f31f865818 100644 --- a/src/main.c +++ b/src/main.c @@ -1845,6 +1845,7 @@ int sqlite3_trace_v2( return SQLITE_OK; } +#ifndef SQLITE_OMIT_DEPRECATED /* ** Register a profile function. The pArg from the previously registered ** profile function is returned. @@ -1873,6 +1874,7 @@ void *sqlite3_profile( sqlite3_mutex_leave(db->mutex); return pOld; } +#endif /* SQLITE_OMIT_DEPRECATED */ #endif /* SQLITE_OMIT_TRACE */ /* diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 43dfedb727..2de88f41f4 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2912,7 +2912,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ }else{ pDb->zTrace = 0; } -#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) +#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) \ + && !defined(SQLITE_OMIT_DEPRECATED) if( pDb->zTrace ){ pDb->interp = interp; sqlite3_trace(pDb->db, DbTraceHandler, pDb); From bd441f77009be56eb5c815a3accd578f03c609b7 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 02:31:48 +0000 Subject: [PATCH 27/42] Change SQLITE_TRACE_STMT to return unexpanded SQL text in the X argument. Add documentation on how and when to use sqlite3_expanded_sql(P) to compute the expanded text for legacy sqlite3_trace() compatibility. FossilOrigin-Name: 163e15229d837a5471007cffb8d41faafd081737 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 7 +++++-- src/vdbe.c | 9 ++++++--- tool/srcck1.c | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index da3ec9d304..819e488286 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scode\sso\sthat\sthe\sdeprecated\ssqlite3_trace()\sand\ssqlite3_profile()\s\ninterfaces\sare\snot\scalled\swhen\sSQLITE_OMIT_DEPRECATED\sis\sused. -D 2016-07-25T00:05:56.727 +C Change\sSQLITE_TRACE_STMT\sto\sreturn\sunexpanded\sSQL\stext\sin\sthe\sX\sargument.\nAdd\sdocumentation\son\show\sand\swhen\sto\suse\ssqlite3_expanded_sql(P)\sto\scompute\nthe\sexpanded\stext\sfor\slegacy\ssqlite3_trace()\scompatibility. +D 2016-07-25T02:31:48.358 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c ad6375a1cbfb13786bfc7ae28e00d822aedefd35 -F src/sqlite.h.in 3dc7317ded4bf66facd845705f45f21d03517940 +F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -449,7 +449,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 -F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 +F src/vdbe.c 7718d72427fd3abae6603a7a225e3eec12137d4a F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c c3f6715a99995c11748ecad91d25e93fd9fc390b @@ -1475,7 +1475,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/sqldiff.c 4478f0d30230de6adde90bdb0bfe60f68c5ab782 -F tool/srcck1.c 4c39bdfa9a92edd20233ee720df84dbeb2417602 +F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh c5a617b8c61a0926747a56c65f5671ef8ac0e148 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c8e0539b970585cbb3619461a53abb0c3b308a17 -R d97169b5da173af1e8c3e0989fc5f73b +P 1c5baae3c545096a29a093f7d4387771f1db507c +R 287171615483ae1144a14be35a6974e0 U drh -Z 74b666fd406733750b5703b09cc23966 +Z fb84b0dd7373ed024b44202f95be044f diff --git a/manifest.uuid b/manifest.uuid index 5edb03d00b..6cdf0fb62f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c5baae3c545096a29a093f7d4387771f1db507c \ No newline at end of file +163e15229d837a5471007cffb8d41faafd081737 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ed68cf0a13..e8f5d24845 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2813,8 +2813,11 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** execution of the prepared statement, such as at the start of each ** trigger subprogram. ^The P argument is a pointer to the ** [prepared statement]. ^The X argument is a pointer to a string which -** is the expanded SQL text of the prepared statement or a comment that -** indicates the invocation of a trigger. +** is the unexpanded SQL text of the prepared statement or an SQL comment +** that indicates the invocation of a trigger. ^The callback can compute +** the same text that would have been returned by the legacy [sqlite3_trace()] +** interface by using the X argument when X begins with "--" and invoking +** [sqlite3_expanded_sql(P)] otherwise. ** ** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
**
^An SQLITE_TRACE_PROFILE callback provides approximately the same diff --git a/src/vdbe.c b/src/vdbe.c index cdbd7301b8..d198d1ff8c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6785,21 +6785,24 @@ case OP_Init: { /* jump */ char *z; #ifndef SQLITE_OMIT_TRACE + /* If the P4 argument is not NULL, then it must be an SQL comment string. + ** The "--" string is broken up to prevent false-positives with srcck1.c */ + assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 ); if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 ){ - z = sqlite3VdbeExpandSql(p, zTrace); #ifndef SQLITE_OMIT_DEPRECATED if( db->mTrace & SQLITE_TRACE_LEGACY ){ void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; + z = sqlite3VdbeExpandSql(p, zTrace); x(db->pTraceArg, z); + sqlite3_free(z); }else #endif { - (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,z); + (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace); } - sqlite3_free(z); } #ifdef SQLITE_USE_FCNTL_TRACE zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); diff --git a/tool/srcck1.c b/tool/srcck1.c index e95765185f..20084ac47f 100644 --- a/tool/srcck1.c +++ b/tool/srcck1.c @@ -58,7 +58,7 @@ static char *readFile(const char *zFilename){ return z; } -/* Change the C code in the argument to see if it might have +/* Check the C code in the argument to see if it might have ** side effects. The only accurate way to know this is to do a full ** parse of the C code, which this routine does not do. This routine ** uses a simple heuristic of looking for: From 5fe63bfb93ebccf1f00b8a8e1c9d2ed82f0bd86f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 02:42:22 +0000 Subject: [PATCH 28/42] Evidence marks and code reformatting for SQLITE_TRACE_STMT operation. FossilOrigin-Name: e1e022383114525241454f63ea8b9768fb7ec657 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 819e488286..9f9642d316 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sSQLITE_TRACE_STMT\sto\sreturn\sunexpanded\sSQL\stext\sin\sthe\sX\sargument.\nAdd\sdocumentation\son\show\sand\swhen\sto\suse\ssqlite3_expanded_sql(P)\sto\scompute\nthe\sexpanded\stext\sfor\slegacy\ssqlite3_trace()\scompatibility. -D 2016-07-25T02:31:48.358 +C Evidence\smarks\sand\scode\sreformatting\sfor\sSQLITE_TRACE_STMT\soperation. +D 2016-07-25T02:42:22.338 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -449,7 +449,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 -F src/vdbe.c 7718d72427fd3abae6603a7a225e3eec12137d4a +F src/vdbe.c ea260b61e73b11a71e70b28a8e25866e2899e5da F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c c3f6715a99995c11748ecad91d25e93fd9fc390b @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c5baae3c545096a29a093f7d4387771f1db507c -R 287171615483ae1144a14be35a6974e0 +P 163e15229d837a5471007cffb8d41faafd081737 +R 54f5b446e83fdc6cfb9e4fb83bcacd6b U drh -Z fb84b0dd7373ed024b44202f95be044f +Z cd50dce290ecc3f8f1fad92c2e3b32fc diff --git a/manifest.uuid b/manifest.uuid index 6cdf0fb62f..be4af97fc7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -163e15229d837a5471007cffb8d41faafd081737 \ No newline at end of file +e1e022383114525241454f63ea8b9768fb7ec657 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index d198d1ff8c..5d21ad064c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6782,12 +6782,19 @@ case OP_MaxPgcnt: { /* out2 */ */ case OP_Init: { /* jump */ char *zTrace; - char *z; + + /* If the P4 argument is not NULL, then it must be an SQL comment string. + ** The "--" string is broken up to prevent false-positives with srcck1.c. + ** + ** This assert() provides evidence for: + ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that + ** would have been returned by the legacy sqlite3_trace() interface by + ** using the X argument when X begins with "--" and invoking + ** sqlite3_expanded_sql(P) otherwise. + */ + assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 ); #ifndef SQLITE_OMIT_TRACE - /* If the P4 argument is not NULL, then it must be an SQL comment string. - ** The "--" string is broken up to prevent false-positives with srcck1.c */ - assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 ); if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 @@ -6795,7 +6802,7 @@ case OP_Init: { /* jump */ #ifndef SQLITE_OMIT_DEPRECATED if( db->mTrace & SQLITE_TRACE_LEGACY ){ void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; - z = sqlite3VdbeExpandSql(p, zTrace); + char *z = sqlite3VdbeExpandSql(p, zTrace); x(db->pTraceArg, z); sqlite3_free(z); }else From c530b9c65bab03a581a9f898151256ecf2680649 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:27:22 +0000 Subject: [PATCH 29/42] Add --enable-memsys3 and --enable-memsys5 options to the configure script. FossilOrigin-Name: 67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 --- configure | 73 +++++++++++++++++++++++++++++++++++++++++---------- configure.ac | 24 +++++++++++++++++ manifest | 16 +++++------ manifest.uuid | 2 +- src/shell.c | 2 ++ 5 files changed, 94 insertions(+), 23 deletions(-) diff --git a/configure b/configure index f4d4c48077..ee62dcc9bd 100755 --- a/configure +++ b/configure @@ -772,6 +772,7 @@ LIBOBJS BUILD_CFLAGS USE_GCOV OPT_FEATURE_FLAGS +SQLITE_MEMSYS5 USE_AMALGAMATION TARGET_DEBUG TARGET_HAVE_EDITLINE @@ -903,6 +904,8 @@ with_readline_inc enable_debug enable_amalgamation enable_load_extension +enable_memsys3 +enable_memsys5 enable_fts3 enable_fts4 enable_fts5 @@ -1552,6 +1555,8 @@ Optional Features: separately --disable-load-extension Disable loading of external extensions + --enable-memsys3 Enable MEMSYS3 + --enable-memsys5 Enable MEMSYS5 --enable-fts3 Enable the FTS3 extension --enable-fts4 Enable the FTS4 extension --enable-fts5 Enable the FTS5 extension @@ -3925,13 +3930,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3928: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3933: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3931: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3936: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3934: output\"" >&5) + (eval echo "\"\$as_me:3939: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5137,7 +5142,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5140 "configure"' > conftest.$ac_ext + echo '#line 5145 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6662,11 +6667,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6665: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6670: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6669: \$? = $ac_status" >&5 + echo "$as_me:6674: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7001,11 +7006,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7004: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7009: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7008: \$? = $ac_status" >&5 + echo "$as_me:7013: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7106,11 +7111,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7109: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7114: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7113: \$? = $ac_status" >&5 + echo "$as_me:7118: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7161,11 +7166,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7164: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7169: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7168: \$? = $ac_status" >&5 + echo "$as_me:7173: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9541,7 +9546,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9544 "configure" +#line 9549 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9637,7 +9642,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9640 "configure" +#line 9645 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11339,6 +11344,46 @@ else OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1" fi +########## +# Do we want to support memsys3 and/or memsys5 +# +# Check whether --enable-memsys3 was given. +if test "${enable_memsys3+set}" = set; then : + enableval=$enable_memsys3; +else + enable_memsys3=yes +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 +$as_echo_n "checking whether to support MEMSYS3... " >&6; } +if test "$enable_memsys3" = "yes"; then + SQLITE_ENABLE_MEMSYS3=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + +# Check whether --enable-memsys5 was given. +if test "${enable_memsys5+set}" = set; then : + enableval=$enable_memsys5; +else + enable_memsys3=yes +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5 +$as_echo_n "checking whether to support MEMSYS5... " >&6; } +if test "$enable_memsys5" = "yes"; then + SQLITE_ENABLE_MEMSYS5=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + ######### # See whether we should enable Full Text Search extensions # Check whether --enable-fts3 was given. diff --git a/configure.ac b/configure.ac index e5727ea7f2..7ab6bf9024 100644 --- a/configure.ac +++ b/configure.ac @@ -588,6 +588,30 @@ else OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1" fi +########## +# Do we want to support memsys3 and/or memsys5 +# +AC_ARG_ENABLE(memsys3, +AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]),,enable_memsys3=yes) +AC_MSG_CHECKING([whether to support MEMSYS3]) +if test "$enable_memsys3" = "yes"; then + SQLITE_ENABLE_MEMSYS3=1 + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST(SQLITE_MEMSYS5) +AC_ARG_ENABLE(memsys5, +AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]),,enable_memsys3=yes) +AC_MSG_CHECKING([whether to support MEMSYS5]) +if test "$enable_memsys5" = "yes"; then + SQLITE_ENABLE_MEMSYS5=1 + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST(SQLITE_MEMSYS5) + ######### # See whether we should enable Full Text Search extensions AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3], diff --git a/manifest b/manifest index 9f9642d316..6391e1baa3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Evidence\smarks\sand\scode\sreformatting\sfor\sSQLITE_TRACE_STMT\soperation. -D 2016-07-25T02:42:22.338 +C Add\s--enable-memsys3\sand\s--enable-memsys5\soptions\sto\sthe\sconfigure\sscript. +D 2016-07-25T11:27:22.245 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 25cf7eb52a88846e4c1978016a9db22763c54f41 x -F configure.ac 480e1a17d5316b1751c8edcb15b8e6b8ab0a6cc3 +F configure 7f1096018e7277653bdccbc3522763950716c04e x +F configure.ac 312a1d5cee98d125c4d5af63ae244d1d4d4e61ae F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -384,7 +384,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 -F src/shell.c ad6375a1cbfb13786bfc7ae28e00d822aedefd35 +F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 163e15229d837a5471007cffb8d41faafd081737 -R 54f5b446e83fdc6cfb9e4fb83bcacd6b +P e1e022383114525241454f63ea8b9768fb7ec657 +R f029b1d7e77fec56f765d45dc22f3d18 U drh -Z cd50dce290ecc3f8f1fad92c2e3b32fc +Z 774059649b6fa0105cfafff42cfa581a diff --git a/manifest.uuid b/manifest.uuid index be4af97fc7..3b4218203e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1e022383114525241454f63ea8b9768fb7ec657 \ No newline at end of file +67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 4a546ccfef..e8d215b95a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -5324,6 +5324,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ szHeap = integerValue(zSize); if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000; sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); +#else + (void)cmdline_option_value(argc, argv, ++i); #endif }else if( strcmp(z,"-scratch")==0 ){ int n, sz; From 26197d1b62c26a5f13a720e478238af4e3b8ee1b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:32:09 +0000 Subject: [PATCH 30/42] Fix the --enable-memsysN options in configure so that they actually work. FossilOrigin-Name: 679552550e085497b98478bbe28056d99fe4aab4 --- configure | 12 ++++++------ configure.ac | 10 ++++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/configure b/configure index ee62dcc9bd..de3dfdd49d 100755 --- a/configure +++ b/configure @@ -11349,14 +11349,14 @@ fi # # Check whether --enable-memsys3 was given. if test "${enable_memsys3+set}" = set; then : - enableval=$enable_memsys3; + enableval=$enable_memsys3; enable_memsys3=yes else - enable_memsys3=yes + enable_memsys3=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 $as_echo_n "checking whether to support MEMSYS3... " >&6; } -if test "$enable_memsys3" = "yes"; then +if test "${enable_memsys3}" = "yes"; then SQLITE_ENABLE_MEMSYS3=1 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -11367,14 +11367,14 @@ fi # Check whether --enable-memsys5 was given. if test "${enable_memsys5+set}" = set; then : - enableval=$enable_memsys5; + enableval=$enable_memsys5; enable_memsys5=yes else - enable_memsys3=yes + enable_memsys5=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5 $as_echo_n "checking whether to support MEMSYS5... " >&6; } -if test "$enable_memsys5" = "yes"; then +if test "${enable_memsys5}" = "yes"; then SQLITE_ENABLE_MEMSYS5=1 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } diff --git a/configure.ac b/configure.ac index 7ab6bf9024..da8d7db09f 100644 --- a/configure.ac +++ b/configure.ac @@ -592,9 +592,10 @@ fi # Do we want to support memsys3 and/or memsys5 # AC_ARG_ENABLE(memsys3, -AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]),,enable_memsys3=yes) + AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]), + [enable_memsys3=yes],[enable_memsys3=no]) AC_MSG_CHECKING([whether to support MEMSYS3]) -if test "$enable_memsys3" = "yes"; then +if test "${enable_memsys3}" = "yes"; then SQLITE_ENABLE_MEMSYS3=1 AC_MSG_RESULT([yes]) else @@ -602,9 +603,10 @@ else fi AC_SUBST(SQLITE_MEMSYS5) AC_ARG_ENABLE(memsys5, -AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]),,enable_memsys3=yes) + AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]), + [enable_memsys5=yes],[enable_memsys5=no]) AC_MSG_CHECKING([whether to support MEMSYS5]) -if test "$enable_memsys5" = "yes"; then +if test "${enable_memsys5}" = "yes"; then SQLITE_ENABLE_MEMSYS5=1 AC_MSG_RESULT([yes]) else diff --git a/manifest b/manifest index 6391e1baa3..2f9c340bb9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s--enable-memsys3\sand\s--enable-memsys5\soptions\sto\sthe\sconfigure\sscript. -D 2016-07-25T11:27:22.245 +C Fix\sthe\s--enable-memsysN\soptions\sin\sconfigure\sso\sthat\sthey\sactually\swork. +D 2016-07-25T11:32:09.826 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 7f1096018e7277653bdccbc3522763950716c04e x -F configure.ac 312a1d5cee98d125c4d5af63ae244d1d4d4e61ae +F configure 71e6c9bb642ef53357cb8dbc858fc84998f3bc6d x +F configure.ac b67f6fc9f3e22edabd4be3911289400423e5ffa9 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e1e022383114525241454f63ea8b9768fb7ec657 -R f029b1d7e77fec56f765d45dc22f3d18 +P 67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 +R bb2ee4817e32d59609fbb5b8d40bbd12 U drh -Z 774059649b6fa0105cfafff42cfa581a +Z dcc29f2a3f4c1199964573b0937d7a95 diff --git a/manifest.uuid b/manifest.uuid index 3b4218203e..faaef17b8e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 \ No newline at end of file +679552550e085497b98478bbe28056d99fe4aab4 \ No newline at end of file From 6fe4c184fb593a593d690f34cb0e1591ac5715a2 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:39:24 +0000 Subject: [PATCH 31/42] Another attempt at getting --enable-memsysN working. FossilOrigin-Name: 5f40e6ad599eea59a5adc3a11d6f7998872736b4 --- configure | 35 ++++++++++++++++------------------- configure.ac | 6 ++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/configure b/configure index de3dfdd49d..85d56a1ede 100755 --- a/configure +++ b/configure @@ -772,7 +772,6 @@ LIBOBJS BUILD_CFLAGS USE_GCOV OPT_FEATURE_FLAGS -SQLITE_MEMSYS5 USE_AMALGAMATION TARGET_DEBUG TARGET_HAVE_EDITLINE @@ -3930,13 +3929,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3933: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3932: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3936: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3935: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3939: output\"" >&5) + (eval echo "\"\$as_me:3938: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5142,7 +5141,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5145 "configure"' > conftest.$ac_ext + echo '#line 5144 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6667,11 +6666,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6670: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6669: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6674: \$? = $ac_status" >&5 + echo "$as_me:6673: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7006,11 +7005,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7009: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7008: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7013: \$? = $ac_status" >&5 + echo "$as_me:7012: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7111,11 +7110,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7114: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7113: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7118: \$? = $ac_status" >&5 + echo "$as_me:7117: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7166,11 +7165,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7169: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7168: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7173: \$? = $ac_status" >&5 + echo "$as_me:7172: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9546,7 +9545,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9549 "configure" +#line 9548 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9642,7 +9641,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9645 "configure" +#line 9644 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11357,14 +11356,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 $as_echo_n "checking whether to support MEMSYS3... " >&6; } if test "${enable_memsys3}" = "yes"; then - SQLITE_ENABLE_MEMSYS3=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - # Check whether --enable-memsys5 was given. if test "${enable_memsys5+set}" = set; then : enableval=$enable_memsys5; enable_memsys5=yes @@ -11375,7 +11373,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5 $as_echo_n "checking whether to support MEMSYS5... " >&6; } if test "${enable_memsys5}" = "yes"; then - SQLITE_ENABLE_MEMSYS5=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS5" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else @@ -11383,7 +11381,6 @@ else $as_echo "no" >&6; } fi - ######### # See whether we should enable Full Text Search extensions # Check whether --enable-fts3 was given. diff --git a/configure.ac b/configure.ac index da8d7db09f..07dd3cb88a 100644 --- a/configure.ac +++ b/configure.ac @@ -596,23 +596,21 @@ AC_ARG_ENABLE(memsys3, [enable_memsys3=yes],[enable_memsys3=no]) AC_MSG_CHECKING([whether to support MEMSYS3]) if test "${enable_memsys3}" = "yes"; then - SQLITE_ENABLE_MEMSYS3=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi -AC_SUBST(SQLITE_MEMSYS5) AC_ARG_ENABLE(memsys5, AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]), [enable_memsys5=yes],[enable_memsys5=no]) AC_MSG_CHECKING([whether to support MEMSYS5]) if test "${enable_memsys5}" = "yes"; then - SQLITE_ENABLE_MEMSYS5=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS5" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi -AC_SUBST(SQLITE_MEMSYS5) ######### # See whether we should enable Full Text Search extensions diff --git a/manifest b/manifest index 2f9c340bb9..8310f7e4f2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s--enable-memsysN\soptions\sin\sconfigure\sso\sthat\sthey\sactually\swork. -D 2016-07-25T11:32:09.826 +C Another\sattempt\sat\sgetting\s--enable-memsysN\sworking. +D 2016-07-25T11:39:24.067 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 71e6c9bb642ef53357cb8dbc858fc84998f3bc6d x -F configure.ac b67f6fc9f3e22edabd4be3911289400423e5ffa9 +F configure f62e6614b26418ce81392b2c28b2a6cf268f1d5d x +F configure.ac 83c4e53031a3582d0b9200dcb3700189a24f1b1c F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 -R bb2ee4817e32d59609fbb5b8d40bbd12 +P 679552550e085497b98478bbe28056d99fe4aab4 +R 5c303973b5bb214411149d73b1469581 U drh -Z dcc29f2a3f4c1199964573b0937d7a95 +Z 6145af1bb509746e3a2a7850c862eafe diff --git a/manifest.uuid b/manifest.uuid index faaef17b8e..8d55876e78 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -679552550e085497b98478bbe28056d99fe4aab4 \ No newline at end of file +5f40e6ad599eea59a5adc3a11d6f7998872736b4 \ No newline at end of file From 5d513ba08ca3b60dceb0b1223acf42ef0d443c1e Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:57:21 +0000 Subject: [PATCH 32/42] If both MEMSYS3 and MEMSYS5 are enabled, than automatically disable MEMSYS3. FossilOrigin-Name: ccc22e14dc5d910d632807f49484be54dc2fde83 --- configure | 38 +++++++++++++++++++------------------- configure.ac | 20 ++++++++++---------- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqliteInt.h | 10 +++++++--- test/releasetest.tcl | 1 - 6 files changed, 46 insertions(+), 43 deletions(-) diff --git a/configure b/configure index 85d56a1ede..fbcf7309b1 100755 --- a/configure +++ b/configure @@ -903,8 +903,8 @@ with_readline_inc enable_debug enable_amalgamation enable_load_extension -enable_memsys3 enable_memsys5 +enable_memsys3 enable_fts3 enable_fts4 enable_fts5 @@ -1554,8 +1554,8 @@ Optional Features: separately --disable-load-extension Disable loading of external extensions - --enable-memsys3 Enable MEMSYS3 --enable-memsys5 Enable MEMSYS5 + --enable-memsys3 Enable MEMSYS3 --enable-fts3 Enable the FTS3 extension --enable-fts4 Enable the FTS4 extension --enable-fts5 Enable the FTS5 extension @@ -11346,23 +11346,6 @@ fi ########## # Do we want to support memsys3 and/or memsys5 # -# Check whether --enable-memsys3 was given. -if test "${enable_memsys3+set}" = set; then : - enableval=$enable_memsys3; enable_memsys3=yes -else - enable_memsys3=no -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 -$as_echo_n "checking whether to support MEMSYS3... " >&6; } -if test "${enable_memsys3}" = "yes"; then - OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi # Check whether --enable-memsys5 was given. if test "${enable_memsys5+set}" = set; then : enableval=$enable_memsys5; enable_memsys5=yes @@ -11380,6 +11363,23 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +# Check whether --enable-memsys3 was given. +if test "${enable_memsys3+set}" = set; then : + enableval=$enable_memsys3; enable_memsys3=yes +else + enable_memsys3=no +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 +$as_echo_n "checking whether to support MEMSYS3... " >&6; } +if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi ######### # See whether we should enable Full Text Search extensions diff --git a/configure.ac b/configure.ac index 07dd3cb88a..c9e3af9220 100644 --- a/configure.ac +++ b/configure.ac @@ -591,16 +591,6 @@ fi ########## # Do we want to support memsys3 and/or memsys5 # -AC_ARG_ENABLE(memsys3, - AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]), - [enable_memsys3=yes],[enable_memsys3=no]) -AC_MSG_CHECKING([whether to support MEMSYS3]) -if test "${enable_memsys3}" = "yes"; then - OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi AC_ARG_ENABLE(memsys5, AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]), [enable_memsys5=yes],[enable_memsys5=no]) @@ -611,6 +601,16 @@ if test "${enable_memsys5}" = "yes"; then else AC_MSG_RESULT([no]) fi +AC_ARG_ENABLE(memsys3, + AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]), + [enable_memsys3=yes],[enable_memsys3=no]) +AC_MSG_CHECKING([whether to support MEMSYS3]) +if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi ######### # See whether we should enable Full Text Search extensions diff --git a/manifest b/manifest index 8310f7e4f2..6a45ebc22e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\sattempt\sat\sgetting\s--enable-memsysN\sworking. -D 2016-07-25T11:39:24.067 +C If\sboth\sMEMSYS3\sand\sMEMSYS5\sare\senabled,\sthan\sautomatically\sdisable\sMEMSYS3. +D 2016-07-25T11:57:21.222 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure f62e6614b26418ce81392b2c28b2a6cf268f1d5d x -F configure.ac 83c4e53031a3582d0b9200dcb3700189a24f1b1c +F configure 35ce04a15ca046262bf9baaa2ced9337708cc653 x +F configure.ac b5d3df43161374f8dffd2e5f4b88fbb51685b975 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -388,7 +388,7 @@ F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 -F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 +F src/sqliteInt.h 49081ceab08eda9943d555aee57392c5b35d1c60 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1009,7 +1009,7 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/regexp2.test aa7ffcc21350007a78361b82bcf3b74d12227144 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 7d80014d0245b3f9d02d393d420bf03ca155aec0 +F test/releasetest.tcl 3a66c7b8fbe55bcd97c907217c3d812d1d3c6b93 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 679552550e085497b98478bbe28056d99fe4aab4 -R 5c303973b5bb214411149d73b1469581 +P 5f40e6ad599eea59a5adc3a11d6f7998872736b4 +R b01daae186a7f9a051c9362d4aae0591 U drh -Z 6145af1bb509746e3a2a7850c862eafe +Z d2602db348bfa53fd2c4a084ddf1dc40 diff --git a/manifest.uuid b/manifest.uuid index 8d55876e78..9bc4c35374 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f40e6ad599eea59a5adc3a11d6f7998872736b4 \ No newline at end of file +ccc22e14dc5d910d632807f49484be54dc2fde83 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0be4947513..879e6703ca 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3440,11 +3440,15 @@ int sqlite3HeapNearlyFull(void); # define sqlite3StackFree(D,P) sqlite3DbFree(D,P) #endif -#ifdef SQLITE_ENABLE_MEMSYS3 -const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); -#endif +/* Do not allow both MEMSYS5 and MEMSYS3 to be defined together. If they +** are, disable MEMSYS3 +*/ #ifdef SQLITE_ENABLE_MEMSYS5 const sqlite3_mem_methods *sqlite3MemGetMemsys5(void); +#undef SQLITE_ENABLE_MEMSYS3 +#endif +#ifdef SQLITE_ENABLE_MEMSYS3 +const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); #endif diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 2961fc385d..e13a3d7340 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -120,7 +120,6 @@ array set ::Configs [strip_comments { -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_MEMSYS5=1 - -DSQLITE_ENABLE_MEMSYS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_HIDDEN_COLUMNS From 26fe413be6d02028d56ce8e4970ab3655af2132c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 12:01:18 +0000 Subject: [PATCH 33/42] Update the vacuummem.test script so that it works on mac as well as on linux. FossilOrigin-Name: ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vacuummem.test | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6a45ebc22e..9cd5c96943 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sboth\sMEMSYS3\sand\sMEMSYS5\sare\senabled,\sthan\sautomatically\sdisable\sMEMSYS3. -D 2016-07-25T11:57:21.222 +C Update\sthe\svacuummem.test\sscript\sso\sthat\sit\sworks\son\smac\sas\swell\sas\son\slinux. +D 2016-07-25T12:01:18.862 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1324,7 +1324,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 -F test/vacuummem.test ae20cc80a4960d3507d27cf0f2f4555988ceb6df +F test/vacuummem.test e53a3fdca4612a99c515e1afe7934728a2383764 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test 765802c7a66d37fabd5ac8e2f2dbe572b43eb9ab @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5f40e6ad599eea59a5adc3a11d6f7998872736b4 -R b01daae186a7f9a051c9362d4aae0591 +P ccc22e14dc5d910d632807f49484be54dc2fde83 +R f8760ea1979a3d1e72e54c3ea906ea99 U drh -Z d2602db348bfa53fd2c4a084ddf1dc40 +Z 5b9cf50a9e82d7593d62c569e8fac940 diff --git a/manifest.uuid b/manifest.uuid index 9bc4c35374..9f906f5e5e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ccc22e14dc5d910d632807f49484be54dc2fde83 \ No newline at end of file +ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e \ No newline at end of file diff --git a/test/vacuummem.test b/test/vacuummem.test index b0f5cf2038..b214c83b3d 100644 --- a/test/vacuummem.test +++ b/test/vacuummem.test @@ -41,18 +41,19 @@ do_execsql_test 1.0 { CREATE INDEX t1b ON t1(b); CREATE INDEX t1c ON t1(c); } +set ans "#/[memory_used]/" -do_test 1.1 { memory_used } {#/2300000/} +do_test 1.1 { memory_used } $ans do_execsql_test 1.2 VACUUM -do_test 1.3 { memory_used } {#/2300000/} +do_test 1.3 { memory_used } $ans do_execsql_test 1.4 { SELECT count(*) FROM t1 WHERE +a IS NOT NULL } {100000} -do_test 1.5 { memory_used } {#/2300000/} +do_test 1.5 { memory_used } $ans From 2aed97959263530f211c80bb70fe3c55cca09787 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 12:10:25 +0000 Subject: [PATCH 34/42] Disable the DBSTATUS_CACHE_USED_SHARED tests on mac when memsys3/5 is disabled due to differences in the allocation sizes for the Darwin memory allocator. FossilOrigin-Name: d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 --- manifest | 12 ++++----- manifest.uuid | 2 +- test/dbstatus.test | 62 ++++++++++++++++++++++++---------------------- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index 9cd5c96943..7e15c062ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\svacuummem.test\sscript\sso\sthat\sit\sworks\son\smac\sas\swell\sas\son\slinux. -D 2016-07-25T12:01:18.862 +C Disable\sthe\sDBSTATUS_CACHE_USED_SHARED\stests\son\smac\swhen\smemsys3/5\sis\sdisabled\ndue\sto\sdifferences\sin\sthe\sallocation\ssizes\sfor\sthe\sDarwin\smemory\sallocator. +D 2016-07-25T12:10:25.504 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 2bb4d576f11c0f57f5633dad373ad1a57c2a7195 +F test/dbstatus.test 58b31ba1dee1a6524189666c5882ab145d1f229b F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ccc22e14dc5d910d632807f49484be54dc2fde83 -R f8760ea1979a3d1e72e54c3ea906ea99 +P ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e +R 3485ec1f1845ad365519b5b860f50dc5 U drh -Z 5b9cf50a9e82d7593d62c569e8fac940 +Z 3712e6b13d05abd58f12d65f644b4035 diff --git a/manifest.uuid b/manifest.uuid index 9f906f5e5e..1d8d5dc41a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e \ No newline at end of file +d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 \ No newline at end of file diff --git a/test/dbstatus.test b/test/dbstatus.test index fb4cbe04ba..a3518e9b6f 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -379,36 +379,40 @@ foreach ::lookaside_buffer_size {0 64 120} { # The following tests focus on DBSTATUS_CACHE_USED_SHARED # ifcapable shared_cache { - proc do_cacheused_test {tn db res} { - set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] - set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] - set cu [lindex $cu 1] - set pcu [lindex $pcu 1] - uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"] + if {[permutation]=="memsys3" + || [permutation]=="memsys5" + || $::tcl_platform(os)!="Darwin"} { + proc do_cacheused_test {tn db res} { + set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] + set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] + set cu [lindex $cu 1] + set pcu [lindex $pcu 1] + uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"] + } + reset_db + sqlite3 db file:test.db?cache=shared + + do_execsql_test 4.0 { + PRAGMA auto_vacuum=NONE; + CREATE TABLE t1(a, b, c); + INSERT INTO t1 VALUES(1, 2, 3); + } + do_cacheused_test 4.0.1 db { 4568 4568 } + do_execsql_test 4.1 { + CREATE TEMP TABLE tt(a, b, c); + INSERT INTO tt VALUES(1, 2, 3); + } + do_cacheused_test 4.1.1 db { 9000 9000 } + + sqlite3 db2 file:test.db?cache=shared + do_cacheused_test 4.2.1 db2 { 4568 2284 } + do_cacheused_test 4.2.2 db { 9000 6716 } + db close + do_cacheused_test 4.2.3 db2 { 4568 4568 } + sqlite3 db file:test.db?cache=shared + do_cacheused_test 4.2.4 db2 { 4568 2284 } + db2 close } - reset_db - sqlite3 db file:test.db?cache=shared - - do_execsql_test 4.0 { - PRAGMA auto_vacuum=NONE; - CREATE TABLE t1(a, b, c); - INSERT INTO t1 VALUES(1, 2, 3); - } - do_cacheused_test 4.0.1 db { 4568 4568 } - do_execsql_test 4.1 { - CREATE TEMP TABLE tt(a, b, c); - INSERT INTO tt VALUES(1, 2, 3); - } - do_cacheused_test 4.1.1 db { 9000 9000 } - - sqlite3 db2 file:test.db?cache=shared - do_cacheused_test 4.2.1 db2 { 4568 2284 } - do_cacheused_test 4.2.2 db { 9000 6716 } - db close - do_cacheused_test 4.2.3 db2 { 4568 4568 } - sqlite3 db file:test.db?cache=shared - do_cacheused_test 4.2.4 db2 { 4568 2284 } - db2 close } finish_test From 017256802b4ca58df779e7a7d32abc5373fa3175 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 14:20:01 +0000 Subject: [PATCH 35/42] Changes to test scripts to get them all running on OpenBSD. FossilOrigin-Name: 9e7bedeee444cbf0b1a9165e88928c5d85088de1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/dbstatus.test | 2 +- test/shell1.test | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7e15c062ff..621866c6f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\sDBSTATUS_CACHE_USED_SHARED\stests\son\smac\swhen\smemsys3/5\sis\sdisabled\ndue\sto\sdifferences\sin\sthe\sallocation\ssizes\sfor\sthe\sDarwin\smemory\sallocator. -D 2016-07-25T12:10:25.504 +C Changes\sto\stest\sscripts\sto\sget\sthem\sall\srunning\son\sOpenBSD. +D 2016-07-25T14:20:01.353 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 58b31ba1dee1a6524189666c5882ab145d1f229b +F test/dbstatus.test 73149851b3aff14fc6db478e58f9083a66422cf5 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1064,7 +1064,7 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 2f2aee20db294b9924e81f6ccbe60f19e21e8506 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test c90b0415cea6eeefb86b4ab1651b06247922ca52 +F test/shell1.test 77896b65f1cde4ee79e38b2c0ed8578a8f4000e5 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test da513d522ef6f01cee8475dcf8332bff8982b3dd F test/shell4.test 69995ee1cc278eb149aa8746ce1f935f4eaf98b9 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e -R 3485ec1f1845ad365519b5b860f50dc5 +P d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 +R f74cc55ec1e76de02d5d11db76d4d3f2 U drh -Z 3712e6b13d05abd58f12d65f644b4035 +Z 27b5d9cc228b8d41a7c82f29fd5cd771 diff --git a/manifest.uuid b/manifest.uuid index 1d8d5dc41a..83360d7bd0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 \ No newline at end of file +9e7bedeee444cbf0b1a9165e88928c5d85088de1 \ No newline at end of file diff --git a/test/dbstatus.test b/test/dbstatus.test index a3518e9b6f..711d66ebb3 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -381,7 +381,7 @@ foreach ::lookaside_buffer_size {0 64 120} { ifcapable shared_cache { if {[permutation]=="memsys3" || [permutation]=="memsys5" - || $::tcl_platform(os)!="Darwin"} { + || $::tcl_platform(os)=="Linux"} { proc do_cacheused_test {tn db res} { set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] diff --git a/test/shell1.test b/test/shell1.test index 498cd64a9f..03c2dee1d1 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -870,6 +870,7 @@ do_test shell1-5.0 { if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} { continue } + if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue set hex [format %02X $i] set char [subst \\x$hex]; set oldChar $char set escapes [list] From a522473c65f6705a8d18023208dbebea41a9b79f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 14:40:43 +0000 Subject: [PATCH 36/42] Add a new %ifdef to parse.y so that the build works with SQLITE_OMIT_SUBQUERY. FossilOrigin-Name: 38a48cfb9a8212970c4a4f8458643c22ed067e8b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/parse.y | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 621866c6f1..bd35ced110 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\stest\sscripts\sto\sget\sthem\sall\srunning\son\sOpenBSD. -D 2016-07-25T14:20:01.353 +C Add\sa\snew\s%ifdef\sto\sparse.y\sso\sthat\sthe\sbuild\sworks\swith\sSQLITE_OMIT_SUBQUERY. +D 2016-07-25T14:40:43.866 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -372,7 +372,7 @@ F src/os_win.c 520f23475f1de530c435d30b67b7b15fe90874b0 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 031a87445e5e0afc85312d1c380e123ad6c7aeaf -F src/parse.y f374ab20106362eb3f5c01b3e6a002f0bbead7ff +F src/parse.y 99b676e6fc2f4e331ab93e76b3987cffdbd28efa F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 -R f74cc55ec1e76de02d5d11db76d4d3f2 +P 9e7bedeee444cbf0b1a9165e88928c5d85088de1 +R 235239c649979125e6dc80ee3d149e81 U drh -Z 27b5d9cc228b8d41a7c82f29fd5cd771 +Z 63a00886286115a66584905bc421be70 diff --git a/manifest.uuid b/manifest.uuid index 83360d7bd0..b1d3af8c41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e7bedeee444cbf0b1a9165e88928c5d85088de1 \ No newline at end of file +38a48cfb9a8212970c4a4f8458643c22ed067e8b \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 8a65131e28..087c52c839 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1194,13 +1194,14 @@ nexprlist(A) ::= nexprlist(A) COMMA expr(Y). nexprlist(A) ::= expr(Y). {A = sqlite3ExprListAppend(pParse,0,Y.pExpr); /*A-overwrites-Y*/} +%ifndef SQLITE_OMIT_SUBQUERY /* A paren_exprlist is an optional expression list contained inside ** of parenthesis */ %type paren_exprlist {ExprList*} %destructor paren_exprlist {sqlite3ExprListDelete(pParse->db, $$);} paren_exprlist(A) ::= . {A = 0;} paren_exprlist(A) ::= LP exprlist(X) RP. {A = X;} - +%endif SQLITE_OMIT_SUBQUERY ///////////////////////////// The CREATE INDEX command /////////////////////// From 422dded5a9f9fe9aa26da20c5565be903609a83f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 16:10:43 +0000 Subject: [PATCH 37/42] Minor test infrastructure changes to better support SEE testing. FossilOrigin-Name: 8dcb9d506b5eef3a21d97877217e0df69966a915 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/tester.tcl | 1 + test/walcrash4.test | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index bd35ced110..d28b4841ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\s%ifdef\sto\sparse.y\sso\sthat\sthe\sbuild\sworks\swith\sSQLITE_OMIT_SUBQUERY. -D 2016-07-25T14:40:43.866 +C Minor\stest\sinfrastructure\schanges\sto\sbetter\ssupport\sSEE\stesting. +D 2016-07-25T16:10:43.028 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1128,7 +1128,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 -F test/tester.tcl a52b5be1bb586afa1c8bcdcd4b86588645e1ae52 +F test/tester.tcl 949b4a73bd0324b7c796818d0d6a6715712932b3 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1366,7 +1366,7 @@ F test/walcksum.test bb234a1bb42248b3515d992b719708015c384278 F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af -F test/walcrash4.test 3374d6a0813bfe9d841a973958e0552b545a6423 +F test/walcrash4.test e7b6e7639a950a0cca8e210e248c8dad4d63bf20 F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9e7bedeee444cbf0b1a9165e88928c5d85088de1 -R 235239c649979125e6dc80ee3d149e81 +P 38a48cfb9a8212970c4a4f8458643c22ed067e8b +R abfe7130c6ed9b2d2a4c15502875beef U drh -Z 63a00886286115a66584905bc421be70 +Z 61654b6f48f562a527ce39380211aaf2 diff --git a/manifest.uuid b/manifest.uuid index b1d3af8c41..ccfb379c00 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38a48cfb9a8212970c4a4f8458643c22ed067e8b \ No newline at end of file +8dcb9d506b5eef3a21d97877217e0df69966a915 \ No newline at end of file diff --git a/test/tester.tcl b/test/tester.tcl index 3f1edc32ae..3fe84c641f 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -373,6 +373,7 @@ proc do_not_use_codec {} { set ::do_not_use_codec 1 reset_db } +unset -nocomplain do_not_use_codec # Return true if the "reserved_bytes" integer on database files is non-zero. # diff --git a/test/walcrash4.test b/test/walcrash4.test index 3abc16d1eb..80839b39e5 100644 --- a/test/walcrash4.test +++ b/test/walcrash4.test @@ -17,6 +17,7 @@ source $testdir/lock_common.tcl source $testdir/wal_common.tcl ifcapable !wal {finish_test ; return } set testprefix walcrash4 +do_not_use_codec #------------------------------------------------------------------------- # At one point, if "PRAGMA synchronous=full" is set and the platform From 07d9a031870a5eacb5cb31fdf67138ff5579acab Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 21:11:53 +0000 Subject: [PATCH 38/42] Fix a test case in FTS5 to make it compatible with Tcl 8.5. FossilOrigin-Name: a495f8e77e14241150f79e746c7303284f04621a --- ext/fts5/test/fts5simple.test | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 2bc02cf49a..5ac413c885 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -265,7 +265,7 @@ do_test 11.0 { execsql " INSERT INTO t4 VALUES('a b c \x1A'); INSERT INTO t4 VALUES('a b c d\x1A'); - INSERT INTO t4 VALUES('a b c \x1Ad'); + INSERT INTO t4 VALUES('a b c \x1Ag'); INSERT INTO t4 VALUES('a b c d'); " } {} diff --git a/manifest b/manifest index d28b4841ce..e46a5f0762 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stest\sinfrastructure\schanges\sto\sbetter\ssupport\sSEE\stesting. -D 2016-07-25T16:10:43.028 +C Fix\sa\stest\scase\sin\sFTS5\sto\smake\sit\scompatible\swith\sTcl\s8.5. +D 2016-07-25T21:11:53.996 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -180,7 +180,7 @@ F ext/fts5/test/fts5rank.test 2bdc0c5f22ccc1f9dbe9f4d0b82a491dce6f8a32 F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 16908a99d6efc9ba21081b4f2b86b3fc699839a6 -F ext/fts5/test/fts5simple.test cd23d4072ea095d652c9b6db12284cc642e49c98 +F ext/fts5/test/fts5simple.test 5da9b15ed534eb0be9f279d8a2bb2e24d30e4e38 F ext/fts5/test/fts5simple2.test 98377ae1ff7749a42c21fe1a139c1ed312522c46 F ext/fts5/test/fts5simple3.test 8e71733b3d1b0e695011d02c68ebc5ca40b6124e F ext/fts5/test/fts5synonym.test 6475d189c2e20d60795808f83e36bf9318708d48 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38a48cfb9a8212970c4a4f8458643c22ed067e8b -R abfe7130c6ed9b2d2a4c15502875beef +P 8dcb9d506b5eef3a21d97877217e0df69966a915 +R 39b75cd52198f904a29885025a5d8665 U drh -Z 61654b6f48f562a527ce39380211aaf2 +Z ed1d5b465897ee96bacfa15f366335db diff --git a/manifest.uuid b/manifest.uuid index ccfb379c00..9a340b022c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8dcb9d506b5eef3a21d97877217e0df69966a915 \ No newline at end of file +a495f8e77e14241150f79e746c7303284f04621a \ No newline at end of file From 2b62b5def80c984918d197631723ea583a215efb Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 22:40:12 +0000 Subject: [PATCH 39/42] In the VACUUM command, set the cache_size of the transient vacuum_db database to be the same as the database being vacuumed. FossilOrigin-Name: b78d99548ac53ac10dcc38368cc4b29c8cbcb09b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vacuum.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index e46a5f0762..e225d5909f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\scase\sin\sFTS5\sto\smake\sit\scompatible\swith\sTcl\s8.5. -D 2016-07-25T21:11:53.996 +C In\sthe\sVACUUM\scommand,\sset\sthe\scache_size\sof\sthe\stransient\svacuum_db\sdatabase\nto\sbe\sthe\ssame\sas\sthe\sdatabase\sbeing\svacuumed. +D 2016-07-25T22:40:12.561 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -448,7 +448,7 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 +F src/vacuum.c 7949183a9ce2270fc76503384b1159fcb1e39723 F src/vdbe.c ea260b61e73b11a71e70b28a8e25866e2899e5da F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8dcb9d506b5eef3a21d97877217e0df69966a915 -R 39b75cd52198f904a29885025a5d8665 +P a495f8e77e14241150f79e746c7303284f04621a +R 8704dbefb85fb183a067d36d9af66cac U drh -Z ed1d5b465897ee96bacfa15f366335db +Z 422685421478fa78357b95bed0587f82 diff --git a/manifest.uuid b/manifest.uuid index 9a340b022c..3c7462248c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a495f8e77e14241150f79e746c7303284f04621a \ No newline at end of file +b78d99548ac53ac10dcc38368cc4b29c8cbcb09b \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 9ab7f766ee..16c4be01c0 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -197,6 +197,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ } #endif + sqlite3BtreeSetCacheSize(pTemp, db->aDb[0].pSchema->cache_size); rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); if( rc!=SQLITE_OK ) goto end_of_vacuum; From 426f4ab0092550430f76bb73bebc0b9f49c052b3 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Jul 2016 04:31:14 +0000 Subject: [PATCH 40/42] Make sure affinity is applied correctly on lower-bound range constraints in the min() optimization. Fix for ticket [a0bac8b3c3d1bb]. FossilOrigin-Name: b819bace9c2a0b0159122b26db96a8f50a6f0eac --- manifest | 15 ++++++++------- manifest.uuid | 2 +- src/wherecode.c | 1 + test/minmax.test | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e225d5909f..287421d143 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sVACUUM\scommand,\sset\sthe\scache_size\sof\sthe\stransient\svacuum_db\sdatabase\nto\sbe\sthe\ssame\sas\sthe\sdatabase\sbeing\svacuumed. -D 2016-07-25T22:40:12.561 +C Make\ssure\saffinity\sis\sapplied\scorrectly\son\slower-bound\srange\sconstraints\nin\sthe\smin()\soptimization.\s\sFix\sfor\sticket\s[a0bac8b3c3d1bb]. +D 2016-07-26T04:31:14.412 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -465,7 +465,7 @@ F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 -F src/wherecode.c 11e38f5e2dc5c007143fbf7fdb14bca40a6b74ad +F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -929,7 +929,7 @@ F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7 F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2 F test/memsubsys1.test 6d268d0ae90f8d61a2356a1838665654d83de518 F test/memsubsys2.test 3e4a8d0c05fd3e5fa92017c64666730a520c7e08 -F test/minmax.test 42fbad0e81afaa6e0de41c960329f2b2c3526efd +F test/minmax.test 6751e87b409fe11b02e70a306d846fa544e25a41 F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f @@ -1507,7 +1507,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a495f8e77e14241150f79e746c7303284f04621a -R 8704dbefb85fb183a067d36d9af66cac +P b78d99548ac53ac10dcc38368cc4b29c8cbcb09b +Q +0e9f534fef72ca142a4296ab5285c82aada38ba7 +R b5725dd72810ef0d52d5b0abd989daf2 U drh -Z 422685421478fa78357b95bed0587f82 +Z a046c0beaad1d7947f30a6bdc44927b5 diff --git a/manifest.uuid b/manifest.uuid index 3c7462248c..989f1b27ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b78d99548ac53ac10dcc38368cc4b29c8cbcb09b \ No newline at end of file +b819bace9c2a0b0159122b26db96a8f50a6f0eac \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 0b307761be..d78982f5b5 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1319,6 +1319,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( } nConstraint++; testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); + bSeekPastNull = 0; }else if( bSeekPastNull ){ sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq); nConstraint++; diff --git a/test/minmax.test b/test/minmax.test index fb9bbb383a..04a3f06dff 100644 --- a/test/minmax.test +++ b/test/minmax.test @@ -628,5 +628,19 @@ do_test_13_noopt 13.7 { SELECT min(c), count(c) FROM t1 WHERE a='a'; } {1 5} +# 2016-07-26. https://www.sqlite.org/src/info/a0bac8b3c3d1bb75 +# Incorrect result on a min() query after a CREATE INDEX. +# +do_execsql_test 14.1 { + CREATE TABLE t14(a INTEGER, b INTEGER); + INSERT INTO t14(a,b) VALUES(100,2),(200,2),(300,2),(400,1),(500,2); + SELECT min(a) FROM t14 WHERE b='2' AND a>'50'; +} {100} +do_execsql_test 14.2 { + CREATE INDEX t14ba ON t14(b,a); + SELECT min(a) FROM t14 WHERE b='2' AND a>'50'; +} {100} + + finish_test From 9d608759016b18d532a5a8e6bb17840f05e4b7d8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Jul 2016 04:49:43 +0000 Subject: [PATCH 41/42] Copy the cache_spill setting from the main database over to the vacuum_db transient database when running a VACUUM. FossilOrigin-Name: c0e7d98ef2a13ede5ae865083ede1aaffdf43310 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/vacuum.c | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 287421d143..8ca4a9cd2c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\saffinity\sis\sapplied\scorrectly\son\slower-bound\srange\sconstraints\nin\sthe\smin()\soptimization.\s\sFix\sfor\sticket\s[a0bac8b3c3d1bb]. -D 2016-07-26T04:31:14.412 +C Copy\sthe\scache_spill\ssetting\sfrom\sthe\smain\sdatabase\sover\sto\sthe\nvacuum_db\stransient\sdatabase\swhen\srunning\sa\sVACUUM. +D 2016-07-26T04:49:43.617 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -448,7 +448,7 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c 7949183a9ce2270fc76503384b1159fcb1e39723 +F src/vacuum.c 9dd2f5d276bc6094d8f1d85ecd41b30c1a002a43 F src/vdbe.c ea260b61e73b11a71e70b28a8e25866e2899e5da F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d @@ -1507,8 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b78d99548ac53ac10dcc38368cc4b29c8cbcb09b -Q +0e9f534fef72ca142a4296ab5285c82aada38ba7 -R b5725dd72810ef0d52d5b0abd989daf2 +P b819bace9c2a0b0159122b26db96a8f50a6f0eac +R 2279949c9ee671e45067af58637c4ef8 U drh -Z a046c0beaad1d7947f30a6bdc44927b5 +Z ef49efbba33d277501e077ba267218c2 diff --git a/manifest.uuid b/manifest.uuid index 989f1b27ca..59d5af71df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b819bace9c2a0b0159122b26db96a8f50a6f0eac \ No newline at end of file +c0e7d98ef2a13ede5ae865083ede1aaffdf43310 \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 16c4be01c0..b72663c066 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -198,6 +198,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ #endif sqlite3BtreeSetCacheSize(pTemp, db->aDb[0].pSchema->cache_size); + sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0)); rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); if( rc!=SQLITE_OK ) goto end_of_vacuum; From 2900a6222f475f4d495c302aa5d5aab3dc1f0237 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 26 Jul 2016 10:46:21 +0000 Subject: [PATCH 42/42] Ensure that the sqlite3_scrub_backup() extension creates a backup database at least as large as indicated by the database header, even if the last page of the input database is a free-list leaf. FossilOrigin-Name: 483994a54dee3c7a3801e0e9d3c96fa9dbd8d2fd --- ext/misc/scrub.c | 16 ++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ext/misc/scrub.c b/ext/misc/scrub.c index 1d21fc5389..92718e23d1 100644 --- a/ext/misc/scrub.c +++ b/ext/misc/scrub.c @@ -74,6 +74,7 @@ struct ScrubState { u32 szPage; /* Page size */ u32 szUsable; /* Usable bytes on each page */ u32 nPage; /* Number of pages */ + u32 iLastPage; /* Page number of last page written so far*/ u8 *page1; /* Content of page 1 */ }; @@ -130,6 +131,7 @@ static void scrubBackupWrite(ScrubState *p, int pgno, const u8 *pData){ scrubBackupErr(p, "write failed for page %d", pgno); p->rcErr = SQLITE_IOERR; } + if( pgno>p->iLastPage ) p->iLastPage = pgno; } /* Prepare a statement against the "db" database. */ @@ -541,6 +543,20 @@ int sqlite3_scrub_backup( } sqlite3_finalize(pStmt); + /* If the last page of the input db file is a free-list leaf, then the + ** backup file on disk is still smaller than the size indicated within + ** the database header. In this case, write a page of zeroes to the + ** last page of the backup database so that SQLite does not mistakenly + ** think the db is corrupt. */ + if( s.iLastPage