Compare commits

..

429 Commits

Author SHA1 Message Date
mistachkin 49e1125b69 Add and enhance the new tests.
FossilOrigin-Name: f4cbd18db47af4af990d7891dcc831e92b3f17e0
2016-04-04 15:47:46 +00:00
mistachkin 1810f22809 Refinements to the previous check-in.
FossilOrigin-Name: b36dfdff787dc4a107b2c3fcbb98bfc4922872d8
2016-04-04 02:33:34 +00:00
mistachkin 1fe36bb8a8 Experimental changes to the command line shell to make it work better with Unicode on Windows.
FossilOrigin-Name: 74183a5f803999e1d4e288851c72519c3c53f6b5
2016-04-04 02:16:44 +00:00
mistachkin 1293120345 More refactoring and cleanup work on the Win32 string conversion and utility routines.
FossilOrigin-Name: 02ccb444a3d0b9a52ffd04cae9d9b6f654128c35
2016-04-04 02:05:46 +00:00
mistachkin 5daed673b8 Revise and enhance the Win32 string conversion routines.
FossilOrigin-Name: 345860c92195544aad44ea9b0d14c9ebbd50adf2
2016-04-03 22:44:16 +00:00
mistachkin 899c5c9d34 Replace the new fprintf() calls.
FossilOrigin-Name: f76c3a0ca40989fe9401c3b6f662f8e6ef2a730c
2016-04-03 20:50:02 +00:00
mistachkin 0784f8a460 Merge updates from trunk.
FossilOrigin-Name: 566b551e5a81440a5c8ff865ceb4422c76d67cf7
2016-04-03 20:45:04 +00:00
drh 076b6468f5 Preupdate hook documentation fixes. No changes to code.
FossilOrigin-Name: 59814f35d13db1f6379b9ae218b5432bc03c6197
2016-04-01 17:54:07 +00:00
drh f6661a8896 When reading an sqlite_stat1 table with missing entries for some indexes,
set the default for the missing indexes after all other indexes are set
so that the default values are more in line with indexes that are actually
in the stat1 table.

FossilOrigin-Name: a62340dc0507e36f6dec05b1fda68d8399ec62ec
2016-04-01 12:35:22 +00:00
mistachkin 2779989110 Update the clean target in the MSVC makefile.
FossilOrigin-Name: 69f4d83210f6425b2c0d699b397ef4fa4422d438
2016-03-31 22:53:37 +00:00
drh 5996a77987 Enhance the query planner so that IS and IS NULL operators are able to drive
an index on a LEFT OUTER JOIN.

FossilOrigin-Name: c648539b52ca28c0b2cb61208e2c32b1d29626a1
2016-03-31 20:40:28 +00:00
mistachkin 05004784a5 Updates for the MSVC makefiles.
FossilOrigin-Name: 7cf0cab730e2d570c82dd789279ad6501ac598c8
2016-03-30 16:23:06 +00:00
mistachkin b932bf63e6 Fix typo in comment. No changes to code.
FossilOrigin-Name: 64d75cbe2c45af67124fa7ce5688d91cc6ddb755
2016-03-30 16:22:18 +00:00
drh c556f3c33f Simplifications and clarification to update callback handling in the
OP_Delete and OP_Insert opcodes.

FossilOrigin-Name: 47887ef89ed60ddb869d65e0957c1c4b2115f169
2016-03-30 15:30:07 +00:00
drh 9fc4caf64c Increase the version number to 3.13.0 on account of the new session extension.
FossilOrigin-Name: e9bcd5acb9ab7b3d55c96519ca10f51f35e24cd9
2016-03-30 14:26:36 +00:00
drh 3875a96ad9 Remove a redundant test for disabling RESTRICT with defer_foreign_keys=ON.
FossilOrigin-Name: 9cdf813c6aaaddc01d2d4e04636c83fcda04d971
2016-03-30 14:17:36 +00:00
drh 838083975a Incorporate the sessions extension and the
SQLITE_ENABLE_PREUPDATE_HOOK compile-time option.

FossilOrigin-Name: 4af7a90f980ade3566fc5da2f0db2669ac7d8256
2016-03-30 13:43:09 +00:00
drh 74c3302fd1 Avoid compiler warnings and excess opcodes when SQLITE_ENABLE_PREUPDATE_HOOK
is not used.  Fix the EXPLAIN output for P4_TABLE opcodes.

FossilOrigin-Name: 5ab46d760dff327491703478d6d7c7c44a0147ca
2016-03-30 12:56:55 +00:00
drh fbcd3130f6 Improvements to the performance testing program "speedtest1.c" and the
shell script that invokes it.

FossilOrigin-Name: e4bee561fdead5d35c24da3fe8a11bf6548550c6
2016-03-30 12:20:24 +00:00
drh 799b8372d1 Merge changes for 3.12.0.
FossilOrigin-Name: ed22eb653f2809446ace6a27e7ea3926ac6db30c
2016-03-29 10:19:29 +00:00
drh 10df23fe4f Version 3.12.0
FossilOrigin-Name: e9bb4cf40f4971974a74468ef922bdee481c988b
2016-03-29 10:14:15 +00:00
drh 72cd360caf Fix the multiplexor so that it does not assume that the xGetLastError method
is non-NULL in the child VFS.

FossilOrigin-Name: f6a88cccbc0c62a0b453f4711298c9d5e1882b18
2016-03-28 11:01:54 +00:00
drh 60c4249fcc More changes to the shellN.test scripts to get them working on all variations
of Windows.

FossilOrigin-Name: 8213c2f58167243411d29cc58e303b4be656f756
2016-03-26 15:36:36 +00:00
drh eaa544d44d Remove the catchcmd_collapse_space procedure in tester.tcl - no longer needed.
FossilOrigin-Name: 3bd499d3bdf4e80f83513966c2ee9dd11e67cbd1
2016-03-26 14:41:13 +00:00
drh 15707ac992 Update shell1.test tests to deal with backslash escaping in TCL on Windows-style
pathnames.

FossilOrigin-Name: 219a251e182bf43376fbc8ae1ce6f77f18a1b092
2016-03-26 13:26:35 +00:00
drh 4f69540b71 Do not run the shell3.test module under mingw because of mingw's dodgy
command-line parsing.

FossilOrigin-Name: a7c080a90a236fbc18b9a42b78dbed4dd8a25160
2016-03-25 20:10:20 +00:00
mistachkin 82452480ea In the Win32 VFS, avoid trying to use rand_s() on Windows CE.
FossilOrigin-Name: 183350fa7cc6a5ab8bd0a86cab231a6e4c915890
2016-03-25 17:19:57 +00:00
drh 5729c31daf Add the catchcmd_collapse_space command and use it to help make shell testing
more robust against TCL space escapes.

FossilOrigin-Name: 93caabb66082f76ef161a51ac822b919517a7171
2016-03-25 17:09:16 +00:00
drh ddb2b4a310 Fix two instances of undefined behavior in the C code - both harmless for
all current compilers.

FossilOrigin-Name: 99fd194c83dbcfcdcc582983b86678b85b1b9570
2016-03-25 12:10:32 +00:00
drh cb620b4797 Make test cases in shell1.test robust against TCL deciding to quote strings
using lots of backslashes.

FossilOrigin-Name: 817e93f42c09eb876421e27eb8eceb7b077cb45d
2016-03-24 20:55:03 +00:00
mistachkin eb2329bed3 Prevent negative values of SQLITE_DEFAULT_CACHE_SIZE from making SQLITE_WIN32_HEAP_INIT_SIZE negative.
FossilOrigin-Name: e0737f5236ed3e85bd03203c880ee41b34619137
2016-03-24 20:36:47 +00:00
drh d38a2e2511 Larger margins for one memsubsys1 range check when running with a
non-zero reserved-bytes value.

FossilOrigin-Name: 6db1d1fbc6c1acc896fa635dfdc5564800502c40
2016-03-24 15:32:19 +00:00
dan cc47eac005 Fix some test scripts so that they work with various permutations.
FossilOrigin-Name: f4d234b5013bf93b6eac7f8be6d4c074cf9f5293
2016-03-24 15:09:14 +00:00
drh 565d64014b Merge the beta changes into sessions.
FossilOrigin-Name: beb5ea1439995fb8ab112451a8ffcc08fe42d0c4
2016-03-24 14:34:26 +00:00
drh c5412d533c Avoid calling realloc() with a zero size in fuzzcheck.c.
FossilOrigin-Name: a1fd14694c1adc54e5c443ebfdef38e38637f5c5
2016-03-23 17:54:19 +00:00
dan 231ee68808 Fix "ifcapable" tests in capi3.test and capi3c.test so that the tests work with more build configurations.
FossilOrigin-Name: 3fa88f68c3e1bbb3421cb0d2b82b9bb3fe7b9b14
2016-03-23 16:32:29 +00:00
drh 997de998a8 Remove an unused local variable from FTS5.
FossilOrigin-Name: 0ed693c29f184223cde3b3d51f0e06273e586803
2016-03-23 15:53:45 +00:00
dan 848b190e40 Explicitly limit the size of fts5 tokens to 32768 bytes.
FossilOrigin-Name: 70fc69eed9b09159899d7cbd1416a59d04210a63
2016-03-23 15:04:00 +00:00
drh 3767026113 Update a requirement mark. No changes to code.
FossilOrigin-Name: 412984642af40578ec611d8c0b7c0508cb5cf9c9
2016-03-23 13:46:05 +00:00
drh d7564865ad The sqlite3_column_decltype() routine should return NULL, not an empty string,
if the column has no declared type.

FossilOrigin-Name: 605eba4a756e7185119088e2242f82691d078b01
2016-03-22 20:05:09 +00:00
mistachkin 527b0435fa Fix harmless compiler warning for MSVC.
FossilOrigin-Name: 142cd359d37f1d8d53de32e329523d9a93c7d6e5
2016-03-22 15:26:03 +00:00
drh c5e7f94494 Fix a harmless compiler warning.
FossilOrigin-Name: 5ace870d3ac3e9eb29cb4602c9036873adbcb99d
2016-03-22 15:25:16 +00:00
dan 0a2f2b546a Fix some errors in fts5 test scripts.
FossilOrigin-Name: e1ab2d376a72786098125a41c1ea8140fcbd15c6
2016-03-22 15:01:54 +00:00
drh 3bfa7e82b6 Create the "uptr" typedef (the same as uintptr_t when available) and use it
to cast pointers before comparison.

FossilOrigin-Name: 2484cc0c3ffc8834a155f89af1581bd07d453a90
2016-03-22 14:37:59 +00:00
drh 0b98207c5b Avoid the possibility of integer overflow on a pointer comparison test for
corruption in the database file.

FossilOrigin-Name: ff1b1ac3313ba9d70414e928ef3dd82913298a1a
2016-03-22 14:10:45 +00:00
drh 13969f5af0 Fix harmless compiler warnings.
FossilOrigin-Name: 25d776e4523aefeec007943fe29aa17c23ccb301
2016-03-21 22:28:51 +00:00
dan 6737aab5cf Add tests to ensure that fts5 is now deterministic.
FossilOrigin-Name: 3d076094ce411bffcfeb76c0284d15d0f83bd459
2016-03-21 16:25:34 +00:00
drh 4567beefac Skip recently added test cases in nolock.test when running in
the inmemory_journal permutation.

FossilOrigin-Name: a1dcf7af42bb7394d46138318f9367fe9e8be560
2016-03-21 16:19:29 +00:00
drh 6369bc3fbb Remove an unreachable branch from the unlink verification logic in the UNIX
VFS.

FossilOrigin-Name: 4dc30cce7fdb7dba9a9aad96bb8b499b965610b2
2016-03-21 16:06:42 +00:00
drh dbf8a16cb3 Merge 3.12.0 beta changes from trunk.
FossilOrigin-Name: 3296a0ceedef43c2790f0b36471f91138a575243
2016-03-21 15:32:19 +00:00
dan f5268268b7 Have fts5 cache the structure of its index in main memory. Use "PRAGMA data_version" to figure out when this cache should be invalidated.
FossilOrigin-Name: 902f221754f3cc6fb4ae049c135f85efce604ed3
2016-03-21 15:30:50 +00:00
dan 3c6707f72b Rearrange code so that tests pass whether SQLITE_DEBUG is defined or not.
FossilOrigin-Name: 89296a46c3b891ee0b637ff6f89d828d6e46e7b5
2016-03-21 15:18:13 +00:00
drh d260dd3534 Add the sqlite3_system_errno() interface.
FossilOrigin-Name: 4bd12b57ea177cfb1f44d54bfa7aedfb8a8c0c64
2016-03-21 14:46:37 +00:00
dan cf9bce34ab Add test file fts5multiclient.test.
FossilOrigin-Name: 7832466f9177cca59455ba272802145297fcd53d
2016-03-19 14:47:28 +00:00
dan c9460ab989 Fix some OOM-handling issues in the fts5 changes on this branch.
FossilOrigin-Name: 020a0bda59fe93b9361ceeed0d5a8ba4177380c8
2016-03-17 12:39:56 +00:00
dan db8d320d63 Merge the changes on the reusable-pragma branch into this one.
FossilOrigin-Name: 6c4a17b963916d19c9433d7a251338042f32e9fa
2016-03-16 20:53:33 +00:00
dan f55fb6615b Have fts5 cache the decoded structure of fts5 indexes in memory. Use "PRAGMA data_version" to detect stale caches.
FossilOrigin-Name: 33ef2210ef19e55c8d460bfe9d3dc146034c8acc
2016-03-16 19:48:10 +00:00
drh 47e1842e5b Merge all recent enhancements from trunk.
FossilOrigin-Name: 6a7ee04b0ddac36a87d5ed2ac89a53e537f4d5a3
2016-03-16 01:16:30 +00:00
drh c5c67abb9a Merge the virtual table query planner enhancement, the RTREE cost estimate
fix, and the statement journal spill delay enhancement from trunk.

FossilOrigin-Name: 17fd8f3cf0ec565e08403dc8e10a1cffc2bbe165
2016-03-07 17:49:17 +00:00
drh 2606aca80f Merge recent enhancements from trunk. Default page size is 4096. Writes
to statement journals are avoided.

FossilOrigin-Name: 456df3365e2df60e34762f2024bb551538b3f72b
2016-03-04 16:42:43 +00:00
dan fd37e67b16 Disable the RESTRICT foreign key action if "PRAGMA defer_foreign_keys" is set.
FossilOrigin-Name: 8fea1166016c659ece83e0045bc348f478a9ba6a
2016-02-25 19:52:11 +00:00
drh d3e1af4aa0 Merge all the latest changes from trunk.
FossilOrigin-Name: b86590043e17705ada90562cf30f69b3e3ef65a4
2016-02-25 18:54:30 +00:00
drh 7f219fad58 Merge 3.11.0 changes.
FossilOrigin-Name: 631023dd9aa19cd8d92d712941d58e7148821995
2016-02-15 17:39:10 +00:00
dan a66e386225 Fix another test problem in sessionfault.test.
FossilOrigin-Name: f6d1cf79437f892220e93635c377513160ee7fd7
2016-02-13 15:08:25 +00:00
drh 50d348b1e1 Harden sqlite3session_delete() against trying to delete a session that
is not currently on the session list.

FossilOrigin-Name: 6c2d34df76fb7823f307c11a1135ab30674421a9
2016-02-13 14:45:56 +00:00
dan 6fee795885 Fix a problem in sessionfault.test causing it to segfault following a test failure. This commit does not fix the actual test failure - just the subsequent segfault.
FossilOrigin-Name: 582b2ae77d65b1e142ceb5774f37b0aaa3851378
2016-02-13 14:39:46 +00:00
drh d8b7d6e44c Merge the changes for the 3.11.0 release candidate from trunk.
FossilOrigin-Name: 4d7a802e73ef0352f840bc8d74c560afb7666ff7
2016-02-13 14:07:56 +00:00
drh 1a606f8246 Merge enhancements and fixes from trunk.
FossilOrigin-Name: f040a5bb62f3473fba6450c97c68f538d1df21ef
2016-02-09 15:44:18 +00:00
drh 0ac7cfaf99 Merge enhancements from trunk.
FossilOrigin-Name: a533608cb0de3cbc1e28a794aab99864b8c249f4
2016-02-05 14:15:34 +00:00
drh 33c1eb6477 Merge all recent enhancements from trunk.
FossilOrigin-Name: f3f9200115caf4b356f90ec97c351d1afbcb9bf6
2016-02-02 02:22:30 +00:00
dan 2beb2c390b Disable the RESTRICT foreign key action if "PRAGMA defer_foreign_keys" is set.
FossilOrigin-Name: 82470d1c3a41221c78bcdd402b2219c4c21c43af
2016-01-21 17:25:56 +00:00
drh e1ed0bb607 Merge the LIKE-operator bug fix from trunk.
FossilOrigin-Name: 36cb3d6e274a06a78693ca506feaad0b14bde11d
2016-01-20 16:02:48 +00:00
drh 20f272c96f Merge recent enhancements from trunk.
FossilOrigin-Name: 327af5f644a49b2f41d5456958f9d61a2b704e1c
2016-01-20 11:33:37 +00:00
drh cb75bff3f7 Merge the latest fixes and enhancements from trunk.
FossilOrigin-Name: 007e5c6df60f9743ac6914332f59925e4a7a861c
2016-01-14 14:48:17 +00:00
drh 604ce70448 Merge recent enhancements, and especially the WAL overwrite change, from trunk.
FossilOrigin-Name: c4a858b228a164be2f89f5b01833f0b5e0d7735b
2016-01-11 13:10:41 +00:00
mistachkin e787cbbe2a Merge updates from trunk.
FossilOrigin-Name: 5cbab63756f6f276996f39d16d70b178581f63cd
2016-01-06 20:50:02 +00:00
drh f56a2a07ff Merge changes for version 3.10.0.
FossilOrigin-Name: fa4705c91f9650ecd7ec967dbbf0028aabd8a98c
2016-01-06 15:14:53 +00:00
drh 721f26dc9a Merge in last-minute patches for the 3.10.0 beta.
FossilOrigin-Name: c785cd7813e4ef6d6f2cb362a0f822713db6bcea
2016-01-04 19:02:47 +00:00
mistachkin 710b33b999 Alternative to [76f5efa6], move definition of utf8_printf up.
FossilOrigin-Name: 54c5522dda239cb9775709495ed7eb56a5dd8e11
2016-01-03 18:59:28 +00:00
drh 8de1d77c60 Merge the latest enhancements from trunk.
FossilOrigin-Name: c0be246a740c8f33a7c07e1414688364dee56ece
2016-01-01 13:25:06 +00:00
drh 173b60999e Merge recent enhancements from trunk.
FossilOrigin-Name: f6c9273cab877b8b6b327250195f3392393d060a
2015-12-16 19:47:54 +00:00
drh 1bb15fc973 Merge recent enhancements from trunk.
FossilOrigin-Name: d1a1278d7f3306536dc9cbd8fb300898f1e373e8
2015-12-02 20:40:26 +00:00
drh 769dc6e2a2 Merge the latest enhancements from trunk.
FossilOrigin-Name: 7d6cfc79e7e5534ebacd980479917bc528a638f7
2015-11-19 19:40:40 +00:00
drh 98a0e0083f Merge recent enhancements and bug fixes from trunk.
FossilOrigin-Name: 78bc42e664e9fa9ee21ad9762c369f291fcdf5db
2015-11-07 01:33:30 +00:00
drh e2ef7dc05b Merge all recent enhancements and fixes from trunk.
FossilOrigin-Name: 0546d1cd1a3402890edade7970c269cc3f17bc98
2015-11-02 18:57:26 +00:00
drh d286b9fb7d Merge all the latest enhancements from trunk.
FossilOrigin-Name: 395a153ff7b3c7a72f3d02b6fe76d72383f4e480
2015-10-30 16:50:00 +00:00
drh 5db9901479 Merge the version 3.9.1 updates.
FossilOrigin-Name: 2bbb9595ccc4fdd854bf16a1efcddbc42a7ff14e
2015-10-16 20:20:08 +00:00
drh 2c22b5259e Merge in the final few changes before the 3.9.0 release.
FossilOrigin-Name: e1afdbb50120f7d058b25538c6cb8ce3bb34993d
2015-10-13 20:42:16 +00:00
drh 4918480252 Pull in the latest 3.9.0 tweaks from trunk.
FossilOrigin-Name: ed174ccf0ae615647ba026fed649d26dc9a98640
2015-10-10 20:35:10 +00:00
drh 973bc6f1a8 Merge the version 3.9.0 changes and the incorporation of JSON1 and FTS5
into the amalgamation from trunk.

FossilOrigin-Name: c1d96fb654b2c0f66d586aa39d80ea0468186690
2015-10-09 15:29:24 +00:00
drh 2d000eafbe Merge the 3.8.12 beta changes from trunk.
FossilOrigin-Name: 35b1b8d4b97715030700e37b292bb4f1bb3f44d6
2015-10-08 14:55:30 +00:00
dan 6c39e6a800 Changes to the sesssions module ensure that tables appear within changesets and patchsets in the same order that they were attached to the sessions object.
FossilOrigin-Name: 7695890230dc1e0c6db9b7aa509db2039c7f7239
2015-10-01 16:35:57 +00:00
drh 32af5eda6a Merge recent enhancements from trunk, and especially the fix for
ticket [1b266395d6bc10].

FossilOrigin-Name: b2face9aa95ade96a5666c70b6b31064c1ad0977
2015-09-30 14:50:39 +00:00
drh 9ec0efd946 Merge all the latest trunk enhancements into the sessions branch.
FossilOrigin-Name: c91065f8edb1e54076791716fc20d3fcfe3070dc
2015-09-24 14:26:51 +00:00
dan 438b881540 Merge the latest trunk enhancements with this branch.
FossilOrigin-Name: b7469c44be77358e02892a3abc696f7caa0dcd3b
2015-09-15 15:55:15 +00:00
drh 91762f2d18 Merge the latest trunk enhancements.
FossilOrigin-Name: 22ce9218fb2bb56cc5dd4e32077a16f669250d5f
2015-09-14 10:47:29 +00:00
drh 6b86881788 Merge recent trunk enhancements.
FossilOrigin-Name: 6a513c05850949900f396c7a61accb97cc6d2af5
2015-09-03 14:48:25 +00:00
drh 5969c657ae Merge recent enhancements from trunk.
FossilOrigin-Name: cb77236673e30af1e8749d984dedecc8f901b255
2015-09-01 18:52:35 +00:00
drh 89a10b2d53 Merge recent trunk enhancements, include table-valued functions.
FossilOrigin-Name: e9196d566690de0e9815f8cd85be7844322b5a79
2015-08-20 23:54:25 +00:00
drh 87c44ef2f7 Merge test improvements and minor fixes from trunk.
FossilOrigin-Name: 0298a9a780695b666e7c683700d9f2f889d6f826
2015-07-24 22:21:01 +00:00
drh 244c8d7077 Merge all changes in the latest 3.8.11 beta into the sessions branch.
Changes include the rename of OTA to RBU, the WITHOUT-ROWID-OR-Skipscan fix,
and improvements to pcache1.

FossilOrigin-Name: 7f0ee77062d2fcb014942c7c62c163ccc801f21b
2015-07-23 21:59:58 +00:00
drh 38151adfe2 Merge trunk changes, including the addition of FTS5 and pcache1 performance
enhancements.

FossilOrigin-Name: db4cbefb8674c6cfff27c1e918741de1885c845c
2015-07-14 15:39:22 +00:00
drh bed6de557a Merge in the latest enhancements from trunks, especially the use of
_byteswap_ulong() and similar intrinsics on MSVC.

FossilOrigin-Name: 85ca4409bdca7aee801e9fba1c49a87fabbf2064
2015-07-02 18:47:12 +00:00
drh 59b4bd4840 Merge all the latest enhancements from trunk. This merge include FTS5
and a number of notable performance enhancements.

FossilOrigin-Name: 39936b33b0668aad81aa574d4d74c92b0ddd218a
2015-06-30 16:29:59 +00:00
drh be7d497836 Merge all the latest enhancements from trunk.
FossilOrigin-Name: 924f471291dfd458307a11819aa640cc1a02ac63
2015-06-25 15:44:49 +00:00
drh 5600329bc0 Merge all recent enhancements and fixes from trunk.
FossilOrigin-Name: 199bfb67fdf642cca6cd5d460fa4dc602b94837a
2015-06-17 18:18:51 +00:00
drh 60c97e6aa8 Merge recent trunk enhancements and fixes.
FossilOrigin-Name: c39cb0e2571f58c87053de009e2c135d71b2c3af
2015-06-11 18:01:29 +00:00
dan 5898ad6954 Add the sqlite3changegroup_xxx() APIs to the sessions module. For combining multiple changesets or patchsets.
FossilOrigin-Name: 0c1a901cd60e557fc676b97625243163dfe9be9d
2015-06-11 17:26:10 +00:00
dan 807547038d Add the "finish_test" command to the end of new test script sessionE.test.
FossilOrigin-Name: fb3914070791c84b5f323b7359ac845246d8a844
2015-06-02 09:20:46 +00:00
dan 6dc29e60c8 Modify the sessions module to ignore all operations on tables with no primary keys as documented.
FossilOrigin-Name: bdaf9575cd9ebb33dc5da4062a84bca79e7b0fec
2015-06-02 09:19:22 +00:00
drh ad2c1dd782 Import recent enhancements from trunk.
FossilOrigin-Name: 54bec164ebeaf62d783352b3c4d0de8845394091
2015-05-29 19:04:58 +00:00
drh eafdd67242 Merge bug fixes from trunk.
FossilOrigin-Name: 519054bb72e8f8977b11161c81b0e96ba7bca589
2015-05-22 23:51:30 +00:00
drh 893ca50d0f Merge enhancements from trunk, including the new sqlite3_value_dup() API and
the addition of the apSqlParam field in the sqlite3_rtree_query_info object
of R-Tree.

FossilOrigin-Name: cdc0ca6fb36e787b981fb544a27c6df838f85704
2015-05-22 23:26:18 +00:00
drh dbbd816059 Merge the Makefile.msc fix and the compiler warning fix from trunk. Also
fix another compiler warning in sqlite3session_diff().

FossilOrigin-Name: 7530e1bf557083ef91447a02f05b019dbe60fa70
2015-05-19 23:04:26 +00:00
drh adf3bf5811 Merge recent trunk changes, include the R-Tree enhancement that allows
8-byte BLOB arguments to geometry functions, and the fix for the TEXT affinity
problem that could cause corrupt indexes.

FossilOrigin-Name: 0a0de8b72ca24f287f9c84766a14e12ea4564b59
2015-05-19 22:42:23 +00:00
drh 5f9a57fc49 Merge in the IS-operator enhancements and other recent changes from trunk.
FossilOrigin-Name: 4f9229445c293b39c80b2a662901f608c85b36ef
2015-05-14 15:17:20 +00:00
drh 060c3ffc71 Merge in the 3.8.10 release changes.
FossilOrigin-Name: 0404ef885e47f0df1daa04feb28452beb4d32a35
2015-05-07 12:29:54 +00:00
drh d689fd3a92 Merge all trunk enhancements and fixes into the sessions branch.
FossilOrigin-Name: de7083cfe2bb00b689bec6bcc75e994f564ceda6
2015-05-05 17:12:27 +00:00
dan b9db909952 Modify the sqlite3session_diff() API so that tables with no PRIMARY KEYs are ignored. This matches the other sessions APIs. Also change sqlite3session_diff() so that it returns SQLITE_SCHEMA, instead of SQLITE_ERROR, if the tables being compared do not have compatible schemas.
FossilOrigin-Name: aada0ad08e3baa10d14d1f3393183110289e068e
2015-04-23 17:22:49 +00:00
dan 4cc923e3e3 Fix the error message returned by sqlite3session_diff() for tables with no PRIMARY KEY.
FossilOrigin-Name: 4d34a3d40da210bebb2a2e6dff094f9a39c92798
2015-04-23 15:03:14 +00:00
dan dd009f839c Fix a performance problem in sqlite3session_diff().
FossilOrigin-Name: ea400eca314d81761fe5c0e329b906c045f0dfe4
2015-04-23 14:40:17 +00:00
drh 6ea60c7c53 Merge the latest trunk enhancements and fixes into the sessions branch.
FossilOrigin-Name: 4e5f17d189eb0578a544c21fc150f9e2ee3428e3
2015-04-23 13:49:53 +00:00
drh 850b0d031d Merge all recent trunk enhancements and fixes into the sessions branch.
FossilOrigin-Name: b8ef1cdee307441e8d97b4bfc21f8547692eea9f
2015-04-20 01:32:53 +00:00
dan 10dc553c13 Hold the database mutex for the duration of sqlite3session_diff().
FossilOrigin-Name: 6f33050115562833c43da3c99dd37aeb0bf966b6
2015-04-17 11:31:08 +00:00
drh 92f283c0d4 Fix a stray backslash character in a printf format string in
sessionDiffFindModified()

FossilOrigin-Name: abb192a1d79388d4717f459b91e34f9c035935f2
2015-04-16 13:52:03 +00:00
drh ff363ee121 Merge all recent trunk fixes and enhancements into the sessions branch.
FossilOrigin-Name: e65e65f9bc9b4bf5c9dd6e3a77a0d5f03c40e006
2015-04-15 14:14:38 +00:00
drh df3c171881 Merge all recent trunk enhancements into the sessions branch.
FossilOrigin-Name: 5f14f34f072921e229bc20a5185c0cdb3f464c04
2015-04-12 01:33:37 +00:00
dan 58bd114a6f Merge the sessions-diff branch with this one.
FossilOrigin-Name: 805baa57e5d2e97dccddc08eb72f2564df4802e8
2015-04-11 17:09:36 +00:00
dan 730bb805a8 Updates to comments describing the changeset and patchset formats.
FossilOrigin-Name: 5342f721e878b52f207731ea57411f3669ae3f3f
2015-04-09 19:19:22 +00:00
dan 3cc89d9567 Fix problems in the sessions module causing it to produce spurious SQLITE_NOMEM errors when handling SQL text or blob values zero bytes in size.
FossilOrigin-Name: b9459d5980c6249a5c1bc5ea72cb4f3b1ba0e433
2015-04-08 16:43:31 +00:00
dan cf8e91442d Add experimental API sqlite3session_diff().
FossilOrigin-Name: c4340b2ea2115ad97dcac036f9034e132ab789e5
2015-04-08 16:01:12 +00:00
drh 159e6b304c Merge printf() width and precision overflow fixes from trunk.
FossilOrigin-Name: aeca95ac77f6f320a916f7e3c5a7a588ef4a20c8
2015-04-07 23:10:44 +00:00
drh af76530fb0 Merge obscure problem fixes from trunk.
FossilOrigin-Name: 271c110bcf5bf2ea7e113dd01dec876a08e3c047
2015-04-06 12:08:24 +00:00
drh edb3e433ba Merge recent enhancements from trunk.
FossilOrigin-Name: aea439bdc6d4d3a8568423171abf381843188826
2015-04-01 16:39:06 +00:00
drh 2a07f5ecec Merge all recent trunk enhancements and fixes into the sessions branch.
FossilOrigin-Name: df94e61f93da390cb75c48975c50e9d62096ea0b
2015-03-31 00:10:21 +00:00
drh edea911945 Merge all recent trunk enhancements into the sessions branch.
FossilOrigin-Name: 54aaa6f29ad1bf84148c2403eed77e8311f68d66
2015-03-24 19:02:13 +00:00
drh 099006de44 Merge all recent trunk enhancements into the sessions branch.
FossilOrigin-Name: 1d1c57c3566d86cd44f146688b620131b3b57e52
2015-03-17 18:54:10 +00:00
drh c11a172d5f Merge recent trunk enhancements into the sessions branch.
FossilOrigin-Name: 68c8937e83b770d5ec6b1855c1bde81057c11b5f
2015-03-09 13:07:45 +00:00
drh 2f82071478 Merge the latest trunk fixes into the sessions branch.
FossilOrigin-Name: 131a2d3116436ca6304777c9c5d46b7c4051d949
2015-02-25 14:02:53 +00:00
drh 878acb32ef Merge all recent trunk changes into the sessions branch.
FossilOrigin-Name: f36bb5fa5c5e3430808fe35d58f45559a216d341
2015-02-21 15:13:50 +00:00
drh 1ee4a2dd88 Merge all the latest enhancements from trunk.
FossilOrigin-Name: ae7eef117f28a5dae7a05805f2d31ac532a9fcc5
2015-02-06 15:40:32 +00:00
drh 9c2e9f7afa Merge all 3.8.8 changes into the sessions branch.
FossilOrigin-Name: bebd131a3554ea95921e6edbc8aa36674ef25fe3
2015-01-16 12:44:52 +00:00
drh 7a20f698df Merge trunk 3.8.8 beta changes into the sessions branch
FossilOrigin-Name: 0ba124540b5b2a9ceda0f4f4a46e6be54edad813
2015-01-14 17:16:23 +00:00
drh f7af7a17b9 Merge recent enhancements from trunk, including test scripts enhancements and
the removal of limits on the number of terms in a VALUES clause.

FossilOrigin-Name: 5a2dec55bfadc328b430a5231a037b37831a5530
2015-01-08 20:06:06 +00:00
drh c8ae34dc6a Merge the fix to PRAGMA data_version and testing improvements from trunk.
FossilOrigin-Name: 86e39123c1bca457672bc63eff00a823745077e5
2014-12-31 14:27:29 +00:00
drh b5a4387097 Merge the PRAGMA data_version redefinition and other fixes from trunk.
FossilOrigin-Name: 315243e49d30abd0eb31e3795ecf492aee179e4b
2014-12-22 18:48:48 +00:00
drh e465ac29cd Merge the PRAGMA data_version command and the enhancements to FK query planning
from trunk into the sessions branch.

FossilOrigin-Name: d4f82af0a4a9db222e3405cff05c41157e7bd5d9
2014-12-20 14:58:32 +00:00
drh 032f461900 Merge threading fixes from trunk into the sessions branch.
FossilOrigin-Name: 9817a2864eebe2dc90ce505fe0faa8b069ff48ff
2014-12-16 01:05:38 +00:00
drh 52fa3a89f6 Merge the KeyInfo cache mutex fix from trunk.
FossilOrigin-Name: f0940c73bd13cb49a3d229ce2517736324392cfb
2014-12-09 14:54:26 +00:00
drh dd2921ec1d Merge the fix for the shared-cache KeyInfo cache bug from trunk.
FossilOrigin-Name: 5a73da6a3083926a3dafd28c0604122296dc9184
2014-12-05 20:05:10 +00:00
drh c0d33d20f7 Import from trunk the fix the "test" target on the autoconf and MSVC makefiles
and some minor compiler warning fixes.

FossilOrigin-Name: c9f20eb2fbba0868df85ebb98877f9bb969be8a4
2014-12-05 00:41:17 +00:00
drh 34794c3d0c Incorporate the SQLITE_CHECKPOINT_TRUNCATE enhancement and a couple of
obscure bug fixes from trunk.

FossilOrigin-Name: 34ffa3b3c002b0e87d8382ad76e87dbaec0b2bc6
2014-12-04 23:35:08 +00:00
drh 6e09b16852 Merge all recent fixes and enhancements from trunk into sessions.
FossilOrigin-Name: 2617d93713d9f4cf907ab2e7baef6a0f74f7198e
2014-12-02 16:31:01 +00:00
drh 04e8a58669 Merge recent trunk enhancements, including the read-after-ROLLBACK change
and the addition of sqlite3_stmt_scanstatus() support, as well as various
minor bug fixes.

FossilOrigin-Name: f09055f3c4348264c7336f90646375f0d98b061e
2014-11-18 21:20:57 +00:00
drh ca3e10ea37 Merge recent trunk enhancements, and in particular the improvements to
the b-tree balancing logic, into the sessions branch.

FossilOrigin-Name: 28b044a51215a3f64dafb2cf3b6cb7d2029580ef
2014-10-31 14:53:32 +00:00
drh bc2866ca7a Merge all version 3.8.7 updates from trunk.
FossilOrigin-Name: f4de9e07be3819db222317725e62ea997cd22a20
2014-10-17 11:53:22 +00:00
dan abae0c4f1d Fix a problem causing sqlite3changeset_concat() to fail to detect attempts to concatenate patchsets which changesets.
FossilOrigin-Name: 236704a9d1551a50a55bd6e0b6473191a7a7dd21
2014-10-15 20:02:21 +00:00
dan f11b256b0b Merge latest trunk changes with this branch.
FossilOrigin-Name: 1b2824f1d11ac336779372e322aecfb36fb2a31d
2014-10-15 19:37:13 +00:00
drh 92fe38ece5 Merge recent trunk micro-optimizations and the DESC index GROUP BY ORDER BY
bug fix into the sessions branch.

FossilOrigin-Name: 83d4114f2aa404e670ced33511183baacd813a01
2014-10-14 13:41:32 +00:00
drh 78aad7cd1d Merge all recent trunk changes.
FossilOrigin-Name: abfef254721ca29b653f24bfe80e88adaa92dc6c
2014-10-10 12:56:35 +00:00
drh 595db25b28 Merge the latest enhancements from trunk.
FossilOrigin-Name: 2695772c984c215649a16e1e3e18a8048a6a60dd
2014-10-01 01:52:42 +00:00
drh f1a08ad88d Change the names of the stream interface APIs to be of the form
"_strm" instead of "_str".  In other words, added an "m" to the end, to
try to make it clear that we are talking about a "stream" and not a "string.

FossilOrigin-Name: 1f44bfdc237ee6304f4aa56e5c5d1c0d74fcc944
2014-09-27 20:45:48 +00:00
drh 6382b6dc71 Merge recent trunk changes (performance enhancements) into the sessions
branch.

FossilOrigin-Name: 497367cb57345dd37793e5f369b34d12be56172e
2014-09-27 19:51:50 +00:00
dan f05ac11214 Fix a segfault in the sessions module that could follow an OOM.
FossilOrigin-Name: 09985fa6b60a0bf38e23bbccd4d8e1d1cbf66124
2014-09-27 18:18:32 +00:00
dan e8fa8c9649 Fix a segfault in the streaming API functions triggered by a very long table name.
FossilOrigin-Name: d2642543eed54da1ac0f757d43dd4d72482eb752
2014-09-27 16:33:09 +00:00
dan 16228167c2 Improve sessions module documentation and comments. Fix some other code issues.
FossilOrigin-Name: bfc8bd80f8b225cebc66478448510ce84223ae7d
2014-09-27 12:26:18 +00:00
dan fa29ecc4ed Fix a problem with concatenating patchsets containing DELETE and INSERT operations on the same row.
FossilOrigin-Name: 4d8537eafb40e3687abc057ba26a1f7014f2c2d9
2014-09-26 10:52:21 +00:00
dan cbf6d2d2aa Add streaming version of sqlite3changeset_concat().
FossilOrigin-Name: 88eb6656bdb047a104837a2e15e7fe18c0a7a159
2014-09-25 20:43:28 +00:00
dan fa122adac1 Add streaming version of sqlite3changeset_invert() to sessions module.
FossilOrigin-Name: 8ded6a46794c7bff1c8b790c662ba7e92f576380
2014-09-25 14:54:20 +00:00
dan 4757c65866 Add streaming version of sqlite3changeset_apply(). Tests and fixes for the same and sqlite3changeset_start_str().
FossilOrigin-Name: b917fc146876f764442de08d5ec36e5b4cf5ab52
2014-09-24 17:13:20 +00:00
dan ef7a630496 Begin adding 'streaming' APIs to sessions module. This is a work in progress.
FossilOrigin-Name: 3c7d3d950bbf5f5ed3696ebc61c77ca48bafe2b5
2014-09-23 20:39:55 +00:00
drh 6b011d83b4 Merge all recent trunk changes into the sessions branch.
FossilOrigin-Name: 6406b77f2c447751a2fbb16f01c61cdcfd6af59e
2014-09-21 22:49:20 +00:00
drh a4a8a3c22e Merge support for large files on Android from trunk.
FossilOrigin-Name: c2885c6bb24cc55178467e57e77bf71df58b3b13
2014-09-08 15:04:24 +00:00
drh bf9ed6f9af Merge the latest trunk changes, including the multi-threaded sorter, into
the sessions branch.

FossilOrigin-Name: d4cce2c71e64ab7b6a65a81b88b69445ed859351
2014-09-02 15:49:47 +00:00
drh e1ed0b0e17 Merge recent performance enhancements and the CAST operator enhancements
into the sessions branch.

FossilOrigin-Name: 08ae974ac80fabe53f515bbbd93ccf55de8ee671
2014-08-26 02:15:07 +00:00
drh 2571e4eddd Merge all recent trunk changes, especially the fix for
ticket [369d57fb8e5ccdff06f1], but also the skip-scan improvement and
performance improvements in the b-tree code.

FossilOrigin-Name: 0b9e2c3269695713b538561d999c68097db70f0c
2014-08-21 16:09:36 +00:00
drh 3a432b0b47 Disable the hook-7.5.2 tests when using sessions, since that are not correct
in that case.

FossilOrigin-Name: 6d5b9332e8d8bb572ac98b0f4e47e59ad12aac26
2014-08-19 00:33:22 +00:00
drh 2967e0cc9c Improved response to error conditions in the ".session" shell command and
in the "changeset" command-line program.

FossilOrigin-Name: b69f7dd1f35846c3bb9f4f160d50c4f03796f887
2014-08-19 00:26:17 +00:00
drh 9f674f2600 Fix the autoconf and MSVC makefiles so that they construct the changeset
command-line utility upon request.  Delete that utility program when
"make clean" is run.

FossilOrigin-Name: 4dc15fe066f079ff31c89a5e0242dd5b3c851d29
2014-08-18 20:23:29 +00:00
drh f5ab08c779 Fix a harmless compiler warning in the sessionAppendDelete() function.
FossilOrigin-Name: 1324d08d0c639378cf1b03bd6410db81947747ac
2014-08-18 20:14:30 +00:00
drh 5f77b89ecd Add the "changeset" command-line tool for analyzing and manipulating
changesets in files on disk.  Add the ".session" command to the command-line
tool.

FossilOrigin-Name: 31addb627fdbaeb908e0611ad82f6db7537428ea
2014-08-18 20:08:25 +00:00
drh 03168cacd5 A reasonably complete implementation of the "changeset" command-line tool
and the ".sessions" command in the command-line shell.

FossilOrigin-Name: 7b12f1f9c012f33d376242920583807b014b3287
2014-08-18 20:01:31 +00:00
drh 3a67b0453e Add the "changeset" command-line utility for getting an ASCII dump of
change sets.

FossilOrigin-Name: 55bb3544a6b474c04853270067a35ca4b0079f52
2014-08-18 17:56:31 +00:00
dan 082c96dffa Add miscellaneous test cases to improve coverage of sessions module.
FossilOrigin-Name: 0fac6cfffe628ea02c78ebad065307309ec9eaa1
2014-08-18 16:03:46 +00:00
drh e62296100f Begin adding commands to the command-line interface for interacting with
the sessions extension.  This is the first check-in of a work-in-progress.

FossilOrigin-Name: c2fcf0b9f4bdc48dfc6530bda4f531b94a833207
2014-08-18 15:08:26 +00:00
drh 8b7a2e3a1e Merge the latest trunk changes, and in particular the refactoring of the
object names in the command-line shell.

FossilOrigin-Name: 419d286a2fc465f6e0f9662909d0cc52a18eefa4
2014-08-18 13:48:41 +00:00
dan 2e934cd40c Add tests for sessions module.
FossilOrigin-Name: 82fdb1975f5b29a751089a8582713372999ae56e
2014-08-18 08:42:36 +00:00
dan a71d2371d0 Fix some missing and out-of-date comments in the sessions module.
FossilOrigin-Name: 05c1d9149b27c68e2654ed28491722927d2176f5
2014-08-16 19:01:00 +00:00
dan 64277f4a70 Fixes for the sqlite3changeset_concat() API regarding patchsets.
FossilOrigin-Name: dccb34859508eac8146ae5b19c447673d04be3b0
2014-08-16 16:47:55 +00:00
dan 73b3c05590 Begin adding the sqlite3session_patchset() API to the sessions extension. This is an interim commit.
FossilOrigin-Name: 60a4565a8c44762a002cd02979317df5ca47e899
2014-08-15 20:15:49 +00:00
drh f3a3dfe9f1 Update the sessions branch for version 3.8.6.
FossilOrigin-Name: 2acbeac1fd9b9feb26e1c24d4ae50ce79f17a3f8
2014-08-15 15:10:46 +00:00
drh d0738004ca Merge the trunk changes for 3.8.6 beta3 into the sessions branch.
FossilOrigin-Name: d49455d9a972fc2224d9beb97165a998ca56e838
2014-08-13 14:43:32 +00:00
drh 73472e38ce Merge the second InterlockedCompareExchange() fix from trunk.
FossilOrigin-Name: 69018967f6e38521dd9b0fa9ce05c9b947635335
2014-08-06 12:00:08 +00:00
drh 0894993e88 Fix an obsolete comment in the func.c source file. No changes to code.
FossilOrigin-Name: 7a145c9409e70b92946534eb44c2e205f7309897
2014-08-06 11:49:31 +00:00
drh 6a3d6085ad Merge in the fix for the InterlockedCompareExchange() build issue.
FossilOrigin-Name: 091aa5f1047f0ec984a69ab1f356c1960813b77b
2014-08-06 03:16:56 +00:00
drh 58c4cbe152 Merge the latest 3.8.6 beta changes from trunk.
FossilOrigin-Name: 68a6d5e2f43702c78057ae2f2a7345c981d24e17
2014-08-06 01:25:47 +00:00
drh 39a7bfd361 Merge the fix for the CREATE UNIQUE INDEX problem into the sessions branch.
FossilOrigin-Name: 43401ee624587ffa166c3cda7e5265ad0d81da5c
2014-07-30 14:29:54 +00:00
drh aae73527ad Merge recent trunk changes, and especially the fix for the R-Tree problem
described in ticket [d2889096e7bdeac6].

FossilOrigin-Name: 8f1beeade0ddf802900c9d203a4fd678d1190394
2014-07-29 12:40:45 +00:00
drh 35c3d8cc75 Merge recent trunk changes into the sessions branch.
FossilOrigin-Name: a9db017eabdefafcda87c497e8bafa07002ac0fe
2014-07-24 16:23:51 +00:00
drh f257b4c613 Merge the latest trunk enhancements into the sessions branch.
FossilOrigin-Name: a5d94eaba6aa12ff16d2a0af2fc752bcdb461877
2014-06-30 20:02:55 +00:00
drh 83f951ee95 Merge the 3.8.5 release candidate changes into the sessions branch.
FossilOrigin-Name: 09e75d82d02f900e58eceaaa010a42fc7044c89f
2014-06-03 20:09:48 +00:00
drh cbabb20390 Merge trunk changes into the sessions branch.
FossilOrigin-Name: 9f18e78f039ffa89a8806810ad385bdc51bc88ed
2014-05-29 20:29:13 +00:00
drh aff0fbb6a5 Merge recent trunk changes into the sessions branch.
FossilOrigin-Name: a769c7e03e6d4163986d49652687de34d15906a0
2014-05-26 20:00:00 +00:00
drh d963982049 Merge recent trunk changes into the sessions branch.
FossilOrigin-Name: 2d33afe0c43cb99caa521c48b721c3b0971e967c
2014-05-20 00:20:23 +00:00
drh 2e525f18e2 Merge all recent trunk enhancements and fixes into the sessions branch.
FossilOrigin-Name: e158812c34b01ce516d26636a489509bf61d1c27
2014-04-28 18:02:21 +00:00
drh ae28b301e1 Add the sqlite3_rtree_query_callback() API to the RTree virtual table.
FossilOrigin-Name: 3dca2809352c6c6d56db74447a814f77011c6220
2014-04-28 17:51:12 +00:00
drh c686929914 Enhance the sqlite3_rtree_query_info object to report on the number of
elements in the priority queue at each level.

FossilOrigin-Name: f7dad408dd46a1e3612b6142a3afb1d0d4fcda00
2014-04-25 16:29:03 +00:00
drh 98cf9d74f8 Fix the generation of sqlite3_rtree_query_info.iRowid and add test cases
to verify that it is fixed.

FossilOrigin-Name: eba95ead49f8f8ce45d400186562ff0066537c5c
2014-04-21 18:13:37 +00:00
drh 74188329ce Be sure to initialize the sqlite3_rtree_query_info.iRowid field for the
leaves of the R-Tree when doing a query callback search.

FossilOrigin-Name: 4394693882c04c19ebe87ef7547c57e679554397
2014-04-21 15:53:45 +00:00
drh a6ca7f2c1b Fix an off-by-one error in setting the "iLevel" field of the
sqlite3_rtree_query_info structure passed into the RTree query callback.

FossilOrigin-Name: d708f159abfb3b87e2844463088d4fb7f8da9c97
2014-04-21 15:21:19 +00:00
drh ec7c03a08b Further improvements to the RTREE_DECODE_COORD() method, to take advantage
of known processor byte orders when available.  This makes the code 3% faster,
according to valgrind.  Also add test cases to make sure the on-disk
representation is correct.

FossilOrigin-Name: 6f3e94f4b1b403cd7bfc5e8e0ffbd61b5174d3a4
2014-04-18 01:37:08 +00:00
drh e49b2718e0 Merge the latest changes from sessions.
FossilOrigin-Name: d9eef5b03c7c4bb69c11eda41152ee81aed1cac7
2014-04-18 01:14:46 +00:00
drh a1a483d54e Merge recent trunk changes into sessions.
FossilOrigin-Name: 95e77efe076ab421bd246119c47dba5dacf9d087
2014-04-18 01:10:05 +00:00
drh a5db90fc8e Performance optimization on byte-swapping in R-Tree.
FossilOrigin-Name: 444084fd620fc3f45cfb87b83f532d76bd2744e7
2014-04-17 23:23:29 +00:00
drh 1821cbacf1 More test cases with very long priority queues.
FossilOrigin-Name: 71692aa97c78676f0ba80eaeec0ad9ac225f4427
2014-04-17 15:34:58 +00:00
drh b640595f97 Test cases and bug fixes for the sqlite3_rtree_query_callback()
mechanism.

FossilOrigin-Name: 1ccaaed6b516ec2ce953c1b31025a82ba76d00e7
2014-04-17 14:52:20 +00:00
drh 78b486ea12 Refactor the constraint checking logic in RTree. The new-style constraint
callbacks created by sqlite3_rtree_query_callback() are now hooked up from
end to end, though still untested.

FossilOrigin-Name: 32a13870175a1dd1d33af3572dde09ff607a04b6
2014-04-17 13:15:33 +00:00
drh 18b5142b29 Performance optimization on nodeGetCell() in R-Tree.
FossilOrigin-Name: 5d20ff9ec837ad35bc44d6c25d13764b350e81dd
2014-04-16 21:02:28 +00:00
drh 22596b6b3c Convert the RTree module query mechanism over to using a priority queue for
walking the RTree.

FossilOrigin-Name: f26936f71a16ab25590540f7feb273514dfb69ff
2014-04-16 17:23:23 +00:00
drh 933a5ff2d4 TCL tests now all pass.
FossilOrigin-Name: f864baccd3fe0ee939ac1ec20069792f649cddc0
2014-04-16 17:15:14 +00:00
drh ab908cfcb4 Fix a bug in rowid=? query handling. More problems remain.
FossilOrigin-Name: 5b0e6ba4a5050cf81cf41b977b28d714163569e0
2014-04-16 14:45:11 +00:00
drh f247982e37 Bug fixes to the priority-queue implementation for R-Trees. Improved tracing
capability.  Some queries work now, but still many problems.

FossilOrigin-Name: a439ddd629c6bb5ea2e7e274673fee4f5c207acf
2014-04-16 13:00:08 +00:00
drh 96ce1b36aa Initial attempt at getting R-Tree queries to work using a priority queue.
This check-in compiles, but R-Trees do not work well.  And there are
debugging printf()s left in the code.  This is an incremental check-in.

FossilOrigin-Name: 53688a25c23c394278a357829793889970aa4157
2014-04-15 21:06:14 +00:00
drh de8c279b28 Fix comments on the rtreenode() and rtreedepth() test function in the R-Tree
module.

FossilOrigin-Name: ade5b986e8baab9df7bdaf7ccfaee2d6ba55fa3c
2014-04-14 14:43:09 +00:00
drh b6c3aeac90 Remove over 300 lines of unused code, code that implemented the older
Guttman insertion algorithms that are no longer used.

FossilOrigin-Name: 3ba5f295c709faebf5505e61f6dc5266b811b086
2014-04-14 12:18:17 +00:00
drh 8ae04b53c9 Continuing work on the new custom query mechanism for r-tree.
FossilOrigin-Name: ca7357e66ca60f59477b1db000c2cdaeb8082ae1
2014-04-13 16:10:09 +00:00
drh 0ccb6cdc87 Continuing clean-up of the R-Tree module in preparation for cutting in the
new generalized query mechanism.

FossilOrigin-Name: 66c858f20586424e15d0bfa3d7b56643bde66226
2014-04-12 17:44:00 +00:00
drh c9cb207acf Add the new interfaces to rtree, though they do not yet work. Add the
"show_speedtest1_rtree.tcl" script for showing the test data used for the
R-Tree tests of speedtest1.  Change speedtest1 to generate better R-Tree
test data.

FossilOrigin-Name: 0b70275972c7a6a533566c1e50bffbf3ac531e95
2014-04-11 23:14:48 +00:00
drh eb7c4f2aea Add the --verify option to speedtest1. Add verification test cases to
the "rtree" testset and a case that uses a custom geometry callback.

FossilOrigin-Name: 9d485c4207a81f32334857d4a608c5c511dd2b83
2014-04-11 17:41:08 +00:00
drh dcc5c7b2fc Update comments in the R-Tree module in preparation for some big changes.
Add an "rtree" performance test to speedtest1.

FossilOrigin-Name: 20a73ec0b2f56609a4504052e198e32803d30207
2014-04-11 16:14:54 +00:00
drh 652cc4b6dc Merge all recent changes from trunk,
including the fix for the OP_SCopy-vs-OP_Copy problem.

FossilOrigin-Name: 9515c8344a6743bbb0c6a6e49fb79fb3139090df
2014-04-03 16:35:33 +00:00
drh 24ed9d0445 Merge in fixes (including the corrupt-database crash fix) and
performance enhancements from trunk.

FossilOrigin-Name: fc8ca1a87e7127bd28f32fd809aec3e24355fbfa
2014-03-26 19:43:30 +00:00
drh 092378860d Bump the version number to 3.8.4.1., to conform with trunk.
FossilOrigin-Name: 42c9d8fc5fe4f0250bfa1f977c7cc63e5741408f
2014-03-12 10:03:13 +00:00
drh 181aed3c25 Version 3.8.4 for sessions (plus two minor fixes).
FossilOrigin-Name: 917c410808756e1697bd628f4c9c57dd13d08ce7
2014-03-11 01:48:06 +00:00
drh 4e2f459987 Merge the fix for the journal_mode=PERSIST error recovery delay bug.
FossilOrigin-Name: bb6a75f4bbcaaabc3ad47992c7c87868c70e8daf
2014-03-07 14:36:50 +00:00
drh 87778c7f96 Fix a harmless compiler warning in the sessions test harness.
FossilOrigin-Name: d389e20ab07a76d0c4be3801265977fa977a4394
2014-03-06 15:01:11 +00:00
drh b7bc8c9849 Enhance the test harness for the sessions interface so that it does not
use SQLite operations that can encounter an OOM error in places where it
is unable to report an OOM error back up to the test script.

FossilOrigin-Name: bc0e661033b78f27866932244e6204985ae39000
2014-03-06 14:53:25 +00:00
drh f2eded23f5 Merge the latest 3.8.4 tweaks from trunk.
FossilOrigin-Name: 1ed463d91866182fbc884fb88770717ee5bf33ce
2014-03-06 13:48:31 +00:00
drh 3bde1354ff Merge compiler-warning fixes from trunk.
FossilOrigin-Name: a1f2b0428518ec18af74a0e01deb4e40cd95a78f
2014-03-05 23:12:55 +00:00
drh 0503cf491f Merge in various obscure bug fixes and the removal of Mem.memType from trunk.
FossilOrigin-Name: 0828975d580d309a1c66da4b6caeb65b21a01199
2014-03-05 14:49:51 +00:00
drh 7826a9b83f Merge the performance enhancements of trunk (and some obscure bug fixes)
into the sessions branch.

FossilOrigin-Name: 7f51ad97f0b24c57453d58faf25eee68861faa23
2014-03-04 14:34:14 +00:00
drh 15d4211400 Sync with trunk. Bring in the command-line shell updates and the new 3.8.4
version number.

FossilOrigin-Name: 2cd35ff6512e1973077f7ffc2c902476eabbe672
2014-02-11 16:31:14 +00:00
drh 5671ef69ec Sync the latest trunk changes, and in particular the STAT4 IS NOT NULL fix.
FossilOrigin-Name: b006792695d23980e1923b21915d5c1138ecf29d
2014-02-11 04:30:29 +00:00
drh 4b46eb108d Sync with version 3.8.3.
FossilOrigin-Name: a704b65b9476d60c88b5bc82f2743faa2bce5ac2
2014-02-03 13:58:42 +00:00
dan 43a6c6b2d4 Merge latest fixes from the trunk.
FossilOrigin-Name: 6b6dcd4cc75317628072abac7c58b41361cc72b4
2014-01-29 14:21:31 +00:00
drh 19913f4419 Bring in the latest updates from trunk.
FossilOrigin-Name: 7b5f3773867ed0e4ed17bd473ba972d500035318
2014-01-28 18:06:17 +00:00
drh c187698614 Bring in all the latest trunk changes, including the Common Table
Expressions implementation.

FossilOrigin-Name: 9b43e559195680e558264c4c00d34dc9cf9d9146
2014-01-24 14:05:18 +00:00
drh d9e3c267b4 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: cfd110bf5db2c1993a5e2ca718648bd9c17ee22c
2013-12-24 12:09:42 +00:00
drh c8d985e09c Merge in all recent preformance enhancements from trunk.
FossilOrigin-Name: 32477642d79615fb85680bdac812ad9655cf6902
2013-12-14 18:24:46 +00:00
drh 65106c77bb Update to the 3.8.2 release.
FossilOrigin-Name: e579661a7950fe9f8eb10012946100c874ba54b0
2013-12-06 15:49:45 +00:00
drh 27964431ea Merge in trunk changes.
FossilOrigin-Name: a2914d6b17358de05eb39f764c0c13d2d4cf8f3b
2013-12-03 20:51:33 +00:00
drh 52208a6332 Merge all recent 3.8.2 beta changes from trunk.
FossilOrigin-Name: 67c34ccfa9596a923695dc4994ec87b331f8326c
2013-12-02 21:58:19 +00:00
drh 5b8d1ab454 Merge all recent trunk changes.
FossilOrigin-Name: 3a2a1bd47875e114d8e6f31c1768908f401d2861
2013-11-27 21:53:51 +00:00
drh 1b2ee4fe1a Merge in performance enhancements from trunk.
FossilOrigin-Name: fc9ae839569eb28eb734c52d95676c59b2e27494
2013-11-26 18:00:29 +00:00
drh 212c6be141 Merge the skip-scan optimization into the sessions branch.
FossilOrigin-Name: 7596d1bf8040f7cefc7b22c5e609acc5d66820bf
2013-11-14 19:18:39 +00:00
drh cf1ef10b62 Import recent bug fixes from trunk.
FossilOrigin-Name: 20eeee4cd34a9bffe6bf65962126ddf8ca04eb3e
2013-11-12 15:39:01 +00:00
drh fba5765b57 Fix two test cases (due to changes in the formatting of constraint errors)
so that all tests now pass.

FossilOrigin-Name: 129e2b69178147d04ee27fce66c17b39f8654da3
2013-11-11 23:02:10 +00:00
drh cbf1b8ef7d Merge in the WITHOUT ROWID changes. A few tests are failing now. They will
be fixed in a follow-on check-in.

FossilOrigin-Name: 5addd1234ded59ce60fb633b76ac87d483377edd
2013-11-11 22:55:26 +00:00
drh d63d4b7bd7 Merge all trunk changes since 3.8.1 into the sessions branch.
FossilOrigin-Name: aa72ea8a004de7fe744fc13baef19d05aea607d5
2013-10-28 22:47:24 +00:00
drh d82d4750a8 Merge the latest trunk changes.
FossilOrigin-Name: 5806546822b717d712dc7cd9de88a86f5bf2f715
2013-10-16 14:32:47 +00:00
drh 9327c70f68 Merge the latest trunk changes into the sessions branch. This merge
should fix the build for WinRT.

FossilOrigin-Name: e111e4edf9d7b2d4d6d6673a7576801839e9537d
2013-10-15 14:10:44 +00:00
drh a63b852992 Synchronize with the trunk.
FossilOrigin-Name: 136445ba020c9475d3f5a7843d7d0add98477138
2013-10-10 20:13:18 +00:00
drh 59255f9a98 Merge in all the latest trunk changes, including the win32-longpath VFS and
the fix for the segfault in the omit-left-join optimization.

FossilOrigin-Name: cdd3838b7876639cf99904b2054884247fbff529
2013-09-03 14:49:07 +00:00
drh 5f9742e0ff Merge from trunk: (1) Recent bug fixes (2) STAT4 support (3) win32-longpath
support.

FossilOrigin-Name: e7ebc8f74fe91dee26f952fdf49e427b45448667
2013-08-29 15:08:38 +00:00
dan 9f0656d8c5 Merge recent trunk changes.
FossilOrigin-Name: 6cc54de88bba00e07fac9de36caac216d94bf070
2013-08-23 17:54:46 +00:00
dan 7531a5a378 Add the sqlite3session_table_filter API to the sessions extension.
FossilOrigin-Name: b7e4dd889d37c8f57c2d3c7900e802f644aac3ea
2013-08-23 17:43:32 +00:00
drh 32683532f0 Merge in minor bug fixes and performance tweaks from trunk leading up to
the version 3.8.0 release.

FossilOrigin-Name: 831492dca8bcfb1a1f83a8bb15de9cc94f29f07e
2013-08-22 15:07:08 +00:00
drh 90bf3d7422 Merge performance enhancements and compiler warning fixes from trunk.
FossilOrigin-Name: 3e4033285deb417bd72c008917729dbf3bf4e90d
2013-08-20 13:02:16 +00:00
drh db78b96111 Merge in all the latest updates and enhancements from trunk.
FossilOrigin-Name: 67587a3348b84424b2ab1f2df1ea923a5168e2e4
2013-08-19 12:49:06 +00:00
drh 700a7fdf83 Merge in the latest changes from trunk.
FossilOrigin-Name: 69d5bed017bda3e184857febcc8b6f6bed6ad228
2013-08-06 14:52:27 +00:00
drh 7fb30bd0dd Merge in the latest trunk changes, including partial indexes, the MAX_PATH
fix in os_win.c, and the sqlite3_cancel_auto_extension() API.

FossilOrigin-Name: 7e1acb390770d1bd189fac7a3a7f96106f96e3a4
2013-08-02 20:44:48 +00:00
drh 6f855952d0 Merge recent trunk changes (such as the query_only PRAGMA, the
defer_foreign_keys PRAGMA, and the SQLITE_DBSTATUS_DEFERRED_FKS parameter
to sqlite3_db_status()) into the sessions branch.

FossilOrigin-Name: 8dfc0b78c38e519b64a796243ff7c0aff688ff36
2013-07-11 15:31:57 +00:00
drh 07001c45a1 Remove the undocumented sqlite3_foreign_key_check() API and replace it with
sqlite3_db_status(db, SQLITE_DBSTATUS_DEFERRED_FKS, ...).  Add test cases
for the new functionality.

FossilOrigin-Name: d39e65fe702a2e11477f2d996f77404f45763368
2013-07-11 13:49:59 +00:00
drh 963c74df59 Rename the SQLITE_DeferForeignKeys macro to shorter SQLITE_DeferFKs. Move
the "defer_foreign_keys" pragma into the flagPragma() routine.

FossilOrigin-Name: 3a2ab74c85a40e0e7ef2d6aef6ec23837cb788e6
2013-07-11 12:19:12 +00:00
drh 888e16e7c5 Pull in all the latest changes from trunk.
FossilOrigin-Name: af3ca4c6e557e6bc92584586b5a97d9be41b0b82
2013-07-09 13:05:49 +00:00
dan bded90b487 Fix a bug preventing some FK constraint checking from being deferred until the end of changeset application.
FossilOrigin-Name: 1452defb8cfcc489230314dd1e0425feba46c49d
2013-07-04 15:22:53 +00:00
dan cb3e4b797e Experimental change to the handling of foreign key constraint violations when applying a changeset: all foreign keys, immediate and deferred, are deferred until the end of the transaction (or sub-transaction) opened by the sqlite3changeset_apply(). A single call to the conflict-handler (if any) is made if any FK constraint violations are still present in the database at this point. The conflict-handler may choose to rollback the changeset, or to apply it, constraint violations and all.
FossilOrigin-Name: 1d44e5d3c2b1dc958442f9114a960b256e002ed3
2013-07-03 19:53:05 +00:00
dan 35e2858e98 Fixes for the sessions module so that it works with sqlite3_extended_error_codes() set.
FossilOrigin-Name: c2972b6aed23f6c76a289534de9ea4732a48f40e
2013-07-02 20:23:40 +00:00
drh fd64cedc4b Bring the sessions branch up-to-date with all the latest trunk changes.
FossilOrigin-Name: 086a127236ee99d67513490fb7b5549e8b752c44
2013-06-26 13:31:50 +00:00
drh 85b303df54 Update the sessions branch to the official 3.7.17 release code.
FossilOrigin-Name: fc88f7311ba888015634b89b5909890208f543f5
2013-05-20 13:01:19 +00:00
drh 466af9baae Update the sessions branch to the latest 3.7.17 beta.
FossilOrigin-Name: af8057ef5dcaa72dc0d2ab5d1553b06757449fa1
2013-05-17 10:58:08 +00:00
drh ad1818d9ed Update the sessions branch with the latest trunk changes.
FossilOrigin-Name: d09355050a74344c1cb6d303af9f601cd41e2368
2013-05-15 18:45:14 +00:00
drh 644abec3a4 Merge trunk changes into the sessions branch.
FossilOrigin-Name: 512f8a1ef8c4cf50723cfc4a78b7370dc37358d9
2013-05-09 23:40:58 +00:00
drh 2464dee6bc Merge all recent trunk changes into the sessions branch.
FossilOrigin-Name: ae6c4a0906ad8caabd8c605bb39c5fb979ab39a2
2013-05-08 18:50:04 +00:00
drh ec7ecb8c9a Merge all recent trunk changes into the sessions branch.
FossilOrigin-Name: 3879ab1b532828fcc12a50a95b6730faebcb69e9
2013-05-03 18:29:22 +00:00
drh 16fb176814 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 6994826c0784280f2e9728dfa4185848846d03df
2013-04-22 23:59:06 +00:00
drh 8bc8bfcb05 Fix the xCheckReservedLock() method on the windows VFS so that it cannot return a false positive when two or more processes use it at the same time on the same file. Ticket [7ff3120e4fa54abb55]. Update to version 3.7.16.2.
FossilOrigin-Name: 67b3c0efa7d5e0cb7cc0fc7606ab3f26ea5419fd
2013-04-12 13:53:50 +00:00
drh 226fb534dd Version 3.7.16.2
FossilOrigin-Name: cbea02d93865ce0e06789db95fd9168ebac970c7
2013-04-12 11:52:43 +00:00
drh 7f6e147a51 Increase the version number to 3.7.16.2 and cherrypick the
fix for ticket [7ff3120e4fa54abb55].  This check-in is a release
candidate.

FossilOrigin-Name: 86f26f9152988e47d7e1cfcca9eedf5e6265a225
2013-04-11 19:04:20 +00:00
mistachkin 73c4041b43 Correct minor typo in two regular expressions.
FossilOrigin-Name: f1eed92b7b0ef4ee22a11d8bb4f9a572b56ce019
2013-04-11 00:45:28 +00:00
drh eeeee7f55d Designate the beginning and the end of the sqlite3session.h file in the
constructed sqlite3.h file.

FossilOrigin-Name: 53f5be74327162a2bd25a91eaf7c91b126294727
2013-04-10 15:01:36 +00:00
drh 8dd661aad1 Merge the changes for the 3.7.16.1 release candidate into the sessions branch.
FossilOrigin-Name: ee35a89712b8ea9f4e70d61a29150348896b519f
2013-03-28 01:19:26 +00:00
drh 1ffe7c7fab Also export the sqlite3changeset interfaces in the amalgamated version of
the sessions extension.

FossilOrigin-Name: 5b399f2bc43612c52ea2289001d852d7ba6f9750
2013-03-19 17:10:10 +00:00
drh e191e2c6d0 Include the sqlite3session.h header file in with sqlite3.h. Make sure
the session APIs are all public.

FossilOrigin-Name: ec490336bc6629d3910667ece1bbc4685a199546
2013-03-19 15:23:18 +00:00
drh c03edc0b62 Adjust the MSVC makefile so that it correctly handles the sessions
extension being included in the amalgamation.  Import the test case
changes that appeared in 3.7.16 final.

FossilOrigin-Name: 9bac09a99aef5f18386037b409869d760c520d53
2013-03-18 16:24:33 +00:00
mistachkin 38b4daa122 Fix typos in MSVC makefile.
FossilOrigin-Name: 2d15c2685750b930c5b7e2f06cb056b24a037967
2013-03-13 19:02:39 +00:00
drh 8ce2b0956a Fix main.mk so that it builds the amalgamation correctly.
FossilOrigin-Name: 0b84e277245f10f928c010ea5958923681c6d582
2013-03-13 12:20:15 +00:00
drh 498dcae0f0 Fix a compiler warning in sqlite3VdbePreUpdateHook().
Add sqlite3session.c to the amalgamation.
Fix the Makefile.in to work with sessions.

FossilOrigin-Name: e54b0225f226a163ec874df7d4b738efba12b3a7
2013-03-13 11:42:00 +00:00
dan bfb5a031e5 Merge latest trunk changes into this branch.
FossilOrigin-Name: d6cd3c780c6bc718d37e0f0b884e3e9a423d57be
2013-03-13 06:34:51 +00:00
dan 1bc8b87e46 Merge recent changes to trunk into sessions branch.
FossilOrigin-Name: 62adb0e0d70e619becb68ffd2625d979bcc777cd
2013-03-12 11:38:59 +00:00
drh b05567ed4b Merge all the latest trunk changes into the sessions branch.
FossilOrigin-Name: d69d21903b883067c66dbcdefe6b369a6fe328b0
2013-03-06 02:12:18 +00:00
drh dab942860c Enhancements to the query planner to make use of indices for ORDER BY even
when IN constraints are in the WHERE clause.  Add extended error codes for
all SQLITE_CONSTRAINT errors.

FossilOrigin-Name: 7e14dc734d7d941da5c3aa6612e26d93b5b929bd
2013-02-13 13:42:50 +00:00
drh 3dbfbcf43e Enhancements to the query planner to exploit transitive relationships in the
WHERE clause, and other minor changes to bring the sessions branch into
alignment with the trunk.

FossilOrigin-Name: 82d3d1ae824e1fbc7958657be79231590ec17ace
2013-01-25 02:10:06 +00:00
drh e6dcfb85df Merge latest trunk changes into the sessions branch, especially the
ORDER BY bug fix of 3.7.15.2.

FossilOrigin-Name: 34af6fac679aeb18ab8349f74e95f3cb6e722ea4
2013-01-09 14:49:37 +00:00
drh 89ded43b36 Merge recent trunk changes into the sessions branch.
FossilOrigin-Name: 7e068e39b3b31364271664e0afb1cd95a235c26f
2013-01-03 22:22:55 +00:00
drh bd36911f4d Pull the latest trunk changes into the sessions branch, and in particular
the collating-sequence refactorization.

FossilOrigin-Name: 4f6d69ae94671df92b976525f75404c01270fef9
2012-12-08 23:37:22 +00:00
drh 26cd614dad Update the sessions branch to include the SQLLOG enhancement, the
SQLITE_IOERR_DELETE_NOENT fix, and a fix for the number-of-documents
bug in FTS4.

FossilOrigin-Name: ba8d08b67021a32fda069c18b7eb93523e6f0d1f
2012-11-27 21:56:28 +00:00
drh afe5b83dcd Merge the latest changes from trunk: chiefly the outer/inner loop query
optimizer scoring enhancement and the INSTR() function.

FossilOrigin-Name: 2993ca20207f8dac02f58d01e31d68c84328356a
2012-11-10 01:27:59 +00:00
drh 3dc2b9032f Pull all the latest trunk enhancements into the sessions branch.
FossilOrigin-Name: fce667f2d93a4ba65ccf1e748469576a3cd7ffcc
2012-10-30 21:03:48 +00:00
drh 036a71a97c Merge all the latest core changes into the sessions branch.
FossilOrigin-Name: 76767d651fe733614b1719aef9ad5ed4568234e4
2012-10-15 14:25:16 +00:00
drh d1102b1ec7 Merge the latest trunk changes, especially the ORDER BY optimizer enhancements
but also other fixes, onto the sessions branch.

FossilOrigin-Name: f1fbb8c5bfa84e84e0b8e2872d83b06a0c0d5acc
2012-10-09 14:58:15 +00:00
drh c4645dacfb Merge the latest trunk changes (especially "PRAGMA busy_timeout" and the
ORDER BY query planner optimizations) into the sessions branch.

FossilOrigin-Name: 6ca8eae1f89d19ee23cbc3a869d85b57d29b4a7d
2012-09-28 13:05:48 +00:00
drh 40eaa08620 Update the sessionfault-9.1 and -9.2 tests to account for the change in
version 3.7.11 in which a pending statement no longer blocks ROLLBACK but
instead causes the next call on that statement to return SQLITE_ABORT.

FossilOrigin-Name: fae9eb197fcef726fd2c7c701afe6805fc008cf9
2012-09-28 12:55:56 +00:00
dan 7417cefec6 Update with latest trunk changes.
FossilOrigin-Name: 87995dc9409482f0a7a367bfc51d78ac0f63b8c3
2012-08-31 14:23:16 +00:00
drh 310874ca00 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: aa62d6881b5aae64e15dbae70ce8e77bcc2a9f0b
2012-08-25 01:21:36 +00:00
drh 16de7f4d32 Merge all the latest trunk changes into the sessions branch.
FossilOrigin-Name: fc07a4795e027108674d1d41eb4350df629ddc8b
2012-08-15 16:21:55 +00:00
dan 618fea4830 Merge latest trunk changes with sessions branch.
FossilOrigin-Name: 47f8f0711d63ef4166db9115db44b166959df14c
2012-06-09 19:15:43 +00:00
drh 8973a04e3b Merge all trunk changes, including the WinRT enhancements, into the
sessions branch.

FossilOrigin-Name: c62140398344fd1a68a3e6dfe8b4fab280731ebb
2012-06-07 23:58:36 +00:00
drh c706edac44 Merge the 64-to-32-bit RTree rounding fixes from trunk into the sessions branch.
FossilOrigin-Name: 7eff45c28058fd1cb06dfd7f253cf2e4866e8c7c
2012-05-29 00:48:55 +00:00
drh 14bcd7d25e Merge the unicode61 tokenizer and the shared-cache-memory database changes
into the sessions branch.

FossilOrigin-Name: df817e70afc3f41e680d8f84dfa5772d5b3ae4d9
2012-05-28 18:22:41 +00:00
drh e56467fc9f Version 3.7.12.1
FossilOrigin-Name: d07b7b67d1b3bf65cfe8d96d45a7f1d387bea7ce
2012-05-22 13:01:39 +00:00
drh 7b9370a445 Version 3.7.12
FossilOrigin-Name: be71d2f6678c5dd8a165a67ef6d3f64678227260
2012-05-14 01:58:36 +00:00
dan 3581020e53 Update sessions branch with trunk changes.
FossilOrigin-Name: 3f4848a871a4229ff6951eefaf7673de46d2c43f
2012-05-12 11:50:41 +00:00
drh caee673b0d Merge in the windows AV-defense enhancements for open() and the table
constraint parser fixes for legacy schemas, all from trunk.

FossilOrigin-Name: 323570b8bd52c7e1b0c8c7a0e4f57f6fdebead11
2012-05-10 12:17:18 +00:00
drh 0d7706f41a Update the sessions branch with all the latest changes from trunk.
FossilOrigin-Name: 0f347fbfc7d8821f56f1ae0d1a9472a375631e65
2012-05-04 23:31:14 +00:00
drh efa50bdac1 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 2b7a91e61794ce9ffe210bad584454e52c79924e
2012-04-19 20:00:31 +00:00
drh bd91913dc0 Import all the latest trunk changes into the sessions branch.
FossilOrigin-Name: 87a0eab5d98fff93aa2147c04c4af27be42fb365
2012-04-18 01:41:37 +00:00
drh 108606837e Merge all recent trunk changes into the sessions branch.
FossilOrigin-Name: fb9b9987de965e194fef56bca563ee65c49f0950
2012-03-30 17:30:33 +00:00
dan 6d972c1b98 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 2277c70b6f14e2f8043112a5c49a8bc18b7504f3
2012-03-19 11:17:17 +00:00
drh ddf01aeb16 Merge in the latest trunk changes.
FossilOrigin-Name: ff86875ca35e04cea6c3d5e1b5117a4f227a6b15
2012-03-05 16:26:00 +00:00
drh fdf1795618 Pull all the latest trunk changes into the sessions branch.
FossilOrigin-Name: 361fb66a799f4f253e61ca94d999accde2c75b2c
2012-02-10 17:54:52 +00:00
mistachkin adb96a62e5 Support building with SQLITE_ENABLE_SESSION under MSVC.
FossilOrigin-Name: 2845654d425164de143e82b9fdb255d81a01af56
2012-01-16 12:33:36 +00:00
dan af49af7f9e Update sessions branch with latest changes from trunk.
FossilOrigin-Name: 01c84fd391a0ca1f5245c7eff0644d0cc6cff86b
2012-01-14 13:50:12 +00:00
drh 54cced185c Merge all of the latest trunk changes into the sessions branch.
FossilOrigin-Name: a9bcb432f58b96f079a73c456efd4851c582221e
2012-01-05 13:02:36 +00:00
drh f004e1d69e Merge in all changes found in the version 3.7.9 release candidate.
FossilOrigin-Name: 23580718e1c15ddb89682d0e7566da4d7276bfe9
2011-10-31 14:34:31 +00:00
drh efb1ca3738 Merge the latest trunk enhancements into the sessions branch.
FossilOrigin-Name: 8baef58170ff851d0c4387a6888f59b487b4f33c
2011-10-21 17:08:23 +00:00
drh 29c21c77af Merge all the latest trunk changes into the sessions branch - especially
the SQLITE_ENABLE_STAT3 enhancements.

FossilOrigin-Name: 403431cac6b039b0693915c5422f08dc60dae230
2011-10-11 12:58:38 +00:00
drh 946e610a84 Merge in all trunk changes through the version 3.7.8 release.
FossilOrigin-Name: 98619a23fd11a5eb319687adfdacc91ff2db896c
2011-09-19 20:28:07 +00:00
drh 063d96fc18 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 5efb02949dbeabccfe1d848d275529f03f3dfc84
2011-09-16 19:40:24 +00:00
dan 93bca69578 Merge latest changes from the trunk into the sessions branch.
FossilOrigin-Name: c00e45ede7cbf71a3a6d1ccad0b9275010ca8493
2011-09-14 19:41:44 +00:00
drh 7cca2e6259 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: eb036d6f81e15bac013316bf5b1b2ba3e0bd4605
2011-08-26 19:20:47 +00:00
drh 0e9a916c36 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: c5709036087b6b4fb6391ab7e4b4b870aac87a31
2011-08-03 21:46:58 +00:00
drh 7f197bb7b0 Avoid segfaulting on an incremental blob write if SQLITE_ENABLE_PREUPDATE_HOOK
set but no pre-update hooks are defined.

FossilOrigin-Name: 62c446340475b52b843c0345eda32ebe86fa9159
2011-08-03 21:32:11 +00:00
dan 964cbd469b Fix errors in a comment in sqlite3session.c. No changes to code.
FossilOrigin-Name: d5f4c4c0bf0d488db11c6ab0d26ca3554a57d0ff
2011-07-26 17:53:53 +00:00
dan 1e556c3fe5 Fix a test case in sessionfault.test. No changes to code.
FossilOrigin-Name: dc6ecacd7724089a0387e69a0fd5cdbfdd2023f8
2011-07-26 15:57:56 +00:00
dan cfec7eee20 Fix a problem causing sqlite3changeset_invert() to effectively drop UPDATE changes.
FossilOrigin-Name: bb3e65d9724dcecdc54b4c9fb0448f95d14495ff
2011-07-26 15:50:36 +00:00
drh 8a3bb3fddd Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 110cfd6920cf3011aeaf7e586f8db867bfc69fbb
2011-07-22 12:49:27 +00:00
dan ff53032641 Fix the sqlite3session_isempty() method so that it returns, as documented, non-zero when no changes have been recorded by the session object.
FossilOrigin-Name: d04e0fd82a15aee963e35830caf8159b4b6ccd87
2011-07-18 15:22:56 +00:00
dan a93166e030 Fix error in a comment in sqlite3session.h. No changes to code.
FossilOrigin-Name: 70c84e50209722a61d66fd737e42d49275745b62
2011-07-16 18:35:53 +00:00
dan b69ec3482a Note in the documentation that when iterating through a changeset, all changes to a single table are grouped together. Also add the sqlite3session_isempty() function.
FossilOrigin-Name: 364f3b820a26f9b15cf74a0222ed5e302becc54f
2011-07-16 18:05:07 +00:00
dan 4f52804206 Add a few casts required by 64-bit VS2010 to the sessions code.
FossilOrigin-Name: 5ac4a06111b5fad5f58c20ef5d2b65aeb23e105a
2011-07-15 19:11:32 +00:00
dan 40368988da Add the xFilter callback to the sqlite3changeset_apply() function. This callback allows the application to accept or reject changes on a per-table basis when applying a changeset.
FossilOrigin-Name: 282474c42f24f0e66c69b576b72ef8ce764d49e2
2011-07-13 15:21:02 +00:00
dan e437ca5ec0 Modifications so that the sessions extension works with blob handles.
FossilOrigin-Name: 82ac16c4f873d3bd7c22f36ba7b974b4903a2d50
2011-07-11 19:45:38 +00:00
drh 88ab69f614 Pull the latest version 3.7.7 release-candidate changes into the
sessions branch.

FossilOrigin-Name: 840bf9c2d92192ee3cc2aa7c0e9bdb805a066fd4
2011-06-23 17:40:15 +00:00
drh 893ab7ccba Pull the latest trunk changes into the sessions branch.
FossilOrigin-Name: 5d95b42946b5cf0346164aebe0a8c4f37527bc31
2011-06-23 02:11:11 +00:00
dan 53ae686bfb Update sessions branch with latest trunk changes.
FossilOrigin-Name: 48d5cab3ac08b25ec94d6ecfd25779320558110f
2011-06-22 12:01:08 +00:00
drh 34ffcfff02 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: f3d148e0d10e16cd744ec88a2961fd617368c5ed
2011-06-21 01:29:16 +00:00
dan 467eb01caa (no comment)
FossilOrigin-Name: 699b884383f735fb9630d87d25dab61c97dc4485
2011-06-20 11:17:11 +00:00
drh 8863f35f5c Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 4c5e276c902e0b93cfc05bf2e1db966ecdac0ed0
2011-06-20 10:44:10 +00:00
drh bf0ed47d82 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 832886b1e6edb916d9824924c7d88202f4eb1969
2011-05-30 13:39:20 +00:00
drh 4ec233f12a Merge all the latest trunk changes into the sessions branch, especially
the disappearing WAL transaction fix.

FossilOrigin-Name: 5b1b536cf828850d0e8ac2ab08e8696082715877
2011-05-19 02:48:46 +00:00
drh 0576a30dad Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 6883580e6c8973010a42d1d2c5bde04c6b2f4eb7
2011-05-05 15:46:16 +00:00
dan 23328bedf0 Merge trunk changes into sessions branch.
FossilOrigin-Name: b91b4c31fe311b292044c9c747feba294ffce25c
2011-04-18 17:30:56 +00:00
dan 77fc1d5bb4 Fix further missing comments and other minor issues in the session module code.
FossilOrigin-Name: 99f0f35092b0b78b7016b21c242da263ab64b77b
2011-04-18 15:47:08 +00:00
dan 798693b2b1 Fix some missing comments and other issues with session module code.
FossilOrigin-Name: 20d7c280235201e519f296372f269e7cecda24da
2011-04-18 12:05:03 +00:00
dan 80fe2d9310 Further coverage tests for the session module.
FossilOrigin-Name: 69a01c708bf044eacf21a8951fe9e7d9fb4332c5
2011-04-18 07:36:27 +00:00
dan 6734007d75 Improve test coverage of session module.
FossilOrigin-Name: f46d4b641d613c39a80b12106e6a6ac0efc8be83
2011-04-16 19:23:10 +00:00
dan b08a1efae5 Improve coverage of session module.
FossilOrigin-Name: 3dfd1d63bddfa9bd9018eb00bee1d496379630b5
2011-04-15 19:18:57 +00:00
dan 1756ae10e1 Add tests and fixes for OOM handling in sqlite3changeset_concat().
FossilOrigin-Name: df0b2d21dcd81679e55b24866f97568019932983
2011-04-15 16:03:32 +00:00
dan f29123b572 Have sqlite3changeset_concat() return SQLITE_SCHEMA if an attempt is made to concatenate changesets based on incompatible database schemas.
FossilOrigin-Name: 343b64517d244b75097e38342dc273eb5a52915b
2011-04-15 15:04:31 +00:00
dan 29e03e977c Add documentation for sqlite3changeset_concat() to sqlite3session.h.
FossilOrigin-Name: ada9efa53a6ea55f89d237cfd530f1d180343e19
2011-04-15 12:04:50 +00:00
dan 6cda207f5f Add further tests for the sqlite3changeset_concat() function. Also fixes.
FossilOrigin-Name: 1fc3f15d88c160b45642b46d1d54c591af058ba2
2011-04-14 18:01:41 +00:00
dan 5d607a6e06 Start adding the sqlite3changeset_concat() function to the session module.
FossilOrigin-Name: 8927b2260b8d84f53776cb29e1d2fa41b6b0de0e
2011-04-14 11:16:21 +00:00
drh 9e3fbc0157 Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 83705e90a54bad462a5b7fbca70cc129998f871c
2011-04-09 18:07:51 +00:00
drh 36828bd9bb Add a missing "extern C" terminator to the end of sqlite3session.h.
FossilOrigin-Name: 29090b695a95feaba1b74f9894997083a060263a
2011-04-06 23:40:28 +00:00
drh cfdbde214b Fix VC++ compiler warnings.
FossilOrigin-Name: 7b7c8d366c51e89aefc6efc9dcffe3f62c7e1d25
2011-04-06 23:39:28 +00:00
drh 22e9c155ae Merge in the latest changes from the trunk.
FossilOrigin-Name: 435b57dc2be7b071270a6cddece297758b8153aa
2011-04-06 22:33:50 +00:00
drh d7162fa64e Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: 45f20261720dcd73eb887f7e3df100723000418b
2011-04-05 22:13:49 +00:00
drh c94f31236e Pull the latest trunk changes (and hence the schema-parse-refactor changes)
into the sessions branch.

FossilOrigin-Name: 03ca83422f0259ae5525aeecc14171811252a67d
2011-04-05 13:27:30 +00:00
drh b92fce1eae Merge the latest changes of trunk into the session branch.
FossilOrigin-Name: 95d53c44320b9639f2623aa9cc88d0d3e1a3be8f
2011-04-04 13:19:36 +00:00
dan 3d06237770 Merge latest trunk changes.
FossilOrigin-Name: d184cf00574b52b93f1f089025d6a0addca57558
2011-04-01 15:43:40 +00:00
dan 5d8a298495 If the sessions module is being built as part of the amalgamation, do not try to include sqliteInt.h and vdbeInt.h.
FossilOrigin-Name: f87bfe6e12093e5958b658a49d3766fb29562cbb
2011-04-01 15:30:39 +00:00
drh 9b1c62d416 Add the SQLITE_ENABLE_PREUPDATE_HOOK compile-time option.
FossilOrigin-Name: 6634521461e6acff7cc778590e62d57831f9230d
2011-03-30 21:04:43 +00:00
drh 67c495ac20 Disable the truncate optimization if there is a preupdate hook.
FossilOrigin-Name: d051694e024c590e4687cae1368f900799b7442d
2011-03-30 17:25:35 +00:00
drh 930e1b6a5d Add documentation to the sqlite3_preupdate_hook() interface and its relatives.
FossilOrigin-Name: 8180f2881fa970429e28d4f3258a56cfaabbcabd
2011-03-30 17:07:47 +00:00
drh 5847b5f9c3 Merge in all the latest changes from trunk.
FossilOrigin-Name: b11d941e92897663da46160185e6e305d4e28fe6
2011-03-30 02:03:12 +00:00
dan e5754eec26 Improve coverage of session module a bit more.
FossilOrigin-Name: 4255a9f609c4fd43582a0874143eabe211199726
2011-03-25 19:06:09 +00:00
dan f51e5f6c99 Improve coverage of session module code.
FossilOrigin-Name: 666123c8d07be87d477e67b1cebef2b0fba5b4bc
2011-03-25 10:52:01 +00:00
dan a9605b9125 Fix handling of schema changes mid-session.
FossilOrigin-Name: 76d2d2ad3b2a5171393b7894f35f463ff284e53b
2011-03-24 16:53:57 +00:00
dan ca62ad57f0 Fix handling of schema mismatches in sqlite3session.c so that it matches the docs in sqlite3session.h.
FossilOrigin-Name: 506a0d7a710e1ff2f367821e73f5080fcf63fbc5
2011-03-24 16:04:54 +00:00
dan 244593c846 Store primary key definitions for modified tables in changesets. Add the sqlite3changeset_pk() API to extract this data from a changeset iterator.
FossilOrigin-Name: 54298ee5ed183d1f1c49524f25e8ae1407f3d4b5
2011-03-24 11:22:59 +00:00
drh 9a48bf528d Merge in all the latest changes from the trunk, and especially the interface
changes to the SystemCall methods of the VFS.

FossilOrigin-Name: 9c3a6e479988e96086bef00c79dbce508a14da0d
2011-03-23 22:48:46 +00:00
dan b4480e942f Add the "indirect flag" to the changeset blob format. Also the sqlite3session_indirect() API.
FossilOrigin-Name: 1feaf2d35fd9ec777319717ae2c2929d66fe7baa
2011-03-23 16:03:11 +00:00
dan 1e7a2d4315 Add API function sqlite3_preupdate_depth(), for determining the depth of the trigger stack from within a pre-update callback.
FossilOrigin-Name: bdea70895c2c686a4dd3f4bf0a475fd1501d9551
2011-03-22 18:45:29 +00:00
dan 245b49b203 Fix a crash that can follow an OOM when "all tables" are registered with a session module.
FossilOrigin-Name: 183c236e991faaabdc768e52e926c52cf4a7abc9
2011-03-22 16:54:12 +00:00
dan ff4d0f41bb If a NULL pointer is passed to sqlite3session_attach() in place of a table name, attach all database tables to the session object.
FossilOrigin-Name: e9037e4e4ccaa5c633759c4d041b60b631b92c6c
2011-03-22 15:21:03 +00:00
dan 7aa469cdd3 Add OOM tests and related fixes for the session module.
FossilOrigin-Name: 06048a68b351e3eb15a890cb54db8a1d4b345fbc
2011-03-22 12:08:00 +00:00
shaneh 157546f4df Fix a couple typos for consistency in sessions documentation.
FossilOrigin-Name: 510198f171b9f77a4ad49c06c978c5fbb3a5b7f9
2011-03-22 02:03:23 +00:00
dan db04571c79 Remove some unreachable code in sqlite3session.c. Add test cases.
FossilOrigin-Name: 39cdfa5324ae91bfbbac733b1e3e2d33ca883340
2011-03-21 19:41:29 +00:00
drh 8cc9c1aa15 Merge in the sqlite3_db_config() enhancements for enabling and disabling
FKs and triggers from trunk.

FossilOrigin-Name: 2b3c8b9d9aa909f64a29ed8167de24c328c50d85
2011-03-21 17:17:49 +00:00
dan 12ca0b5695 Add start of fault-injection tests for session module. Fix some bugs related to the same.
FossilOrigin-Name: 32e95164d1192b87b1ab019549fd2394642cd3fe
2011-03-21 16:17:42 +00:00
dan 27453faef8 Clarify handling of NULL values in PK columns in sqlite3session.h. Add tests and fixes for the same.
FossilOrigin-Name: aed4273054cbd150c86b36ea951d17c981633ba0
2011-03-21 11:55:06 +00:00
dan 4e895da185 Fix session module problems with real (floating point) values.
FossilOrigin-Name: a192d04f4e3a9e4960a4d96d1d3ee8635bc1034d
2011-03-21 11:03:24 +00:00
dan 77e6500473 Fix some typos in sqlite3session.h.
FossilOrigin-Name: 0853e530cc8d96f025f5160540e8ab3243dea11b
2011-03-21 07:23:09 +00:00
dan a2df3d9f95 Documentation format updates to sqlite3session.h.
FossilOrigin-Name: f227f60210fba3930f3050aebb1facee8bac9c0b
2011-03-20 11:20:41 +00:00
dan d7fb7d24c6 Fix a problem involving session objects and attached databases.
FossilOrigin-Name: ad91d30073a8faa7eb064dd2e1cc4d2297d7b3f8
2011-03-19 19:19:26 +00:00
dan 1f34f8cc71 Fix a bug in changeset generation code.
FossilOrigin-Name: 825df75ba453c853953e17ec29653e11c46f92bb
2011-03-19 18:46:15 +00:00
dan 4565faa990 Move session1.test from test/ to ext/session/.
FossilOrigin-Name: c4436a936ab302aec3b7f41a4552f69ad5815744
2011-03-19 17:07:57 +00:00
dan 4131639c63 Fix a problem with resizing a hash table in sqlite3session.c.
FossilOrigin-Name: 6e5907e14d3316d56313243c4f8ce8f14d0858fc
2011-03-19 16:26:11 +00:00
dan 7cf7df7d35 Fix some bugs in sqlite3changeset_apply().
FossilOrigin-Name: 7250318dda542c5bbf28852c1f1d0f3c52ae8f96
2011-03-19 15:37:02 +00:00
dan 319eeb7b33 Fix a problem with INTEGER PRIMARY KEY columns and the pre-update hook.
FossilOrigin-Name: 24d4d5dd007197a141555bcca6f2ac9ab47cde80
2011-03-19 08:38:50 +00:00
drh 516ae18005 Merge the fix to ticket [f7b4edece25c99485] into the sessions branch.
FossilOrigin-Name: 1b736ac2934f2361dee5062e9033cbf26b41fc3a
2011-03-19 02:37:38 +00:00
dan 4c22025225 Hold the database mutex for the duration of an sqlite3changeset_apply() call. Also for the duration of all sqlite3session_xxx() calls.
FossilOrigin-Name: c615c38c3283e21c33550c093099a793761123a7
2011-03-18 18:03:13 +00:00
drh 304637c026 Fixes for compiler warnings. Minor code cleanup.
FossilOrigin-Name: 9604d13001e0a195718c7f03fc0e73e352226caa
2011-03-18 16:47:27 +00:00
dan 2635a3be20 Further improvements to documentation in sqlite3session.h.
FossilOrigin-Name: 07019bb9e8d8f2445d1e0342f74ab520e9804cb5
2011-03-18 16:13:53 +00:00
drh ea022cffdd Fix a memory allocation issues in the preupdate hook so that the hook.test
script runs clean in valgrind.

FossilOrigin-Name: bd94f4c8b1c4590c437030f0122015f1a37e2582
2011-03-18 15:13:31 +00:00
dan c21111daff Update comments in sqlite3session.h. More to come.
FossilOrigin-Name: e73e9082f3b14088752717193a10dd7657deb8af
2011-03-18 13:05:15 +00:00
drh 0639c34ecd Merge all the latest trunk enhancements into the sessions branch.
FossilOrigin-Name: 94fd5bb6da5ef4d850c2ed4ad38afabc5569dae6
2011-03-18 12:35:36 +00:00
dan e8d5648e16 Change to the session module to use user-defined primary keys instead of rowids when collecting changes.
FossilOrigin-Name: 6614cfcb9c41da71ddec3c44a3de0d4d849e1cdd
2011-03-17 19:20:27 +00:00
dan 37db03bf73 Add the sqlite3_preupdate_new() API, for retrieving the new.* values from within a pre-update callback.
FossilOrigin-Name: 526545c49f64d9063d1b888cfc14ece62fa3c13c
2011-03-16 19:59:18 +00:00
dan 6566ebe1b6 Remove the sqlite3_transaction_hook() API.
FossilOrigin-Name: b0015a1cfe63c924ee5f250aa08460522882009b
2011-03-16 09:49:14 +00:00
dan 296c76589f Fix some bugs and other code issues in the session module.
FossilOrigin-Name: f2930840e4af3d7d9cb199d316502932fcbbb867
2011-03-15 16:37:27 +00:00
dan 0c698471d1 Fix handling of return values from the conflict handler. Document the conflict handler arguments and return codes in sqlite3session.h.
FossilOrigin-Name: cbbb274e500237dbf7155a51d4f9c17583d704ea
2011-03-14 19:49:23 +00:00
dan 37f133ec31 Fix some issues with UPDATE changes in the session module.
FossilOrigin-Name: 57862efe718fdc93401998f9058511292a0e1a50
2011-03-12 17:22:46 +00:00
dan d5f0767c9c Add the sqlite3changeset_apply() function. Does not yet handle all cases.
FossilOrigin-Name: 2b19be7bf753c7dd12e1c3b384981a3ea1bc8145
2011-03-11 19:05:52 +00:00
dan 91ddd5595b Add a function to the session extension invert a changeset.
FossilOrigin-Name: 75d5dff725dbb66d67d56ad042926f1daae56dbe
2011-03-09 11:17:05 +00:00
dan 4fccf43aae Add start of sessions feature.
FossilOrigin-Name: 269a81a37d7dbdcdec3c2322074916af0fbac91c
2011-03-08 19:22:50 +00:00
dan 21e8d0126d Add the experimental sqlite3_transaction_hook() API.
FossilOrigin-Name: 093d8cd8e2f3a6af5d40cf810e396f4919eb5cef
2011-03-03 20:05:59 +00:00
dan 46c47d4677 Add the experimental sqlite3_preupdate_hook() API.
FossilOrigin-Name: 6145d7b89f83500318713779c60f79a7ab2098ba
2011-03-01 18:42:07 +00:00
91 changed files with 14355 additions and 601 deletions
+21 -8
View File
@@ -30,7 +30,8 @@ BCC = @BUILD_CC@ @BUILD_CFLAGS@
#
CC = @CC@
CFLAGS = @CPPFLAGS@ @CFLAGS@
TCC = $(CC) $(CFLAGS) -I. -I${TOP}/src -I${TOP}/ext/rtree -I${TOP}/ext/fts3
TCC = ${CC} ${CFLAGS} -I. -I${TOP}/src -I${TOP}/ext/rtree -I${TOP}/ext/icu
TCC += -I${TOP}/ext/fts3 -I${TOP}/ext/async -I${TOP}/ext/session
# Define this for the autoconf-based build, so that the code knows it can
# include the generated config.h
@@ -81,6 +82,7 @@ TEMP_STORE = -DSQLITE_TEMP_STORE=@TEMP_STORE@
# The same set of OMIT and ENABLE flags should be passed to the
# LEMON parser generator and the mkkeywordhash tool as well.
OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@
OPT_FEATURE_FLAGS += -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK
TCC += $(OPT_FEATURE_FLAGS)
@@ -179,7 +181,8 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
random.lo resolve.lo rowset.lo rtree.lo select.lo sqlite3rbu.lo status.lo \
random.lo resolve.lo rowset.lo rtree.lo \
sqlite3session.lo select.lo sqlite3rbu.lo status.lo \
table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
update.lo util.lo vacuum.lo \
vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
@@ -341,14 +344,15 @@ SRC += \
SRC += \
$(TOP)/ext/rtree/rtree.h \
$(TOP)/ext/rtree/rtree.c
SRC += \
$(TOP)/ext/session/sqlite3session.c \
$(TOP)/ext/session/sqlite3session.h
SRC += \
$(TOP)/ext/rbu/sqlite3rbu.h \
$(TOP)/ext/rbu/sqlite3rbu.c
SRC += \
$(TOP)/ext/misc/json1.c
# Generated source code files
#
SRC += \
@@ -405,7 +409,8 @@ TESTSRC = \
$(TOP)/src/test_windirent.c \
$(TOP)/src/test_wsd.c \
$(TOP)/ext/fts3/fts3_term.c \
$(TOP)/ext/fts3/fts3_test.c \
$(TOP)/ext/fts3/fts3_test.c \
$(TOP)/ext/session/test_session.c \
$(TOP)/ext/rbu/test_rbu.c
# Statically linked extensions
@@ -474,7 +479,8 @@ TESTSRC2 = \
$(TOP)/ext/fts3/fts3_term.c \
$(TOP)/ext/fts3/fts3_tokenizer.c \
$(TOP)/ext/fts3/fts3_write.c \
$(TOP)/ext/async/sqlite3async.c
$(TOP)/ext/async/sqlite3async.c \
$(TOP)/ext/session/sqlite3session.c
# Header files used by all library source files.
#
@@ -634,6 +640,7 @@ mptest: mptester$(TEXE)
sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl
$(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl
cp tsrc/shell.c tsrc/sqlite3ext.h .
cp $(TOP)/ext/session/sqlite3session.h .
sqlite3ext.h: .target_source
cp tsrc/sqlite3ext.h .
@@ -997,6 +1004,9 @@ fts3_write.lo: $(TOP)/ext/fts3/fts3_write.c $(HDR) $(EXTHDR)
rtree.lo: $(TOP)/ext/rtree/rtree.c $(HDR) $(EXTHDR)
$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rtree/rtree.c
sqlite3session.lo: $(TOP)/ext/session/sqlite3session.c $(HDR) $(EXTHDR)
$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/session/sqlite3session.c
json1.lo: $(TOP)/ext/misc/json1.c
$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/misc/json1.c
@@ -1129,6 +1139,9 @@ showjournal$(TEXE): $(TOP)/tool/showjournal.c sqlite3.lo
showwal$(TEXE): $(TOP)/tool/showwal.c sqlite3.lo
$(LTLINK) -o $@ $(TOP)/tool/showwal.c sqlite3.lo $(TLIBS)
changeset$(TEXE): $(TOP)/ext/session/changeset.c sqlite3.lo
$(LTLINK) -o $@ $(TOP)/ext/session/changeset.c sqlite3.lo $(TLIBS)
rollback-test$(TEXE): $(TOP)/tool/rollback-test.c sqlite3.lo
$(LTLINK) -o $@ $(TOP)/tool/rollback-test.c sqlite3.lo $(TLIBS)
@@ -1152,7 +1165,7 @@ loadfts$(EXE): $(TOP)/tool/loadfts.c libsqlite3.la
# releasetest.tcl script.
#
checksymbols: sqlite3.lo
nm -g --defined-only sqlite3.o | grep -v " sqlite3_" ; test $$? -ne 0
nm -g --defined-only sqlite3.o | egrep -v ' sqlite3(changeset|session)?_' ; test $$? -ne 0
echo '0 errors out of 1 tests'
# Build the amalgamation-autoconf package. The amalamgation-tarball target builds
@@ -1221,7 +1234,7 @@ clean:
rm -f testfixture$(TEXE) test.db
rm -f LogEst$(TEXE) fts3view$(TEXE) rollback-test$(TEXE) showdb$(TEXE)
rm -f showjournal$(TEXE) showstat4$(TEXE) showwal$(TEXE) speedtest1$(TEXE)
rm -f wordcount$(TEXE)
rm -f wordcount$(TEXE) changeset$(TEXE)
rm -f sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def
rm -f sqlite3.c
rm -f sqlite3rc.h
+24 -4
View File
@@ -264,6 +264,8 @@ SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
!ENDIF
# These are the "extended" SQLite compilation options used when compiling for
@@ -607,6 +609,8 @@ TCC = $(TCC) -I$(TOP)\ext\fts3
RCC = $(RCC) -I$(TOP)\ext\fts3
TCC = $(TCC) -I$(TOP)\ext\rtree
RCC = $(RCC) -I$(TOP)\ext\rtree
TCC = $(TCC) -I$(TOP)\ext\session
RCC = $(RCC) -I$(TOP)\ext\session
!ENDIF
# The mksqlite3c.tcl script accepts some options on the command
@@ -991,7 +995,8 @@ LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \
mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
pager.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
random.lo resolve.lo rowset.lo rtree.lo select.lo sqlite3rbu.lo status.lo \
random.lo resolve.lo rowset.lo rtree.lo \
sqlite3session.lo select.lo sqlite3rbu.lo status.lo \
table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
update.lo util.lo vacuum.lo \
vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
@@ -1178,6 +1183,7 @@ SRC07 = \
$(TOP)\ext\fts3\fts3_write.c \
$(TOP)\ext\icu\icu.c \
$(TOP)\ext\rtree\rtree.c \
$(TOP)\ext\session\sqlite3session.c \
$(TOP)\ext\rbu\sqlite3rbu.c \
$(TOP)\ext\misc\json1.c
@@ -1200,7 +1206,8 @@ SRC09 = \
$(TOP)\ext\fts3\fts3_tokenizer.h \
$(TOP)\ext\icu\sqliteicu.h \
$(TOP)\ext\rtree\rtree.h \
$(TOP)\ext\rbu\sqlite3rbu.h
$(TOP)\ext\rbu\sqlite3rbu.h \
$(TOP)\ext\session\sqlite3session.h
# Generated source code files
#
@@ -1266,7 +1273,8 @@ TESTSRC = \
$(TOP)\src\test_wsd.c \
$(TOP)\ext\fts3\fts3_term.c \
$(TOP)\ext\fts3\fts3_test.c \
$(TOP)\ext\rbu\test_rbu.c
$(TOP)\ext\rbu\test_rbu.c \
$(TOP)\ext\session\test_session.c
# Statically linked extensions.
#
@@ -1289,6 +1297,7 @@ TESTEXT = \
$(TOP)\ext\misc\wholenumber.c
# Source code to the library files needed by the test fixture
# (non-amalgamation)
#
TESTSRC2 = \
$(SRC00) \
@@ -1347,6 +1356,8 @@ EXTHDR = $(EXTHDR) \
$(TOP)\ext\icu\sqliteicu.h
EXTHDR = $(EXTHDR) \
$(TOP)\ext\rtree\sqlite3rtree.h
EXTHDR = $(EXTHDR) \
$(TOP)\ext\session\sqlite3session.h
# executables needed for testing
#
@@ -1492,6 +1503,7 @@ mptest: mptester.exe
sqlite3.c: .target_source sqlite3ext.h $(TOP)\tool\mksqlite3c.tcl
$(TCLSH_CMD) $(TOP)\tool\mksqlite3c.tcl $(MKSQLITE3C_ARGS)
copy tsrc\shell.c .
copy $(TOP)\ext\session\sqlite3session.h .
sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl
$(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl
@@ -1870,6 +1882,9 @@ fts3_write.lo: $(TOP)\ext\fts3\fts3_write.c $(HDR) $(EXTHDR)
rtree.lo: $(TOP)\ext\rtree\rtree.c $(HDR) $(EXTHDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) $(NO_WARN) -DSQLITE_CORE -c $(TOP)\ext\rtree\rtree.c
sqlite3session.lo: $(TOP)\ext\session\sqlite3sesion.c $(HDR) $(EXTHDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) $(NO_WARN) -DSQLITE_CORE -c $(TOP)\ext\session\sqlite3session.c
# FTS5 things
#
FTS5_SRC = \
@@ -2017,6 +2032,10 @@ showwal.exe: $(TOP)\tool\showwal.c $(SQLITE3C) $(SQLITE3H)
$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
$(TOP)\tool\showwal.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
changeset.exe: $(TOP)\ext\session\changeset.c $(SQLITE3C)
$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
$(TOP)\ext\session\changeset.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
fts3view.exe: $(TOP)\ext\fts3\tool\fts3view.c $(SQLITE3C) $(SQLITE3H)
$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
$(TOP)\ext\fts3\tool\fts3view.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
@@ -2065,11 +2084,12 @@ clean:
del /Q testloadext.dll 2>NUL
del /Q testfixture.exe test.db 2>NUL
del /Q LogEst.exe fts3view.exe rollback-test.exe showdb.exe 2>NUL
del /Q changeset.exe 2>NUL
del /Q showjournal.exe showstat4.exe showwal.exe speedtest1.exe 2>NUL
del /Q mptester.exe wordcount.exe rbu.exe srcck1.exe 2>NUL
del /Q sqlite3.c sqlite3-*.c 2>NUL
del /Q sqlite3rc.h 2>NUL
del /Q shell.c sqlite3ext.h 2>NUL
del /Q shell.c sqlite3ext.h sqlite3session.h 2>NUL
del /Q sqlite3_analyzer.exe sqlite3_analyzer.c 2>NUL
del /Q sqlite-*-output.vsix 2>NUL
del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe 2>NUL
+1 -1
View File
@@ -1 +1 @@
3.12.0
3.13.0
+2
View File
@@ -249,6 +249,8 @@ SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
!ENDIF
# These are the "extended" SQLite compilation options used when compiling for
Vendored
+9 -9
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for sqlite 3.12.0.
# Generated by GNU Autoconf 2.69 for sqlite 3.13.0.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -726,8 +726,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='sqlite'
PACKAGE_TARNAME='sqlite'
PACKAGE_VERSION='3.12.0'
PACKAGE_STRING='sqlite 3.12.0'
PACKAGE_VERSION='3.13.0'
PACKAGE_STRING='sqlite 3.13.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1460,7 +1460,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures sqlite 3.12.0 to adapt to many kinds of systems.
\`configure' configures sqlite 3.13.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1525,7 +1525,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of sqlite 3.12.0:";;
short | recursive ) echo "Configuration of sqlite 3.13.0:";;
esac
cat <<\_ACEOF
@@ -1646,7 +1646,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
sqlite configure 3.12.0
sqlite configure 3.13.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2065,7 +2065,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by sqlite $as_me 3.12.0, which was
It was created by sqlite $as_me 3.13.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -12079,7 +12079,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by sqlite $as_me 3.12.0, which was
This file was extended by sqlite $as_me 3.13.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12145,7 +12145,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
sqlite config.status 3.12.0
sqlite config.status 3.13.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
+6
View File
@@ -47,6 +47,10 @@ typedef sqlite3_uint64 u64;
#endif
/* Truncate very long tokens to this many bytes. Hard limit is
** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset
** field that occurs at the start of each leaf page (see fts5_index.c). */
#define FTS5_MAX_TOKEN_SIZE 32768
/*
** Maximum number of prefix indexes on single FTS5 table. This must be
@@ -480,6 +484,7 @@ int sqlite3Fts5IndexReads(Fts5Index *p);
int sqlite3Fts5IndexReinit(Fts5Index *p);
int sqlite3Fts5IndexOptimize(Fts5Index *p);
int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge);
int sqlite3Fts5IndexReset(Fts5Index *p);
int sqlite3Fts5IndexLoadConfig(Fts5Index *p);
@@ -622,6 +627,7 @@ int sqlite3Fts5StorageDeleteAll(Fts5Storage *p);
int sqlite3Fts5StorageRebuild(Fts5Storage *p);
int sqlite3Fts5StorageOptimize(Fts5Storage *p);
int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge);
int sqlite3Fts5StorageReset(Fts5Storage *p);
/*
** End of interface to code in fts5_storage.c.
+2
View File
@@ -1493,6 +1493,7 @@ static int fts5ParseTokenize(
/* If an error has already occurred, this is a no-op */
if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;
if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;
if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){
Fts5ExprTerm *pSyn;
@@ -2495,6 +2496,7 @@ static int fts5ExprPopulatePoslistsCb(
UNUSED_PARAM2(iUnused1, iUnused2);
if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;
if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++;
for(i=0; i<pExpr->nPhrase; i++){
Fts5ExprTerm *pTerm;
+137 -30
View File
@@ -304,6 +304,10 @@ struct Fts5Index {
sqlite3_stmt *pIdxDeleter; /* "DELETE FROM %_idx WHERE segid=? */
sqlite3_stmt *pIdxSelect;
int nRead; /* Total number of blocks read */
sqlite3_stmt *pDataVersion;
i64 iStructVersion; /* data_version when pStruct read */
Fts5Structure *pStruct; /* Current db structure (or NULL) */
};
struct Fts5DoclistIter {
@@ -959,6 +963,50 @@ static void fts5StructureExtendLevel(
}
}
static Fts5Structure *fts5StructureReadUncached(Fts5Index *p){
Fts5Structure *pRet = 0;
Fts5Config *pConfig = p->pConfig;
int iCookie; /* Configuration cookie */
Fts5Data *pData;
pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);
if( p->rc==SQLITE_OK ){
/* TODO: Do we need this if the leaf-index is appended? Probably... */
memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);
p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);
if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){
p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);
}
fts5DataRelease(pData);
if( p->rc!=SQLITE_OK ){
fts5StructureRelease(pRet);
pRet = 0;
}
}
return pRet;
}
static i64 fts5IndexDataVersion(Fts5Index *p){
i64 iVersion = 0;
if( p->rc==SQLITE_OK ){
if( p->pDataVersion==0 ){
p->rc = fts5IndexPrepareStmt(p, &p->pDataVersion,
sqlite3_mprintf("PRAGMA %Q.data_version", p->pConfig->zDb)
);
if( p->rc ) return 0;
}
if( SQLITE_ROW==sqlite3_step(p->pDataVersion) ){
iVersion = sqlite3_column_int64(p->pDataVersion, 0);
}
p->rc = sqlite3_reset(p->pDataVersion);
}
return iVersion;
}
/*
** Read, deserialize and return the structure record.
**
@@ -971,26 +1019,49 @@ static void fts5StructureExtendLevel(
** is called, it is a no-op.
*/
static Fts5Structure *fts5StructureRead(Fts5Index *p){
Fts5Config *pConfig = p->pConfig;
Fts5Structure *pRet = 0; /* Object to return */
int iCookie; /* Configuration cookie */
Fts5Data *pData;
pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);
if( p->rc ) return 0;
/* TODO: Do we need this if the leaf-index is appended? Probably... */
memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);
p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);
if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){
p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);
if( p->pStruct==0 ){
p->iStructVersion = fts5IndexDataVersion(p);
if( p->rc==SQLITE_OK ){
p->pStruct = fts5StructureReadUncached(p);
}
}
fts5DataRelease(pData);
if( p->rc!=SQLITE_OK ){
fts5StructureRelease(pRet);
pRet = 0;
#if 0
else{
Fts5Structure *pTest = fts5StructureReadUncached(p);
if( pTest ){
int i, j;
assert_nc( p->pStruct->nSegment==pTest->nSegment );
assert_nc( p->pStruct->nLevel==pTest->nLevel );
for(i=0; i<pTest->nLevel; i++){
assert_nc( p->pStruct->aLevel[i].nMerge==pTest->aLevel[i].nMerge );
assert_nc( p->pStruct->aLevel[i].nSeg==pTest->aLevel[i].nSeg );
for(j=0; j<pTest->aLevel[i].nSeg; j++){
Fts5StructureSegment *p1 = &pTest->aLevel[i].aSeg[j];
Fts5StructureSegment *p2 = &p->pStruct->aLevel[i].aSeg[j];
assert_nc( p1->iSegid==p2->iSegid );
assert_nc( p1->pgnoFirst==p2->pgnoFirst );
assert_nc( p1->pgnoLast==p2->pgnoLast );
}
}
fts5StructureRelease(pTest);
}
}
#endif
if( p->rc!=SQLITE_OK ) return 0;
assert( p->iStructVersion!=0 );
assert( p->pStruct!=0 );
fts5StructureRef(p->pStruct);
return p->pStruct;
}
static void fts5StructureInvalidate(Fts5Index *p){
if( p->pStruct ){
fts5StructureRelease(p->pStruct);
p->pStruct = 0;
}
return pRet;
}
/*
@@ -2250,6 +2321,18 @@ static void fts5LeafSeek(
fts5SegIterLoadNPos(p, pIter);
}
static sqlite3_stmt *fts5IdxSelectStmt(Fts5Index *p){
if( p->pIdxSelect==0 ){
Fts5Config *pConfig = p->pConfig;
fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf(
"SELECT pgno FROM '%q'.'%q_idx' WHERE "
"segid=? AND term<=? ORDER BY term DESC LIMIT 1",
pConfig->zDb, pConfig->zName
));
}
return p->pIdxSelect;
}
/*
** Initialize the object pIter to point to term pTerm/nTerm within segment
** pSeg. If there is no such term in the index, the iterator is set to EOF.
@@ -2267,6 +2350,7 @@ static void fts5SegIterSeekInit(
int iPg = 1;
int bGe = (flags & FTS5INDEX_QUERY_SCAN);
int bDlidx = 0; /* True if there is a doclist-index */
sqlite3_stmt *pIdxSelect = 0;
assert( bGe==0 || (flags & FTS5INDEX_QUERY_DESC)==0 );
assert( pTerm && nTerm );
@@ -2275,23 +2359,16 @@ static void fts5SegIterSeekInit(
/* This block sets stack variable iPg to the leaf page number that may
** contain term (pTerm/nTerm), if it is present in the segment. */
if( p->pIdxSelect==0 ){
Fts5Config *pConfig = p->pConfig;
fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf(
"SELECT pgno FROM '%q'.'%q_idx' WHERE "
"segid=? AND term<=? ORDER BY term DESC LIMIT 1",
pConfig->zDb, pConfig->zName
));
}
pIdxSelect = fts5IdxSelectStmt(p);
if( p->rc ) return;
sqlite3_bind_int(p->pIdxSelect, 1, pSeg->iSegid);
sqlite3_bind_blob(p->pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC);
if( SQLITE_ROW==sqlite3_step(p->pIdxSelect) ){
i64 val = sqlite3_column_int(p->pIdxSelect, 0);
sqlite3_bind_int(pIdxSelect, 1, pSeg->iSegid);
sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC);
if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){
i64 val = sqlite3_column_int(pIdxSelect, 0);
iPg = (int)(val>>1);
bDlidx = (val & 0x0001);
}
p->rc = sqlite3_reset(p->pIdxSelect);
p->rc = sqlite3_reset(pIdxSelect);
if( iPg<pSeg->pgnoFirst ){
iPg = pSeg->pgnoFirst;
@@ -3481,6 +3558,17 @@ static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
}
}
assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );
{
sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);
if( p->rc==SQLITE_OK ){
u8 aBlob[2] = {0xff, 0xff};
sqlite3_bind_int(pIdxSelect, 1, iSegid);
sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);
assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
p->rc = sqlite3_reset(pIdxSelect);
}
}
#endif
}
}
@@ -3727,6 +3815,9 @@ static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){
Fts5PageWriter *pPage = &pWriter->writer;
i64 iRowid;
static int nCall = 0;
nCall++;
assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );
/* Set the szLeaf header field. */
@@ -4347,6 +4438,7 @@ static void fts5FlushOneHash(Fts5Index *p){
** for the new level-0 segment. */
pStruct = fts5StructureRead(p);
iSegid = fts5AllocateSegid(p, pStruct);
fts5StructureInvalidate(p);
if( iSegid ){
const int pgsz = p->pConfig->pgsz;
@@ -4531,7 +4623,7 @@ static Fts5Structure *fts5IndexOptimizeStruct(
if( pNew ){
Fts5StructureLevel *pLvl;
int nByte = nSeg * sizeof(Fts5StructureSegment);
nByte = nSeg * sizeof(Fts5StructureSegment);
pNew->nLevel = pStruct->nLevel+1;
pNew->nRef = 1;
pNew->nWriteCounter = pStruct->nWriteCounter;
@@ -4566,6 +4658,7 @@ int sqlite3Fts5IndexOptimize(Fts5Index *p){
assert( p->rc==SQLITE_OK );
fts5IndexFlush(p);
pStruct = fts5StructureRead(p);
fts5StructureInvalidate(p);
if( pStruct ){
pNew = fts5IndexOptimizeStruct(p, pStruct);
@@ -4596,6 +4689,7 @@ int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge){
Fts5Structure *pStruct = fts5StructureRead(p);
if( pStruct ){
int nMin = p->pConfig->nUsermerge;
fts5StructureInvalidate(p);
if( nMerge<0 ){
Fts5Structure *pNew = fts5IndexOptimizeStruct(p, pStruct);
fts5StructureRelease(pStruct);
@@ -5023,6 +5117,7 @@ int sqlite3Fts5IndexSync(Fts5Index *p, int bCommit){
int sqlite3Fts5IndexRollback(Fts5Index *p){
fts5CloseReader(p);
fts5IndexDiscardData(p);
fts5StructureInvalidate(p);
/* assert( p->rc==SQLITE_OK ); */
return SQLITE_OK;
}
@@ -5034,6 +5129,7 @@ int sqlite3Fts5IndexRollback(Fts5Index *p){
*/
int sqlite3Fts5IndexReinit(Fts5Index *p){
Fts5Structure s;
fts5StructureInvalidate(p);
memset(&s, 0, sizeof(Fts5Structure));
fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)"", 0);
fts5StructureWrite(p, &s);
@@ -5092,11 +5188,13 @@ int sqlite3Fts5IndexClose(Fts5Index *p){
int rc = SQLITE_OK;
if( p ){
assert( p->pReader==0 );
fts5StructureInvalidate(p);
sqlite3_finalize(p->pWriter);
sqlite3_finalize(p->pDeleter);
sqlite3_finalize(p->pIdxWriter);
sqlite3_finalize(p->pIdxDeleter);
sqlite3_finalize(p->pIdxSelect);
sqlite3_finalize(p->pDataVersion);
sqlite3Fts5HashFree(p->pHash);
sqlite3_free(p->zDataTbl);
sqlite3_free(p);
@@ -6352,3 +6450,12 @@ int sqlite3Fts5IndexInit(sqlite3 *db){
}
return rc;
}
int sqlite3Fts5IndexReset(Fts5Index *p){
assert( p->pStruct==0 || p->iStructVersion!=0 );
if( fts5IndexDataVersion(p)!=p->iStructVersion ){
fts5StructureInvalidate(p);
}
return fts5IndexReturn(p);
}
+25 -14
View File
@@ -597,27 +597,38 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
return SQLITE_OK;
}
static int fts5NewTransaction(Fts5Table *pTab){
Fts5Cursor *pCsr;
for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){
if( pCsr->base.pVtab==(sqlite3_vtab*)pTab ) return SQLITE_OK;
}
return sqlite3Fts5StorageReset(pTab->pStorage);
}
/*
** Implementation of xOpen method.
*/
static int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){
Fts5Table *pTab = (Fts5Table*)pVTab;
Fts5Config *pConfig = pTab->pConfig;
Fts5Cursor *pCsr; /* New cursor object */
Fts5Cursor *pCsr = 0; /* New cursor object */
int nByte; /* Bytes of space to allocate */
int rc = SQLITE_OK; /* Return code */
int rc; /* Return code */
nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);
if( pCsr ){
Fts5Global *pGlobal = pTab->pGlobal;
memset(pCsr, 0, nByte);
pCsr->aColumnSize = (int*)&pCsr[1];
pCsr->pNext = pGlobal->pCsr;
pGlobal->pCsr = pCsr;
pCsr->iCsrId = ++pGlobal->iNextId;
}else{
rc = SQLITE_NOMEM;
rc = fts5NewTransaction(pTab);
if( rc==SQLITE_OK ){
nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);
if( pCsr ){
Fts5Global *pGlobal = pTab->pGlobal;
memset(pCsr, 0, nByte);
pCsr->aColumnSize = (int*)&pCsr[1];
pCsr->pNext = pGlobal->pCsr;
pGlobal->pCsr = pCsr;
pCsr->iCsrId = ++pGlobal->iNextId;
}else{
rc = SQLITE_NOMEM;
}
}
*ppCsr = (sqlite3_vtab_cursor*)pCsr;
return rc;
@@ -1578,8 +1589,8 @@ static int fts5SyncMethod(sqlite3_vtab *pVtab){
** Implementation of xBegin() method.
*/
static int fts5BeginMethod(sqlite3_vtab *pVtab){
UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */
fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);
fts5NewTransaction((Fts5Table*)pVtab);
return SQLITE_OK;
}
+6
View File
@@ -369,6 +369,7 @@ static int fts5StorageInsertCallback(
Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext;
Fts5Index *pIdx = pCtx->pStorage->pIndex;
UNUSED_PARAM2(iUnused1, iUnused2);
if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;
if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
pCtx->szCol++;
}
@@ -640,6 +641,10 @@ int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge){
return sqlite3Fts5IndexMerge(p->pIndex, nMerge);
}
int sqlite3Fts5StorageReset(Fts5Storage *p){
return sqlite3Fts5IndexReset(p->pIndex);
}
/*
** Allocate a new rowid. This is used for "external content" tables when
** a NULL value is inserted into the rowid column. The new rowid is allocated
@@ -811,6 +816,7 @@ static int fts5StorageIntegrityCallback(
int iCol;
UNUSED_PARAM2(iUnused1, iUnused2);
if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;
if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
pCtx->szCol++;
+8 -1
View File
@@ -432,9 +432,16 @@ proc funk {} {
}
db func funk funk
# This test case corrupts the structure record within the first invocation
# of function funk(). Which used to cause the bm25() function to throw an
# exception. But since bm25() can now used the cached structure record,
# it never sees the corruption introduced by funk() and so the following
# statement no longer fails.
#
do_catchsql_test 16.2 {
SELECT funk(), bm25(n1), funk() FROM n1 WHERE n1 MATCH 'a+b+c+d'
} {1 {SQL logic error or missing database}}
} {0 {{} -1e-06 {}}}
# {1 {SQL logic error or missing database}}
#-------------------------------------------------------------------------
#
+4
View File
@@ -179,6 +179,10 @@ for {set i 1} {1} {incr i} {
if {$end<=$i} break
lset var end [expr $end - $i]
set struct [binary format c* $var]
db close
sqlite3 db test.db
db eval {
BEGIN;
UPDATE t1_data SET block = $struct WHERE id=10;
+67
View File
@@ -0,0 +1,67 @@
# 2016 March 21
#
# 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 script is testing the FTS5 module.
#
# Specifically, that the fts5 module is deterministic. At one point, when
# segment ids were allocated using sqlite3_randomness(), this was not the
# case.
#
source [file join [file dirname [info script]] fts5_common.tcl]
set testprefix fts5aa
return_if_no_fts5
proc do_determin_test {tn} {
uplevel [list
do_execsql_test $tn {
SELECT (SELECT md5sum(id, block) FROM t1_data)==
(SELECT md5sum(id, block) FROM t2_data),
(SELECT md5sum(id, block) FROM t1_data)==
(SELECT md5sum(id, block) FROM t3_data)
} {1 1}
]
}
foreach_detail_mode $::testprefix {
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix="1 2", detail=%DETAIL%);
CREATE VIRTUAL TABLE t2 USING fts5(a, b, prefix="1 2", detail=%DETAIL%);
CREATE VIRTUAL TABLE t3 USING fts5(a, b, prefix="1 2", detail=%DETAIL%);
}
do_test 1.1 {
foreach t {t1 t2 t3} {
execsql [string map [list TBL $t] {
INSERT INTO TBL VALUES('a b c', 'd e f');
INSERT INTO TBL VALUES('c1 c2 c3', 'c1 c2 c3');
INSERT INTO TBL VALUES('xyzxyzxyz', 'xyzxyzxyz');
}]
}
} {}
do_determin_test 1.2
do_test 1.3 {
foreach t {t1 t2 t3} {
execsql [string map [list TBL $t] {
INSERT INTO TBL(TBL) VALUES('optimize');
}]
}
} {}
do_determin_test 1.4
}
finish_test
+2 -2
View File
@@ -178,7 +178,7 @@ do_execsql_test 3.2 {
ORDER BY rowid DESC;
} {16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
do_execsql_test 3.2 {
do_execsql_test 3.3 {
INSERT INTO abc(abc) VALUES('integrity-check');
INSERT INTO abc(abc) VALUES('optimize');
INSERT INTO abc(abc) VALUES('integrity-check');
@@ -187,7 +187,7 @@ do_execsql_test 3.2 {
set v [lindex $vocab 0]
set i 0
foreach v $vocab {
do_execsql_test 3.3.[incr i] {
do_execsql_test 3.4.[incr i] {
SELECT rowid FROM abc WHERE abc MATCH $v
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
}
+1 -1
View File
@@ -86,7 +86,7 @@ set ::res [db eval {SELECT rowid, x1 FROM x1 WHERE x1 MATCH '*reads'}]
do_faultsim_test 4 -faults oom-* -body {
db eval {SELECT rowid, x, x1 FROM x1 WHERE x1 MATCH '*reads'}
} -test {
faultsim_test_result {0 {0 {} 4}}
faultsim_test_result {0 {0 {} 3}}
}
#-------------------------------------------------------------------------
+48
View File
@@ -0,0 +1,48 @@
# 2016 March 17
#
# 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.
#
#*************************************************************************
#
source [file join [file dirname [info script]] fts5_common.tcl]
source $testdir/lock_common.tcl
set testprefix fts5multiclient
return_if_no_fts5
foreach_detail_mode $testprefix {
do_multiclient_test tn {
do_test 1.$tn.1 {
sql1 { CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%) }
sql1 { INSERT INTO t1 VALUES('a b c') }
sql2 { SELECT rowid FROM t1('b') }
} {1}
do_test 1.$tn.2 {
sql2 { INSERT INTO t1 VALUES('a b c') }
sql1 { SELECT rowid FROM t1('b') }
} {1 2}
do_test 1.$tn.3 {
sql2 { INSERT INTO t1 VALUES('a b c') }
sql1 { SELECT rowid FROM t1('b') }
} {1 2 3}
do_test 1.$tn.4 {
sql2 { INSERT INTO t1 VALUES('a b c') }
sql1 { INSERT INTO t1 VALUES('a b c') }
sql3 { INSERT INTO t1(t1) VALUES('integrity-check') }
} {}
};# do_multiclient_test
};# foreach_detail_mode
finish_test
+23 -3
View File
@@ -340,7 +340,7 @@ do_test 14.2 {
#-------------------------------------------------------------------------
db func rnddoc fts5_rnddoc
do_execsql_test 4.0 {
do_execsql_test 14.3 {
CREATE VIRTUAL TABLE x1 USING fts5(x);
INSERT INTO x1(x1, rank) VALUES('pgsz', 32);
@@ -348,9 +348,9 @@ do_execsql_test 4.0 {
INSERT INTO x1 SELECT rnddoc(5) FROM ii;
}
do_execsql_test 4.1 {
do_execsql_test 14.4 {
SELECT rowid, x, x1 FROM x1 WHERE x1 MATCH '*reads'
} {0 {} 4}
} {0 {} 3}
#-------------------------------------------------------------------------
reset_db
@@ -448,4 +448,24 @@ do_execsql_test 20.2 {
INSERT INTO x1(x1) VALUES('integrity-check');
} {}
#-------------------------------------------------------------------------
reset_db
set doc "a b [string repeat x 100000]"
do_execsql_test 21.0 {
CREATE VIRTUAL TABLE x1 USING fts5(x);
INSERT INTO x1(rowid, x) VALUES(11111, $doc);
INSERT INTO x1(rowid, x) VALUES(11112, $doc);
}
do_execsql_test 21.1 {
INSERT INTO x1(x1) VALUES('integrity-check');
}
do_execsql_test 21.2 {
SELECT rowid FROM x1($doc);
} {11111 11112}
do_execsql_test 21.3 {
DELETE FROM x1 WHERE rowid=11111;
INSERT INTO x1(x1) VALUES('integrity-check');
SELECT rowid FROM x1($doc);
} {11112}
finish_test
+416
View File
@@ -0,0 +1,416 @@
/*
** 2014-08-18
**
** 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 contains code to implement the "changeset" command line
** utility for displaying and transforming changesets generated by
** the Sessions extension.
*/
#include "sqlite3.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
/*
** Show a usage message on stderr then quit.
*/
static void usage(const char *argv0){
fprintf(stderr, "Usage: %s FILENAME COMMAND ...\n", argv0);
fprintf(stderr,
"COMMANDs:\n"
" apply DB Apply the changeset to database file DB\n"
" concat FILE2 OUT Concatenate FILENAME and FILE2 into OUT\n"
" dump Show the complete content of the changeset\n"
" invert OUT Write an inverted changeset into file OUT\n"
" sql Give a pseudo-SQL rendering of the changeset\n"
);
exit(1);
}
/*
** Read the content of a disk file into an in-memory buffer
*/
static void readFile(const char *zFilename, int *pSz, void **ppBuf){
FILE *f;
int sz;
void *pBuf;
f = fopen(zFilename, "rb");
if( f==0 ){
fprintf(stderr, "cannot open \"%s\" for reading\n", zFilename);
exit(1);
}
fseek(f, 0, SEEK_END);
sz = (int)ftell(f);
rewind(f);
pBuf = sqlite3_malloc( sz ? sz : 1 );
if( pBuf==0 ){
fprintf(stderr, "cannot allocate %d to hold content of \"%s\"\n",
sz, zFilename);
exit(1);
}
if( sz>0 ){
if( fread(pBuf, sz, 1, f)!=1 ){
fprintf(stderr, "cannot read all %d bytes of \"%s\"\n", sz, zFilename);
exit(1);
}
fclose(f);
}
*pSz = sz;
*ppBuf = pBuf;
}
/* Array for converting from half-bytes (nybbles) into ASCII hex
** digits. */
static const char hexdigits[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
/*
** Render an sqlite3_value as an SQL string.
*/
static void renderValue(sqlite3_value *pVal){
switch( sqlite3_value_type(pVal) ){
case SQLITE_FLOAT: {
double r1;
char zBuf[50];
r1 = sqlite3_value_double(pVal);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1);
printf("%s", zBuf);
break;
}
case SQLITE_INTEGER: {
printf("%lld", sqlite3_value_int64(pVal));
break;
}
case SQLITE_BLOB: {
char const *zBlob = sqlite3_value_blob(pVal);
int nBlob = sqlite3_value_bytes(pVal);
int i;
printf("x'");
for(i=0; i<nBlob; i++){
putchar(hexdigits[(zBlob[i]>>4)&0x0F]);
putchar(hexdigits[(zBlob[i])&0x0F]);
}
putchar('\'');
break;
}
case SQLITE_TEXT: {
const unsigned char *zArg = sqlite3_value_text(pVal);
putchar('\'');
while( zArg[0] ){
putchar(zArg[0]);
if( zArg[0]=='\'' ) putchar(zArg[0]);
zArg++;
}
putchar('\'');
break;
}
default: {
assert( sqlite3_value_type(pVal)==SQLITE_NULL );
printf("NULL");
break;
}
}
}
/*
** Number of conflicts seen
*/
static int nConflict = 0;
/*
** The conflict callback
*/
static int conflictCallback(
void *pCtx,
int eConflict,
sqlite3_changeset_iter *pIter
){
int op, bIndirect, nCol, i;
const char *zTab;
unsigned char *abPK;
const char *zType = "";
const char *zOp = "";
const char *zSep = " ";
nConflict++;
sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
sqlite3changeset_pk(pIter, &abPK, 0);
switch( eConflict ){
case SQLITE_CHANGESET_DATA: zType = "DATA"; break;
case SQLITE_CHANGESET_NOTFOUND: zType = "NOTFOUND"; break;
case SQLITE_CHANGESET_CONFLICT: zType = "PRIMARY KEY"; break;
case SQLITE_CHANGESET_FOREIGN_KEY: zType = "FOREIGN KEY"; break;
case SQLITE_CHANGESET_CONSTRAINT: zType = "CONSTRAINT"; break;
}
switch( op ){
case SQLITE_UPDATE: zOp = "UPDATE of"; break;
case SQLITE_INSERT: zOp = "INSERT into"; break;
case SQLITE_DELETE: zOp = "DELETE from"; break;
}
printf("%s conflict on %s table %s with primary key", zType, zOp, zTab);
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
if( abPK[i]==0 ) continue;
printf("%s", zSep);
if( op==SQLITE_INSERT ){
sqlite3changeset_new(pIter, i, &pVal);
}else{
sqlite3changeset_old(pIter, i, &pVal);
}
renderValue(pVal);
zSep = ",";
}
printf("\n");
return SQLITE_CHANGESET_OMIT;
}
int main(int argc, char **argv){
int sz, rc;
void *pBuf = 0;
if( argc<3 ) usage(argv[0]);
readFile(argv[1], &sz, &pBuf);
/* changeset FILENAME apply DB
** Apply the changeset in FILENAME to the database file DB
*/
if( strcmp(argv[2],"apply")==0 ){
sqlite3 *db;
if( argc!=4 ) usage(argv[0]);
rc = sqlite3_open(argv[3], &db);
if( rc!=SQLITE_OK ){
fprintf(stderr, "unable to open database file \"%s\": %s\n",
argv[3], sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
sqlite3_exec(db, "BEGIN", 0, 0, 0);
nConflict = 0;
rc = sqlite3changeset_apply(db, sz, pBuf, 0, conflictCallback, 0);
if( rc ){
fprintf(stderr, "sqlite3changeset_apply() returned %d\n", rc);
}
if( nConflict ){
fprintf(stderr, "%d conflicts - no changes applied\n", nConflict);
sqlite3_exec(db, "ROLLBACK", 0, 0, 0);
}else if( rc ){
fprintf(stderr, "sqlite3changeset_apply() returns %d "
"- no changes applied\n", rc);
sqlite3_exec(db, "ROLLBACK", 0, 0, 0);
}else{
sqlite3_exec(db, "COMMIT", 0, 0, 0);
}
sqlite3_close(db);
}else
/* changeset FILENAME concat FILE2 OUT
** Add changeset FILE2 onto the end of the changeset in FILENAME
** and write the result into OUT.
*/
if( strcmp(argv[2],"concat")==0 ){
int szB;
void *pB;
int szOut;
void *pOutBuf;
FILE *out;
const char *zOut = argv[4];
if( argc!=5 ) usage(argv[0]);
out = fopen(zOut, "wb");
if( out==0 ){
fprintf(stderr, "cannot open \"%s\" for writing\n", zOut);
exit(1);
}
readFile(argv[3], &szB, &pB);
rc = sqlite3changeset_concat(sz, pBuf, szB, pB, &szOut, &pOutBuf);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite3changeset_concat() returns %d\n", rc);
}else if( szOut>0 && fwrite(pOutBuf, szOut, 1, out)!=1 ){
fprintf(stderr, "unable to write all %d bytes of output to \"%s\"\n",
szOut, zOut);
}
fclose(out);
sqlite3_free(pOutBuf);
sqlite3_free(pB);
}else
/* changeset FILENAME dump
** Show the complete content of the changeset in FILENAME
*/
if( strcmp(argv[2],"dump")==0 ){
int cnt = 0;
int i;
sqlite3_changeset_iter *pIter;
rc = sqlite3changeset_start(&pIter, sz, pBuf);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite3changeset_start() returns %d\n", rc);
exit(1);
}
while( sqlite3changeset_next(pIter)==SQLITE_ROW ){
int op, bIndirect, nCol;
const char *zTab;
unsigned char *abPK;
sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
cnt++;
printf("%d: %s table=[%s] indirect=%d nColumn=%d\n",
cnt, op==SQLITE_INSERT ? "INSERT" :
op==SQLITE_UPDATE ? "UPDATE" : "DELETE",
zTab, bIndirect, nCol);
sqlite3changeset_pk(pIter, &abPK, 0);
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
pVal = 0;
sqlite3changeset_old(pIter, i, &pVal);
if( pVal ){
printf(" old[%d]%s = ", i, abPK[i] ? "pk" : " ");
renderValue(pVal);
printf("\n");
}
pVal = 0;
sqlite3changeset_new(pIter, i, &pVal);
if( pVal ){
printf(" new[%d]%s = ", i, abPK[i] ? "pk" : " ");
renderValue(pVal);
printf("\n");
}
}
}
sqlite3changeset_finalize(pIter);
}else
/* changeset FILENAME invert OUT
** Invert the changes in FILENAME and writes the result on OUT
*/
if( strcmp(argv[2],"invert")==0 ){
FILE *out;
int szOut = 0;
void *pOutBuf = 0;
const char *zOut = argv[3];
if( argc!=4 ) usage(argv[0]);
out = fopen(zOut, "wb");
if( out==0 ){
fprintf(stderr, "cannot open \"%s\" for writing\n", zOut);
exit(1);
}
rc = sqlite3changeset_invert(sz, pBuf, &szOut, &pOutBuf);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite3changeset_invert() returns %d\n", rc);
}else if( szOut>0 && fwrite(pOutBuf, szOut, 1, out)!=1 ){
fprintf(stderr, "unable to write all %d bytes of output to \"%s\"\n",
szOut, zOut);
}
fclose(out);
sqlite3_free(pOutBuf);
}else
/* changeset FILE sql
** Show the content of the changeset as pseudo-SQL
*/
if( strcmp(argv[2],"sql")==0 ){
int cnt = 0;
char *zPrevTab = 0;
char *zSQLTabName = 0;
sqlite3_changeset_iter *pIter = 0;
rc = sqlite3changeset_start(&pIter, sz, pBuf);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite3changeset_start() returns %d\n", rc);
exit(1);
}
printf("BEGIN;\n");
while( sqlite3changeset_next(pIter)==SQLITE_ROW ){
int op, bIndirect, nCol;
const char *zTab;
sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
cnt++;
if( zPrevTab==0 || strcmp(zPrevTab,zTab)!=0 ){
sqlite3_free(zPrevTab);
sqlite3_free(zSQLTabName);
zPrevTab = sqlite3_mprintf("%s", zTab);
if( !isalnum(zTab[0]) || sqlite3_strglob("*[^a-zA-Z0-9]*",zTab)==0 ){
zSQLTabName = sqlite3_mprintf("\"%w\"", zTab);
}else{
zSQLTabName = sqlite3_mprintf("%s", zTab);
}
printf("/****** Changes for table %s ***************/\n", zSQLTabName);
}
switch( op ){
case SQLITE_DELETE: {
unsigned char *abPK;
int i;
const char *zSep = " ";
sqlite3changeset_pk(pIter, &abPK, 0);
printf("/* %d */ DELETE FROM %s WHERE", cnt, zSQLTabName);
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
if( abPK[i]==0 ) continue;
printf("%sc%d=", zSep, i+1);
zSep = " AND ";
sqlite3changeset_old(pIter, i, &pVal);
renderValue(pVal);
}
printf(";\n");
break;
}
case SQLITE_UPDATE: {
unsigned char *abPK;
int i;
const char *zSep = " ";
sqlite3changeset_pk(pIter, &abPK, 0);
printf("/* %d */ UPDATE %s SET", cnt, zSQLTabName);
for(i=0; i<nCol; i++){
sqlite3_value *pVal = 0;
sqlite3changeset_new(pIter, i, &pVal);
if( pVal ){
printf("%sc%d=", zSep, i+1);
zSep = ", ";
renderValue(pVal);
}
}
printf(" WHERE");
zSep = " ";
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
if( abPK[i]==0 ) continue;
printf("%sc%d=", zSep, i+1);
zSep = " AND ";
sqlite3changeset_old(pIter, i, &pVal);
renderValue(pVal);
}
printf(";\n");
break;
}
case SQLITE_INSERT: {
int i;
printf("/* %d */ INSERT INTO %s VALUES", cnt, zSQLTabName);
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
printf("%c", i==0 ? '(' : ',');
sqlite3changeset_new(pIter, i, &pVal);
renderValue(pVal);
}
printf(");\n");
break;
}
}
}
printf("COMMIT;\n");
sqlite3changeset_finalize(pIter);
sqlite3_free(zPrevTab);
sqlite3_free(zSQLTabName);
}else
/* If nothing else matches, show the usage comment */
usage(argv[0]);
sqlite3_free(pBuf);
return 0;
}
+573
View File
@@ -0,0 +1,573 @@
# 2011 March 07
#
# 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.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session1
do_execsql_test 1.0 {
CREATE TABLE t1(x PRIMARY KEY, y);
INSERT INTO t1 VALUES('abc', 'def');
}
#-------------------------------------------------------------------------
# Test creating, attaching tables to and deleting session objects.
#
do_test 1.1 { sqlite3session S db main } {S}
do_test 1.2 { S delete } {}
do_test 1.3 { sqlite3session S db main } {S}
do_test 1.4 { S attach t1 } {}
do_test 1.5 { S delete } {}
do_test 1.6 { sqlite3session S db main } {S}
do_test 1.7 { S attach t1 ; S attach t2 ; S attach t3 } {}
do_test 1.8 { S attach t1 ; S attach t2 ; S attach t3 } {}
do_test 1.9 { S delete } {}
do_test 1.10 {
sqlite3session S db main
S attach t1
execsql { INSERT INTO t1 VALUES('ghi', 'jkl') }
} {}
do_test 1.11 { S delete } {}
do_test 1.12 {
sqlite3session S db main
S attach t1
execsql { INSERT INTO t1 VALUES('mno', 'pqr') }
execsql { UPDATE t1 SET x = 111 WHERE rowid = 1 }
execsql { DELETE FROM t1 WHERE rowid = 2 }
} {}
do_test 1.13 {
S changeset
S delete
} {}
#-------------------------------------------------------------------------
# Simple changeset tests. Also test the sqlite3changeset_invert()
# function.
#
do_test 2.1.1 {
execsql { DELETE FROM t1 }
sqlite3session S db main
S attach t1
execsql { INSERT INTO t1 VALUES(1, 'Sukhothai') }
execsql { INSERT INTO t1 VALUES(2, 'Ayutthaya') }
execsql { INSERT INTO t1 VALUES(3, 'Thonburi') }
} {}
do_changeset_test 2.1.2 S {
{INSERT t1 0 X. {} {i 1 t Sukhothai}}
{INSERT t1 0 X. {} {i 2 t Ayutthaya}}
{INSERT t1 0 X. {} {i 3 t Thonburi}}
}
do_changeset_invert_test 2.1.3 S {
{DELETE t1 0 X. {i 1 t Sukhothai} {}}
{DELETE t1 0 X. {i 2 t Ayutthaya} {}}
{DELETE t1 0 X. {i 3 t Thonburi} {}}
}
do_test 2.1.4 { S delete } {}
do_test 2.2.1 {
sqlite3session S db main
S attach t1
execsql { DELETE FROM t1 WHERE 1 }
} {}
do_changeset_test 2.2.2 S {
{DELETE t1 0 X. {i 1 t Sukhothai} {}}
{DELETE t1 0 X. {i 2 t Ayutthaya} {}}
{DELETE t1 0 X. {i 3 t Thonburi} {}}
}
do_changeset_invert_test 2.2.3 S {
{INSERT t1 0 X. {} {i 1 t Sukhothai}}
{INSERT t1 0 X. {} {i 2 t Ayutthaya}}
{INSERT t1 0 X. {} {i 3 t Thonburi}}
}
do_test 2.2.4 { S delete } {}
do_test 2.3.1 {
execsql { DELETE FROM t1 }
sqlite3session S db main
execsql { INSERT INTO t1 VALUES(1, 'Sukhothai') }
execsql { INSERT INTO t1 VALUES(2, 'Ayutthaya') }
execsql { INSERT INTO t1 VALUES(3, 'Thonburi') }
S attach t1
execsql {
UPDATE t1 SET x = 10 WHERE x = 1;
UPDATE t1 SET y = 'Surin' WHERE x = 2;
UPDATE t1 SET x = 20, y = 'Thapae' WHERE x = 3;
}
} {}
do_changeset_test 2.3.2 S {
{INSERT t1 0 X. {} {i 10 t Sukhothai}}
{DELETE t1 0 X. {i 1 t Sukhothai} {}}
{UPDATE t1 0 X. {i 2 t Ayutthaya} {{} {} t Surin}}
{DELETE t1 0 X. {i 3 t Thonburi} {}}
{INSERT t1 0 X. {} {i 20 t Thapae}}
}
do_changeset_invert_test 2.3.3 S {
{DELETE t1 0 X. {i 10 t Sukhothai} {}}
{INSERT t1 0 X. {} {i 1 t Sukhothai}}
{UPDATE t1 0 X. {i 2 t Surin} {{} {} t Ayutthaya}}
{INSERT t1 0 X. {} {i 3 t Thonburi}}
{DELETE t1 0 X. {i 20 t Thapae} {}}
}
do_test 2.3.4 { S delete } {}
do_test 2.4.1 {
sqlite3session S db main
S attach t1
execsql { INSERT INTO t1 VALUES(100, 'Bangkok') }
execsql { DELETE FROM t1 WHERE x = 100 }
} {}
do_changeset_test 2.4.2 S {}
do_changeset_invert_test 2.4.3 S {}
do_test 2.4.4 { S delete } {}
#-------------------------------------------------------------------------
# Test the application of simple changesets. These tests also test that
# the conflict callback is invoked correctly. For these tests, the
# conflict callback always returns OMIT.
#
db close
forcedelete test.db test.db2
sqlite3 db test.db
sqlite3 db2 test.db2
proc xConflict {args} {
lappend ::xConflict $args
return ""
}
proc bgerror {args} { set ::background_error $args }
proc do_conflict_test {tn args} {
set O(-tables) [list]
set O(-sql) [list]
set O(-conflicts) [list]
array set V $args
foreach key [array names V] {
if {![info exists O($key)]} {error "no such option: $key"}
}
array set O $args
sqlite3session S db main
foreach t $O(-tables) { S attach $t }
execsql $O(-sql)
set ::xConflict [list]
sqlite3changeset_apply db2 [S changeset] xConflict
set conflicts [list]
foreach c $O(-conflicts) {
lappend conflicts $c
}
after 1 {set go 1}
vwait go
uplevel do_test $tn [list { set ::xConflict }] [list $conflicts]
S delete
}
proc do_db2_test {testname sql {result {}}} {
uplevel do_test $testname [list "execsql {$sql} db2"] [list [list {*}$result]]
}
# Test INSERT changesets.
#
do_test 3.1.0 {
execsql { CREATE TABLE t1(a PRIMARY KEY, b NOT NULL) } db2
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES(1, 'one');
INSERT INTO t1 VALUES(2, 'two');
} db
} {}
do_db2_test 3.1.1 "INSERT INTO t1 VALUES(6, 'VI')"
do_conflict_test 3.1.2 -tables t1 -sql {
INSERT INTO t1 VALUES(3, 'three');
INSERT INTO t1 VALUES(4, 'four');
INSERT INTO t1 VALUES(5, 'five');
INSERT INTO t1 VALUES(6, 'six');
INSERT INTO t1 VALUES(7, 'seven');
INSERT INTO t1 VALUES(8, NULL);
} -conflicts {
{INSERT t1 CONSTRAINT {i 8 n {}}}
{INSERT t1 CONFLICT {i 6 t six} {i 6 t VI}}
}
do_db2_test 3.1.3 "SELECT * FROM t1" {
6 VI 3 three 4 four 5 five 7 seven
}
do_execsql_test 3.1.4 "SELECT * FROM t1" {
1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 {}
}
# Test DELETE changesets.
#
do_execsql_test 3.2.1 {
PRAGMA foreign_keys = on;
CREATE TABLE t2(a PRIMARY KEY, b);
CREATE TABLE t3(c, d REFERENCES t2);
INSERT INTO t2 VALUES(1, 'one');
INSERT INTO t2 VALUES(2, 'two');
INSERT INTO t2 VALUES(3, 'three');
INSERT INTO t2 VALUES(4, 'four');
}
do_db2_test 3.2.2 {
PRAGMA foreign_keys = on;
CREATE TABLE t2(a PRIMARY KEY, b);
CREATE TABLE t3(c, d REFERENCES t2);
INSERT INTO t2 VALUES(1, 'one');
INSERT INTO t2 VALUES(2, 'two');
INSERT INTO t2 VALUES(4, 'five');
INSERT INTO t3 VALUES('i', 1);
}
do_conflict_test 3.2.3 -tables t2 -sql {
DELETE FROM t2 WHERE a = 1;
DELETE FROM t2 WHERE a = 2;
DELETE FROM t2 WHERE a = 3;
DELETE FROM t2 WHERE a = 4;
} -conflicts {
{DELETE t2 NOTFOUND {i 3 t three}}
{DELETE t2 DATA {i 4 t four} {i 4 t five}}
{FOREIGN_KEY 1}
}
do_execsql_test 3.2.4 "SELECT * FROM t2" {}
do_db2_test 3.2.5 "SELECT * FROM t2" {4 five}
# Test UPDATE changesets.
#
do_execsql_test 3.3.1 {
CREATE TABLE t4(a, b, c, PRIMARY KEY(b, c));
INSERT INTO t4 VALUES(1, 2, 3);
INSERT INTO t4 VALUES(4, 5, 6);
INSERT INTO t4 VALUES(7, 8, 9);
INSERT INTO t4 VALUES(10, 11, 12);
}
do_db2_test 3.3.2 {
CREATE TABLE t4(a NOT NULL, b, c, PRIMARY KEY(b, c));
INSERT INTO t4 VALUES(0, 2, 3);
INSERT INTO t4 VALUES(4, 5, 7);
INSERT INTO t4 VALUES(7, 8, 9);
INSERT INTO t4 VALUES(10, 11, 12);
}
do_conflict_test 3.3.3 -tables t4 -sql {
UPDATE t4 SET a = -1 WHERE b = 2;
UPDATE t4 SET a = -1 WHERE b = 5;
UPDATE t4 SET a = NULL WHERE c = 9;
UPDATE t4 SET a = 'x' WHERE b = 11;
} -conflicts {
{UPDATE t4 CONSTRAINT {i 7 i 8 i 9} {n {} {} {} {} {}}}
{UPDATE t4 DATA {i 1 i 2 i 3} {i -1 {} {} {} {}} {i 0 i 2 i 3}}
{UPDATE t4 NOTFOUND {i 4 i 5 i 6} {i -1 {} {} {} {}}}
}
do_db2_test 3.3.4 { SELECT * FROM t4 } {0 2 3 4 5 7 7 8 9 x 11 12}
do_execsql_test 3.3.5 { SELECT * FROM t4 } {-1 2 3 -1 5 6 {} 8 9 x 11 12}
#-------------------------------------------------------------------------
# This next block of tests verifies that values returned by the conflict
# handler are intepreted correctly.
#
proc test_reset {} {
db close
db2 close
forcedelete test.db test.db2
sqlite3 db test.db
sqlite3 db2 test.db2
}
proc xConflict {args} {
lappend ::xConflict $args
return $::conflict_return
}
foreach {tn conflict_return after} {
1 OMIT {1 2 value1 4 5 7 10 x x}
2 REPLACE {1 2 value1 4 5 value2 10 8 9}
} {
test_reset
do_test 4.$tn.1 {
foreach db {db db2} {
execsql {
CREATE TABLE t1(a, b, c, PRIMARY KEY(a));
INSERT INTO t1 VALUES(1, 2, 3);
INSERT INTO t1 VALUES(4, 5, 6);
INSERT INTO t1 VALUES(7, 8, 9);
} $db
}
execsql {
REPLACE INTO t1 VALUES(4, 5, 7);
REPLACE INTO t1 VALUES(10, 'x', 'x');
} db2
} {}
do_conflict_test 4.$tn.2 -tables t1 -sql {
UPDATE t1 SET c = 'value1' WHERE a = 1; -- no conflict
UPDATE t1 SET c = 'value2' WHERE a = 4; -- DATA conflict
UPDATE t1 SET a = 10 WHERE a = 7; -- CONFLICT conflict
} -conflicts {
{INSERT t1 CONFLICT {i 10 i 8 i 9} {i 10 t x t x}}
{UPDATE t1 DATA {i 4 {} {} i 6} {{} {} {} {} t value2} {i 4 i 5 i 7}}
}
do_db2_test 4.$tn.3 "SELECT * FROM t1 ORDER BY a" $after
}
foreach {tn conflict_return} {
1 OMIT
2 REPLACE
} {
test_reset
do_test 5.$tn.1 {
# Create an identical schema in both databases.
set schema {
CREATE TABLE "'foolish name'"(x, y, z, PRIMARY KEY(x, y));
}
execsql $schema db
execsql $schema db2
# Add some rows to [db2]. These rows will cause conflicts later
# on when the changeset from [db] is applied to it.
execsql {
INSERT INTO "'foolish name'" VALUES('one', 'one', 'ii');
INSERT INTO "'foolish name'" VALUES('one', 'two', 'i');
INSERT INTO "'foolish name'" VALUES('two', 'two', 'ii');
} db2
} {}
do_conflict_test 5.$tn.2 -tables {{'foolish name'}} -sql {
INSERT INTO "'foolish name'" VALUES('one', 'two', 2);
} -conflicts {
{INSERT {'foolish name'} CONFLICT {t one t two i 2} {t one t two t i}}
}
set res(REPLACE) {one one ii one two 2 two two ii}
set res(OMIT) {one one ii one two i two two ii}
do_db2_test 5.$tn.3 {
SELECT * FROM "'foolish name'" ORDER BY x, y
} $res($conflict_return)
do_test 5.$tn.1 {
set schema {
CREATE TABLE d1("z""z" PRIMARY KEY, y);
INSERT INTO d1 VALUES(1, 'one');
INSERT INTO d1 VALUES(2, 'two');
}
execsql $schema db
execsql $schema db2
execsql {
UPDATE d1 SET y = 'TWO' WHERE "z""z" = 2;
} db2
} {}
do_conflict_test 5.$tn.2 -tables d1 -sql {
DELETE FROM d1 WHERE "z""z" = 2;
} -conflicts {
{DELETE d1 DATA {i 2 t two} {i 2 t TWO}}
}
set res(REPLACE) {1 one}
set res(OMIT) {1 one 2 TWO}
do_db2_test 5.$tn.3 "SELECT * FROM d1" $res($conflict_return)
}
#-------------------------------------------------------------------------
# Test that two tables can be monitored by a single session object.
#
test_reset
set schema {
CREATE TABLE t1(a COLLATE nocase PRIMARY KEY, b);
CREATE TABLE t2(a, b PRIMARY KEY);
}
do_test 6.0 {
execsql $schema db
execsql $schema db2
execsql {
INSERT INTO t1 VALUES('a', 'b');
INSERT INTO t2 VALUES('a', 'b');
} db2
} {}
set conflict_return ""
do_conflict_test 6.1 -tables {t1 t2} -sql {
INSERT INTO t1 VALUES('1', '2');
INSERT INTO t1 VALUES('A', 'B');
INSERT INTO t2 VALUES('A', 'B');
} -conflicts {
{INSERT t1 CONFLICT {t A t B} {t a t b}}
}
do_db2_test 6.2 "SELECT * FROM t1" {a b 1 2}
do_db2_test 6.3 "SELECT * FROM t2" {a b A B}
#-------------------------------------------------------------------------
# Test that session objects are not confused by changes to table in
# other databases.
#
catch { db2 close }
drop_all_tables
forcedelete test.db2
do_iterator_test 7.1 * {
ATTACH 'test.db2' AS aux;
CREATE TABLE main.t1(x PRIMARY KEY, y);
CREATE TABLE aux.t1(x PRIMARY KEY, y);
INSERT INTO main.t1 VALUES('one', 1);
INSERT INTO main.t1 VALUES('two', 2);
INSERT INTO aux.t1 VALUES('three', 3);
INSERT INTO aux.t1 VALUES('four', 4);
} {
{INSERT t1 0 X. {} {t two i 2}}
{INSERT t1 0 X. {} {t one i 1}}
}
#-------------------------------------------------------------------------
# Test the sqlite3session_isempty() function.
#
do_test 8.1 {
execsql {
CREATE TABLE t5(x PRIMARY KEY, y);
CREATE TABLE t6(x PRIMARY KEY, y);
INSERT INTO t5 VALUES('a', 'b');
INSERT INTO t6 VALUES('a', 'b');
}
sqlite3session S db main
S attach *
S isempty
} {1}
do_test 8.2 {
execsql { DELETE FROM t5 }
S isempty
} {0}
do_test 8.3 {
S delete
sqlite3session S db main
S attach t5
execsql { DELETE FROM t5 }
S isempty
} {1}
do_test 8.4 { S delete } {}
do_test 8.5 {
sqlite3session S db main
S attach t5
S attach t6
execsql { INSERT INTO t5 VALUES(1, 2) }
S isempty
} {0}
do_test 8.6 {
S delete
sqlite3session S db main
S attach t5
S attach t6
execsql { INSERT INTO t6 VALUES(1, 2) }
S isempty
} {0}
do_test 8.7 { S delete } {}
#-------------------------------------------------------------------------
#
do_execsql_test 9.1 {
CREATE TABLE t7(a, b, c, d, e PRIMARY KEY, f, g);
INSERT INTO t7 VALUES(1, 1, 1, 1, 1, 1, 1);
}
do_test 9.2 {
sqlite3session S db main
S attach *
execsql { UPDATE t7 SET b=2, d=2 }
} {}
do_changeset_test 9.2 S {{UPDATE t7 0 ....X.. {{} {} i 1 {} {} i 1 i 1 {} {} {} {}} {{} {} i 2 {} {} i 2 {} {} {} {} {} {}}}}
S delete
catch { db2 close }
#-------------------------------------------------------------------------
# Test a really long table name.
#
reset_db
set tblname [string repeat tblname123 100]
do_test 10.1.1 {
execsql "
CREATE TABLE $tblname (a PRIMARY KEY, b);
INSERT INTO $tblname VALUES('xyz', 'def');
"
sqlite3session S db main
S attach $tblname
execsql "
INSERT INTO $tblname VALUES('uvw', 'abc');
DELETE FROM $tblname WHERE a = 'xyz';
"
} {}
breakpoint
do_changeset_test 10.1.2 S "
{INSERT $tblname 0 X. {} {t uvw t abc}}
{DELETE $tblname 0 X. {t xyz t def} {}}
"
do_test 10.1.4 { S delete } {}
#---------------------------------------------------------------
reset_db
do_execsql_test 11.1 {
CREATE TABLE t1(a, b);
}
do_test 11.2 {
sqlite3session S db main
S attach t1
execsql {
INSERT INTO t1 VALUES(1, 2);
}
S changeset
} {}
S delete
#-------------------------------------------------------------------------
# Test a really long table name.
#
reset_db
set tblname [string repeat tblname123 100]
do_test 10.1.1 {
execsql "
CREATE TABLE $tblname (a PRIMARY KEY, b);
INSERT INTO $tblname VALUES('xyz', 'def');
"
sqlite3session S db main
S attach $tblname
execsql "
INSERT INTO $tblname VALUES('uvw', 'abc');
DELETE FROM $tblname WHERE a = 'xyz';
"
} {}
breakpoint
do_changeset_test 10.1.2 S "
{INSERT $tblname 0 X. {} {t uvw t abc}}
{DELETE $tblname 0 X. {t xyz t def} {}}
"
do_test 10.1.4 { S delete } {}
finish_test
+591
View File
@@ -0,0 +1,591 @@
# 2011 Mar 16
#
# 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.
#
#***********************************************************************
#
# The focus of this file is testing the session module.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session2
proc test_reset {} {
catch { db close }
catch { db2 close }
forcedelete test.db test.db2
sqlite3 db test.db
sqlite3 db2 test.db2
}
##########################################################################
# End of proc definitions. Start of tests.
##########################################################################
test_reset
do_execsql_test 1.0 {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('i', 'one');
}
do_iterator_test 1.1 t1 {
DELETE FROM t1 WHERE a = 'i';
INSERT INTO t1 VALUES('ii', 'two');
} {
{DELETE t1 0 X. {t i t one} {}}
{INSERT t1 0 X. {} {t ii t two}}
}
do_iterator_test 1.2 t1 {
INSERT INTO t1 VALUES(1.5, 99.9)
} {
{INSERT t1 0 X. {} {f 1.5 f 99.9}}
}
do_iterator_test 1.3 t1 {
UPDATE t1 SET b = 100.1 WHERE a = 1.5;
UPDATE t1 SET b = 99.9 WHERE a = 1.5;
} { }
do_iterator_test 1.4 t1 {
UPDATE t1 SET b = 100.1 WHERE a = 1.5;
} {
{UPDATE t1 0 X. {f 1.5 f 99.9} {{} {} f 100.1}}
}
# Execute each of the following blocks of SQL on database [db1]. Collect
# changes using a session object. Apply the resulting changeset to
# database [db2]. Then check that the contents of the two databases are
# identical.
#
set set_of_tests {
1 { INSERT INTO %T1% VALUES(1, 2) }
2 {
INSERT INTO %T2% VALUES(1, NULL);
INSERT INTO %T2% VALUES(2, NULL);
INSERT INTO %T2% VALUES(3, NULL);
DELETE FROM %T2% WHERE a = 2;
INSERT INTO %T2% VALUES(4, NULL);
UPDATE %T2% SET b=0 WHERE b=1;
}
3 { INSERT INTO %T3% SELECT *, NULL FROM %T2% }
4 {
INSERT INTO %T3% SELECT a||a, b||b, NULL FROM %T3%;
DELETE FROM %T3% WHERE rowid%2;
}
5 { UPDATE %T3% SET c = a||b }
6 { UPDATE %T1% SET a = 32 }
7 {
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
DELETE FROM %T1% WHERE (rowid%3)==0;
}
8 {
BEGIN;
INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;
ROLLBACK;
}
9 {
BEGIN;
UPDATE %T1% SET b = 'xxx';
ROLLBACK;
}
10 {
BEGIN;
DELETE FROM %T1% WHERE 1;
ROLLBACK;
}
11 {
INSERT INTO %T1% VALUES(randomblob(21000), randomblob(0));
INSERT INTO %T1% VALUES(1.5, 1.5);
INSERT INTO %T1% VALUES(4.56, -99.999999999999999999999);
}
12 {
INSERT INTO %T2% VALUES(NULL, NULL);
}
13 {
DELETE FROM %T1% WHERE 1;
-- Insert many rows with real primary keys. Enough to force the session
-- objects hash table to resize.
INSERT INTO %T1% VALUES(0.1, 0.1);
INSERT INTO %T1% SELECT a+0.1, b+0.1 FROM %T1%;
INSERT INTO %T1% SELECT a+0.2, b+0.2 FROM %T1%;
INSERT INTO %T1% SELECT a+0.4, b+0.4 FROM %T1%;
INSERT INTO %T1% SELECT a+0.8, b+0.8 FROM %T1%;
INSERT INTO %T1% SELECT a+1.6, b+1.6 FROM %T1%;
INSERT INTO %T1% SELECT a+3.2, b+3.2 FROM %T1%;
INSERT INTO %T1% SELECT a+6.4, b+6.4 FROM %T1%;
INSERT INTO %T1% SELECT a+12.8, b+12.8 FROM %T1%;
INSERT INTO %T1% SELECT a+25.6, b+25.6 FROM %T1%;
INSERT INTO %T1% SELECT a+51.2, b+51.2 FROM %T1%;
INSERT INTO %T1% SELECT a+102.4, b+102.4 FROM %T1%;
INSERT INTO %T1% SELECT a+204.8, b+204.8 FROM %T1%;
}
14 {
DELETE FROM %T1% WHERE 1;
}
15 {
INSERT INTO %T1% VALUES(1, 1);
INSERT INTO %T1% SELECT a+2, b+2 FROM %T1%;
INSERT INTO %T1% SELECT a+4, b+4 FROM %T1%;
INSERT INTO %T1% SELECT a+8, b+8 FROM %T1%;
INSERT INTO %T1% SELECT a+256, b+256 FROM %T1%;
}
16 {
INSERT INTO %T4% VALUES('abc', 'def');
INSERT INTO %T4% VALUES('def', 'abc');
}
17 { UPDATE %T4% SET b = 1 }
18 { DELETE FROM %T4% WHERE 1 }
19 {
INSERT INTO t1 VALUES('', '');
INSERT INTO t1 VALUES(X'', X'');
}
20 {
DELETE FROM t1;
INSERT INTO t1 VALUES('', NULL);
}
}
test_reset
do_common_sql {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(a, b INTEGER PRIMARY KEY);
CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b));
CREATE TABLE t4(a, b, PRIMARY KEY(b, a));
}
foreach {tn sql} [string map {%T1% t1 %T2% t2 %T3% t3 %T4% t4} $set_of_tests] {
do_then_apply_sql $sql
do_test 2.$tn { compare_db db db2 } {}
}
# The following block of tests is similar to the last, except that the
# session object is recording changes made to an attached database. The
# main database contains a table of the same name as the table being
# modified within the attached db.
#
test_reset
forcedelete test.db3
sqlite3 db3 test.db3
do_test 3.0 {
execsql {
ATTACH 'test.db3' AS 'aux';
CREATE TABLE t1(a, b PRIMARY KEY);
CREATE TABLE t2(x, y, z);
CREATE TABLE t3(a);
CREATE TABLE aux.t1(a PRIMARY KEY, b);
CREATE TABLE aux.t2(a, b INTEGER PRIMARY KEY);
CREATE TABLE aux.t3(a, b, c, PRIMARY KEY(a, b));
CREATE TABLE aux.t4(a, b, PRIMARY KEY(b, a));
}
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(a, b INTEGER PRIMARY KEY);
CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b));
CREATE TABLE t4(a, b, PRIMARY KEY(b, a));
} db2
} {}
proc xTrace {args} { puts $args }
foreach {tn sql} [
string map {%T1% aux.t1 %T2% aux.t2 %T3% aux.t3 %T4% aux.t4} $set_of_tests
] {
do_then_apply_sql $sql aux
do_test 3.$tn { compare_db db2 db3 } {}
}
catch {db3 close}
#-------------------------------------------------------------------------
# The following tests verify that NULL values in primary key columns are
# handled correctly by the session module.
#
test_reset
do_execsql_test 4.0 {
CREATE TABLE t1(a PRIMARY KEY);
CREATE TABLE t2(a, b, c, PRIMARY KEY(c, b));
CREATE TABLE t3(a, b INTEGER PRIMARY KEY);
}
foreach {tn sql changeset} {
1 {
INSERT INTO t1 VALUES(123);
INSERT INTO t1 VALUES(NULL);
INSERT INTO t1 VALUES(456);
} {
{INSERT t1 0 X {} {i 456}}
{INSERT t1 0 X {} {i 123}}
}
2 {
UPDATE t1 SET a = NULL;
} {
{DELETE t1 0 X {i 456} {}}
{DELETE t1 0 X {i 123} {}}
}
3 { DELETE FROM t1 } { }
4 {
INSERT INTO t3 VALUES(NULL, NULL)
} {
{INSERT t3 0 .X {} {n {} i 1}}
}
5 { INSERT INTO t2 VALUES(1, 2, NULL) } { }
6 { INSERT INTO t2 VALUES(1, NULL, 3) } { }
7 { INSERT INTO t2 VALUES(1, NULL, NULL) } { }
8 { INSERT INTO t2 VALUES(1, 2, 3) } { {INSERT t2 0 .XX {} {i 1 i 2 i 3}} }
9 { DELETE FROM t2 WHERE 1 } { {DELETE t2 0 .XX {i 1 i 2 i 3} {}} }
} {
do_iterator_test 4.$tn {t1 t2 t3} $sql $changeset
}
#-------------------------------------------------------------------------
# Test that if NULL is passed to sqlite3session_attach(), all database
# tables are attached to the session object.
#
test_reset
do_execsql_test 5.0 {
CREATE TABLE t1(a PRIMARY KEY);
CREATE TABLE t2(x, y PRIMARY KEY);
}
foreach {tn sql changeset} {
1 { INSERT INTO t1 VALUES(35) } { {INSERT t1 0 X {} {i 35}} }
2 { INSERT INTO t2 VALUES(36, 37) } { {INSERT t2 0 .X {} {i 36 i 37}} }
3 {
DELETE FROM t1 WHERE 1;
UPDATE t2 SET x = 34;
} {
{DELETE t1 0 X {i 35} {}}
{UPDATE t2 0 .X {i 36 i 37} {i 34 {} {}}}
}
} {
do_iterator_test 5.$tn * $sql $changeset
}
#-------------------------------------------------------------------------
# The next block of tests verify that the "indirect" flag is set
# correctly within changesets. The indirect flag is set for a change
# if either of the following are true:
#
# * The sqlite3session_indirect() API has been used to set the session
# indirect flag to true, or
# * The change was made by a trigger.
#
# If the same row is updated more than once during a session, then the
# change is considered indirect only if all changes meet the criteria
# above.
#
test_reset
db function indirect [list S indirect]
do_execsql_test 6.0 {
CREATE TABLE t1(a PRIMARY KEY, b, c);
CREATE TABLE t2(x PRIMARY KEY, y);
CREATE TRIGGER AFTER INSERT ON t2 WHEN new.x%2 BEGIN
INSERT INTO t2 VALUES(new.x+1, NULL);
END;
}
do_iterator_test 6.1.1 * {
INSERT INTO t1 VALUES(1, 'one', 'i');
SELECT indirect(1);
INSERT INTO t1 VALUES(2, 'two', 'ii');
SELECT indirect(0);
INSERT INTO t1 VALUES(3, 'three', 'iii');
} {
{INSERT t1 0 X.. {} {i 1 t one t i}}
{INSERT t1 1 X.. {} {i 2 t two t ii}}
{INSERT t1 0 X.. {} {i 3 t three t iii}}
}
do_iterator_test 6.1.2 * {
SELECT indirect(1);
UPDATE t1 SET c = 'I' WHERE a = 1;
SELECT indirect(0);
} {
{UPDATE t1 1 X.. {i 1 {} {} t i} {{} {} {} {} t I}}
}
do_iterator_test 6.1.3 * {
SELECT indirect(1);
UPDATE t1 SET c = '.' WHERE a = 1;
SELECT indirect(0);
UPDATE t1 SET c = 'o' WHERE a = 1;
} {
{UPDATE t1 0 X.. {i 1 {} {} t I} {{} {} {} {} t o}}
}
do_iterator_test 6.1.4 * {
SELECT indirect(0);
UPDATE t1 SET c = 'x' WHERE a = 1;
SELECT indirect(1);
UPDATE t1 SET c = 'i' WHERE a = 1;
} {
{UPDATE t1 0 X.. {i 1 {} {} t o} {{} {} {} {} t i}}
}
do_iterator_test 6.1.4 * {
SELECT indirect(1);
UPDATE t1 SET c = 'y' WHERE a = 1;
SELECT indirect(1);
UPDATE t1 SET c = 'I' WHERE a = 1;
} {
{UPDATE t1 1 X.. {i 1 {} {} t i} {{} {} {} {} t I}}
}
do_iterator_test 6.1.5 * {
INSERT INTO t2 VALUES(1, 'x');
} {
{INSERT t2 0 X. {} {i 1 t x}}
{INSERT t2 1 X. {} {i 2 n {}}}
}
do_iterator_test 6.1.6 * {
SELECT indirect(1);
INSERT INTO t2 VALUES(3, 'x');
SELECT indirect(0);
UPDATE t2 SET y = 'y' WHERE x>2;
} {
{INSERT t2 0 X. {} {i 3 t y}}
{INSERT t2 0 X. {} {i 4 t y}}
}
do_iterator_test 6.1.7 * {
SELECT indirect(1);
DELETE FROM t2 WHERE x = 4;
SELECT indirect(0);
INSERT INTO t2 VALUES(4, 'new');
} {
{UPDATE t2 0 X. {i 4 t y} {{} {} t new}}
}
do_iterator_test 6.1.8 * {
CREATE TABLE t3(a, b PRIMARY KEY);
CREATE TABLE t4(a, b PRIMARY KEY);
CREATE TRIGGER t4t AFTER UPDATE ON t4 BEGIN
UPDATE t3 SET a = new.a WHERE b = new.b;
END;
SELECT indirect(1);
INSERT INTO t3 VALUES('one', 1);
INSERT INTO t4 VALUES('one', 1);
SELECT indirect(0);
UPDATE t4 SET a = 'two' WHERE b = 1;
} {
{INSERT t3 1 .X {} {t two i 1}}
{INSERT t4 0 .X {} {t two i 1}}
}
sqlite3session S db main
do_execsql_test 6.2.1 {
SELECT indirect(0);
SELECT indirect(-1);
SELECT indirect(45);
SELECT indirect(-100);
} {0 0 1 1}
S delete
#-------------------------------------------------------------------------
# Test that if a conflict-handler that has been passed either NOTFOUND or
# CONSTRAINT returns REPLACE - the sqlite3changeset_apply() call returns
# MISUSE and rolls back any changes made so far.
#
# 7.1.*: NOTFOUND conflict-callback.
# 7.2.*: CONSTRAINT conflict-callback.
#
proc xConflict {args} {return REPLACE}
test_reset
do_execsql_test 7.1.1 {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES(1, 'one');
INSERT INTO t1 VALUES(2, 'two');
}
do_test 7.1.2 {
execsql {
CREATE TABLE t1(a PRIMARY KEY, b NOT NULL);
INSERT INTO t1 VALUES(1, 'one');
} db2
} {}
do_test 7.1.3 {
set changeset [changeset_from_sql {
UPDATE t1 SET b = 'five' WHERE a = 1;
UPDATE t1 SET b = 'six' WHERE a = 2;
}]
set x [list]
sqlite3session_foreach c $changeset { lappend x $c }
set x
} [list \
{UPDATE t1 0 X. {i 1 t one} {{} {} t five}} \
{UPDATE t1 0 X. {i 2 t two} {{} {} t six}} \
]
do_test 7.1.4 {
list [catch {sqlite3changeset_apply db2 $changeset xConflict} msg] $msg
} {1 SQLITE_MISUSE}
do_test 7.1.5 { execsql { SELECT * FROM t1 } db2 } {1 one}
do_test 7.2.1 {
set changeset [changeset_from_sql { UPDATE t1 SET b = NULL WHERE a = 1 }]
set x [list]
sqlite3session_foreach c $changeset { lappend x $c }
set x
} [list \
{UPDATE t1 0 X. {i 1 t five} {{} {} n {}}} \
]
do_test 7.2.2 {
list [catch {sqlite3changeset_apply db2 $changeset xConflict} msg] $msg
} {1 SQLITE_MISUSE}
do_test 7.2.3 { execsql { SELECT * FROM t1 } db2 } {1 one}
#-------------------------------------------------------------------------
# Test that if a conflict-handler returns ABORT, application of the
# changeset is rolled back and the sqlite3changeset_apply() method returns
# SQLITE_ABORT.
#
# Also test that the same thing happens if a conflict handler returns an
# unrecognized integer value. Except, in this case SQLITE_MISUSE is returned
# instead of SQLITE_ABORT.
#
foreach {tn conflict_return apply_return} {
1 ABORT SQLITE_ABORT
2 567 SQLITE_MISUSE
} {
test_reset
proc xConflict {args} [list return $conflict_return]
do_test 8.$tn.0 {
do_common_sql {
CREATE TABLE t1(x, y, PRIMARY KEY(x, y));
INSERT INTO t1 VALUES('x', 'y');
}
execsql { INSERT INTO t1 VALUES('w', 'w') }
set changeset [changeset_from_sql { DELETE FROM t1 WHERE 1 }]
set x [list]
sqlite3session_foreach c $changeset { lappend x $c }
set x
} [list \
{DELETE t1 0 XX {t w t w} {}} \
{DELETE t1 0 XX {t x t y} {}} \
]
do_test 8.$tn.1 {
list [catch {sqlite3changeset_apply db2 $changeset xConflict} msg] $msg
} [list 1 $apply_return]
do_test 8.$tn.2 {
execsql {SELECT * FROM t1} db2
} {x y}
}
#-------------------------------------------------------------------------
# Try to cause an infinite loop as follows:
#
# 1. Have a changeset insert a row that causes a CONFLICT callback,
# 2. Have the conflict handler return REPLACE,
# 3. After the session module deletes the conflicting row, have a trigger
# re-insert it.
# 4. Goto step 1...
#
# This doesn't work, as the second invocation of the conflict handler is a
# CONSTRAINT, not a CONFLICT. There is at most one CONFLICT callback for
# each change in the changeset.
#
test_reset
proc xConflict {type args} {
if {$type == "CONFLICT"} { return REPLACE }
return OMIT
}
do_test 9.1 {
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
}
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('x', 2);
CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN
INSERT INTO t1 VALUES(old.a, old.b);
END;
} db2
} {}
do_test 9.2 {
set changeset [changeset_from_sql { INSERT INTO t1 VALUES('x', 1) }]
sqlite3changeset_apply db2 $changeset xConflict
} {}
do_test 9.3 {
execsql { SELECT * FROM t1 } db2
} {x 2}
#-------------------------------------------------------------------------
#
test_reset
db function enable [list S enable]
do_common_sql {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('x', 'X');
}
do_iterator_test 10.1 t1 {
INSERT INTO t1 VALUES('y', 'Y');
SELECT enable(0);
INSERT INTO t1 VALUES('z', 'Z');
SELECT enable(1);
} {
{INSERT t1 0 X. {} {t y t Y}}
}
sqlite3session S db main
do_execsql_test 10.2 {
SELECT enable(0);
SELECT enable(-1);
SELECT enable(1);
SELECT enable(-1);
} {0 0 1 1}
S delete
finish_test
+211
View File
@@ -0,0 +1,211 @@
# 2011 March 24
#
# 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 the session module. More
# specifically, it focuses on testing the session modules response to
# database schema modifications and mismatches.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session3
#-------------------------------------------------------------------------
# These tests - session3-1.* - verify that the session module behaves
# correctly when confronted with a schema mismatch when applying a
# changeset (in function sqlite3changeset_apply()).
#
# session3-1.1.*: Table does not exist in target db.
# session3-1.2.*: Table has wrong number of columns in target db.
# session3-1.3.*: Table has wrong PK columns in target db.
#
db close
sqlite3_shutdown
test_sqlite3_log log
sqlite3 db test.db
proc log {code msg} { lappend ::log $code $msg }
forcedelete test.db2
sqlite3 db2 test.db2
do_execsql_test 1.0 {
CREATE TABLE t1(a PRIMARY KEY, b);
}
do_test 1.1 {
set ::log {}
do_then_apply_sql {
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(3, 4);
}
set ::log
} {SQLITE_SCHEMA {sqlite3changeset_apply(): no such table: t1}}
do_test 1.2.0 {
execsql { CREATE TABLE t1(a PRIMARY KEY, b, c) } db2
} {}
do_test 1.2.1 {
set ::log {}
do_then_apply_sql {
INSERT INTO t1 VALUES(5, 6);
INSERT INTO t1 VALUES(7, 8);
}
set ::log
} {SQLITE_SCHEMA {sqlite3changeset_apply(): table t1 has 3 columns, expected 2}}
do_test 1.3.0 {
execsql {
DROP TABLE t1;
CREATE TABLE t1(a, b PRIMARY KEY);
} db2
} {}
do_test 1.3.1 {
set ::log {}
do_then_apply_sql {
INSERT INTO t1 VALUES(9, 10);
INSERT INTO t1 VALUES(11, 12);
}
set ::log
} {SQLITE_SCHEMA {sqlite3changeset_apply(): primary key mismatch for table t1}}
#-------------------------------------------------------------------------
# These tests - session3-2.* - verify that the session module behaves
# correctly when the schema of an attached table is modified during the
# session.
#
# session3-2.1.*: Table is dropped midway through the session.
# session3-2.2.*: Table is dropped and recreated with a different # cols.
# session3-2.3.*: Table is dropped and recreated with a different PK.
#
# In all of these scenarios, the call to sqlite3session_changeset() will
# return SQLITE_SCHEMA. Also:
#
# session3-2.4.*: Table is dropped and recreated with an identical schema.
# In this case sqlite3session_changeset() returns SQLITE_OK.
#
do_test 2.1 {
execsql { CREATE TABLE t2(a, b PRIMARY KEY) }
sqlite3session S db main
S attach t2
execsql {
INSERT INTO t2 VALUES(1, 2);
DROP TABLE t2;
}
list [catch { S changeset } msg] $msg
} {1 SQLITE_SCHEMA}
do_test 2.2.1 {
S delete
sqlite3session S db main
execsql { CREATE TABLE t2(a, b PRIMARY KEY, c) }
S attach t2
execsql {
INSERT INTO t2 VALUES(1, 2, 3);
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY);
}
list [catch { S changeset } msg] $msg
} {1 SQLITE_SCHEMA}
do_test 2.2.2 {
S delete
sqlite3session S db main
execsql {
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY, c);
}
S attach t2
execsql {
INSERT INTO t2 VALUES(1, 2, 3);
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY, c, d);
}
list [catch { S changeset } msg] $msg
} {1 SQLITE_SCHEMA}
do_test 2.2.3 {
S delete
sqlite3session S db main
execsql {
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY, c);
}
S attach t2
execsql {
INSERT INTO t2 VALUES(1, 2, 3);
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY);
INSERT INTO t2 VALUES(4, 5);
}
list [catch { S changeset } msg] $msg
} {1 SQLITE_SCHEMA}
do_test 2.2.4 {
S delete
sqlite3session S db main
execsql {
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY, c);
}
S attach t2
execsql {
INSERT INTO t2 VALUES(1, 2, 3);
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY, c, d);
INSERT INTO t2 VALUES(4, 5, 6, 7);
}
list [catch { S changeset } msg] $msg
} {1 SQLITE_SCHEMA}
do_test 2.3 {
S delete
sqlite3session S db main
execsql {
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY);
}
S attach t2
execsql {
INSERT INTO t2 VALUES(1, 2);
DROP TABLE t2;
CREATE TABLE t2(a PRIMARY KEY, b);
}
list [catch { S changeset } msg] $msg
} {1 SQLITE_SCHEMA}
do_test 2.4 {
S delete
sqlite3session S db main
execsql {
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY);
}
S attach t2
execsql {
INSERT INTO t2 VALUES(1, 2);
DROP TABLE t2;
CREATE TABLE t2(a, b PRIMARY KEY);
}
list [catch { S changeset } msg] $msg
} {0 {}}
S delete
catch { db close }
catch { db2 close }
sqlite3_shutdown
test_sqlite3_log
sqlite3_initialize
finish_test
+68
View File
@@ -0,0 +1,68 @@
# 2011 March 25
#
# 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 the session module.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session4
do_test 1.0 {
execsql {
CREATE TABLE x(a, b, c, d, e, PRIMARY KEY(c, e));
INSERT INTO x VALUES(65.21, X'28B0', 16.35, NULL, 'doers');
INSERT INTO x VALUES(NULL, 78.49, 2, X'60', -66);
INSERT INTO x VALUES('cathedral', NULL, 35, NULL, X'B220937E80A2D8');
INSERT INTO x VALUES(NULL, 'masking', -91.37, NULL, X'596D');
INSERT INTO x VALUES(19, 'domains', 'espouse', -94, 'throw');
}
sqlite3session S db main
set changeset [changeset_from_sql {
DELETE FROM x WHERE e = -66;
UPDATE x SET a = 'parameterizable', b = 31.8 WHERE c = 35;
INSERT INTO x VALUES(-75.61, -17, 16.85, NULL, X'D73DB02678');
}]
set {} {}
} {}
# This currently causes crashes. sqlite3changeset_invert() does not handle
# corrupt changesets well.
if 0 {
do_test 1.1 {
for {set i 0} {$i < [string length $changeset]} {incr i} {
set before [string range $changeset 0 [expr $i-1]]
set after [string range $changeset [expr $i+1] end]
for {set j 10} {$j < 260} {incr j} {
set x [binary format "a*ca*" $before $j $after]
catch { sqlite3changeset_invert $x }
}
}
} {}
}
do_test 1.2 {
set x [binary format "ca*" 0 [string range $changeset 1 end]]
list [catch { sqlite3changeset_invert $x } msg] $msg
} {1 SQLITE_CORRUPT}
do_test 1.3 {
set x [binary format "ca*" 0 [string range $changeset 1 end]]
list [catch { sqlite3changeset_apply db $x xConflict } msg] $msg
} {1 SQLITE_CORRUPT}
finish_test
+408
View File
@@ -0,0 +1,408 @@
# 2011 April 13
#
# 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 the session module.
# Specifically, for the sqlite3changeset_concat() command.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session5
# Organization of tests:
#
# session5-1.*: Simple tests to check the concat() function produces
# correct results.
#
# session5-2.*: More complicated tests.
#
# session5-3.*: Schema mismatch errors.
#
# session5-4.*: Test the concat cases that indicate that the database
# was modified in between recording of the two changesets
# being concatenated (i.e. two changesets that INSERT rows
# with the same PK values).
#
proc do_concat_test {tn args} {
set subtest 0
foreach sql $args {
incr subtest
sqlite3session S db main ; S attach *
execsql $sql
set c [S changeset]
if {[info commands s_prev] != ""} {
set c_concat [sqlite3changeset_concat $c_prev $c]
set c_two [s_prev changeset]
s_prev delete
set h_concat [changeset_to_list $c_concat]
set h_two [changeset_to_list $c_two]
do_test $tn.$subtest [list set {} $h_concat] $h_two
}
set c_prev $c
rename S s_prev
}
catch { s_prev delete }
}
#-------------------------------------------------------------------------
# Test cases session5-1.* - simple tests.
#
do_execsql_test 1.0 {
CREATE TABLE t1(a PRIMARY KEY, b);
}
do_concat_test 1.1.1 {
INSERT INTO t1 VALUES(1, 'one');
} {
INSERT INTO t1 VALUES(2, 'two');
}
do_concat_test 1.1.2 {
UPDATE t1 SET b = 'five' WHERE a = 1;
} {
UPDATE t1 SET b = 'six' WHERE a = 2;
}
do_concat_test 1.1.3 {
DELETE FROM t1 WHERE a = 1;
} {
DELETE FROM t1 WHERE a = 2;
}
# 1.2.1: INSERT + DELETE -> (none)
# 1.2.2: INSERT + UPDATE -> INSERT
#
# 1.2.3: DELETE + INSERT (matching data) -> (none)
# 1.2.4: DELETE + INSERT (non-matching data) -> UPDATE
#
# 1.2.5: UPDATE + UPDATE (matching data) -> (none)
# 1.2.6: UPDATE + UPDATE (non-matching data) -> UPDATE
# 1.2.7: UPDATE + DELETE -> DELETE
#
do_concat_test 1.2.1 {
INSERT INTO t1 VALUES('x', 'y');
} {
DELETE FROM t1 WHERE a = 'x';
}
do_concat_test 1.2.2 {
INSERT INTO t1 VALUES(5.0, 'five');
} {
UPDATE t1 SET b = 'six' WHERE a = 5.0;
}
do_execsql_test 1.2.3.1 "INSERT INTO t1 VALUES('I', 'one')"
do_concat_test 1.2.3.2 {
DELETE FROM t1 WHERE a = 'I';
} {
INSERT INTO t1 VALUES('I', 'one');
}
do_concat_test 1.2.4 {
DELETE FROM t1 WHERE a = 'I';
} {
INSERT INTO t1 VALUES('I', 'two');
}
do_concat_test 1.2.5 {
UPDATE t1 SET b = 'five' WHERE a = 'I';
} {
UPDATE t1 SET b = 'two' WHERE a = 'I';
}
do_concat_test 1.2.6 {
UPDATE t1 SET b = 'six' WHERE a = 'I';
} {
UPDATE t1 SET b = 'seven' WHERE a = 'I';
}
do_concat_test 1.2.7 {
UPDATE t1 SET b = 'eight' WHERE a = 'I';
} {
DELETE FROM t1 WHERE a = 'I';
}
#-------------------------------------------------------------------------
# Test cases session5-2.* - more complex tests.
#
db function indirect indirect
proc indirect {{x -1}} {
S indirect $x
s_prev indirect $x
}
do_concat_test 2.1 {
CREATE TABLE abc(a, b, c PRIMARY KEY);
INSERT INTO abc VALUES(NULL, NULL, 1);
INSERT INTO abc VALUES('abcdefghijkl', NULL, 2);
} {
DELETE FROM abc WHERE c = 1;
UPDATE abc SET c = 1 WHERE c = 2;
} {
INSERT INTO abc VALUES('abcdefghijkl', NULL, 2);
INSERT INTO abc VALUES(1.0, 2.0, 3);
} {
UPDATE abc SET a = a-1;
} {
CREATE TABLE def(d, e, f, PRIMARY KEY(e, f));
INSERT INTO def VALUES('x', randomblob(11000), 67);
INSERT INTO def SELECT d, e, f+1 FROM def;
INSERT INTO def SELECT d, e, f+2 FROM def;
INSERT INTO def SELECT d, e, f+4 FROM def;
} {
DELETE FROM def WHERE rowid>4;
} {
INSERT INTO def SELECT d, e, f+4 FROM def;
} {
INSERT INTO abc VALUES(22, 44, -1);
} {
UPDATE abc SET c=-2 WHERE c=-1;
UPDATE abc SET c=-3 WHERE c=-2;
} {
UPDATE abc SET c=-4 WHERE c=-3;
} {
UPDATE abc SET a=a+1 WHERE c=-3;
UPDATE abc SET a=a+1 WHERE c=-3;
} {
UPDATE abc SET a=a+1 WHERE c=-3;
UPDATE abc SET a=a+1 WHERE c=-3;
} {
INSERT INTO abc VALUES('one', 'two', 'three');
} {
SELECT indirect(1);
UPDATE abc SET a='one point five' WHERE c = 'three';
} {
SELECT indirect(0);
UPDATE abc SET a='one point six' WHERE c = 'three';
} {
CREATE TABLE x1(a, b, PRIMARY KEY(a));
SELECT indirect(1);
INSERT INTO x1 VALUES(1, 2);
} {
SELECT indirect(1);
UPDATE x1 SET b = 3 WHERE a = 1;
}
catch {db close}
forcedelete test.db
sqlite3 db test.db
do_concat_test 2.2 {
CREATE TABLE t1(a, b, PRIMARY KEY(b));
CREATE TABLE t2(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('string', 1);
INSERT INTO t1 VALUES(4, 2);
INSERT INTO t1 VALUES(X'FFAAFFAAFFAA', 3);
} {
INSERT INTO t2 VALUES('one', 'two');
INSERT INTO t2 VALUES(1, NULL);
UPDATE t1 SET a = 5 WHERE a = 2;
} {
DELETE FROM t2 WHERE a = 1;
UPDATE t1 SET a = 4 WHERE a = 2;
INSERT INTO t2 VALUES('x', 'y');
}
do_test 2.3.0 {
catch {db close}
forcedelete test.db
sqlite3 db test.db
set sql1 ""
set sql2 ""
for {set i 1} {$i < 120} {incr i} {
append sql1 "INSERT INTO x1 VALUES($i*4, $i);"
}
for {set i 1} {$i < 120} {incr i} {
append sql2 "DELETE FROM x1 WHERE a = $i*4;"
}
set {} {}
} {}
do_concat_test 2.3 {
CREATE TABLE x1(a PRIMARY KEY, b)
} $sql1 $sql2 $sql1 $sql2
do_concat_test 2.4 {
CREATE TABLE x2(a PRIMARY KEY, b);
CREATE TABLE x3(a PRIMARY KEY, b);
INSERT INTO x2 VALUES('a', 'b');
INSERT INTO x2 VALUES('x', 'y');
INSERT INTO x3 VALUES('a', 'b');
} {
INSERT INTO x2 VALUES('c', 'd');
INSERT INTO x3 VALUES('e', 'f');
INSERT INTO x3 VALUES('x', 'y');
}
do_concat_test 2.5 {
UPDATE x3 SET b = 'Y' WHERE a = 'x'
} {
DELETE FROM x3 WHERE a = 'x'
} {
DELETE FROM x2 WHERE a = 'a'
} {
INSERT INTO x2 VALUES('a', 'B');
}
for {set k 1} {$k <=10} {incr k} {
do_test 2.6.$k.1 {
drop_all_tables
set sql1 ""
set sql2 ""
for {set i 1} {$i < 120} {incr i} {
append sql1 "INSERT INTO x1 VALUES(randomblob(20+(random()%10)), $i);"
}
for {set i 1} {$i < 120} {incr i} {
append sql2 "DELETE FROM x1 WHERE rowid = $i;"
}
set {} {}
} {}
do_concat_test 2.6.$k {
CREATE TABLE x1(a PRIMARY KEY, b)
} $sql1 $sql2 $sql1 $sql2
}
for {set k 1} {$k <=10} {incr k} {
do_test 2.7.$k.1 {
drop_all_tables
set sql1 ""
set sql2 ""
for {set i 1} {$i < 120} {incr i} {
append sql1 {
INSERT INTO x1 VALUES(
CASE WHEN random()%2 THEN random() ELSE randomblob(20+random()%10) END,
CASE WHEN random()%2 THEN random() ELSE randomblob(20+random()%10) END
);
}
}
for {set i 1} {$i < 120} {incr i} {
append sql2 "DELETE FROM x1 WHERE rowid = $i;"
}
set {} {}
} {}
do_concat_test 2.7.$k {
CREATE TABLE x1(a PRIMARY KEY, b)
} $sql1 $sql2 $sql1 $sql2
}
#-------------------------------------------------------------------------
# Test that schema incompatibilities are detected correctly.
#
# session5-3.1: Incompatible number of columns.
# session5-3.2: Incompatible PK definition.
#
do_test 3.1 {
db close
forcedelete test.db
sqlite3 db test.db
execsql { CREATE TABLE t1(a PRIMARY KEY, b) }
set c1 [changeset_from_sql { INSERT INTO t1 VALUES(1, 2) }]
execsql {
DROP TABLE t1;
CREATE TABLE t1(a PRIMARY KEY, b, c);
}
set c2 [changeset_from_sql { INSERT INTO t1 VALUES(2, 3, 4) }]
list [catch { sqlite3changeset_concat $c1 $c2 } msg] $msg
} {1 SQLITE_SCHEMA}
do_test 3.2 {
db close
forcedelete test.db
sqlite3 db test.db
execsql { CREATE TABLE t1(a PRIMARY KEY, b) }
set c1 [changeset_from_sql { INSERT INTO t1 VALUES(1, 2) }]
execsql {
DROP TABLE t1;
CREATE TABLE t1(a, b PRIMARY KEY);
}
set c2 [changeset_from_sql { INSERT INTO t1 VALUES(2, 3) }]
list [catch { sqlite3changeset_concat $c1 $c2 } msg] $msg
} {1 SQLITE_SCHEMA}
#-------------------------------------------------------------------------
# Test that concat() handles these properly:
#
# session5-4.1: INSERT + INSERT
# session5-4.2: UPDATE + INSERT
# session5-4.3: DELETE + UPDATE
# session5-4.4: DELETE + DELETE
#
proc do_concat_test2 {tn sql1 sqlX sql2 expected} {
sqlite3session S db main ; S attach *
execsql $sql1
set ::c1 [S changeset]
S delete
execsql $sqlX
sqlite3session S db main ; S attach *
execsql $sql2
set ::c2 [S changeset]
S delete
uplevel do_test $tn [list {
changeset_to_list [sqlite3changeset_concat $::c1 $::c2]
}] [list [normalize_list $expected]]
}
drop_all_tables db
do_concat_test2 4.1 {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('key', 'value');
} {
DELETE FROM t1 WHERE a = 'key';
} {
INSERT INTO t1 VALUES('key', 'xxx');
} {
{INSERT t1 0 X. {} {t key t value}}
}
do_concat_test2 4.2 {
UPDATE t1 SET b = 'yyy';
} {
DELETE FROM t1 WHERE a = 'key';
} {
INSERT INTO t1 VALUES('key', 'value');
} {
{UPDATE t1 0 X. {t key t xxx} {{} {} t yyy}}
}
do_concat_test2 4.3 {
DELETE FROM t1 WHERE a = 'key';
} {
INSERT INTO t1 VALUES('key', 'www');
} {
UPDATE t1 SET b = 'valueX' WHERE a = 'key';
} {
{DELETE t1 0 X. {t key t value} {}}
}
do_concat_test2 4.4 {
DELETE FROM t1 WHERE a = 'key';
} {
INSERT INTO t1 VALUES('key', 'ttt');
} {
DELETE FROM t1 WHERE a = 'key';
} {
{DELETE t1 0 X. {t key t valueX} {}}
}
finish_test
+90
View File
@@ -0,0 +1,90 @@
# 2011 July 11
#
# 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 sessions extension.
# Specifically, it tests that sessions work when the database is modified
# using incremental blob handles.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session6
proc do_then_apply_tcl {tcl {dbname main}} {
proc xConflict args { return "OMIT" }
set rc [catch {
sqlite3session S db $dbname
db eval "SELECT name FROM $dbname.sqlite_master WHERE type = 'table'" {
S attach $name
}
eval $tcl
sqlite3changeset_apply db2 [S changeset] xConflict
} msg]
catch { S delete }
if {$rc} {error $msg}
}
test_sqlite3_log x
proc x {args} {puts $args}
forcedelete test.db2
sqlite3 db2 test.db2
do_common_sql {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(c PRIMARY KEY, d);
}
# Test a blob update.
#
do_test 1.1 {
do_then_apply_tcl {
db eval { INSERT INTO t1 VALUES(1, 'helloworld') }
db eval { INSERT INTO t2 VALUES(2, 'onetwothree') }
}
compare_db db db2
} {}
do_test 1.2 {
do_then_apply_tcl {
set fd [db incrblob t1 b 1]
puts -nonewline $fd 1234567890
close $fd
}
compare_db db db2
} {}
# Test an attached database.
#
do_test 2.1 {
forcedelete test.db3
file copy test.db2 test.db3
execsql { ATTACH 'test.db3' AS aux; }
do_then_apply_tcl {
set fd [db incrblob aux t2 d 1]
puts -nonewline $fd fourfivesix
close $fd
} aux
sqlite3 db3 test.db3
compare_db db2 db3
} {}
db3 close
db2 close
finish_test
+91
View File
@@ -0,0 +1,91 @@
# 2011 July 13
#
# 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.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session8
proc noop {args} {}
# Like [dbcksum] in tester.tcl. Except this version is not sensitive
# to changes in the value of implicit IPK columns.
#
proc udbcksum {db dbname} {
if {$dbname=="temp"} {
set master sqlite_temp_master
} else {
set master $dbname.sqlite_master
}
set alltab [$db eval "SELECT name FROM $master WHERE type='table'"]
set txt [$db eval "SELECT * FROM $master"]\n
foreach tab $alltab {
append txt [lsort [$db eval "SELECT * FROM $dbname.$tab"]]\n
}
return [md5 $txt]
}
proc do_then_undo {tn sql} {
set ck1 [udbcksum db main]
sqlite3session S db main
S attach *
db eval $sql
set ck2 [udbcksum db main]
set invert [sqlite3changeset_invert [S changeset]]
S delete
sqlite3changeset_apply db $invert noop
set ck3 [udbcksum db main]
set a [expr {$ck1==$ck2}]
set b [expr {$ck1==$ck3}]
uplevel [list do_test $tn.1 "set {} $a" 0]
uplevel [list do_test $tn.2 "set {} $b" 1]
}
do_execsql_test 1.1 {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES("abc", "xyz");
}
do_then_undo 1.2 { INSERT INTO t1 VALUES(3, 4); }
do_then_undo 1.3 { DELETE FROM t1 WHERE b=2; }
do_then_undo 1.4 { UPDATE t1 SET b = 3 WHERE a = 1; }
do_execsql_test 2.1 {
CREATE TABLE t2(a, b PRIMARY KEY);
INSERT INTO t2 VALUES(1, 2);
INSERT INTO t2 VALUES('abc', 'xyz');
}
do_then_undo 1.2 { INSERT INTO t2 VALUES(3, 4); }
do_then_undo 1.3 { DELETE FROM t2 WHERE b=2; }
do_then_undo 1.4 { UPDATE t1 SET a = '123' WHERE b = 'xyz'; }
do_execsql_test 3.1 {
CREATE TABLE t3(a, b, c, d, e, PRIMARY KEY(c, e));
INSERT INTO t3 VALUES('x', 45, 0.0, 'abcdef', 12);
INSERT INTO t3 VALUES(45, 0.0, 'abcdef', 12, 'x');
INSERT INTO t3 VALUES(0.0, 'abcdef', 12, 'x', 45);
}
do_then_undo 3.2 { UPDATE t3 SET b=b||b WHERE e!='x' }
do_then_undo 3.3 { UPDATE t3 SET a = 46 }
finish_test
+287
View File
@@ -0,0 +1,287 @@
# 2013 July 04
#
# 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 tests that the sessions module handles foreign key constraint
# violations when applying changesets as required.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session9
#--------------------------------------------------------------------
# Basic tests.
#
proc populate_db {} {
drop_all_tables
execsql {
PRAGMA foreign_keys = 1;
CREATE TABLE p1(a PRIMARY KEY, b);
CREATE TABLE c1(a PRIMARY KEY, b REFERENCES p1);
CREATE TABLE c2(a PRIMARY KEY,
b REFERENCES p1 DEFERRABLE INITIALLY DEFERRED
);
INSERT INTO p1 VALUES(1, 'one');
INSERT INTO p1 VALUES(2, 'two');
INSERT INTO p1 VALUES(3, 'three');
INSERT INTO p1 VALUES(4, 'four');
}
}
proc capture_changeset {sql} {
sqlite3session S db main
foreach t [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
S attach $t
}
execsql $sql
set ret [S changeset]
S delete
return $ret
}
do_test 1.1 {
populate_db
set cc [capture_changeset {
INSERT INTO c1 VALUES('ii', 2);
INSERT INTO c2 VALUES('iii', 3);
}]
set {} {}
} {}
proc xConflict {args} {
lappend ::xConflict {*}$args
return $::conflictret
}
foreach {tn delrow trans conflictargs conflictret} {
1 2 0 {FOREIGN_KEY 1} OMIT
2 3 0 {FOREIGN_KEY 1} OMIT
3 2 1 {FOREIGN_KEY 1} OMIT
4 3 1 {FOREIGN_KEY 1} OMIT
5 2 0 {FOREIGN_KEY 1} ABORT
6 3 0 {FOREIGN_KEY 1} ABORT
7 2 1 {FOREIGN_KEY 1} ABORT
8 3 1 {FOREIGN_KEY 1} ABORT
} {
set A(OMIT) {0 {}}
set A(ABORT) {1 SQLITE_CONSTRAINT}
do_test 1.2.$tn.1 {
populate_db
execsql { DELETE FROM p1 WHERE a=($delrow+0) }
if {$trans} { execsql BEGIN }
set ::xConflict [list]
list [catch {sqlite3changeset_apply db $::cc xConflict} msg] $msg
} $A($conflictret)
do_test 1.2.$tn.2 { set ::xConflict } $conflictargs
set A(OMIT) {1 1}
set A(ABORT) {0 0}
do_test 1.2.$tn.3 {
execsql { SELECT count(*) FROM c1 UNION ALL SELECT count(*) FROM c2 }
} $A($conflictret)
do_test 1.2.$tn.4 { expr ![sqlite3_get_autocommit db] } $trans
do_test 1.2.$tn.5 {
if { $trans } { execsql COMMIT }
} {}
}
#--------------------------------------------------------------------
# Test that closing a transaction clears the defer_foreign_keys flag.
#
foreach {tn open noclose close} {
1 BEGIN {} COMMIT
2 BEGIN {} ROLLBACK
3 {SAVEPOINT one} {} {RELEASE one}
4 {SAVEPOINT one} {ROLLBACK TO one} {RELEASE one}
} {
execsql $open
do_execsql_test 2.$tn.1 { PRAGMA defer_foreign_keys } {0}
do_execsql_test 2.$tn.2 {
PRAGMA defer_foreign_keys = 1;
PRAGMA defer_foreign_keys;
} {1}
execsql $noclose
do_execsql_test 2.$tn.3 { PRAGMA defer_foreign_keys } {1}
execsql $close
do_execsql_test 2.$tn.4 { PRAGMA defer_foreign_keys } {0}
}
#--------------------------------------------------------------------
# Test that a cyclic relationship can be inserted and deleted.
#
# This situation does not come up in practice, but testing it serves to
# show that it does not matter which order parent and child keys
# are processed in internally when applying a changeset.
#
drop_all_tables
do_execsql_test 3.1 {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(x PRIMARY KEY, y);
}
# Create changesets as follows:
#
# $cc1 - Insert a row into t1.
# $cc2 - Insert a row into t2.
# $cc - Combination of $cc1 and $cc2.
#
# $ccdel1 - Delete the row from t1.
# $ccdel2 - Delete the row from t2.
# $ccdel - Combination of $cc1 and $cc2.
#
do_test 3.2 {
set cc1 [capture_changeset {
INSERT INTO t1 VALUES('one', 'value one');
}]
set ccdel1 [capture_changeset { DELETE FROM t1; }]
set cc2 [capture_changeset {
INSERT INTO t2 VALUES('value one', 'one');
}]
set ccdel2 [capture_changeset { DELETE FROM t2; }]
set cc [capture_changeset {
INSERT INTO t1 VALUES('one', 'value one');
INSERT INTO t2 VALUES('value one', 'one');
}]
set ccdel [capture_changeset {
DELETE FROM t1;
DELETE FROM t2;
}]
set {} {}
} {}
# Now modify the database schema to create a cyclic foreign key dependency
# between tables t1 and t2. This means that although changesets $cc and
# $ccdel can be applied, none of the others may without violating the
# foreign key constraints.
#
do_test 3.3 {
drop_all_tables
execsql {
CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t2);
CREATE TABLE t2(x PRIMARY KEY, y REFERENCES t1);
}
proc conflict_handler {args} { return "ABORT" }
sqlite3changeset_apply db $cc conflict_handler
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
}
} {one {value one} {value one} one}
do_test 3.3.1 {
list [catch {sqlite3changeset_apply db $::ccdel1 conflict_handler} msg] $msg
} {1 SQLITE_CONSTRAINT}
do_test 3.3.2 {
list [catch {sqlite3changeset_apply db $::ccdel2 conflict_handler} msg] $msg
} {1 SQLITE_CONSTRAINT}
do_test 3.3.4.1 {
list [catch {sqlite3changeset_apply db $::ccdel conflict_handler} msg] $msg
} {0 {}}
do_execsql_test 3.3.4.2 {
SELECT * FROM t1;
SELECT * FROM t2;
} {}
do_test 3.5.1 {
list [catch {sqlite3changeset_apply db $::cc1 conflict_handler} msg] $msg
} {1 SQLITE_CONSTRAINT}
do_test 3.5.2 {
list [catch {sqlite3changeset_apply db $::cc2 conflict_handler} msg] $msg
} {1 SQLITE_CONSTRAINT}
#--------------------------------------------------------------------
# Test that if a change that affects FK processing is not applied
# due to a separate constraint, SQLite does not get confused and
# increment FK counters anyway.
#
drop_all_tables
do_execsql_test 4.1 {
CREATE TABLE p1(x PRIMARY KEY, y);
CREATE TABLE c1(a PRIMARY KEY, b REFERENCES p1);
INSERT INTO p1 VALUES(1,1);
}
do_execsql_test 4.2.1 {
BEGIN;
PRAGMA defer_foreign_keys = 1;
INSERT INTO c1 VALUES('x', 'x');
}
do_catchsql_test 4.2.2 { COMMIT } {1 {FOREIGN KEY constraint failed}}
do_catchsql_test 4.2.3 { ROLLBACK } {0 {}}
do_execsql_test 4.3.1 {
BEGIN;
PRAGMA defer_foreign_keys = 1;
INSERT INTO c1 VALUES(1, 1);
}
do_catchsql_test 4.3.2 {
INSERT INTO c1 VALUES(1, 'x')
} {1 {UNIQUE constraint failed: c1.a}}
do_catchsql_test 4.3.3 { COMMIT } {0 {}}
do_catchsql_test 4.3.4 { BEGIN ; COMMIT } {0 {}}
#--------------------------------------------------------------------
# Test that if a DELETE change cannot be applied due to an
# SQLITE_CONSTRAINT error thrown by a trigger program, things do not
# go awry.
drop_all_tables
reset_db
do_execsql_test 5.1 {
CREATE TABLE x1(x PRIMARY KEY, y);
CREATE TABLE x2(x PRIMARY KEY, y);
INSERT INTO x2 VALUES(1, 1);
INSERT INTO x1 VALUES(1, 1);
}
set ::cc [changeset_from_sql { DELETE FROM x1; }]
do_execsql_test 5.2 {
INSERT INTO x1 VALUES(1, 1);
CREATE TRIGGER tr1 AFTER DELETE ON x1 BEGIN
INSERT INTO x2 VALUES(old.x, old.y);
END;
} {}
proc conflict_handler {args} { return "ABORT" }
do_test 5.3 {
list [catch {sqlite3changeset_apply db $::cc conflict_handler} msg] $msg
} {1 SQLITE_ABORT}
do_execsql_test 5.4 {
SELECT * FROM X1;
} {1 1}
finish_test
+106
View File
@@ -0,0 +1,106 @@
# 2013 July 04
#
# 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 tests that filter callbacks work as required.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessionA
forcedelete test.db2
sqlite3 db2 test.db2
foreach {tn db} {1 db 2 db2} {
do_test 1.$tn.1 {
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(a PRIMARY KEY, b);
CREATE TABLE t3(a PRIMARY KEY, b);
} $db
} {}
}
proc tbl_filter {zTbl} {
return $::table_filter($zTbl)
}
do_test 2.1 {
set ::table_filter(t1) 1
set ::table_filter(t2) 0
set ::table_filter(t3) 1
sqlite3session S db main
S table_filter tbl_filter
execsql {
INSERT INTO t1 VALUES('a', 'b');
INSERT INTO t2 VALUES('c', 'd');
INSERT INTO t3 VALUES('e', 'f');
}
set changeset [S changeset]
S delete
sqlite3changeset_apply db2 $changeset xConflict
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
} db2
} {a b e f}
#-------------------------------------------------------------------------
# Test that filter callbacks passed to sqlite3changeset_apply() are
# invoked correctly.
#
reset_db
do_execsql_test 3.1 {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(x PRIMARY KEY, y);
}
do_test 3.2 {
execsql BEGIN
set ::cs [changeset_from_sql {
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t2 VALUES('x', 'y');
}]
execsql ROLLBACK
set {} {}
} {}
proc filter {x y} {
return [string equal $x $y]
}
do_test 3.3 {
sqlite3changeset_apply db $::cs {} [list filter t1]
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
}
} {1 2}
do_test 3.4 {
execsql { DELETE FROM t1 }
sqlite3changeset_apply db $::cs {} [list filter t2]
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
}
} {x y}
finish_test
+508
View File
@@ -0,0 +1,508 @@
# 2014 August 16
#
# 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 sessions SQLite extension.
# Specifically, this file contains tests for "patchset" changes.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessionB
#
# 1.*: Test that the blobs returned by the session_patchset() API are
# as expected. Also the sqlite3_changeset_iter functions.
#
# 2.*: Test that patchset blobs are handled by sqlite3changeset_apply().
#
# 3.*: Test that sqlite3changeset_invert() works with patchset blobs.
# Correct behaviour is to return SQLITE_CORRUPT.
proc do_sql2patchset_test {tn sql res} {
sqlite3session S db main
S attach *
execsql $sql
uplevel [list do_patchset_test $tn S $res]
S delete
}
#-------------------------------------------------------------------------
# Run simple tests of the _patchset() API.
#
do_execsql_test 1.0 {
CREATE TABLE t1(a, b, c, d, PRIMARY KEY(d, a));
INSERT INTO t1 VALUES(1, 2, 3, 4);
INSERT INTO t1 VALUES(5, 6, 7, 8);
INSERT INTO t1 VALUES(9, 10, 11, 12);
}
do_test 1.1 {
sqlite3session S db main
S attach t1
execsql {
INSERT INTO t1 VALUES('w', 'x', 'y', 'z');
DELETE FROM t1 WHERE d=4;
UPDATE t1 SET c = 14 WHERE a=5;
}
} {}
do_patchset_test 1.2 S {
{UPDATE t1 0 X..X {i 5 {} {} {} {} i 8} {{} {} {} {} i 14 {} {}}}
{INSERT t1 0 X..X {} {t w t x t y t z}}
{DELETE t1 0 X..X {i 1 {} {} {} {} i 4} {}}
}
do_test 1.3 {
S delete
} {}
do_sql2patchset_test 1.4 {
DELETE FROM t1;
} {
{DELETE t1 0 X..X {i 5 {} {} {} {} i 8} {}}
{DELETE t1 0 X..X {t w {} {} {} {} t z} {}}
{DELETE t1 0 X..X {i 9 {} {} {} {} i 12} {}}
}
do_sql2patchset_test 1.5 {
INSERT INTO t1 VALUES(X'61626364', NULL, NULL, 4.2);
INSERT INTO t1 VALUES(4.2, NULL, NULL, X'61626364');
} {
{INSERT t1 0 X..X {} {f 4.2 n {} n {} b abcd}}
{INSERT t1 0 X..X {} {b abcd n {} n {} f 4.2}}
}
do_sql2patchset_test 1.6 {
UPDATE t1 SET b=45 WHERE typeof(a)=='blob';
UPDATE t1 SET c='zzzz' WHERE typeof(a)!='blob';
} {
{UPDATE t1 0 X..X {f 4.2 {} {} {} {} b abcd} {{} {} {} {} t zzzz {} {}}}
{UPDATE t1 0 X..X {b abcd {} {} {} {} f 4.2} {{} {} i 45 {} {} {} {}}}
}
do_sql2patchset_test 1.7 {
UPDATE t1 SET b='xyz' WHERE typeof(a)=='blob';
UPDATE t1 SET c='xyz' WHERE typeof(a)!='blob';
UPDATE t1 SET b=45 WHERE typeof(a)=='blob';
UPDATE t1 SET c='zzzz' WHERE typeof(a)!='blob';
} {
}
do_sql2patchset_test 1.8 {
DELETE FROM t1;
} {
{DELETE t1 0 X..X {f 4.2 {} {} {} {} b abcd} {}}
{DELETE t1 0 X..X {b abcd {} {} {} {} f 4.2} {}}
}
#-------------------------------------------------------------------------
# Run simple tests of _apply() with patchset objects.
#
reset_db
proc noop {args} { error $args }
proc exec_rollback_replay {sql} {
sqlite3session S db main
S attach *
execsql BEGIN
execsql $sql
set patchset [S patchset]
S delete
execsql ROLLBACK
sqlite3changeset_apply db $patchset noop
}
do_execsql_test 2.0 {
CREATE TABLE t2(a, b, c, d, PRIMARY KEY(b,c));
CREATE TABLE t3(w, x, y, z, PRIMARY KEY(w));
}
do_test 2.1 {
exec_rollback_replay {
INSERT INTO t2 VALUES(1, 2, 3, 4);
INSERT INTO t2 VALUES('w', 'x', 'y', 'z');
}
execsql { SELECT * FROM t2 }
} {1 2 3 4 w x y z}
do_test 2.2 {
exec_rollback_replay {
DELETE FROM t2 WHERE a=1;
UPDATE t2 SET d = 'a';
}
execsql { SELECT * FROM t2 }
} {w x y a}
#-------------------------------------------------------------------------
# sqlite3changeset_invert()
#
reset_db
do_execsql_test 3.1 { CREATE TABLE t1(x PRIMARY KEY, y) }
do_test 3.2 {
sqlite3session S db main
S attach *
execsql { INSERT INTO t1 VALUES(1, 2) }
set patchset [S patchset]
S delete
list [catch { sqlite3changeset_invert $patchset } msg] [set msg]
} {1 SQLITE_CORRUPT}
#-------------------------------------------------------------------------
# sqlite3changeset_concat()
#
reset_db
proc do_patchconcat_test {tn args} {
set bRevert 0
if {[lindex $args 0] == "-revert"} {
set bRevert 1
set args [lrange $args 1 end]
}
set nSql [expr [llength $args]-1]
set res [lindex $args $nSql]
set patchlist [list]
execsql BEGIN
if {$bRevert} { execsql { SAVEPOINT x } }
foreach sql [lrange $args 0 end-1] {
sqlite3session S db main
S attach *
execsql $sql
lappend patchlist [S patchset]
S delete
if {$bRevert} { execsql { ROLLBACK TO x } }
}
execsql ROLLBACK
set patch [lindex $patchlist 0]
foreach p [lrange $patchlist 1 end] {
set patch [sqlite3changeset_concat $patch $p]
}
set x [list]
sqlite3session_foreach c $patch { lappend x $c }
uplevel [list do_test $tn [list set {} $x] [list {*}$res]]
}
do_execsql_test 4.1.1 {
CREATE TABLE t1(x PRIMARY KEY, y, z);
}
do_patchconcat_test 4.1.2 {
INSERT INTO t1 VALUES(1, 2, 3);
} {
INSERT INTO t1 VALUES(4, 5, 6);
} {
{INSERT t1 0 X.. {} {i 1 i 2 i 3}}
{INSERT t1 0 X.. {} {i 4 i 5 i 6}}
}
do_execsql_test 4.2.1 {
INSERT INTO t1 VALUES(1, 2, 3);
INSERT INTO t1 VALUES(4, 5, 6);
}
do_patchconcat_test 4.2.2 {
UPDATE t1 SET z = 'abc' WHERE x=1
} {
UPDATE t1 SET z = 'def' WHERE x=4
} {
{UPDATE t1 0 X.. {i 1 {} {} {} {}} {{} {} {} {} t abc}}
{UPDATE t1 0 X.. {i 4 {} {} {} {}} {{} {} {} {} t def}}
}
do_patchconcat_test 4.2.3 {
DELETE FROM t1 WHERE x=1;
} {
DELETE FROM t1 WHERE x=4;
} {
{DELETE t1 0 X.. {i 1 {} {} {} {}} {}}
{DELETE t1 0 X.. {i 4 {} {} {} {}} {}}
}
do_execsql_test 4.3.1 {
CREATE TABLE t2(a, b, c, d, PRIMARY KEY(c, b));
INSERT INTO t2 VALUES('.', 1, 1, '.');
INSERT INTO t2 VALUES('.', 1, 2, '.');
INSERT INTO t2 VALUES('.', 2, 1, '.');
INSERT INTO t2 VALUES('.', 2, 2, '.');
}
# INSERT + INSERT
do_patchconcat_test 4.3.2 -revert {
INSERT INTO t2 VALUES('a', 'a', 'a', 'a');
} {
INSERT INTO t2 VALUES('b', 'a', 'a', 'b');
} {
{INSERT t2 0 .XX. {} {t a t a t a t a}}
}
# INSERT + DELETE
do_patchconcat_test 4.3.3 {
INSERT INTO t2 VALUES('a', 'a', 'a', 'a');
} {
DELETE FROM t2 WHERE c = 'a';
} {
}
# INSERT + UPDATE
do_patchconcat_test 4.3.4 {
INSERT INTO t2 VALUES('a', 'a', 'a', 'a');
} {
UPDATE t2 SET d = 'b' WHERE c='a';
} {
{INSERT t2 0 .XX. {} {t a t a t a t b}}
}
# UPDATE + UPDATE
do_patchconcat_test 4.3.5 {
UPDATE t2 SET a = 'a' WHERE c=1 AND b=2;
} {
UPDATE t2 SET d = 'd' WHERE c=1 AND b=2;
} {
{UPDATE t2 0 .XX. {{} {} i 2 i 1 {} {}} {t a {} {} {} {} t d}}
}
# UPDATE + DELETE
do_patchconcat_test 4.3.6 {
UPDATE t2 SET a = 'a' WHERE c=1 AND b=2;
} {
DELETE FROM t2 WHERE c=1 AND b=2;
} {
{DELETE t2 0 .XX. {{} {} i 2 i 1 {} {}} {}}
}
# DELETE + INSERT
do_patchconcat_test 4.3.7 {
DELETE FROM t2 WHERE b=1;
} {
INSERT INTO t2 VALUES('x', 1, 2, '.');
} {
{DELETE t2 0 .XX. {{} {} i 1 i 1 {} {}} {}}
{UPDATE t2 0 .XX. {{} {} i 1 i 2 {} {}} {t x {} {} {} {} t .}}
}
# DELETE + UPDATE
do_patchconcat_test 4.3.8 -revert {
DELETE FROM t2 WHERE b=1 AND c=2;
} {
UPDATE t2 SET a=5 WHERE b=1 AND c=2;
} {
{DELETE t2 0 .XX. {{} {} i 1 i 2 {} {}} {}}
}
# DELETE + UPDATE
do_patchconcat_test 4.3.9 -revert {
DELETE FROM t2 WHERE b=1 AND c=2;
} {
DELETE FROM t2 WHERE b=1;
} {
{DELETE t2 0 .XX. {{} {} i 1 i 1 {} {}} {}}
{DELETE t2 0 .XX. {{} {} i 1 i 2 {} {}} {}}
}
#-------------------------------------------------------------------------
# More rigorous testing of the _patchset(), _apply and _concat() APIs.
#
# The inputs to each test are a populate database and a list of DML
# statements. This test determines that the final database is the same
# if:
#
# 1) the statements are executed directly on the database.
#
# 2) a single patchset is collected while executing the statements and
# then applied to a copy of the original database file.
#
# 3) individual patchsets are collected for statement while executing
# them and concatenated together before being applied to a copy of
# the original database. The concatenation is done in a couple of
# different ways - linear, pairwise etc.
#
# All tests, as it happens, are run with both changesets and patchsets.
# But the focus is on patchset capabilities.
#
# Return a checksum of the contents of the database file. Implicit IPK
# columns are not included in the checksum - just modifying rowids does
# not change the database checksum.
#
proc databasecksum {db} {
set alltab [$db eval {SELECT name FROM sqlite_master WHERE type='table'}]
foreach tab $alltab {
$db eval "SELECT * FROM $tab LIMIT 1" res { }
set slist [list]
foreach col [lsort $res(*)] {
lappend slist "quote($col)"
}
set sql "SELECT [join $slist ,] FROM $tab"
append txt "[lsort [$db eval $sql]]\n"
}
return [md5 $txt]
}
proc do_patchset_test {tn tstcmd lSql} {
if {$tstcmd != "patchset" && $tstcmd != "changeset"} {
error "have $tstcmd: must be patchset or changeset"
}
foreach fname {test.db2 test.db3 test.db4 test.db5} {
forcedelete $fname
forcecopy test.db $fname
}
# Execute the SQL statements on [db]. Collect a patchset for each
# individual statement, as well as a single patchset for the entire
# operation.
sqlite3session S db main
S attach *
foreach sql $lSql {
sqlite3session T db main
T attach *
db eval $sql
lappend lPatch [T $tstcmd]
T delete
}
set patchset [S $tstcmd]
S delete
# Calculate a checksum for the final database.
set cksum [databasecksum db]
# 1. Apply the single large patchset to test.db2
sqlite3 db2 test.db2
sqlite3changeset_apply db2 $patchset noop
uplevel [list do_test $tn.1 { databasecksum db2 } $cksum ]
db2 close
# 2. Apply each of the single-statement patchsets to test.db3
sqlite3 db2 test.db3
foreach p $lPatch {
sqlite3changeset_apply db2 $p noop
}
uplevel [list do_test $tn.2 { databasecksum db2 } $cksum ]
db2 close
# 3. Concatenate all single-statement patchsets into a single large
# patchset, then apply it to test.db4.
#
sqlite3 db2 test.db4
set big ""
foreach p $lPatch {
set big [sqlite3changeset_concat $big $p]
}
sqlite3changeset_apply db2 $big noop
uplevel [list do_test $tn.3 { databasecksum db2 } $cksum ]
db2 close
# 4. Concatenate all single-statement patchsets pairwise into a single
# large patchset, then apply it to test.db5. Pairwise concatenation:
#
# a b c d e f g h i j k
# -> {a b} {c d} {e f} {g h} {i j} k
# -> {a b c d} {e f g h} {i j k}
# -> {a b c d e f g h} {i j k}
# -> {a b c d e f g h i j k}
# -> APPLY!
#
sqlite3 db2 test.db5
set L $lPatch
while {[llength $L] > 1} {
set O [list]
for {set i 0} {$i < [llength $L]} {incr i 2} {
if {$i==[llength $L]-1} {
lappend O [lindex $L $i]
} else {
set i1 [expr $i+1]
lappend O [sqlite3changeset_concat [lindex $L $i] [lindex $L $i1]]
}
}
set L $O
}
sqlite3changeset_apply db2 [lindex $L 0] noop
uplevel [list do_test $tn.4 { databasecksum db2 } $cksum ]
db2 close
}
proc do_patchset_changeset_test {tn initsql args} {
foreach tstcmd {patchset changeset} {
reset_db
execsql $initsql
set x 0
foreach sql $args {
incr x
set lSql [split $sql ";"]
uplevel [list do_patchset_test $tn.$tstcmd.$x $tstcmd $lSql]
}
}
}
do_patchset_changeset_test 5.1 {
CREATE TABLE t1(a PRIMARY KEY, b, c);
INSERT INTO t1 VALUES(1, 2, 3);
} {
INSERT INTO t1 VALUES(4, 5, 6);
DELETE FROM t1 WHERE a=1;
} {
INSERT INTO t1 VALUES(7, 8, 9);
UPDATE t1 SET c = 5;
INSERT INTO t1 VALUES(10, 11, 12);
UPDATE t1 SET c = 6;
INSERT INTO t1 VALUES(13, 14, 15);
} {
UPDATE t1 SET c=c+1;
DELETE FROM t1 WHERE (a%2);
}
do_patchset_changeset_test 5.2 {
CREATE TABLE t1(a PRIMARY KEY, b, c);
CREATE TABLE t2(a, b, c, d, PRIMARY KEY(c, b));
} {
INSERT INTO t1 VALUES(x'00', 0, 'zero');
INSERT INTO t1 VALUES(x'01', 1, 'one');
INSERT INTO t1 VALUES(x'02', 4, 'four');
INSERT INTO t1 VALUES(x'03', 9, 'nine');
INSERT INTO t1 VALUES(x'04', 16, 'sixteen');
INSERT INTO t1 VALUES(x'05', 25, 'twenty-five');
} {
UPDATE t1 SET a = b WHERE b<=4;
INSERT INTO t2 SELECT NULL, * FROM t1;
DELETE FROM t1 WHERE b=25;
} {
DELETE FROM t2;
INSERT INTO t2 SELECT NULL, * FROM t1;
DELETE FROM t1;
INSERT INTO t1 SELECT b, c, d FROM t2;
UPDATE t1 SET b = b+1;
UPDATE t1 SET b = b+1;
UPDATE t1 SET b = b+1;
}
set initsql { CREATE TABLE t1(a, b, c, PRIMARY KEY(c, b)); }
for {set i 0} {$i < 1000} {incr i} {
append insert "INSERT INTO t1 VALUES($i, $i, $i);"
append delete "DELETE FROM t1 WHERE b=$i;"
}
do_patchset_changeset_test 5.3 \
$initsql $insert $delete \
$insert $delete \
"$insert $delete" \
$delete
finish_test
+198
View File
@@ -0,0 +1,198 @@
# 2014 August 16
#
# 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.
#
#***********************************************************************
#
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessionC
#-------------------------------------------------------------------------
# Test the outcome of a DELETE operation made as part of applying a
# changeset failing with SQLITE_CONSTRAINT. This may happen if an
# ON DELETE RESTRICT foreign key action is triggered, or if a trigger
# program raises a constraint somehow.
#
# UPDATE: The above is no longer true, as "PRAGMA defer_foreign_keys"
# now disables "RESTRICT" processing. The test below has been rewritten
# to use a trigger instead of a foreign key to test this case.
#
do_execsql_test 1.0 {
PRAGMA foreign_keys = 1;
CREATE TABLE p(a PRIMARY KEY, b, c);
CREATE TABLE c(d PRIMARY KEY, e /* REFERENCES p ON DELETE RESTRICT */);
CREATE TRIGGER restrict_trig BEFORE DELETE ON p BEGIN
SELECT raise(ABORT, 'error!') FROM c WHERE e=old.a;
END;
INSERT INTO p VALUES('one', 1, 1);
INSERT INTO p VALUES('two', 2, 2);
INSERT INTO p VALUES('three', 3, 3);
INSERT INTO c VALUES(1, 'one');
INSERT INTO c VALUES(3, 'three');
}
do_test 1.1 {
execsql BEGIN
set C [changeset_from_sql {
INSERT INTO c VALUES(4, 'one');
DELETE FROM p WHERE a='two';
}]
execsql ROLLBACK
execsql {
INSERT INTO c VALUES(2, 'two');
}
} {}
do_test 1.2.1 {
proc xConflict {args} { return "ABORT" }
catch { sqlite3changeset_apply db $C xConflict } msg
set msg
} {SQLITE_ABORT}
do_execsql_test 1.2.2 { SELECT * FROM c } {1 one 3 three 2 two}
do_test 1.3.1 {
proc xConflict {args} { return "OMIT" }
catch { sqlite3changeset_apply db $C xConflict } msg
set msg
} {}
do_execsql_test 1.3.2 { SELECT * FROM c } {1 one 3 three 2 two 4 one}
do_execsql_test 1.3.3 {
SELECT * FROM p;
} {one 1 1 two 2 2 three 3 3}
#-------------------------------------------------------------------------
# Test that concatenating a changeset with a patchset does not work.
# Any attempt to do so returns SQLITE_ERROR.
#
reset_db
do_execsql_test 2.0 {
CREATE TABLE x1(t, v PRIMARY KEY);
INSERT INTO x1 VALUES(12, 55);
INSERT INTO x1 VALUES(55, 14);
}
do_test 2.1 {
execsql BEGIN
sqlite3session S1 db main
S1 attach *
execsql {
UPDATE x1 SET t=13 WHERE v=55;
INSERT INTO x1 VALUES(99, 123);
}
set patchset [S1 patchset]
S1 delete
sqlite3session S1 db main
S1 attach *
execsql {
UPDATE x1 SET t=56 WHERE v=14;
INSERT INTO x1 VALUES(22, 998);
}
set changeset [S1 changeset]
S1 delete
execsql ROLLBACK
} {}
do_test 2.2 {
set rc [catch { sqlite3changeset_concat $patchset $changeset } msg]
list $rc $msg
} {1 SQLITE_ERROR}
do_test 2.3 {
set rc [catch { sqlite3changeset_concat $changeset $patchset } msg]
list $rc $msg
} {1 SQLITE_ERROR}
do_test 2.4 {
set rc [catch { sqlite3changeset_concat {} $patchset } msg]
list $rc $msg
} [list 0 $patchset]
do_test 2.5 {
set rc [catch { sqlite3changeset_concat $patchset {} } msg]
list $rc $msg
} [list 0 $patchset]
do_test 2.6 {
set rc [catch { sqlite3changeset_concat {} $changeset } msg]
list $rc $msg
} [list 0 $changeset]
do_test 2.7 {
set rc [catch { sqlite3changeset_concat $changeset {} } msg]
list $rc $msg
} [list 0 $changeset]
do_test 2.8 {
set rc [catch { sqlite3changeset_concat {} {} } msg]
list $rc $msg
} [list 0 {}]
#-------------------------------------------------------------------------
# Test that the xFilter argument to sqlite3changeset_apply() works.
#
reset_db
do_execsql_test 3.0 {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(a PRIMARY KEY, b);
CREATE TABLE t3(a PRIMARY KEY, b);
}
do_test 3.1 {
execsql BEGIN
set changeset [changeset_from_sql {
INSERT INTO t1 VALUES(1, 1);
INSERT INTO t2 VALUES(2, 2);
INSERT INTO t3 VALUES(3, 3);
}]
execsql ROLLBACK
} {}
do_test 3.2 {
proc xFilter {zName} {
if {$zName == "t1"} { return 1 }
return 0
}
sqlite3changeset_apply db $changeset noop xFilter
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
}
} {1 1}
do_test 3.3 {
proc xFilter {zName} {
if {$zName == "t3"} { return 1 }
return 0
}
sqlite3changeset_apply db $changeset noop xFilter
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
}
} {1 1 3 3}
finish_test
+225
View File
@@ -0,0 +1,225 @@
# 2014 August 16
#
# 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 focuses on the sqlite3session_diff() function.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessionD
proc scksum {db dbname} {
if {$dbname=="temp"} {
set master sqlite_temp_master
} else {
set master $dbname.sqlite_master
}
set alltab [$db eval "SELECT name FROM $master WHERE type='table'"]
set txt [$db eval "SELECT * FROM $master ORDER BY type,name,sql"]
foreach tab $alltab {
set cols [list]
db eval "PRAGMA $dbname.table_info = $tab" x {
lappend cols "quote($x(name))"
}
set cols [join $cols ,]
append txt [db eval "SELECT $cols FROM $tab ORDER BY $cols"]
}
return [md5 $txt]
}
proc do_diff_test {tn setup} {
reset_db
forcedelete test.db2
execsql { ATTACH 'test.db2' AS aux }
execsql $setup
sqlite3session S db main
foreach tbl [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
S attach $tbl
S diff aux $tbl
}
set C [S changeset]
S delete
sqlite3 db2 test.db2
sqlite3changeset_apply db2 $C ""
uplevel do_test $tn.1 [list {execsql { PRAGMA integrity_check } db2}] ok
db2 close
set cksum [scksum db main]
uplevel do_test $tn.2 [list {scksum db aux}] [list $cksum]
}
# Ensure that the diff produced by comparing the current contents of [db]
# with itself is empty.
proc do_empty_diff_test {tn} {
forcedelete test.db2
forcecopy test.db test.db2
execsql { ATTACH 'test.db2' AS aux }
sqlite3session S db main
foreach tbl [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
S attach $tbl
S diff aux $tbl
}
set ::C [S changeset]
S delete
uplevel [list do_test $tn {string length $::C} 0]
}
forcedelete test.db2
do_execsql_test 1.0 {
CREATE TABLE t2(a PRIMARY KEY, b);
INSERT INTO t2 VALUES(1, 'one');
INSERT INTO t2 VALUES(2, 'two');
ATTACH 'test.db2' AS aux;
CREATE TABLE aux.t2(a PRIMARY KEY, b);
}
do_test 1.1 {
sqlite3session S db main
S attach t2
S diff aux t2
set C [S changeset]
S delete
} {}
do_test 1.2 {
sqlite3 db2 test.db2
sqlite3changeset_apply db2 $C ""
db2 close
db eval { SELECT * FROM aux.t2 }
} {1 one 2 two}
do_diff_test 2.1 {
CREATE TABLE aux.t1(x, y, PRIMARY KEY(y));
CREATE TABLE t1(x, y, PRIMARY KEY(y));
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(NULL, 'xyz');
INSERT INTO t1 VALUES(4.5, 5.5);
}
do_diff_test 2.2 {
CREATE TABLE aux.t1(x, y, PRIMARY KEY(y));
CREATE TABLE t1(x, y, PRIMARY KEY(y));
INSERT INTO aux.t1 VALUES(1, 2);
INSERT INTO aux.t1 VALUES(NULL, 'xyz');
INSERT INTO aux.t1 VALUES(4.5, 5.5);
}
do_diff_test 2.3 {
CREATE TABLE aux.t1(a PRIMARY KEY, b TEXT);
CREATE TABLE t1(a PRIMARY KEY, b TEXT);
INSERT INTO aux.t1 VALUES(1, 'one');
INSERT INTO aux.t1 VALUES(2, 'two');
INSERT INTO aux.t1 VALUES(3, 'three');
INSERT INTO t1 VALUES(1, 'I');
INSERT INTO t1 VALUES(2, 'two');
INSERT INTO t1 VALUES(3, 'III');
}
do_diff_test 2.4 {
CREATE TABLE aux.t1(a, b, c, d, PRIMARY KEY(c, b, a));
CREATE TABLE t1(a, b, c, d, PRIMARY KEY(c, b, a));
INSERT INTO t1 VALUES('hvkzyipambwdqlvwv','',-458331.50,X'DA51ED5E84');
INSERT INTO t1 VALUES(X'C5C6B5DD','jjxrath',40917,830244);
INSERT INTO t1 VALUES(-204877.54,X'1704C253D5F3AFA8',155120.88,NULL);
INSERT INTO t1
VALUES('ckmqmzoeuvxisxqy',X'EB5A5D3A1DD22FD1','tidhjcbvbppdt',-642987.37);
INSERT INTO t1 VALUES(-851726,-161992,-469943,-159541);
INSERT INTO t1 VALUES(X'4A6A667F858938',185083,X'7A',NULL);
INSERT INTO aux.t1 VALUES(415075.74,'auawczkb',X'',X'57B4FAAF2595');
INSERT INTO aux.t1 VALUES(727637,711560,-181340,'hphuo');
INSERT INTO aux.t1
VALUES(-921322.81,662959,'lvlgwdgxaurr','ajjrzrbhqflsutnymgc');
INSERT INTO aux.t1 VALUES(-146061,-377892,X'4E','gepvpvvuhszpxabbb');
INSERT INTO aux.t1 VALUES(-851726,-161992,-469943,-159541);
INSERT INTO aux.t1 VALUES(X'4A6A667F858938',185083,X'7A',NULL);
INSERT INTO aux.t1 VALUES(-204877.54,X'1704C253D5F3AFA8',155120.88, 4);
INSERT INTO aux.t1
VALUES('ckmqmzoeuvxisxqy',X'EB5A5D3A1DD22FD1','tidgtsplhjcbvbppdt',-642987.3);
}
reset_db
do_execsql_test 3.0 {
CREATE TABLE t1(a, b, c, PRIMARY KEY(a));
INSERT INTO t1 VALUES(1, 2, 3);
INSERT INTO t1 VALUES(4, 5, 6);
INSERT INTO t1 VALUES(7, 8, 9);
CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b));
INSERT INTO t2 VALUES(1, 2, 3);
INSERT INTO t2 VALUES(4, 5, 6);
INSERT INTO t2 VALUES(7, 8, 9);
CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b, c));
INSERT INTO t3 VALUES(1, 2, 3);
INSERT INTO t3 VALUES(4, 5, 6);
INSERT INTO t3 VALUES(7, 8, 9);
}
do_empty_diff_test 3.1
#-------------------------------------------------------------------------
# Test some error cases:
#
# 1) schema mismatches between the two dbs, and
# 2) tables with no primary keys. This is not actually an error, but
# should not add any changes to the session object.
#
reset_db
forcedelete test.db2
do_execsql_test 4.0 {
ATTACH 'test.db2' AS ixua;
CREATE TABLE ixua.t1(a, b, c);
CREATE TABLE main.t1(a, b, c);
INSERT INTO main.t1 VALUES(1, 2, 3);
CREATE TABLE ixua.t2(a PRIMARY KEY, b, c);
CREATE TABLE main.t2(a PRIMARY KEY, b, x);
}
do_test 4.1.1 {
sqlite3session S db main
S attach t1
list [catch { S diff ixua t1 } msg] $msg
} {0 {}}
do_test 4.1.2 {
string length [S changeset]
} {0}
S delete
do_test 4.2.2 {
sqlite3session S db main
S attach t2
list [catch { S diff ixua t2 } msg] $msg
} {1 {SQLITE_SCHEMA - table schemas do not match}}
S delete
finish_test
+117
View File
@@ -0,0 +1,117 @@
# 2015 June 02
#
# 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 the sessions module.
# Specifically, it tests that operations on tables without primary keys
# are ignored.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessionE
#
# Test plan:
#
# 1.*: Test that non-PK tables are not auto-attached.
# 2.*: Test that explicitly attaching a non-PK table is a no-op.
# 3.*: Test that sqlite3session_diff() on a non-PK table is a no-op.
#
#--------------------------------------------------------------------------
reset_db
do_execsql_test 1.0 {
CREATE TABLE t1(a, b);
CREATE TABLE t2(a PRIMARY KEY, b);
}
do_test 1.1 {
sqlite3session S db main
S attach *
breakpoint
execsql {
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t2 VALUES(1, 2);
}
} {}
do_changeset_test 1.2 S {
{INSERT t2 0 X. {} {i 1 i 2}}
}
S delete
reset_db
do_execsql_test 2.0 {
CREATE TABLE t1(a, b);
CREATE TABLE t2(a PRIMARY KEY, b);
}
do_test 2.1 {
sqlite3session S db main
S attach t1
S attach t2
breakpoint
execsql {
INSERT INTO t1 VALUES(3, 4);
INSERT INTO t2 VALUES(3, 4);
INSERT INTO t1 VALUES(5, 6);
INSERT INTO t2 VALUES(5, 6);
}
} {}
do_changeset_test 2.2 S {
{INSERT t2 0 X. {} {i 3 i 4}}
{INSERT t2 0 X. {} {i 5 i 6}}
}
S delete
reset_db
forcedelete test.db2
do_execsql_test 3.0 {
ATTACH 'test.db2' AS aux;
CREATE TABLE aux.t1(a, b);
CREATE TABLE aux.t2(a PRIMARY KEY, b);
CREATE TABLE t1(a, b);
CREATE TABLE t2(a PRIMARY KEY, b);
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t2 VALUES(3, 4);
}
do_test 3.1 {
sqlite3session S db main
S attach t1
S diff aux t1
S attach t2
S diff aux t2
} {}
do_changeset_test 3.2 S {
{INSERT t2 0 X. {} {i 3 i 4}}
}
do_execsql_test 3.3 {
INSERT INTO t1 VALUES(5, 6);
INSERT INTO t2 VALUES(7, 8);
}
do_changeset_test 3.4 S {
{INSERT t2 0 X. {} {i 3 i 4}}
{INSERT t2 0 X. {} {i 7 i 8}}
}
S delete
finish_test
+295
View File
@@ -0,0 +1,295 @@
# 2015 June 02
#
# 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 the sessions module.
# Specifically, it tests that tables appear in the correct order
# within changesets and patchsets.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessionF
#
# Test plan:
#
# 1.*: Test that sqlite3session_changeset() and sqlite3session_patchset()
# output tables in the right order.
#
# 2.*: Test that sqlite3session_invert() does not modify the order of
# tables within a changeset.
#
# 3.*: Test that sqlite3session_concat outputs tables in the right order.
#
# Create a db schema to use.
#
do_execsql_test 1.0 {
CREATE TABLE t3(e PRIMARY KEY, f);
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(c PRIMARY KEY, d);
}
#-----------------------------------------------------------------------
# 1.* - changeset() and patchset().
#
foreach {tn setup result} {
1 {
S attach *
} {
{INSERT t2 0 X. {} {i 2 t two}}
{INSERT t1 0 X. {} {i 1 t one}}
{INSERT t3 0 X. {} {i 3 t three}}
}
2 {
S attach t1
S attach *
} {
{INSERT t1 0 X. {} {i 1 t one}}
{INSERT t2 0 X. {} {i 2 t two}}
{INSERT t3 0 X. {} {i 3 t three}}
}
3 {
S attach t3
S attach t2
S attach t1
} {
{INSERT t3 0 X. {} {i 3 t three}}
{INSERT t2 0 X. {} {i 2 t two}}
{INSERT t1 0 X. {} {i 1 t one}}
}
} {
execsql {
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
}
sqlite3session S db main
eval $setup
do_execsql_test 1.$tn.1 {
INSERT INTO t2 VALUES(2, 'two');
INSERT INTO t1 VALUES(1, 'one');
INSERT INTO t3 VALUES(3, 'three');
}
do_changeset_test 1.1.$tn.2 S $result
do_patchset_test 1.1.$tn.3 S $result
S delete
}
foreach {tn setup result} {
1 {
S attach *
} {
{INSERT t2 0 X. {} {i 4 t four}}
{INSERT t2 0 X. {} {i 5 t five}}
{INSERT t1 0 X. {} {i 1 t one}}
{INSERT t3 0 X. {} {i 6 t six}}
}
2 {
S attach t1
S attach *
} {
{INSERT t1 0 X. {} {i 1 t one}}
{INSERT t2 0 X. {} {i 4 t four}}
{INSERT t2 0 X. {} {i 5 t five}}
{INSERT t3 0 X. {} {i 6 t six}}
}
3 {
S attach t3
S attach t2
S attach t1
} {
{INSERT t3 0 X. {} {i 6 t six}}
{INSERT t2 0 X. {} {i 4 t four}}
{INSERT t2 0 X. {} {i 5 t five}}
{INSERT t1 0 X. {} {i 1 t one}}
}
} {
execsql {
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
}
sqlite3session S db main
eval $setup
do_execsql_test 1.$tn.1 {
INSERT INTO t2 VALUES(2, 'two');
INSERT INTO t1 VALUES(1, 'one');
DELETE FROM t2;
INSERT INTO t2 VALUES(4, 'four');
INSERT INTO t2 VALUES(5, 'five');
INSERT INTO t3 VALUES(6, 'six');
}
do_changeset_test 1.2.$tn.2 S $result
do_patchset_test 1.2.$tn.2 S $result
S delete
}
#-------------------------------------------------------------------------
# 2.* - invert()
#
foreach {tn setup result} {
1 {
S attach *
} {
{DELETE t2 0 X. {i 4 t four} {}}
{DELETE t2 0 X. {i 5 t five} {}}
{DELETE t1 0 X. {i 1 t one} {}}
{DELETE t3 0 X. {i 6 t six} {}}
}
2 {
S attach t1
S attach *
} {
{DELETE t1 0 X. {i 1 t one} {}}
{DELETE t2 0 X. {i 4 t four} {}}
{DELETE t2 0 X. {i 5 t five} {}}
{DELETE t3 0 X. {i 6 t six} {}}
}
3 {
S attach t3
S attach t2
S attach t1
} {
{DELETE t3 0 X. {i 6 t six} {}}
{DELETE t2 0 X. {i 4 t four} {}}
{DELETE t2 0 X. {i 5 t five} {}}
{DELETE t1 0 X. {i 1 t one} {}}
}
} {
execsql {
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
}
sqlite3session S db main
eval $setup
do_execsql_test 1.$tn.1 {
INSERT INTO t2 VALUES(2, 'two');
INSERT INTO t1 VALUES(1, 'one');
DELETE FROM t2;
INSERT INTO t2 VALUES(4, 'four');
INSERT INTO t2 VALUES(5, 'five');
INSERT INTO t3 VALUES(6, 'six');
}
do_changeset_invert_test 2.$tn.2 S $result
S delete
}
#-------------------------------------------------------------------------
# 3.* - concat()
#
foreach {tn setup1 sql1 setup2 sql2 result} {
1 {
S attach *
} {
INSERT INTO t1 VALUES(1, 'one');
INSERT INTO t2 VALUES(2, 'two');
} {
S attach t2
S attach t1
} {
INSERT INTO t1 VALUES(3, 'three');
INSERT INTO t2 VALUES(4, 'four');
} {
{INSERT t1 0 X. {} {i 1 t one}}
{INSERT t1 0 X. {} {i 3 t three}}
{INSERT t2 0 X. {} {i 2 t two}}
{INSERT t2 0 X. {} {i 4 t four}}
}
1 {
S attach t2
S attach t1
} {
INSERT INTO t1 VALUES(1, 'one');
INSERT INTO t2 VALUES(2, 'two');
} {
S attach *
} {
INSERT INTO t1 VALUES(3, 'three');
INSERT INTO t2 VALUES(4, 'four');
} {
{INSERT t2 0 X. {} {i 2 t two}}
{INSERT t2 0 X. {} {i 4 t four}}
{INSERT t1 0 X. {} {i 1 t one}}
{INSERT t1 0 X. {} {i 3 t three}}
}
1 {
S attach *
} {
INSERT INTO t2 VALUES(2, 'two');
} {
S attach *
} {
INSERT INTO t1 VALUES(3, 'three');
INSERT INTO t2 VALUES(4, 'four');
INSERT INTO t3 VALUES(5, 'five');
} {
{INSERT t2 0 X. {} {i 2 t two}}
{INSERT t2 0 X. {} {i 4 t four}}
{INSERT t1 0 X. {} {i 3 t three}}
{INSERT t3 0 X. {} {i 5 t five}}
}
} {
execsql {
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
}
sqlite3session S db main
eval $setup1
execsql $sql1
set c1 [S changeset]
S delete
sqlite3session S db main
eval $setup2
execsql $sql2
set c2 [S changeset]
S delete
set res [list]
sqlite3session_foreach x [sqlite3changeset_concat $c1 $c2] {
lappend res $x
}
do_test 3.$tn { set res } [list {*}$result]
}
finish_test
+167
View File
@@ -0,0 +1,167 @@
proc do_changeset_test {tn session res} {
set r [list]
foreach x $res {lappend r $x}
uplevel do_test $tn [list [subst -nocommands {
set x [list]
sqlite3session_foreach c [$session changeset] { lappend x [set c] }
set x
}]] [list $r]
}
proc do_patchset_test {tn session res} {
set r [list]
foreach x $res {lappend r $x}
uplevel do_test $tn [list [subst -nocommands {
set x [list]
sqlite3session_foreach c [$session patchset] { lappend x [set c] }
set x
}]] [list $r]
}
proc do_changeset_invert_test {tn session res} {
set r [list]
foreach x $res {lappend r $x}
uplevel do_test $tn [list [subst -nocommands {
set x [list]
set changeset [sqlite3changeset_invert [$session changeset]]
sqlite3session_foreach c [set changeset] { lappend x [set c] }
set x
}]] [list $r]
}
proc do_conflict_test {tn args} {
proc xConflict {args} {
lappend ::xConflict $args
return ""
}
proc bgerror {args} { set ::background_error $args }
set O(-tables) [list]
set O(-sql) [list]
set O(-conflicts) [list]
array set V $args
foreach key [array names V] {
if {![info exists O($key)]} {error "no such option: $key"}
}
array set O $args
sqlite3session S db main
foreach t $O(-tables) { S attach $t }
execsql $O(-sql)
set ::xConflict [list]
sqlite3changeset_apply db2 [S changeset] xConflict
set conflicts [list]
foreach c $O(-conflicts) {
lappend conflicts $c
}
after 1 {set go 1}
vwait go
uplevel do_test $tn [list { set ::xConflict }] [list $conflicts]
S delete
}
proc do_common_sql {sql} {
execsql $sql db
execsql $sql db2
}
proc changeset_from_sql {sql {dbname main}} {
set rc [catch {
sqlite3session S db $dbname
db eval "SELECT name FROM $dbname.sqlite_master WHERE type = 'table'" {
S attach $name
}
db eval $sql
S changeset
} changeset]
catch { S delete }
if {$rc} {
error $changeset
}
return $changeset
}
proc do_then_apply_sql {sql {dbname main}} {
proc xConflict args { return "OMIT" }
set rc [catch {
sqlite3session S db $dbname
db eval "SELECT name FROM $dbname.sqlite_master WHERE type = 'table'" {
S attach $name
}
db eval $sql
sqlite3changeset_apply db2 [S changeset] xConflict
} msg]
catch { S delete }
if {$rc} {error $msg}
}
proc do_iterator_test {tn tbl_list sql res} {
sqlite3session S db main
if {[llength $tbl_list]==0} { S attach * }
foreach t $tbl_list {S attach $t}
execsql $sql
set r [list]
foreach v $res { lappend r $v }
set x [list]
sqlite3session_foreach c [S changeset] { lappend x $c }
uplevel do_test $tn [list [list set {} $x]] [list $r]
S delete
}
# Compare the contents of all tables in [db1] and [db2]. Throw an error if
# they are not identical, or return an empty string if they are.
#
proc compare_db {db1 db2} {
set sql {SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name}
set lot1 [$db1 eval $sql]
set lot2 [$db2 eval $sql]
if {$lot1 != $lot2} {
puts $lot1
puts $lot2
error "databases contain different tables"
}
foreach tbl $lot1 {
set col1 [list]
set col2 [list]
$db1 eval "PRAGMA table_info = $tbl" { lappend col1 $name }
$db2 eval "PRAGMA table_info = $tbl" { lappend col2 $name }
if {$col1 != $col2} { error "table $tbl schema mismatch" }
set sql "SELECT * FROM $tbl ORDER BY [join $col1 ,]"
set data1 [$db1 eval $sql]
set data2 [$db2 eval $sql]
if {$data1 != $data2} {
puts "$data1"
puts "$data2"
error "table $tbl data mismatch"
}
}
return ""
}
proc changeset_to_list {c} {
set list [list]
sqlite3session_foreach elem $c { lappend list $elem }
lsort $list
}
+588
View File
@@ -0,0 +1,588 @@
# 2011 Mar 21
#
# 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.
#
#***********************************************************************
#
# The focus of this file is testing the session module.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
set testprefix sessionfault
forcedelete test.db2
sqlite3 db2 test.db2
do_common_sql {
CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b));
INSERT INTO t1 VALUES(1, 2, 3);
INSERT INTO t1 VALUES(4, 5, 6);
}
faultsim_save_and_close
db2 close
#-------------------------------------------------------------------------
# Test OOM error handling when collecting and applying a simple changeset.
#
# Test 1.1 attaches tables individually by name to the session object.
# Whereas test 1.2 passes NULL to sqlite3session_attach() to attach all
# tables.
#
do_faultsim_test 1.1 -faults oom-* -prep {
catch {db2 close}
catch {db close}
faultsim_restore_and_reopen
sqlite3 db2 test.db2
} -body {
do_then_apply_sql {
INSERT INTO t1 VALUES('a string value', 8, 9);
UPDATE t1 SET c = 10 WHERE a = 1;
DELETE FROM t1 WHERE a = 4;
}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
faultsim_integrity_check
if {$testrc==0} { compare_db db db2 }
}
do_faultsim_test 1.2 -faults oom-* -prep {
catch {db2 close}
catch {db close}
faultsim_restore_and_reopen
} -body {
sqlite3session S db main
S attach *
execsql {
INSERT INTO t1 VALUES('a string value', 8, 9);
UPDATE t1 SET c = 10 WHERE a = 1;
DELETE FROM t1 WHERE a = 4;
}
set ::changeset [S changeset]
set {} {}
} -test {
catch { S delete }
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
faultsim_integrity_check
if {$testrc==0} {
proc xConflict {args} { return "OMIT" }
sqlite3 db2 test.db2
sqlite3changeset_apply db2 $::changeset xConflict
compare_db db db2
}
}
#-------------------------------------------------------------------------
# The following block of tests - 2.* - are designed to check
# the handling of faults in the sqlite3changeset_apply() function.
#
catch {db close}
catch {db2 close}
forcedelete test.db2 test.db
sqlite3 db2 test.db2
sqlite3 db test.db
do_common_sql {
CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b));
INSERT INTO t1 VALUES('apple', 'orange', 'pear');
CREATE TABLE t2(x PRIMARY KEY, y);
}
db2 close
faultsim_save_and_close
foreach {tn conflict_policy sql sql2} {
1 OMIT { INSERT INTO t1 VALUES('one text', 'two text', X'00ff00') } {}
2 OMIT { DELETE FROM t1 WHERE a = 'apple' } {}
3 OMIT { UPDATE t1 SET c = 'banana' WHERE b = 'orange' } {}
4 REPLACE { INSERT INTO t2 VALUES('keyvalue', 'value 1') } {
INSERT INTO t2 VALUES('keyvalue', 'value 2');
}
} {
proc xConflict args [list return $conflict_policy]
do_faultsim_test 2.$tn -faults oom-transient -prep {
catch {db2 close}
catch {db close}
faultsim_restore_and_reopen
set ::changeset [changeset_from_sql $::sql]
sqlite3 db2 test.db2
sqlite3_db_config_lookaside db2 0 0 0
execsql $::sql2 db2
} -body {
sqlite3changeset_apply db2 $::changeset xConflict
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
faultsim_integrity_check
if {$testrc==0} { compare_db db db2 }
}
}
#-------------------------------------------------------------------------
# This test case is designed so that a malloc() failure occurs while
# resizing the session object hash-table from 256 to 512 buckets. This
# is not an error, just a sub-optimal condition.
#
do_faultsim_test 3 -faults oom-* -prep {
catch {db2 close}
catch {db close}
faultsim_restore_and_reopen
sqlite3 db2 test.db2
sqlite3session S db main
S attach t1
execsql { BEGIN }
for {set i 0} {$i < 125} {incr i} {
execsql {INSERT INTO t1 VALUES(10+$i, 10+$i, 10+$i)}
}
} -body {
for {set i 125} {$i < 133} {incr i} {
execsql {INSERT INTO t1 VALUES(10+$i, 10+$i, 1-+$i)}
}
S changeset
set {} {}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
sqlite3changeset_apply db2 [S changeset] xConflict
compare_db db db2
}
catch { S delete }
faultsim_integrity_check
}
catch { db close }
catch { db2 close }
forcedelete test.db2 test.db
sqlite3 db2 test.db2
sqlite3 db test.db
proc xConflict {op tbl type args} {
if { $type=="CONFLICT" || $type=="DATA" } {
return "REPLACE"
}
return "OMIT"
}
do_test 4.0 {
execsql {
PRAGMA encoding = 'utf16';
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES(5, 32);
}
execsql {
PRAGMA encoding = 'utf16';
CREATE TABLE t1(a PRIMARY KEY, b NOT NULL);
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(2, 4);
INSERT INTO t1 VALUES(4, 16);
} db2
} {}
faultsim_save_and_close
db2 close
do_faultsim_test 4 -faults oom-* -prep {
catch {db2 close}
catch {db close}
faultsim_restore_and_reopen
sqlite3 db2 test.db2
sqlite3session S db main
S attach t1
execsql {
INSERT INTO t1 VALUES(1, 45);
INSERT INTO t1 VALUES(2, 55);
INSERT INTO t1 VALUES(3, 55);
UPDATE t1 SET a = 4 WHERE a = 5;
}
} -body {
sqlite3changeset_apply db2 [S changeset] xConflict
} -test {
catch { S delete }
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} { compare_db db db2 }
}
#-------------------------------------------------------------------------
# This block of tests verifies that OOM faults in the
# sqlite3changeset_invert() function are handled correctly.
#
catch {db close}
catch {db2 close}
forcedelete test.db
sqlite3 db test.db
execsql {
CREATE TABLE t1(a, b, PRIMARY KEY(b));
CREATE TABLE t2(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('string', 1);
INSERT INTO t1 VALUES(4, 2);
INSERT INTO t1 VALUES(X'FFAAFFAAFFAA', 3);
}
set changeset [changeset_from_sql {
INSERT INTO t1 VALUES('xxx', 'yyy');
DELETE FROM t1 WHERE a = 'string';
UPDATE t1 SET a = 20 WHERE b = 2;
}]
db close
do_faultsim_test 5.1 -faults oom* -body {
set ::inverse [sqlite3changeset_invert $::changeset]
set {} {}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
set x [list]
sqlite3session_foreach c $::inverse { lappend x $c }
foreach c {
{DELETE t1 0 .X {t xxx t yyy} {}}
{INSERT t1 0 .X {} {t string i 1}}
{UPDATE t1 0 .X {i 20 i 2} {i 4 {} {}}}
} { lappend y $c }
if {$x != $y} { error "changeset no good" }
}
}
catch {db close}
catch {db2 close}
forcedelete test.db
sqlite3 db test.db
execsql {
CREATE TABLE t2(a PRIMARY KEY, b);
INSERT INTO t2 VALUES(1, 'abc');
INSERT INTO t2 VALUES(2, 'def');
}
set changeset [changeset_from_sql {
UPDATE t2 SET b = (b || b || b || b);
UPDATE t2 SET b = (b || b || b || b);
UPDATE t2 SET b = (b || b || b || b);
UPDATE t2 SET b = (b || b || b || b);
}]
db close
set abc [string repeat abc 256]
set def [string repeat def 256]
do_faultsim_test 5.2 -faults oom-tra* -body {
set ::inverse [sqlite3changeset_invert $::changeset]
set {} {}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
set x [list]
sqlite3session_foreach c $::inverse { lappend x $c }
foreach c "
{UPDATE t2 0 X. {i 1 t $::abc} {{} {} t abc}}
{UPDATE t2 0 X. {i 2 t $::def} {{} {} t def}}
" { lappend y $c }
if {$x != $y} { error "changeset no good" }
}
}
catch {db close}
catch {db2 close}
forcedelete test.db
sqlite3 db test.db
set abc [string repeat abc 256]
set def [string repeat def 256]
execsql "
CREATE TABLE t2(a PRIMARY KEY, b);
INSERT INTO t2 VALUES(1, '$abc');
"
set changeset [changeset_from_sql "
INSERT INTO t2 VALUES(2, '$def');
DELETE FROM t2 WHERE a = 1;
"]
db close
do_faultsim_test 5.3 -faults oom-tra* -body {
set ::inverse [sqlite3changeset_invert $::changeset]
set {} {}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
set x [list]
sqlite3session_foreach c $::inverse { lappend x $c }
foreach c "
{INSERT t2 0 X. {} {i 1 t $::abc}}
{DELETE t2 0 X. {i 2 t $::def} {}}
" { lappend y $c }
if {$x != $y} { error "changeset no good" }
}
}
#-------------------------------------------------------------------------
# Test that OOM errors in sqlite3changeset_concat() are handled correctly.
#
catch {db close}
forcedelete test.db
sqlite3 db test.db
do_execsql_test 5.prep1 {
CREATE TABLE t1(a, b, PRIMARY KEY(b));
CREATE TABLE t2(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('string', 1);
INSERT INTO t1 VALUES(4, 2);
INSERT INTO t1 VALUES(X'FFAAFFAAFFAA', 3);
}
do_test 6.prep2 {
sqlite3session M db main
M attach *
set ::c2 [changeset_from_sql {
INSERT INTO t2 VALUES(randomblob(1000), randomblob(1000));
INSERT INTO t2 VALUES('one', 'two');
INSERT INTO t2 VALUES(1, NULL);
UPDATE t1 SET a = 5 WHERE a = 2;
}]
set ::c1 [changeset_from_sql {
DELETE FROM t2 WHERE a = 1;
UPDATE t1 SET a = 4 WHERE a = 2;
INSERT INTO t2 VALUES('x', 'y');
}]
set ::total [changeset_to_list [M changeset]]
M delete
} {}
do_faultsim_test 6 -faults oom-* -body {
set ::result [sqlite3changeset_concat $::c1 $::c2]
set {} {}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
set v [changeset_to_list $::result]
if {$v != $::total} { error "result no good" }
}
}
faultsim_delete_and_reopen
do_execsql_test 7.prep1 {
CREATE TABLE t1(a, b, PRIMARY KEY(a));
}
faultsim_save_and_close
set res [list]
for {set ::i 0} {$::i < 480} {incr ::i 4} {
lappend res "INSERT t1 0 X. {} {i $::i i $::i}"
}
set res [lsort $res]
do_faultsim_test 7 -faults oom-transient -prep {
catch { S delete }
faultsim_restore_and_reopen
sqlite3session S db main
S attach *
} -body {
for {set ::i 0} {$::i < 480} {incr ::i 4} {
execsql {INSERT INTO t1 VALUES($::i, $::i)}
}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
set cres [list [catch {changeset_to_list [S changeset]} msg] $msg]
S delete
if {$cres != "1 SQLITE_NOMEM" && $cres != "0 {$::res}"} {
error "Expected {0 $::res} Got {$cres}"
}
} else {
catch { S changeset }
catch { S delete }
}
}
faultsim_delete_and_reopen
do_test 8.prep {
sqlite3session S db main
S attach *
execsql {
CREATE TABLE t1(a, b, PRIMARY KEY(a));
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(3, 4);
INSERT INTO t1 VALUES(5, 6);
}
set ::changeset [S changeset]
S delete
} {}
set expected [normalize_list {
{INSERT t1 0 X. {} {i 1 i 2}}
{INSERT t1 0 X. {} {i 3 i 4}}
{INSERT t1 0 X. {} {i 5 i 6}}
}]
do_faultsim_test 8.1 -faults oom* -body {
set ::res [list]
sqlite3session_foreach -next v $::changeset { lappend ::res $v }
normalize_list $::res
} -test {
faultsim_test_result [list 0 $::expected] {1 SQLITE_NOMEM}
}
do_faultsim_test 8.2 -faults oom* -body {
set ::res [list]
sqlite3session_foreach v $::changeset { lappend ::res $v }
normalize_list $::res
} -test {
faultsim_test_result [list 0 $::expected] {1 SQLITE_NOMEM}
}
faultsim_delete_and_reopen
do_test 9.1.prep {
execsql {
PRAGMA encoding = 'utf16';
CREATE TABLE t1(a PRIMARY KEY, b);
}
} {}
faultsim_save_and_close
set answers [list {0 {}} {1 SQLITE_NOMEM} \
{1 {callback requested query abort}} \
{1 {abort due to ROLLBACK}}]
do_faultsim_test 9.1 -faults oom-transient -prep {
catch { unset ::c }
faultsim_restore_and_reopen
sqlite3session S db main
S attach *
} -body {
execsql {
INSERT INTO t1 VALUES('abcdefghijklmnopqrstuv', 'ABCDEFGHIJKLMNOPQRSTUV');
}
set ::c [S changeset]
set {} {}
} -test {
S delete
eval faultsim_test_result $::answers
if {[info exists ::c]} {
set expected [normalize_list {
{INSERT t1 0 X. {} {t abcdefghijklmnopqrstuv t ABCDEFGHIJKLMNOPQRSTUV}}
}]
if { [changeset_to_list $::c] != $expected } {
error "changeset mismatch"
}
}
}
faultsim_delete_and_reopen
do_test 9.2.prep {
execsql {
PRAGMA encoding = 'utf16';
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES('abcdefghij', 'ABCDEFGHIJKLMNOPQRSTUV');
}
} {}
faultsim_save_and_close
set answers [list {0 {}} {1 SQLITE_NOMEM} \
{1 {callback requested query abort}} \
{1 {abort due to ROLLBACK}}]
do_faultsim_test 9.2 -faults oom-transient -prep {
catch { unset ::c }
faultsim_restore_and_reopen
sqlite3session S db main
S attach *
} -body {
execsql {
UPDATE t1 SET b = 'xyz';
}
set ::c [S changeset]
set {} {}
} -test {
S delete
eval faultsim_test_result $::answers
if {[info exists ::c]} {
set expected [normalize_list {
{UPDATE t1 0 X. {t abcdefghij t ABCDEFGHIJKLMNOPQRSTUV} {{} {} t xyz}}
}]
if { [changeset_to_list $::c] != $expected } {
error "changeset mismatch"
}
}
}
#-------------------------------------------------------------------------
# Test that if a conflict-handler encounters an OOM in
# sqlite3_value_text() but goes on to return SQLITE_CHANGESET_REPLACE
# anyway, the OOM is picked up by the sessions module.
set bigstr [string repeat abcdefghij 100]
faultsim_delete_and_reopen
do_test 10.prep.1 {
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES($bigstr, $bigstr);
}
sqlite3session S db main
S attach *
execsql { UPDATE t1 SET b = b||'x' }
set C [S changeset]
S delete
execsql { UPDATE t1 SET b = b||'xyz' }
} {}
faultsim_save_and_close
faultsim_restore_and_reopen
do_test 10.prep.2 {
proc xConflict {args} { return "ABORT" }
list [catch { sqlite3changeset_apply db $C xConflict } msg] $msg
} {1 SQLITE_ABORT}
do_execsql_test 10.prep.3 { SELECT b=$bigstr||'x' FROM t1 } 0
do_test 10.prep.4 {
proc xConflict {args} { return "REPLACE" }
list [catch { sqlite3changeset_apply db $C xConflict } msg] $msg
} {0 {}}
do_execsql_test 10.prep.5 { SELECT b=$bigstr||'x' FROM t1 } 1
db close
do_faultsim_test 10 -faults oom-tra* -prep {
faultsim_restore_and_reopen
} -body {
sqlite3changeset_apply_replace_all db $::C
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
if {[db one {SELECT b=$bigstr||'x' FROM t1}]==0} {
error "data does not look right"
}
}
}
#-------------------------------------------------------------------------
# Test an OOM with an sqlite3changeset_apply() filter callback.
#
reset_db
do_test 11.prep {
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE TABLE t2(x PRIMARY KEY, y);
BEGIN;
}
set ::cs [changeset_from_sql {
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t2 VALUES('x', 'y');
}]
execsql ROLLBACK
set {} {}
} {}
proc filter {x} { return [string equal t1 $x] }
faultsim_save_and_close
do_faultsim_test 11 -faults oom-tra* -prep {
faultsim_restore_and_reopen
} -body {
sqlite3changeset_apply db $::cs {} filter
} -test {
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
if {$testrc==0} {
if {[db eval {SELECT * FROM t1 UNION ALL SELECT * FROM t2}] != "1 2"} {
error "data does not look right"
}
}
}
finish_test
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+936
View File
@@ -0,0 +1,936 @@
#if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_SESSION) \
&& defined(SQLITE_ENABLE_PREUPDATE_HOOK)
#include "sqlite3session.h"
#include <assert.h>
#include <string.h>
#include <tcl.h>
typedef struct TestSession TestSession;
struct TestSession {
sqlite3_session *pSession;
Tcl_Interp *interp;
Tcl_Obj *pFilterScript;
};
typedef struct TestStreamInput TestStreamInput;
struct TestStreamInput {
int nStream; /* Maximum chunk size */
unsigned char *aData; /* Pointer to buffer containing data */
int nData; /* Size of buffer aData in bytes */
int iData; /* Bytes of data already read by sessions */
};
#define SESSION_STREAM_TCL_VAR "sqlite3session_streams"
/*
** Attempt to find the global variable zVar within interpreter interp
** and extract an integer value from it. Return this value.
**
** If the named variable cannot be found, or if it cannot be interpreted
** as a integer, return 0.
*/
static int test_tcl_integer(Tcl_Interp *interp, const char *zVar){
Tcl_Obj *pObj;
int iVal = 0;
pObj = Tcl_ObjGetVar2(interp, Tcl_NewStringObj(zVar, -1), 0, TCL_GLOBAL_ONLY);
if( pObj ) Tcl_GetIntFromObj(0, pObj, &iVal);
return iVal;
}
static int test_session_error(Tcl_Interp *interp, int rc, char *zErr){
extern const char *sqlite3ErrName(int);
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
if( zErr ){
Tcl_AppendResult(interp, " - ", zErr, 0);
sqlite3_free(zErr);
}
return TCL_ERROR;
}
static int test_table_filter(void *pCtx, const char *zTbl){
TestSession *p = (TestSession*)pCtx;
Tcl_Obj *pEval;
int rc;
int bRes = 0;
pEval = Tcl_DuplicateObj(p->pFilterScript);
Tcl_IncrRefCount(pEval);
rc = Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zTbl, -1));
if( rc==TCL_OK ){
rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);
}
if( rc==TCL_OK ){
rc = Tcl_GetBooleanFromObj(p->interp, Tcl_GetObjResult(p->interp), &bRes);
}
if( rc!=TCL_OK ){
/* printf("error: %s\n", Tcl_GetStringResult(p->interp)); */
Tcl_BackgroundError(p->interp);
}
Tcl_DecrRefCount(pEval);
return bRes;
}
struct TestSessionsBlob {
void *p;
int n;
};
typedef struct TestSessionsBlob TestSessionsBlob;
static int testStreamOutput(
void *pCtx,
const void *pData,
int nData
){
TestSessionsBlob *pBlob = (TestSessionsBlob*)pCtx;
char *pNew;
assert( nData>0 );
pNew = (char*)sqlite3_realloc(pBlob->p, pBlob->n + nData);
if( pNew==0 ){
return SQLITE_NOMEM;
}
pBlob->p = (void*)pNew;
memcpy(&pNew[pBlob->n], pData, nData);
pBlob->n += nData;
return SQLITE_OK;
}
/*
** Tclcmd: $session attach TABLE
** $session changeset
** $session delete
** $session enable BOOL
** $session indirect INTEGER
** $session patchset
** $session table_filter SCRIPT
*/
static int test_session_cmd(
void *clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
TestSession *p = (TestSession*)clientData;
sqlite3_session *pSession = p->pSession;
struct SessionSubcmd {
const char *zSub;
int nArg;
const char *zMsg;
int iSub;
} aSub[] = {
{ "attach", 1, "TABLE", }, /* 0 */
{ "changeset", 0, "", }, /* 1 */
{ "delete", 0, "", }, /* 2 */
{ "enable", 1, "BOOL", }, /* 3 */
{ "indirect", 1, "BOOL", }, /* 4 */
{ "isempty", 0, "", }, /* 5 */
{ "table_filter", 1, "SCRIPT", }, /* 6 */
{ "patchset", 0, "", }, /* 7 */
{ "diff", 2, "FROMDB TBL", }, /* 8 */
{ 0 }
};
int iSub;
int rc;
if( objc<2 ){
Tcl_WrongNumArgs(interp, 1, objv, "SUBCOMMAND ...");
return TCL_ERROR;
}
rc = Tcl_GetIndexFromObjStruct(interp,
objv[1], aSub, sizeof(aSub[0]), "sub-command", 0, &iSub
);
if( rc!=TCL_OK ) return rc;
if( objc!=2+aSub[iSub].nArg ){
Tcl_WrongNumArgs(interp, 2, objv, aSub[iSub].zMsg);
return TCL_ERROR;
}
switch( iSub ){
case 0: { /* attach */
char *zArg = Tcl_GetString(objv[2]);
if( zArg[0]=='*' && zArg[1]=='\0' ) zArg = 0;
rc = sqlite3session_attach(pSession, zArg);
if( rc!=SQLITE_OK ){
return test_session_error(interp, rc, 0);
}
break;
}
case 7: /* patchset */
case 1: { /* changeset */
TestSessionsBlob o = {0, 0};
if( test_tcl_integer(interp, SESSION_STREAM_TCL_VAR) ){
void *pCtx = (void*)&o;
if( iSub==7 ){
rc = sqlite3session_patchset_strm(pSession, testStreamOutput, pCtx);
}else{
rc = sqlite3session_changeset_strm(pSession, testStreamOutput, pCtx);
}
}else{
if( iSub==7 ){
rc = sqlite3session_patchset(pSession, &o.n, &o.p);
}else{
rc = sqlite3session_changeset(pSession, &o.n, &o.p);
}
}
if( rc==SQLITE_OK ){
Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(o.p, o.n));
}
sqlite3_free(o.p);
if( rc!=SQLITE_OK ){
return test_session_error(interp, rc, 0);
}
break;
}
case 2: /* delete */
Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
break;
case 3: { /* enable */
int val;
if( Tcl_GetIntFromObj(interp, objv[2], &val) ) return TCL_ERROR;
val = sqlite3session_enable(pSession, val);
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));
break;
}
case 4: { /* indirect */
int val;
if( Tcl_GetIntFromObj(interp, objv[2], &val) ) return TCL_ERROR;
val = sqlite3session_indirect(pSession, val);
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));
break;
}
case 5: { /* isempty */
int val;
val = sqlite3session_isempty(pSession);
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));
break;
}
case 6: { /* table_filter */
if( p->pFilterScript ) Tcl_DecrRefCount(p->pFilterScript);
p->interp = interp;
p->pFilterScript = Tcl_DuplicateObj(objv[2]);
Tcl_IncrRefCount(p->pFilterScript);
sqlite3session_table_filter(pSession, test_table_filter, clientData);
break;
}
case 8: { /* diff */
char *zErr = 0;
rc = sqlite3session_diff(pSession,
Tcl_GetString(objv[2]),
Tcl_GetString(objv[3]),
&zErr
);
assert( rc!=SQLITE_OK || zErr==0 );
if( rc ){
return test_session_error(interp, rc, zErr);
}
break;
}
}
return TCL_OK;
}
static void test_session_del(void *clientData){
TestSession *p = (TestSession*)clientData;
if( p->pFilterScript ) Tcl_DecrRefCount(p->pFilterScript);
sqlite3session_delete(p->pSession);
ckfree((char*)p);
}
/*
** Tclcmd: sqlite3session CMD DB-HANDLE DB-NAME
*/
static int test_sqlite3session(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
sqlite3 *db;
Tcl_CmdInfo info;
int rc; /* sqlite3session_create() return code */
TestSession *p; /* New wrapper object */
if( objc!=4 ){
Tcl_WrongNumArgs(interp, 1, objv, "CMD DB-HANDLE DB-NAME");
return TCL_ERROR;
}
if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[2]), &info) ){
Tcl_AppendResult(interp, "no such handle: ", Tcl_GetString(objv[2]), 0);
return TCL_ERROR;
}
db = *(sqlite3 **)info.objClientData;
p = (TestSession*)ckalloc(sizeof(TestSession));
memset(p, 0, sizeof(TestSession));
rc = sqlite3session_create(db, Tcl_GetString(objv[3]), &p->pSession);
if( rc!=SQLITE_OK ){
ckfree((char*)p);
return test_session_error(interp, rc, 0);
}
Tcl_CreateObjCommand(
interp, Tcl_GetString(objv[1]), test_session_cmd, (ClientData)p,
test_session_del
);
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}
static void test_append_value(Tcl_Obj *pList, sqlite3_value *pVal){
if( pVal==0 ){
Tcl_ListObjAppendElement(0, pList, Tcl_NewObj());
Tcl_ListObjAppendElement(0, pList, Tcl_NewObj());
}else{
Tcl_Obj *pObj;
switch( sqlite3_value_type(pVal) ){
case SQLITE_NULL:
Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj("n", 1));
pObj = Tcl_NewObj();
break;
case SQLITE_INTEGER:
Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj("i", 1));
pObj = Tcl_NewWideIntObj(sqlite3_value_int64(pVal));
break;
case SQLITE_FLOAT:
Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj("f", 1));
pObj = Tcl_NewDoubleObj(sqlite3_value_double(pVal));
break;
case SQLITE_TEXT: {
const char *z = (char*)sqlite3_value_blob(pVal);
int n = sqlite3_value_bytes(pVal);
Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj("t", 1));
pObj = Tcl_NewStringObj(z, n);
break;
}
case SQLITE_BLOB:
Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj("b", 1));
pObj = Tcl_NewByteArrayObj(
sqlite3_value_blob(pVal),
sqlite3_value_bytes(pVal)
);
break;
}
Tcl_ListObjAppendElement(0, pList, pObj);
}
}
typedef struct TestConflictHandler TestConflictHandler;
struct TestConflictHandler {
Tcl_Interp *interp;
Tcl_Obj *pConflictScript;
Tcl_Obj *pFilterScript;
};
static int test_obj_eq_string(Tcl_Obj *p, const char *z){
int n;
int nObj;
char *zObj;
n = (int)strlen(z);
zObj = Tcl_GetStringFromObj(p, &nObj);
return (nObj==n && (n==0 || 0==memcmp(zObj, z, n)));
}
static int test_filter_handler(
void *pCtx, /* Pointer to TestConflictHandler structure */
const char *zTab /* Table name */
){
TestConflictHandler *p = (TestConflictHandler *)pCtx;
int res = 1;
Tcl_Obj *pEval;
Tcl_Interp *interp = p->interp;
pEval = Tcl_DuplicateObj(p->pFilterScript);
Tcl_IncrRefCount(pEval);
if( TCL_OK!=Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(zTab, -1))
|| TCL_OK!=Tcl_EvalObjEx(interp, pEval, TCL_EVAL_GLOBAL)
|| TCL_OK!=Tcl_GetIntFromObj(interp, Tcl_GetObjResult(interp), &res)
){
Tcl_BackgroundError(interp);
}
Tcl_DecrRefCount(pEval);
return res;
}
static int test_conflict_handler(
void *pCtx, /* Pointer to TestConflictHandler structure */
int eConf, /* DATA, MISSING, CONFLICT, CONSTRAINT */
sqlite3_changeset_iter *pIter /* Handle describing change and conflict */
){
TestConflictHandler *p = (TestConflictHandler *)pCtx;
Tcl_Obj *pEval;
Tcl_Interp *interp = p->interp;
int ret = 0; /* Return value */
int op; /* SQLITE_UPDATE, DELETE or INSERT */
const char *zTab; /* Name of table conflict is on */
int nCol; /* Number of columns in table zTab */
pEval = Tcl_DuplicateObj(p->pConflictScript);
Tcl_IncrRefCount(pEval);
sqlite3changeset_op(pIter, &zTab, &nCol, &op, 0);
if( eConf==SQLITE_CHANGESET_FOREIGN_KEY ){
int nFk;
sqlite3changeset_fk_conflicts(pIter, &nFk);
Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj("FOREIGN_KEY", -1));
Tcl_ListObjAppendElement(0, pEval, Tcl_NewIntObj(nFk));
}else{
/* Append the operation type. */
Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(
op==SQLITE_INSERT ? "INSERT" :
op==SQLITE_UPDATE ? "UPDATE" :
"DELETE", -1
));
/* Append the table name. */
Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(zTab, -1));
/* Append the conflict type. */
switch( eConf ){
case SQLITE_CHANGESET_DATA:
Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj("DATA",-1));
break;
case SQLITE_CHANGESET_NOTFOUND:
Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj("NOTFOUND",-1));
break;
case SQLITE_CHANGESET_CONFLICT:
Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj("CONFLICT",-1));
break;
case SQLITE_CHANGESET_CONSTRAINT:
Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj("CONSTRAINT",-1));
break;
}
/* If this is not an INSERT, append the old row */
if( op!=SQLITE_INSERT ){
int i;
Tcl_Obj *pOld = Tcl_NewObj();
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
sqlite3changeset_old(pIter, i, &pVal);
test_append_value(pOld, pVal);
}
Tcl_ListObjAppendElement(0, pEval, pOld);
}
/* If this is not a DELETE, append the new row */
if( op!=SQLITE_DELETE ){
int i;
Tcl_Obj *pNew = Tcl_NewObj();
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
sqlite3changeset_new(pIter, i, &pVal);
test_append_value(pNew, pVal);
}
Tcl_ListObjAppendElement(0, pEval, pNew);
}
/* If this is a CHANGESET_DATA or CHANGESET_CONFLICT conflict, append
** the conflicting row. */
if( eConf==SQLITE_CHANGESET_DATA || eConf==SQLITE_CHANGESET_CONFLICT ){
int i;
Tcl_Obj *pConflict = Tcl_NewObj();
for(i=0; i<nCol; i++){
int rc;
sqlite3_value *pVal;
rc = sqlite3changeset_conflict(pIter, i, &pVal);
assert( rc==SQLITE_OK );
test_append_value(pConflict, pVal);
}
Tcl_ListObjAppendElement(0, pEval, pConflict);
}
/***********************************************************************
** This block is purely for testing some error conditions.
*/
if( eConf==SQLITE_CHANGESET_CONSTRAINT
|| eConf==SQLITE_CHANGESET_NOTFOUND
){
sqlite3_value *pVal;
int rc = sqlite3changeset_conflict(pIter, 0, &pVal);
assert( rc==SQLITE_MISUSE );
}else{
sqlite3_value *pVal;
int rc = sqlite3changeset_conflict(pIter, -1, &pVal);
assert( rc==SQLITE_RANGE );
rc = sqlite3changeset_conflict(pIter, nCol, &pVal);
assert( rc==SQLITE_RANGE );
}
if( op==SQLITE_DELETE ){
sqlite3_value *pVal;
int rc = sqlite3changeset_new(pIter, 0, &pVal);
assert( rc==SQLITE_MISUSE );
}else{
sqlite3_value *pVal;
int rc = sqlite3changeset_new(pIter, -1, &pVal);
assert( rc==SQLITE_RANGE );
rc = sqlite3changeset_new(pIter, nCol, &pVal);
assert( rc==SQLITE_RANGE );
}
if( op==SQLITE_INSERT ){
sqlite3_value *pVal;
int rc = sqlite3changeset_old(pIter, 0, &pVal);
assert( rc==SQLITE_MISUSE );
}else{
sqlite3_value *pVal;
int rc = sqlite3changeset_old(pIter, -1, &pVal);
assert( rc==SQLITE_RANGE );
rc = sqlite3changeset_old(pIter, nCol, &pVal);
assert( rc==SQLITE_RANGE );
}
if( eConf!=SQLITE_CHANGESET_FOREIGN_KEY ){
/* eConf!=FOREIGN_KEY is always true at this point. The condition is
** just there to make it clearer what is being tested. */
int nDummy;
int rc = sqlite3changeset_fk_conflicts(pIter, &nDummy);
assert( rc==SQLITE_MISUSE );
}
/* End of testing block
***********************************************************************/
}
if( TCL_OK!=Tcl_EvalObjEx(interp, pEval, TCL_EVAL_GLOBAL) ){
Tcl_BackgroundError(interp);
}else{
Tcl_Obj *pRes = Tcl_GetObjResult(interp);
if( test_obj_eq_string(pRes, "OMIT") || test_obj_eq_string(pRes, "") ){
ret = SQLITE_CHANGESET_OMIT;
}else if( test_obj_eq_string(pRes, "REPLACE") ){
ret = SQLITE_CHANGESET_REPLACE;
}else if( test_obj_eq_string(pRes, "ABORT") ){
ret = SQLITE_CHANGESET_ABORT;
}else{
Tcl_GetIntFromObj(0, pRes, &ret);
}
}
Tcl_DecrRefCount(pEval);
return ret;
}
/*
** The conflict handler used by sqlite3changeset_apply_replace_all().
** This conflict handler calls sqlite3_value_text16() on all available
** sqlite3_value objects and then returns CHANGESET_REPLACE, or
** CHANGESET_OMIT if REPLACE is not applicable. This is used to test the
** effect of a malloc failure within an sqlite3_value_xxx() function
** invoked by a conflict-handler callback.
*/
static int replace_handler(
void *pCtx, /* Pointer to TestConflictHandler structure */
int eConf, /* DATA, MISSING, CONFLICT, CONSTRAINT */
sqlite3_changeset_iter *pIter /* Handle describing change and conflict */
){
int op; /* SQLITE_UPDATE, DELETE or INSERT */
const char *zTab; /* Name of table conflict is on */
int nCol; /* Number of columns in table zTab */
int i;
int x = 0;
sqlite3changeset_op(pIter, &zTab, &nCol, &op, 0);
if( op!=SQLITE_INSERT ){
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
sqlite3changeset_old(pIter, i, &pVal);
sqlite3_value_text16(pVal);
x++;
}
}
if( op!=SQLITE_DELETE ){
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
sqlite3changeset_new(pIter, i, &pVal);
sqlite3_value_text16(pVal);
x++;
}
}
if( eConf==SQLITE_CHANGESET_DATA ){
return SQLITE_CHANGESET_REPLACE;
}
return SQLITE_CHANGESET_OMIT;
}
static int testStreamInput(
void *pCtx, /* Context pointer */
void *pData, /* Buffer to populate */
int *pnData /* IN/OUT: Bytes requested/supplied */
){
TestStreamInput *p = (TestStreamInput*)pCtx;
int nReq = *pnData; /* Bytes of data requested */
int nRem = p->nData - p->iData; /* Bytes of data available */
int nRet = p->nStream; /* Bytes actually returned */
/* Allocate and free some space. There is no point to this, other than
** that it allows the regular OOM fault-injection tests to cause an error
** in this function. */
void *pAlloc = sqlite3_malloc(10);
if( pAlloc==0 ) return SQLITE_NOMEM;
sqlite3_free(pAlloc);
if( nRet>nReq ) nRet = nReq;
if( nRet>nRem ) nRet = nRem;
assert( nRet>=0 );
if( nRet>0 ){
memcpy(pData, &p->aData[p->iData], nRet);
p->iData += nRet;
}
*pnData = nRet;
return SQLITE_OK;
}
/*
** sqlite3changeset_apply DB CHANGESET CONFLICT-SCRIPT ?FILTER-SCRIPT?
*/
static int test_sqlite3changeset_apply(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
sqlite3 *db; /* Database handle */
Tcl_CmdInfo info; /* Database Tcl command (objv[1]) info */
int rc; /* Return code from changeset_invert() */
void *pChangeset; /* Buffer containing changeset */
int nChangeset; /* Size of buffer aChangeset in bytes */
TestConflictHandler ctx;
TestStreamInput sStr;
memset(&sStr, 0, sizeof(sStr));
sStr.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);
if( objc!=4 && objc!=5 ){
Tcl_WrongNumArgs(interp, 1, objv,
"DB CHANGESET CONFLICT-SCRIPT ?FILTER-SCRIPT?"
);
return TCL_ERROR;
}
if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) ){
Tcl_AppendResult(interp, "no such handle: ", Tcl_GetString(objv[2]), 0);
return TCL_ERROR;
}
db = *(sqlite3 **)info.objClientData;
pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[2], &nChangeset);
ctx.pConflictScript = objv[3];
ctx.pFilterScript = objc==5 ? objv[4] : 0;
ctx.interp = interp;
if( sStr.nStream==0 ){
rc = sqlite3changeset_apply(db, nChangeset, pChangeset,
(objc==5) ? test_filter_handler : 0, test_conflict_handler, (void *)&ctx
);
}else{
sStr.aData = (unsigned char*)pChangeset;
sStr.nData = nChangeset;
rc = sqlite3changeset_apply_strm(db, testStreamInput, (void*)&sStr,
(objc==5) ? test_filter_handler : 0, test_conflict_handler, (void *)&ctx
);
}
if( rc!=SQLITE_OK ){
return test_session_error(interp, rc, 0);
}
Tcl_ResetResult(interp);
return TCL_OK;
}
/*
** sqlite3changeset_apply_replace_all DB CHANGESET
*/
static int test_sqlite3changeset_apply_replace_all(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
sqlite3 *db; /* Database handle */
Tcl_CmdInfo info; /* Database Tcl command (objv[1]) info */
int rc; /* Return code from changeset_invert() */
void *pChangeset; /* Buffer containing changeset */
int nChangeset; /* Size of buffer aChangeset in bytes */
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 1, objv, "DB CHANGESET");
return TCL_ERROR;
}
if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) ){
Tcl_AppendResult(interp, "no such handle: ", Tcl_GetString(objv[2]), 0);
return TCL_ERROR;
}
db = *(sqlite3 **)info.objClientData;
pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[2], &nChangeset);
rc = sqlite3changeset_apply(db, nChangeset, pChangeset, 0, replace_handler,0);
if( rc!=SQLITE_OK ){
return test_session_error(interp, rc, 0);
}
Tcl_ResetResult(interp);
return TCL_OK;
}
/*
** sqlite3changeset_invert CHANGESET
*/
static int test_sqlite3changeset_invert(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
int rc; /* Return code from changeset_invert() */
TestStreamInput sIn; /* Input stream */
TestSessionsBlob sOut; /* Output blob */
if( objc!=2 ){
Tcl_WrongNumArgs(interp, 1, objv, "CHANGESET");
return TCL_ERROR;
}
memset(&sIn, 0, sizeof(sIn));
memset(&sOut, 0, sizeof(sOut));
sIn.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);
sIn.aData = Tcl_GetByteArrayFromObj(objv[1], &sIn.nData);
if( sIn.nStream ){
rc = sqlite3changeset_invert_strm(
testStreamInput, (void*)&sIn, testStreamOutput, (void*)&sOut
);
}else{
rc = sqlite3changeset_invert(sIn.nData, sIn.aData, &sOut.n, &sOut.p);
}
if( rc!=SQLITE_OK ){
rc = test_session_error(interp, rc, 0);
}else{
Tcl_SetObjResult(interp,Tcl_NewByteArrayObj((unsigned char*)sOut.p,sOut.n));
}
sqlite3_free(sOut.p);
return rc;
}
/*
** sqlite3changeset_concat LEFT RIGHT
*/
static int test_sqlite3changeset_concat(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
int rc; /* Return code from changeset_invert() */
TestStreamInput sLeft; /* Input stream */
TestStreamInput sRight; /* Input stream */
TestSessionsBlob sOut = {0,0}; /* Output blob */
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 1, objv, "LEFT RIGHT");
return TCL_ERROR;
}
memset(&sLeft, 0, sizeof(sLeft));
memset(&sRight, 0, sizeof(sRight));
sLeft.aData = Tcl_GetByteArrayFromObj(objv[1], &sLeft.nData);
sRight.aData = Tcl_GetByteArrayFromObj(objv[2], &sRight.nData);
sLeft.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);
sRight.nStream = sLeft.nStream;
if( sLeft.nStream>0 ){
rc = sqlite3changeset_concat_strm(
testStreamInput, (void*)&sLeft,
testStreamInput, (void*)&sRight,
testStreamOutput, (void*)&sOut
);
}else{
rc = sqlite3changeset_concat(
sLeft.nData, sLeft.aData, sRight.nData, sRight.aData, &sOut.n, &sOut.p
);
}
if( rc!=SQLITE_OK ){
rc = test_session_error(interp, rc, 0);
}else{
Tcl_SetObjResult(interp,Tcl_NewByteArrayObj((unsigned char*)sOut.p,sOut.n));
}
sqlite3_free(sOut.p);
return rc;
}
/*
** sqlite3session_foreach VARNAME CHANGESET SCRIPT
*/
static int test_sqlite3session_foreach(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
void *pChangeset;
int nChangeset;
sqlite3_changeset_iter *pIter;
int rc;
Tcl_Obj *pVarname;
Tcl_Obj *pCS;
Tcl_Obj *pScript;
int isCheckNext = 0;
TestStreamInput sStr;
memset(&sStr, 0, sizeof(sStr));
if( objc>1 ){
char *zOpt = Tcl_GetString(objv[1]);
isCheckNext = (strcmp(zOpt, "-next")==0);
}
if( objc!=4+isCheckNext ){
Tcl_WrongNumArgs(interp, 1, objv, "?-next? VARNAME CHANGESET SCRIPT");
return TCL_ERROR;
}
pVarname = objv[1+isCheckNext];
pCS = objv[2+isCheckNext];
pScript = objv[3+isCheckNext];
pChangeset = (void *)Tcl_GetByteArrayFromObj(pCS, &nChangeset);
sStr.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);
if( sStr.nStream==0 ){
rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);
}else{
sStr.aData = (unsigned char*)pChangeset;
sStr.nData = nChangeset;
rc = sqlite3changeset_start_strm(&pIter, testStreamInput, (void*)&sStr);
}
if( rc!=SQLITE_OK ){
return test_session_error(interp, rc, 0);
}
while( SQLITE_ROW==sqlite3changeset_next(pIter) ){
int nCol; /* Number of columns in table */
int nCol2; /* Number of columns in table */
int op; /* SQLITE_INSERT, UPDATE or DELETE */
const char *zTab; /* Name of table change applies to */
Tcl_Obj *pVar; /* Tcl value to set $VARNAME to */
Tcl_Obj *pOld; /* Vector of old.* values */
Tcl_Obj *pNew; /* Vector of new.* values */
int bIndirect;
char *zPK;
unsigned char *abPK;
int i;
/* Test that _fk_conflicts() returns SQLITE_MISUSE if called on this
** iterator. */
int nDummy;
if( SQLITE_MISUSE!=sqlite3changeset_fk_conflicts(pIter, &nDummy) ){
sqlite3changeset_finalize(pIter);
return TCL_ERROR;
}
sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
pVar = Tcl_NewObj();
Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj(
op==SQLITE_INSERT ? "INSERT" :
op==SQLITE_UPDATE ? "UPDATE" :
"DELETE", -1
));
Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj(zTab, -1));
Tcl_ListObjAppendElement(0, pVar, Tcl_NewBooleanObj(bIndirect));
zPK = ckalloc(nCol+1);
memset(zPK, 0, nCol+1);
sqlite3changeset_pk(pIter, &abPK, &nCol2);
assert( nCol==nCol2 );
for(i=0; i<nCol; i++){
zPK[i] = (abPK[i] ? 'X' : '.');
}
Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj(zPK, -1));
ckfree(zPK);
pOld = Tcl_NewObj();
if( op!=SQLITE_INSERT ){
int i;
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
sqlite3changeset_old(pIter, i, &pVal);
test_append_value(pOld, pVal);
}
}
pNew = Tcl_NewObj();
if( op!=SQLITE_DELETE ){
int i;
for(i=0; i<nCol; i++){
sqlite3_value *pVal;
sqlite3changeset_new(pIter, i, &pVal);
test_append_value(pNew, pVal);
}
}
Tcl_ListObjAppendElement(0, pVar, pOld);
Tcl_ListObjAppendElement(0, pVar, pNew);
Tcl_ObjSetVar2(interp, pVarname, 0, pVar, 0);
rc = Tcl_EvalObjEx(interp, pScript, 0);
if( rc!=TCL_OK && rc!=TCL_CONTINUE ){
sqlite3changeset_finalize(pIter);
return rc==TCL_BREAK ? TCL_OK : rc;
}
}
if( isCheckNext ){
int rc2 = sqlite3changeset_next(pIter);
rc = sqlite3changeset_finalize(pIter);
assert( (rc2==SQLITE_DONE && rc==SQLITE_OK) || rc2==rc );
}else{
rc = sqlite3changeset_finalize(pIter);
}
if( rc!=SQLITE_OK ){
return test_session_error(interp, rc, 0);
}
return TCL_OK;
}
int TestSession_Init(Tcl_Interp *interp){
Tcl_CreateObjCommand(interp, "sqlite3session", test_sqlite3session, 0, 0);
Tcl_CreateObjCommand(
interp, "sqlite3session_foreach", test_sqlite3session_foreach, 0, 0
);
Tcl_CreateObjCommand(
interp, "sqlite3changeset_invert", test_sqlite3changeset_invert, 0, 0
);
Tcl_CreateObjCommand(
interp, "sqlite3changeset_concat", test_sqlite3changeset_concat, 0, 0
);
Tcl_CreateObjCommand(
interp, "sqlite3changeset_apply", test_sqlite3changeset_apply, 0, 0
);
Tcl_CreateObjCommand(
interp, "sqlite3changeset_apply_replace_all",
test_sqlite3changeset_apply_replace_all, 0, 0
);
return TCL_OK;
}
#endif /* SQLITE_TEST && SQLITE_SESSION && SQLITE_PREUPDATE_HOOK */
+21 -3
View File
@@ -46,6 +46,7 @@
TCCX = $(TCC) $(OPTS) -I. -I$(TOP)/src -I$(TOP)
TCCX += -I$(TOP)/ext/rtree -I$(TOP)/ext/icu -I$(TOP)/ext/fts3
TCCX += -I$(TOP)/ext/async -I$(TOP)/ext/userauth
TCCX += -I$(TOP)/ext/session
TCCX += -I$(TOP)/ext/fts5
THREADLIB += $(LIBS)
@@ -74,6 +75,7 @@ LIBOBJ+= vdbe.o parse.o \
vdbetrace.o wal.o walker.o where.o wherecode.o whereexpr.o \
utf.o vtab.o
LIBOBJ += sqlite3session.o
# All of the source code files.
#
@@ -222,6 +224,9 @@ SRC += \
$(TOP)/ext/rtree/sqlite3rtree.h \
$(TOP)/ext/rtree/rtree.h \
$(TOP)/ext/rtree/rtree.c
SRC += \
$(TOP)/ext/session/sqlite3session.c \
$(TOP)/ext/session/sqlite3session.h
SRC += \
$(TOP)/ext/userauth/userauth.c \
$(TOP)/ext/userauth/sqlite3userauth.h
@@ -381,7 +386,10 @@ TESTSRC2 = \
$(TOP)/ext/fts3/fts3_expr.c \
$(TOP)/ext/fts3/fts3_tokenizer.c \
$(TOP)/ext/fts3/fts3_write.c \
$(TOP)/ext/async/sqlite3async.c
$(TOP)/ext/async/sqlite3async.c \
$(TOP)/ext/session/sqlite3session.c \
$(TOP)/ext/session/test_session.c \
$(FTS5_SRC)
# Header files used by all library source files.
#
@@ -534,6 +542,7 @@ target_source: $(SRC) $(TOP)/tool/vdbe-compress.tcl fts5.c
sqlite3.c: target_source $(TOP)/tool/mksqlite3c.tcl
tclsh $(TOP)/tool/mksqlite3c.tcl
cp tsrc/shell.c tsrc/sqlite3ext.h .
cp $(TOP)/ext/session/sqlite3session.h .
echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c
cat sqlite3.c >>tclsqlite3.c
echo '#endif /* USE_SYSTEM_SQLITE */' >>tclsqlite3.c
@@ -700,10 +709,12 @@ fts5.c: $(FTS5_SRC) $(FTS5_HDR)
userauth.o: $(TOP)/ext/userauth/userauth.c $(HDR) $(EXTHDR)
$(TCCX) -DSQLITE_CORE -c $(TOP)/ext/userauth/userauth.c
sqlite3session.o: $(TOP)/ext/session/sqlite3session.c $(HDR) $(EXTHDR)
$(TCCX) -DSQLITE_CORE -c $(TOP)/ext/session/sqlite3session.c
sqlite3rbu.o: $(TOP)/ext/rbu/sqlite3rbu.c $(HDR) $(EXTHDR)
$(TCCX) -DSQLITE_CORE -c $(TOP)/ext/rbu/sqlite3rbu.c
# Rules for building test programs and for running tests
#
tclsqlite3: $(TOP)/src/tclsqlite.c libsqlite3.a
@@ -734,9 +745,11 @@ testfixture$(EXE): $(TESTSRC2) libsqlite3.a $(TESTSRC) $(TOP)/src/tclsqlite.c
$(TESTSRC) $(TESTSRC2) $(TOP)/src/tclsqlite.c \
-o testfixture$(EXE) $(LIBTCL) libsqlite3.a $(THREADLIB)
amalgamation-testfixture$(EXE): sqlite3.c $(TESTSRC) $(TOP)/src/tclsqlite.c
amalgamation-testfixture$(EXE): sqlite3.c $(TESTSRC) $(TOP)/src/tclsqlite.c \
$(TOP)/ext/session/test_session.c
$(TCCX) $(TCL_FLAGS) -DTCLSH=1 $(TESTFIXTURE_FLAGS) \
$(TESTSRC) $(TOP)/src/tclsqlite.c sqlite3.c \
$(TOP)/ext/session/test_session.c \
-o testfixture$(EXE) $(LIBTCL) $(THREADLIB)
fts3-testfixture$(EXE): sqlite3.c fts3amal.c $(TESTSRC) $(TOP)/src/tclsqlite.c
@@ -832,6 +845,10 @@ showwal$(EXE): $(TOP)/tool/showwal.c sqlite3.o
$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showwal$(EXE) \
$(TOP)/tool/showwal.c sqlite3.o $(THREADLIB)
changeset$(EXE): $(TOP)/ext/session/changeset.c sqlite3.o
$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o changeset$(EXE) \
$(TOP)/ext/session/changeset.c sqlite3.o $(THREADLIB)
fts3view$(EXE): $(TOP)/ext/fts3/tool/fts3view.c sqlite3.o
$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o fts3view$(EXE) \
$(TOP)/ext/fts3/tool/fts3view.c sqlite3.o $(THREADLIB)
@@ -902,6 +919,7 @@ clean:
rm -f showjournal showjournal.exe
rm -f showstat4 showstat4.exe
rm -f showwal showwal.exe
rm -f changeset changeset.exe
rm -f speedtest1 speedtest1.exe
rm -f wordcount wordcount.exe
rm -f rbu rbu.exe
+95 -72
View File
@@ -1,17 +1,17 @@
C Make\ssure\ssystem\serrors\sthat\soccur\sdurign\ssqlite3_step()\sare\scaptured\sfor\nuse\sby\ssqlite3_system_errno().
D 2016-03-21T12:28:02.060
F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
C Add\sand\senhance\sthe\snew\stests.
D 2016-04-04T15:47:46.571
F Makefile.in e812bb732d7af01baa09f1278bd4f4a2e3a09449
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc df0bf9ff7f8b3f4dd9fb4cc43f92fe58f6ec5c66
F Makefile.msc fe57d7e3e74fa383fd01ced796c0ffd966fc094a
F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7
F VERSION c6b1f51809551d60ad001e6d87cf3ab2c7f54b6f
F VERSION 5d234da9b5dae329fab75ff75884cfe0a9cb3fda
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2
F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903
F autoconf/Makefile.am 42f7eb1fb2b06ddd6c6adab3e4388cc0a237ba40
F autoconf/Makefile.msc b8ada5177e6f39c126a88295af5ad0255e08d280
F autoconf/Makefile.msc dc0d0500e4a827cb3891d08d846dd6dd40241b51
F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7
F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1
F autoconf/configure.ac d807b567f73a2b0986ccdd206b782cecb4d08fff
@@ -30,7 +30,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63
F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977
F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc
F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55
F configure c01a159fdf7ea0171ad01ce2937283f2c7972bde x
F configure dbd42c55ca6b65e0fb37ef54121755f26a890edf x
F configure.ac 89e4e02a83d8a1528011f8395621b8c3186b4089
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2
@@ -98,15 +98,15 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8
F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95
F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0
F ext/fts5/fts5.h ff9c2782e8ed890b0de2f697a8d63971939e70c7
F ext/fts5/fts5Int.h 4060504b7979601d99e1385c2b5713036854979a
F ext/fts5/fts5Int.h 3677076aecbf645a7f2a019115c6a4ec3272dd78
F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458
F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd
F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857
F ext/fts5/fts5_expr.c 35e9d92c89e7c7ea0759b73d24da1ecb7630a24b
F ext/fts5/fts5_expr.c 5ca4bafe29aa3d27683c90e836192e4aefd20a3f
F ext/fts5/fts5_hash.c f3a7217c86eb8f272871be5f6aa1b6798960a337
F ext/fts5/fts5_index.c d3759c2f7d878e9e0a392b027a1c6e05c356007d
F ext/fts5/fts5_main.c b8501e1a6a11591c53b18ce7aea7e5386cfb0421
F ext/fts5/fts5_storage.c 2a38c6fa5db193a6a00588865134450ef5812daa
F ext/fts5/fts5_index.c fdd82bb421a5d1e64d004acb43f4dd9970c8d2b3
F ext/fts5/fts5_main.c b4a0fc5bf17f2f1f056ee76cdd7d2af08b360f55
F ext/fts5/fts5_storage.c 3309c6a8e34b974513016fd1ef47c83f5898f94c
F ext/fts5/fts5_tcl.c f8731e0508299bd43f1a2eff7dbeaac870768966
F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc
F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be
@@ -117,7 +117,7 @@ F ext/fts5/fts5_vocab.c dba72ca393d71c2588548b51380387f6b44c77a8
F ext/fts5/fts5parse.y fcc5e92e570d38cab38488b2109cbf67468923b2
F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba
F ext/fts5/test/fts5_common.tcl b01c584144b5064f30e6c648145a2dd6bc440841
F ext/fts5/test/fts5aa.test 7e814df4a0e6c22a6fe2d84f210fdc0b5068a084
F ext/fts5/test/fts5aa.test bd2d88182b9f7f30d300044048ad14683306b745
F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b
F ext/fts5/test/fts5ac.test 55cad4275a1f5acabfe14d8442a8046b47e49e5f
F ext/fts5/test/fts5ad.test 36995f0586f30f5602074e012b9224c71ec5171c
@@ -141,16 +141,17 @@ F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5
F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1
F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62
F ext/fts5/test/fts5corrupt2.test 26c0a39dd9ff73207e6229f83b50b21d37c7658c
F ext/fts5/test/fts5corrupt3.test b9558d5b0ca44a8b6247fbb5d4a47592a8976892
F ext/fts5/test/fts5corrupt3.test f77f65e386231daf62902466b40ff998b2c8ce4f
F ext/fts5/test/fts5detail.test ef5c690535a797413acaf5ad9b8ab5d49972df69
F ext/fts5/test/fts5dlidx.test 13871a14641017ae42f6f1055a8067bafd44cb3d
F ext/fts5/test/fts5determin.test 10648edb75ef1e196b10978fd21a9be0c31e09c3
F ext/fts5/test/fts5dlidx.test 007e9390c94638760797dbec2990c97c3fa08dfe
F ext/fts5/test/fts5doclist.test 8edb5b57e5f144030ed74ec00ef6fa4294fed79b
F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0
F ext/fts5/test/fts5eb.test c516ae0c934be6fd29ec95ea8b5f11f461311535
F ext/fts5/test/fts5fault1.test e09040d3e17b8c0837101e8c79c8a874c4376fb7
F ext/fts5/test/fts5fault2.test d8c6c7f916ccbdfc10b2c69530e9dd3bc8313232
F ext/fts5/test/fts5fault3.test d6e9577d4312e331a913c72931bf131704efc8f3
F ext/fts5/test/fts5fault4.test 532b6dacb963016cbf7003196bd87fb366540277
F ext/fts5/test/fts5fault4.test dcbe3043c5611edd350191ea03a8daa190f0de5a
F ext/fts5/test/fts5fault5.test 10c13a783de3f42a21e3e53e123b62ed0c3a1618
F ext/fts5/test/fts5fault6.test 9682664d679643ac6736e90c225526cc84073cda
F ext/fts5/test/fts5fault7.test cb14ea3c1f42394f06f2284abc58eecee6ff8080
@@ -165,6 +166,7 @@ F ext/fts5/test/fts5integrity.test f5e4f8d284385875068ad0f3e894ce43e9de835d
F ext/fts5/test/fts5matchinfo.test f7dde99697bcb310ea8faa8eb2714d9f4dfc0e1b
F ext/fts5/test/fts5merge.test 9f65f090d214ff865c56bef4f864aaa1182af6e3
F ext/fts5/test/fts5merge2.test a6da3c16d694235938d1939f503cfa53f0943d75
F ext/fts5/test/fts5multiclient.test 5bd54a6bc8ff818be233a50a8dec93da99098f2a
F ext/fts5/test/fts5near.test b214cddb1c1f1bddf45c75af768f20145f7e71cc
F ext/fts5/test/fts5onepass.test 7ed9608e258132cb8d55e7c479b08676ad68810c
F ext/fts5/test/fts5optimize.test 9d3ac53bb9cae58cb070d795db86bcb2f9fec105
@@ -178,7 +180,7 @@ F ext/fts5/test/fts5rank.test 7e9e64eac7245637f6f2033aec4b292aaf611aab
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 ac5006cc3d0d08b3538e1e76c7300de9f24fbed1
F ext/fts5/test/fts5simple.test cd23d4072ea095d652c9b6db12284cc642e49c98
F ext/fts5/test/fts5simple2.test 98377ae1ff7749a42c21fe1a139c1ed312522c46
F ext/fts5/test/fts5simple3.test 8e71733b3d1b0e695011d02c68ebc5ca40b6124e
F ext/fts5/test/fts5synonym.test 6475d189c2e20d60795808f83e36bf9318708d48
@@ -270,13 +272,33 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
F ext/rtree/sqlite3rtree.h 9c5777af3d2921c7b4ae4954e8e5697502289d28
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F ext/session/changeset.c 4ccbaa4531944c24584bf6a61ba3a39c62b6267a
F ext/session/session1.test 5dab50ce55c859e829bae24f0787013f51775fc5
F ext/session/session2.test 284de45abae4cc1082bc52012ee81521d5ac58e0
F ext/session/session3.test a7a9ce59b8d1e49e2cc23d81421ac485be0eea01
F ext/session/session4.test a6ed685da7a5293c5d6f99855bcf41dbc352ca84
F ext/session/session5.test 716bc6fafd625ce60dfa62ae128971628c1a1169
F ext/session/session6.test 443789bc2fca12e4f7075cf692c60b8a2bea1a26
F ext/session/session8.test 8e194b3f655d861ca36de5d4de53f702751bab3b
F ext/session/session9.test 5409d90d8141881d08285ed1c2c0d8d10fb92069
F ext/session/sessionA.test 1feeab0b8e03527f08f2f1defb442da25480138f
F ext/session/sessionB.test 886252dcb7e692e62ef7e357456200912e367823
F ext/session/sessionC.test 97556f5164ac29f2344b24bd7de6a3a35a95c390
F ext/session/sessionD.test d4744c78334162851d2a2f285c7e603e31b49aa2
F ext/session/sessionE.test e60a238c47f0feb3bb707e7f35e22be09c7e8f26
F ext/session/sessionF.test c2f178d4dfd723a5fd94a730ea2ccb44c669e3ce
F ext/session/session_common.tcl a1293167d14774b5e728836720497f40fe4ea596
F ext/session/sessionfault.test d52cbb7bee48cc8ee80335e07eb72fcb6b15eb40
F ext/session/sqlite3session.c b10af3e87ae437bb197b3a23a584d2dc8ad8981a
F ext/session/sqlite3session.h 64e9e7f185725ef43b97f4a9a0c0df0669844f1d
F ext/session/test_session.c 187bd344c5ae9d5be85e22ef7c3010f0c17307ce
F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220
F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
F main.mk 91cfc30d0fa295be28a86657ad3b1053f0428c9e
F main.mk 942e1fd30eb352492cf599aa7fcb5334783e4cbf
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@@ -289,41 +311,41 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c 1bb0709b3048e24217b80ec6bd78a3e99a47c01b
F src/analyze.c ab57b6763dd4c6170a20673d14882c033affd188
F src/analyze.c 39b21e4d9ad8a647e9834aa5ba99a74fb6c98879
F src/attach.c 771153bd1f4ab0b97a44a13dde2c7e5e1efeba22
F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
F src/backup.c f60f0aa55d25d853ffde53d0b0370a7bb7ee41ce
F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63
F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73
F src/btree.c 6eee126fe9d1f57118de9be2be840a4c6e691828
F src/btree.c 577fb5674e2f0aa0a38246afc19e1885a0b8c9b0
F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9
F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5
F src/build.c 213cbf84e99dd834e6ea46615633656d7ef79321
F src/build.c 39faaaeecb77eb3936d4bd5024e865e3836ca323
F src/callback.c 2e76147783386374bf01b227f752c81ec872d730
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198
F src/date.c 0b73e681c11fca867fec554750c07fe0d4e417c1
F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b
F src/delete.c 48802aa3ee6339f576d074336d3ae1b5f40e240f
F src/delete.c eeac28b3d3d88e3541bdf93e91ea7492a7b67842
F src/expr.c 289ffac5240b60fee0a824d3d5ab2d7bd2630c94
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 5cb42d9a59e2a590776fd3fc8ff6f61d40df3c6e
F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb
F src/func.c 552d300265aed09eea21f68ac742a440550c0062
F src/global.c 884d4c7eba9f5fc25c96a23b21520da19b7713e2
F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
F src/insert.c 723d5d708cdb61bdd47c00b9f07c75be45aefc09
F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b
F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
F src/loadext.c e70f8f9e97624a232870ea5486e682c813ac3002
F src/main.c f6c6e61bfd4cc9306a737d0c5c3f1e0eaf6086e0
F src/main.c 5ac9dccc03faadd6f867f67b9018ff41eeeadb46
F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a
F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944
F src/memjournal.c 6423a0817ffd8c7a04ef9e5fb974b6b9dd71f8b6
F src/memjournal.c 5253fd4335a8d9c64e5df25cb9da6329af5242c7
F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495
F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c
F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
@@ -335,8 +357,8 @@ F src/os.c ca10edb445ad2c5fdc7285b49d72bcdf261fa23e
F src/os.h 91ff889115ecd01f436d3611f7f5ea4dc12d92f1
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c 50103f69121bca969761b821e2b0e393b55fe869
F src/os_win.c 551d973ada67127430e41d9e514e53f6beb6c5a7
F src/os_unix.c b1ccb273771f41dbdbe0ba7c1ad63c38ad5972ec
F src/os_win.c b3ba9573d8d893e70a6a8015bbee572ecf7ffbef
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 38718a019ca762ba4f6795425d5a54db70d1790d
F src/pager.h e1d38a2f14849e219df0f91f8323504d134c8a56
@@ -344,23 +366,23 @@ F src/parse.y 5ea8c81c5c41b27887f41b4a7e1c58470d7d3821
F src/pcache.c 647bb53a86b7bbcf55ad88089b3ea5a9170b90df
F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545
F src/pcache1.c c40cdb93586e21b5dd826b5e671240bd91c26b05
F src/pragma.c e7e8f380efec6075a722822306435afc1eeca88a
F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84
F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c
F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e
F src/printf.c 63e6fb12bbe702dd664dc3703776c090383a5a26
F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
F src/resolve.c b8f7174e5f8c33c44ded3a25a973d0bb89228c20
F src/rowset.c 9fe4b3ad7cc00944386bb600233d8f523de07a6e
F src/select.c 6dd2097bb158efe3b8d68683dcc3b4a49e907a34
F src/shell.c 5e0ab1e708dc294330ccd8230536e1801f60822e
F src/sqlite.h.in e877f141b15ef68ef28f84714e69d7234f9a071e
F src/select.c 7849cee0a01952a9c93cd28989daedfa57731143
F src/shell.c ba8974732ad24dc8bffc9d9dae8a729edaf45b0d
F src/sqlite.h.in c46a7b85d3f37371cacea8f98ec825f5e52c420c
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2
F src/sqliteInt.h 4eb80a9b9a512180a9739f99d754915e03d8091a
F src/sqliteLimit.h 7b28cf72cbd52f178bfc97ea266445e351f2cd24
F src/sqliteInt.h 594bf31a7a0cc788688ca947e562576e23bd7904
F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247
F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba
F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
F src/tclsqlite.c 4bf3bea9b03aeac176ac114700f35f76a1de4c8a
F src/tclsqlite.c 56569acc73d36e836b64aefecbbb709a92ba0077
F src/test1.c 7187b7e924bfc97780e6fd2a40dad94a32bddca0
F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b
F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f
@@ -376,7 +398,7 @@ F src/test_backup.c 2e6e6a081870150f20c526a2e9d0d29cda47d803
F src/test_bestindex.c 29af3cc3b963ffe5760c85d142b9b3e5302c1e3d
F src/test_blob.c b2551a9b5573232db5f66f292307c37067937239
F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f
F src/test_config.c 0fb2571777ef43a8442be4f9c62a25f530872328
F src/test_config.c 7003f6f35134de6f19c6588f44783e43390ea277
F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_fs.c f10f840ca4f8c72e4837908bd8347ac4bcab074b
@@ -388,7 +410,7 @@ F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202
F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa
F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd
F src/test_malloc.c 96df9381a1ff1f6d3805ff7231b9baf1386aaabf
F src/test_multiplex.c 6a088d8d9d4aad4bec45dd8878af11b15900702d
F src/test_multiplex.c 6a9de820fcaaf506c59aa14bc8693822333cea48
F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3
F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c
F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10
@@ -413,25 +435,25 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
F src/tokenize.c 3d338cdd00d916ce8a05c397001d64ed58e6fe1c
F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373
F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280
F src/update.c 56b3db7edff0110360a12b76af97c39ebe3ea8b8
F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
F src/util.c cf7dce85ab9af5280b8a45985df2591efbfefe56
F src/util.c 8873d696c9ccc4206058c402e09e101f1b81561a
F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52
F src/vdbe.c f19741f2d8b33e8f09cd2219570b6c9ed924c3f1
F src/vdbe.h 6f44193e7be52fd5f7c308175a936555b1e6b101
F src/vdbeInt.h f88d3115e9bde33b01d81f0dd26d8dd51f995991
F src/vdbeapi.c 95b1f8e527240a18a9aea41a655b013bf07a7009
F src/vdbeaux.c c8dd3e4e932bede6363b380519d05c0557ad27ce
F src/vdbeblob.c 3b570b730109e8f653d9d2081649f6e7015113db
F src/vdbemem.c fe76c1f866de362d9b8332e59d74aa44f6560d69
F src/vdbe.c 0f0e4a6255f9a5272857a818314d081db26bcd90
F src/vdbe.h c16ba943d407baa1c7085eefea73a063fc631863
F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd
F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c
F src/vdbeaux.c fa06ba5441714160ab5f64422660ee286968672f
F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77
F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb
F src/vdbesort.c 307460bfa4de4d1c3901fcd42089159131e34062
F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484
F src/vtab.c fd69fd398e23e57ea4ea377d8a44b6998fc569c7
F src/vtab.c 23b6cdfa996152d43b390504ed4a942c8caf3a00
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 10deb6b43887662691e5f53d10b3c171c401169b
F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c
F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354
F src/where.c fe7925faafbe9a458972035c0bb4753d672f04ed
F src/where.c 99cc6270fc3915201e2a90bbac3768f007a89c44
F src/whereInt.h 93297d56edd137b7ea004490690fb6e2ce028a34
F src/wherecode.c 863aedf086131743763c1960637fde904eadc442
F src/whereexpr.c fb87944b1254234e5bba671aaf6dee476241506a
@@ -521,9 +543,9 @@ F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0
F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de
F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61
F test/capi2.test 011c16da245fdc0106a2785035de6b242c05e738
F test/capi3.test 860dafdc04f651a67781018cb1a0b179d22d7d15
F test/capi3.test f0c66919e43d42e1572a69be039e4527a931b00f
F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4
F test/capi3c.test b28ec47692f0fc50eb61b2d464d8d52e816b3732
F test/capi3c.test 0b9edb0c2156a964b9271cd5ea7ae56736cc2fcb
F test/capi3d.test 485048dc5cd07bc68011e4917ad035ad6047ab82
F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe
F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3
@@ -645,7 +667,7 @@ F test/fkey2.test f3d27ecba480a348c328965d154214719bb158a9
F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49
F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
F test/fkey5.test 5a373303f201ac03c22ba1ef17a733d3f56e611a
F test/fkey6.test ce3c39cd4f910184f5fd4a48db6783c59956224f
F test/fkey6.test d078a1e323a740062bed38df32b8a736fd320dc0
F test/fkey7.test 72e915890ee4a005daaf3002cb208e8fe973ac13
F test/fkey8.test 7bd1dd0174a0e29a90c62c517b9e2a410a0b345d
F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749
@@ -771,7 +793,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1
F test/fuzz3.test b47377143f0c80f91ed29d722861077ff34415d5
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26
F test/fuzzcheck.c 93bb9d309888634615e21ef98d1c30d51483e942
F test/fuzzcheck.c f01d432d001ba29e7916df8411be7d4e7cddc574
F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664
F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973
F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -782,7 +804,7 @@ F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536
F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98
F test/hexlit.test d7b0a5f41123df1e43985b91b8b2e70f95282d21
F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711
F test/hook.test 162d7cef7a2d2b04839fe14402934e6a1b79442f
F test/hook.test 40523db3aa76d62bda71c26f824fa0eabc420f0e
F test/icu.test 73956798bace8982909c00476b216714a6d0559a
F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607
F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8
@@ -890,7 +912,7 @@ F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e
F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f
F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7
F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2
F test/memsubsys1.test 69924593856040e266fdd9aa1ecb4d5a0888eb12
F test/memsubsys1.test 6d268d0ae90f8d61a2356a1838665654d83de518
F test/memsubsys2.test 3e4a8d0c05fd3e5fa92017c64666730a520c7e08
F test/minmax.test 42fbad0e81afaa6e0de41c960329f2b2c3526efd
F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc
@@ -917,7 +939,7 @@ F test/multiplex4.test e8ae4c4bd70606a5727743241f13b5701990abe4
F test/mutex1.test ea2cc74d97f077b9e74c84cbd024f14d79a8126f
F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
F test/nan.test dacc57f80859c06a433d30839336fe227d2038b3
F test/nolock.test 96e922d2d3db71c2dd6557c98e8027a28277b415
F test/nolock.test f196cf8b8fbea4e2ca345140a2b3f3b0da45c76e
F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf
F test/notify2.test 2ecabaa1305083856b7c39cf32816b612740c161
F test/notify3.test 10ff25cde502e72a92053a2f215d64bece4ef934
@@ -951,7 +973,7 @@ F test/parser1.test 222b5cbf3e2e659fec1bf7d723488c8b9c94f1d0
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
F test/permutations.test af8067e4b6d684518956f8e2a744f42bde99014d
F test/permutations.test cd1fa041074ed08eeaa563e4d1bacb0c69337ec1
F test/pragma.test afbf028be1c35b68f57db8eb015c4a3c59d8f28e
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
F test/pragma3.test 3f1984a04657331f838df5c519b443c2088df922
@@ -1014,6 +1036,7 @@ F test/selectE.test a8730ca330fcf40ace158f134f4fe0eb00c7edbf
F test/selectF.test 21c94e6438f76537b72532fa9fd4710cdd455fc3
F test/selectG.test e8600e379589e85e9fefd2fe4d44a4cdd63f6982
F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118
F test/session.test 78fa2365e93d3663a6e933f86e7afc395adf18be
F test/shared.test 1da9dbad400cee0d93f252ccf76e1ae007a63746
F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879
F test/shared3.test ab693f9b6e156b8bfb2a0ad94f29fe69602a5d38
@@ -1026,9 +1049,9 @@ 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 e7dac9830b7d80432be9cebfae06eff9c18675f5
F test/shell2.test 2e7a32c9ee03c6398478637d72416d5b9ebd9777
F test/shell3.test c39453d3012a39ffec944566eca8a6bda10a2284
F test/shell1.test a216486c6aeae4d3e75e37d64e4b6c8974108750
F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b
F test/shell3.test da513d522ef6f01cee8475dcf8332bff8982b3dd
F test/shell4.test 69995ee1cc278eb149aa8746ce1f935f4eaf98b9
F test/shell5.test 50a732c1c2158b1cd62cf53975ce1ea7ce6b9dc9
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
@@ -1040,8 +1063,8 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a
F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5
F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2
F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b
F test/snapshot.test c03eb5ba1602df33c1edc1d12393d6ca7a282a46
F test/snapshot_fault.test 25973aeb1b86a280800e0bcf1eb5ce70e9ef57ab
F test/snapshot.test 9ed24c792fb05382814258daf68b2256f23de57f
F test/snapshot_fault.test 062ff0438a074978d45e9f9a92e7ad459b74ee73
F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f
F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087
F test/sort.test c2adc635c2564241fefec0b3a68391ef6868fd3b
@@ -1058,7 +1081,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523
F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
F test/speedtest1.c 1478cb3fb64ad30f291ddca87ca9dbd72ff552aa
F test/speedtest1.c 21af8db2492a903835b654517ac8d90aed0af91f
F test/spellfix.test f9c1f431e2c096c8775fec032952320c0e4700db
F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3
F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33
@@ -1082,11 +1105,11 @@ F test/tabfunc01.test f977868fa8bb7beb4b2072883190411653473906
F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f
F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
F test/tclsqlite.test c6d9f546f79d15d0134c1e06583fb3ee0c3afad3
F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa
F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6
F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1
F test/tester.tcl f2b99e912d4da1e5755969b8614febd883885c8b
F test/tester.tcl 7b740ee852c55e1e72b6ebe5044acee7aa4e5553
F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@ -1400,8 +1423,8 @@ F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 87240b09c20042999b41d5fabe091b7111287835
F tool/mksqlite3c.tcl 9382100c82a0a08e63265780536a6c8efead4b65
F tool/mksqlite3h.tcl 1d41ab59bffb025121f75b76e183125ce41b3ec8
F tool/mksqlite3c.tcl 63af8429841f08552e6da1d93b3dee4a93ff8071
F tool/mksqlite3h.tcl e7b106fc4f29fbc258e8ba9b88d9108332ea2ade
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
F tool/mkvsix.tcl 4abcaf3267171b2faadaf9b82a0dfbaa6e98f8b7
F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091
@@ -1410,7 +1433,7 @@ F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b
F tool/replace.tcl 7727c60a04299b65a92f5e1590896fea0f25b9e0
F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
F tool/run-speed-test.sh 0ae485af4fe9f826e2b494be8c81f8ca9e222a4a
F tool/run-speed-test.sh f95d19fd669b68c4c38b6b475242841d47c66076
F tool/showdb.c 82dca79a999b2701c62417636345e9974151fdad
F tool/showjournal.c 5bad7ae8784a43d2b270d953060423b8bd480818
F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68
@@ -1428,7 +1451,7 @@ F tool/sqldiff.c ca315aca4e2d24233e8f2000edea5880c53d1875
F tool/srcck1.c 4f65e1a6748e42f24c0ea629dddc934d821c729a
F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43
F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d
F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f
F tool/symbols.sh c5a617b8c61a0926747a56c65f5671ef8ac0e148
F tool/tostr.tcl 96022f35ada2194f6f8ccf6fd95809e90ed277c4
F tool/varint.c 5d94cb5003db9dbbcbcc5df08d66f16071aee003
F tool/vdbe-compress.tcl 5926c71f9c12d2ab73ef35c29376e756eb68361c
@@ -1457,7 +1480,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 a6b6c6c466f3feb257b4fc08ef6b9a27a68ca073
R 6870e1f7d1e452978a882de2dd2b0506
U drh
Z 3347e0ff1ad1a288a0d7114b0f195e81
P b36dfdff787dc4a107b2c3fcbb98bfc4922872d8
R 37b07e38c129266922b712e67867cec6
U mistachkin
Z 3608507dbf100776dbeda9a8b2f0dd8b
+1 -1
View File
@@ -1 +1 @@
b4a1114f730c62e93623f889bc0e4fd8d0b31efa
f4cbd18db47af4af990d7891dcc831e92b3f17e0
+16 -13
View File
@@ -1835,31 +1835,34 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
Index *pIdx = sqliteHashData(i);
sqlite3DefaultRowEst(pIdx);
pIdx->aiRowLogEst[0] = 0;
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
sqlite3DeleteIndexSamples(db, pIdx);
pIdx->aSample = 0;
#endif
}
/* Check to make sure the sqlite_stat1 table exists */
/* Load new statistics out of the sqlite_stat1 table */
sInfo.db = db;
sInfo.zDatabase = db->aDb[iDb].zName;
if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){
return SQLITE_ERROR;
if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)!=0 ){
zSql = sqlite3MPrintf(db,
"SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
if( zSql==0 ){
rc = SQLITE_NOMEM_BKPT;
}else{
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
sqlite3DbFree(db, zSql);
}
}
/* Load new statistics out of the sqlite_stat1 table */
zSql = sqlite3MPrintf(db,
"SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
if( zSql==0 ){
rc = SQLITE_NOMEM_BKPT;
}else{
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
sqlite3DbFree(db, zSql);
/* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
Index *pIdx = sqliteHashData(i);
if( pIdx->aiRowLogEst[0]==0 ) sqlite3DefaultRowEst(pIdx);
}
/* Load the statistics from the sqlite_stat4 table. */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
+9 -4
View File
@@ -2360,12 +2360,12 @@ int sqlite3BtreeOpen(
for(i=0; i<db->nDb; i++){
if( (pSib = db->aDb[i].pBt)!=0 && pSib->sharable ){
while( pSib->pPrev ){ pSib = pSib->pPrev; }
if( p->pBt<pSib->pBt ){
if( (uptr)p->pBt<(uptr)pSib->pBt ){
p->pNext = pSib;
p->pPrev = 0;
pSib->pPrev = p;
}else{
while( pSib->pNext && pSib->pNext->pBt<p->pBt ){
while( pSib->pNext && (uptr)pSib->pNext->pBt<(uptr)p->pBt ){
pSib = pSib->pNext;
}
p->pNext = pSib->pNext;
@@ -4472,8 +4472,13 @@ static int accessPayload(
#endif
assert( offset+amt <= pCur->info.nPayload );
if( &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize] ){
/* Trying to read or write past the end of the data is an error */
assert( aPayload > pPage->aData );
if( (uptr)(aPayload - pPage->aData) > (pBt->usableSize - pCur->info.nLocal) ){
/* Trying to read or write past the end of the data is an error. The
** conditional above is really:
** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
** but is recast into its current form to avoid integer overflow problems
*/
return SQLITE_CORRUPT_BKPT;
}
+11 -10
View File
@@ -1056,9 +1056,6 @@ void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){
memcpy(z, pName->z, pName->n);
z[pName->n] = 0;
sqlite3Dequote(z);
zType = z + sqlite3Strlen30(z) + 1;
memcpy(zType, pType->z, pType->n);
zType[pType->n] = 0;
for(i=0; i<p->nCol; i++){
if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){
sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
@@ -1086,7 +1083,11 @@ void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){
pCol->affinity = SQLITE_AFF_BLOB;
pCol->szEst = 1;
}else{
zType = z + sqlite3Strlen30(z) + 1;
memcpy(zType, pType->z, pType->n);
zType[pType->n] = 0;
pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);
pCol->colFlags |= COLFLAG_HASTYPE;
}
p->nCol++;
pParse->constraintName.n = 0;
@@ -1282,7 +1283,7 @@ void sqlite3AddPrimaryKey(
int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */
){
Table *pTab = pParse->pNewTable;
const char *zName = 0;
Column *pCol = 0;
int iCol = -1, i;
int nTerm;
if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit;
@@ -1294,8 +1295,8 @@ void sqlite3AddPrimaryKey(
pTab->tabFlags |= TF_HasPrimaryKey;
if( pList==0 ){
iCol = pTab->nCol - 1;
pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY;
zName = pTab->aCol[iCol].zName;
pCol = &pTab->aCol[iCol];
pCol->colFlags |= COLFLAG_PRIMKEY;
nTerm = 1;
}else{
nTerm = pList->nExpr;
@@ -1307,8 +1308,8 @@ void sqlite3AddPrimaryKey(
const char *zCName = pCExpr->u.zToken;
for(iCol=0; iCol<pTab->nCol; iCol++){
if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){
pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY;
zName = pTab->aCol[iCol].zName;
pCol = &pTab->aCol[iCol];
pCol->colFlags |= COLFLAG_PRIMKEY;
break;
}
}
@@ -1316,8 +1317,8 @@ void sqlite3AddPrimaryKey(
}
}
if( nTerm==1
&& zName
&& sqlite3StrICmp(sqlite3StrNext(zName), "INTEGER")==0
&& pCol
&& sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
&& sortOrder!=SQLITE_SO_DESC
){
pTab->iPKey = iCol;
+12 -4
View File
@@ -366,6 +366,9 @@ void sqlite3DeleteFrom(
&& pWhere==0
&& !bComplex
&& !IsVirtual(pTab)
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
&& db->xPreUpdateCallback==0
#endif
){
assert( !isView );
sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);
@@ -715,14 +718,19 @@ void sqlite3GenerateRowDelete(
/* Delete the index and table entries. Skip this step if pTab is really
** a view (in which case the only effect of the DELETE statement is to
** fire the INSTEAD OF triggers). */
** fire the INSTEAD OF triggers).
**
** If variable 'count' is non-zero, then this OP_Delete instruction should
** invoke the update-hook. The pre-update-hook, on the other hand should
** be invoked unless table pTab is a system table. The difference is that
** the update-hook is not invoked for rows removed by REPLACE, but the
** pre-update-hook is.
*/
if( pTab->pSelect==0 ){
u8 p5 = 0;
sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek);
sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));
if( count ){
sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
}
sqlite3VdbeChangeP4(v, -1, (char*)pTab, P4_TABLE);
if( eMode!=ONEPASS_OFF ){
sqlite3VdbeChangeP5(v, OPFLAG_AUXDELETE);
}
-1
View File
@@ -1165,7 +1165,6 @@ static Trigger *fkActionTrigger(
if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){
return 0;
}
pTrigger = pFKey->apTrigger[iAction];
if( action!=OE_None && !pTrigger ){
+13 -4
View File
@@ -1431,9 +1431,18 @@ void sqlite3GenerateConstraintChecks(
if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
sqlite3MultiWrite(pParse);
sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
regNewData, 1, 0, OE_Replace,
ONEPASS_SINGLE, -1);
regNewData, 1, 0, OE_Replace, 1, -1);
}else{
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
if( HasRowid(pTab) ){
/* This OP_Delete opcode fires the pre-update-hook only. It does
** not modify the b-tree. It is more efficient to let the coming
** OP_Insert replace the existing entry than it is to delete the
** existing entry and then insert a new one. */
sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
sqlite3VdbeChangeP4(v, -1, (char *)pTab, P4_TABLE);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
if( pTab->pIndex ){
sqlite3MultiWrite(pParse);
sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1);
@@ -1703,7 +1712,7 @@ void sqlite3CompleteInsertion(
}
sqlite3VdbeAddOp3(v, OP_Insert, iDataCur, regRec, regNewData);
if( !pParse->nested ){
sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
sqlite3VdbeChangeP4(v, -1, (char *)pTab, P4_TABLE);
}
sqlite3VdbeChangeP5(v, pik_flags);
}
@@ -2103,7 +2112,7 @@ static int xferOptimization(
}
sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData);
sqlite3VdbeAddOp4(v, OP_Insert, iDest, regData, regRowid,
pDest->zName, 0);
(char*)pDest, P4_TABLE);
sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND);
sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); VdbeCoverage(v);
sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);
+22 -2
View File
@@ -1922,6 +1922,27 @@ void *sqlite3_rollback_hook(
return pRet;
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** Register a callback to be invoked each time a row is updated,
** inserted or deleted using this database connection.
*/
void *sqlite3_preupdate_hook(
sqlite3 *db, /* Attach the hook to this database */
void(*xCallback)( /* Callback function */
void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64),
void *pArg /* First callback argument */
){
void *pRet;
sqlite3_mutex_enter(db->mutex);
pRet = db->pPreUpdateArg;
db->xPreUpdateCallback = xCallback;
db->pPreUpdateArg = pArg;
sqlite3_mutex_leave(db->mutex);
return pRet;
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifndef SQLITE_OMIT_WAL
/*
** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
@@ -3343,8 +3364,7 @@ int sqlite3_table_column_metadata(
** explicitly declared column. Copy meta information from *pCol.
*/
if( pCol ){
zDataType = sqlite3StrNext(pCol->zName);
if( zDataType[0]==0 ) zDataType = 0;
zDataType = sqlite3ColumnType(pCol,0);
zCollSeq = pCol->zColl;
notnull = pCol->notNull!=0;
primarykey = (pCol->colFlags & COLFLAG_PRIMKEY)!=0;
+1 -1
View File
@@ -403,5 +403,5 @@ int sqlite3JournalIsInMemory(sqlite3_file *p){
** pVfs to create the underlying on-disk files.
*/
int sqlite3JournalSize(sqlite3_vfs *pVfs){
return MAX(pVfs->szOsFile, sizeof(MemJournal));
return MAX(pVfs->szOsFile, (int)sizeof(MemJournal));
}
+1 -1
View File
@@ -1366,7 +1366,7 @@ static void verifyDbFile(unixFile *pFile){
sqlite3_log(SQLITE_WARNING, "cannot fstat db file %s", pFile->zPath);
return;
}
if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
if( buf.st_nlink==0 ){
sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
return;
}
+187 -72
View File
@@ -344,11 +344,23 @@ struct winFile {
# define SQLITE_WIN32_HEAP_CREATE (TRUE)
#endif
/*
* This is cache size used in the calculation of the initial size of the
* Win32-specific heap. It cannot be negative.
*/
#ifndef SQLITE_WIN32_CACHE_SIZE
# if SQLITE_DEFAULT_CACHE_SIZE>=0
# define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE)
# else
# define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE))
# endif
#endif
/*
* The initial size of the Win32-specific heap. This value may be zero.
*/
#ifndef SQLITE_WIN32_HEAP_INIT_SIZE
# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_DEFAULT_CACHE_SIZE) * \
# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \
(SQLITE_DEFAULT_PAGE_SIZE) + 4194304)
#endif
@@ -1294,6 +1306,12 @@ void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );
#ifdef SQLITE_ENABLE_API_ARMOR
if( !zBuf ){
(void)SQLITE_MISUSE_BKPT;
return;
}
#endif
#if defined(SQLITE_WIN32_HAS_ANSI)
if( nMin>0 ){
memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);
@@ -1619,147 +1637,244 @@ void sqlite3MemSetDefault(void){
#endif /* SQLITE_WIN32_MALLOC */
/*
** Convert a UTF-8 string to Microsoft Unicode (UTF-16?).
** Convert a UTF-8 string to Microsoft Unicode.
**
** Space to hold the returned string is obtained from malloc.
** Space to hold the returned string is obtained from sqlite3_malloc().
*/
static LPWSTR winUtf8ToUnicode(const char *zFilename){
static LPWSTR winUtf8ToUnicode(const char *zText){
int nChar;
LPWSTR zWideFilename;
LPWSTR zWideText;
nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, NULL, 0);
if( nChar==0 ){
return 0;
}
zWideFilename = sqlite3MallocZero( nChar*sizeof(zWideFilename[0]) );
if( zWideFilename==0 ){
zWideText = sqlite3MallocZero( nChar*sizeof(WCHAR) );
if( zWideText==0 ){
return 0;
}
nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename,
nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, zWideText,
nChar);
if( nChar==0 ){
sqlite3_free(zWideFilename);
zWideFilename = 0;
sqlite3_free(zWideText);
zWideText = 0;
}
return zWideFilename;
return zWideText;
}
/*
** Convert Microsoft Unicode to UTF-8. Space to hold the returned string is
** obtained from sqlite3_malloc().
** Convert a Microsoft Unicode string to UTF-8.
**
** Space to hold the returned string is obtained from sqlite3_malloc().
*/
static char *winUnicodeToUtf8(LPCWSTR zWideFilename){
static char *winUnicodeToUtf8(LPCWSTR zWideText){
int nByte;
char *zFilename;
char *zText;
nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0);
nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, 0, 0, 0, 0);
if( nByte == 0 ){
return 0;
}
zFilename = sqlite3MallocZero( nByte );
if( zFilename==0 ){
zText = sqlite3MallocZero( nByte );
if( zText==0 ){
return 0;
}
nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte,
nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, zText, nByte,
0, 0);
if( nByte == 0 ){
sqlite3_free(zFilename);
zFilename = 0;
sqlite3_free(zText);
zText = 0;
}
return zFilename;
return zText;
}
/*
** Convert an ANSI string to Microsoft Unicode, based on the
** current codepage settings for file apis.
** Convert an ANSI string to Microsoft Unicode, using the ANSI or OEM
** code page.
**
** Space to hold the returned string is obtained
** from sqlite3_malloc.
** Space to hold the returned string is obtained from sqlite3_malloc().
*/
static LPWSTR winMbcsToUnicode(const char *zFilename){
static LPWSTR winMbcsToUnicode(const char *zText, int useAnsi){
int nByte;
LPWSTR zMbcsFilename;
int codepage = osAreFileApisANSI() ? CP_ACP : CP_OEMCP;
LPWSTR zMbcsText;
int codepage = useAnsi ? CP_ACP : CP_OEMCP;
nByte = osMultiByteToWideChar(codepage, 0, zFilename, -1, NULL,
nByte = osMultiByteToWideChar(codepage, 0, zText, -1, NULL,
0)*sizeof(WCHAR);
if( nByte==0 ){
return 0;
}
zMbcsFilename = sqlite3MallocZero( nByte*sizeof(zMbcsFilename[0]) );
if( zMbcsFilename==0 ){
zMbcsText = sqlite3MallocZero( nByte*sizeof(WCHAR) );
if( zMbcsText==0 ){
return 0;
}
nByte = osMultiByteToWideChar(codepage, 0, zFilename, -1, zMbcsFilename,
nByte = osMultiByteToWideChar(codepage, 0, zText, -1, zMbcsText,
nByte);
if( nByte==0 ){
sqlite3_free(zMbcsFilename);
zMbcsFilename = 0;
sqlite3_free(zMbcsText);
zMbcsText = 0;
}
return zMbcsFilename;
return zMbcsText;
}
/*
** Convert Microsoft Unicode to multi-byte character string, based on the
** user's ANSI codepage.
** Convert a Microsoft Unicode string to a multi-byte character string,
** using the ANSI or OEM code page.
**
** Space to hold the returned string is obtained from
** sqlite3_malloc().
** Space to hold the returned string is obtained from sqlite3_malloc().
*/
static char *winUnicodeToMbcs(LPCWSTR zWideFilename){
static char *winUnicodeToMbcs(LPCWSTR zWideText, int useAnsi){
int nByte;
char *zFilename;
int codepage = osAreFileApisANSI() ? CP_ACP : CP_OEMCP;
char *zText;
int codepage = useAnsi ? CP_ACP : CP_OEMCP;
nByte = osWideCharToMultiByte(codepage, 0, zWideFilename, -1, 0, 0, 0, 0);
nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, 0, 0, 0, 0);
if( nByte == 0 ){
return 0;
}
zFilename = sqlite3MallocZero( nByte );
if( zFilename==0 ){
zText = sqlite3MallocZero( nByte );
if( zText==0 ){
return 0;
}
nByte = osWideCharToMultiByte(codepage, 0, zWideFilename, -1, zFilename,
nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, zText,
nByte, 0, 0);
if( nByte == 0 ){
sqlite3_free(zFilename);
zFilename = 0;
sqlite3_free(zText);
zText = 0;
}
return zFilename;
return zText;
}
/*
** Convert multibyte character string to UTF-8. Space to hold the
** returned string is obtained from sqlite3_malloc().
** Convert a multi-byte character string to UTF-8.
**
** Space to hold the returned string is obtained from sqlite3_malloc().
*/
char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){
char *zFilenameUtf8;
static char *winMbcsToUtf8(const char *zText, int useAnsi){
char *zTextUtf8;
LPWSTR zTmpWide;
zTmpWide = winMbcsToUnicode(zFilename);
zTmpWide = winMbcsToUnicode(zText, useAnsi);
if( zTmpWide==0 ){
return 0;
}
zFilenameUtf8 = winUnicodeToUtf8(zTmpWide);
zTextUtf8 = winUnicodeToUtf8(zTmpWide);
sqlite3_free(zTmpWide);
return zFilenameUtf8;
return zTextUtf8;
}
/*
** Convert UTF-8 to multibyte character string. Space to hold the
** returned string is obtained from sqlite3_malloc().
** Convert a UTF-8 string to a multi-byte character string.
**
** Space to hold the returned string is obtained from sqlite3_malloc().
*/
char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
char *zFilenameMbcs;
static char *winUtf8ToMbcs(const char *zText, int useAnsi){
char *zTextMbcs;
LPWSTR zTmpWide;
zTmpWide = winUtf8ToUnicode(zFilename);
zTmpWide = winUtf8ToUnicode(zText);
if( zTmpWide==0 ){
return 0;
}
zFilenameMbcs = winUnicodeToMbcs(zTmpWide);
zTextMbcs = winUnicodeToMbcs(zTmpWide, useAnsi);
sqlite3_free(zTmpWide);
return zFilenameMbcs;
return zTextMbcs;
}
/*
** This is a public wrapper for the winUtf8ToUnicode() function.
*/
LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText){
#ifdef SQLITE_ENABLE_API_ARMOR
if( !zText ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
return winUtf8ToUnicode(zText);
}
/*
** This is a public wrapper for the winUnicodeToUtf8() function.
*/
char *sqlite3_win32_unicode_to_utf8(LPCWSTR zWideText){
#ifdef SQLITE_ENABLE_API_ARMOR
if( !zWideText ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
return winUnicodeToUtf8(zWideText);
}
/*
** This is a public wrapper for the winMbcsToUtf8() function.
*/
char *sqlite3_win32_mbcs_to_utf8(const char *zText){
#ifdef SQLITE_ENABLE_API_ARMOR
if( !zText ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
return winMbcsToUtf8(zText, osAreFileApisANSI());
}
/*
** This is a public wrapper for the winMbcsToUtf8() function.
*/
char *sqlite3_win32_mbcs_to_utf8_v2(const char *zText, int useAnsi){
#ifdef SQLITE_ENABLE_API_ARMOR
if( !zText ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
return winMbcsToUtf8(zText, useAnsi);
}
/*
** This is a public wrapper for the winUtf8ToMbcs() function.
*/
char *sqlite3_win32_utf8_to_mbcs(const char *zText){
#ifdef SQLITE_ENABLE_API_ARMOR
if( !zText ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
return winUtf8ToMbcs(zText, osAreFileApisANSI());
}
/*
** This is a public wrapper for the winUtf8ToMbcs() function.
*/
char *sqlite3_win32_utf8_to_mbcs_v2(const char *zText, int useAnsi){
#ifdef SQLITE_ENABLE_API_ARMOR
if( !zText ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
return winUtf8ToMbcs(zText, useAnsi);
}
/*
@@ -1861,7 +1976,7 @@ static int winGetLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){
if( dwLen > 0 ){
/* allocate a buffer and convert to UTF8 */
sqlite3BeginBenignMalloc();
zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());
sqlite3EndBenignMalloc();
/* free the system buffer allocated by FormatMessage */
osLocalFree(zTemp);
@@ -4306,7 +4421,7 @@ static char *winConvertToUtf8Filename(const void *zFilename){
}
#ifdef SQLITE_WIN32_HAS_ANSI
else{
zConverted = sqlite3_win32_mbcs_to_utf8(zFilename);
zConverted = winMbcsToUtf8(zFilename, osAreFileApisANSI());
}
#endif
/* caller will handle out of memory */
@@ -4327,7 +4442,7 @@ static void *winConvertFromUtf8Filename(const char *zFilename){
}
#ifdef SQLITE_WIN32_HAS_ANSI
else{
zConverted = sqlite3_win32_utf8_to_mbcs(zFilename);
zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());
}
#endif
/* caller will handle out of memory */
@@ -4528,7 +4643,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){
return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
"winGetTempname3", 0);
}
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
zUtf8 = winMbcsToUtf8(zMbcsPath, osAreFileApisANSI());
if( zUtf8 ){
sqlite3_snprintf(nMax, zBuf, "%s", zUtf8);
sqlite3_free(zUtf8);
@@ -5306,7 +5421,7 @@ static int winFullPathname(
"winFullPathname4", zRelative);
}
sqlite3_free(zConverted);
zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());
sqlite3_free(zTemp);
}
#endif
@@ -5424,8 +5539,8 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
EntropyGatherer e;
UNUSED_PARAMETER(pVfs);
memset(zBuf, 0, nBuf);
#if defined(_MSC_VER) && _MSC_VER>=1400
rand_s((int*)zBuf); /* rand_s() is not available with MinGW */
#if defined(_MSC_VER) && _MSC_VER>=1400 && !SQLITE_OS_WINCE
rand_s((unsigned int*)zBuf); /* rand_s() is not available with MinGW */
#endif /* defined(_MSC_VER) && _MSC_VER>=1400 */
e.a = (unsigned char*)zBuf;
e.na = nBuf;
+2 -4
View File
@@ -1066,7 +1066,6 @@ void sqlite3Pragma(
setAllColumnNames(v, 6, azCol); assert( 6==ArraySize(azCol) );
sqlite3ViewGetColumnNames(pParse, pTab);
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
const char *zName;
if( IsHiddenColumn(pCol) ){
nHidden++;
continue;
@@ -1079,11 +1078,10 @@ void sqlite3Pragma(
for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
}
assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );
zName = pCol->zName;
sqlite3VdbeMultiLoad(v, 1, "issisi",
i-nHidden,
zName,
sqlite3StrNext(zName),
pCol->zName,
sqlite3ColumnType(pCol,""),
pCol->notNull ? 1 : 0,
pCol->pDflt ? pCol->pDflt->u.zToken : 0,
k);
+2 -2
View File
@@ -1430,7 +1430,7 @@ static const char *columnTypeImpl(
zOrigCol = "rowid";
}else{
zOrigCol = pTab->aCol[iCol].zName;
zType = sqlite3StrNext(zOrigCol);
zType = sqlite3ColumnType(&pTab->aCol[iCol],0);
estWidth = pTab->aCol[iCol].szEst;
}
zOrigTab = pTab->zName;
@@ -1442,7 +1442,7 @@ static const char *columnTypeImpl(
if( iCol<0 ){
zType = "INTEGER";
}else{
zType = sqlite3StrNext(pTab->aCol[iCol].zName);
zType = sqlite3ColumnType(&pTab->aCol[iCol],0);
estWidth = pTab->aCol[iCol].szEst;
}
#endif
+467 -143
View File
File diff suppressed because it is too large Load Diff
+101 -5
View File
@@ -5187,7 +5187,7 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
** ^The sqlite3_update_hook() interface registers a callback function
** with the [database connection] identified by the first argument
** to be invoked whenever a row is updated, inserted or deleted in
** a rowid table.
** a [rowid table].
** ^Any callback set by a previous call to this function
** for the same database connection is overridden.
**
@@ -5226,8 +5226,8 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
** on the same [database connection] D, or NULL for
** the first call on D.
**
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
** interfaces.
** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],
** and [sqlite3_preupdate_hook()] interfaces.
*/
void *sqlite3_update_hook(
sqlite3*,
@@ -6761,7 +6761,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
** database file in rollback mode databases. Any pages written as part of
** transaction rollback or database recovery operations are not included.
** If an IO or other error occurs while writing a page to disk, the effect
** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
** </dd>
**
@@ -7915,11 +7915,107 @@ void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
*/
int sqlite3_db_cacheflush(sqlite3*);
/*
** CAPI3REF: The pre-update hook.
**
** ^These interfaces are only available if SQLite is compiled using the
** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.
**
** ^The [sqlite3_preupdate_hook()] interface registers a callback function
** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation
** on a [rowid table].
** ^At most one preupdate hook may be registered at a time on a single
** [database connection]; each call to [sqlite3_preupdate_hook()] overrides
** the previous setting.
** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]
** with a NULL pointer as the second parameter.
** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as
** the first parameter to callbacks.
**
** ^The preupdate hook only fires for changes to [rowid tables]; the preupdate
** hook is not invoked for changes to [virtual tables] or [WITHOUT ROWID]
** tables.
**
** ^The second parameter to the preupdate callback is a pointer to
** the [database connection] that registered the preupdate hook.
** ^The third parameter to the preupdate callback is one of the constants
** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the
** kind of update operation that is about to occur.
** ^(The fourth parameter to the preupdate callback is the name of the
** database within the database connection that is being modified. This
** will be "main" for the main database or "temp" for TEMP tables or
** the name given after the AS keyword in the [ATTACH] statement for attached
** databases.)^
** ^The fifth parameter to the preupdate callback is the name of the
** table that is being modified.
** ^The sixth parameter to the preupdate callback is the initial [rowid] of the
** row being changes for SQLITE_UPDATE and SQLITE_DELETE changes and is
** undefined for SQLITE_INSERT changes.
** ^The seventh parameter to the preupdate callback is the final [rowid] of
** the row being changed for SQLITE_UPDATE and SQLITE_INSERT changes and is
** undefined for SQLITE_DELETE changes.
**
** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],
** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces
** provide additional information about a preupdate event. These routines
** may only be called from within a preupdate callback. Invoking any of
** these routines from outside of a preupdate callback or with a
** [database connection] pointer that is different from the one supplied
** to the preupdate callback results in undefined and probably undesirable
** behavior.
**
** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns
** in the row that is being inserted, updated, or deleted.
**
** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to
** a [protected sqlite3_value] that contains the value of the Nth column of
** the table row before it is updated. The N parameter must be between 0
** and one less than the number of columns or the behavior will be
** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE
** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the
** behavior is undefined. The [sqlite3_value] that P points to
** will be destroyed when the preupdate callback returns.
**
** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to
** a [protected sqlite3_value] that contains the value of the Nth column of
** the table row after it is updated. The N parameter must be between 0
** and one less than the number of columns or the behavior will be
** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE
** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the
** behavior is undefined. The [sqlite3_value] that P points to
** will be destroyed when the preupdate callback returns.
**
** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate
** callback was invoked as a result of a direct insert, update, or delete
** operation; or 1 for inserts, updates, or deletes invoked by top-level
** triggers; or 2 for changes resulting from triggers called by top-level
** triggers; and so forth.
**
** See also: [sqlite3_update_hook()]
*/
SQLITE_EXPERIMENTAL void *sqlite3_preupdate_hook(
sqlite3 *db,
void(*xPreUpdate)(
void *pCtx, /* Copy of third arg to preupdate_hook() */
sqlite3 *db, /* Database handle */
int op, /* SQLITE_UPDATE, DELETE or INSERT */
char const *zDb, /* Database name */
char const *zName, /* Table name */
sqlite3_int64 iKey1, /* Rowid of row about to be deleted/updated */
sqlite3_int64 iKey2 /* New rowid value (for a rowid UPDATE) */
),
void*
);
SQLITE_EXPERIMENTAL int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
SQLITE_EXPERIMENTAL int sqlite3_preupdate_count(sqlite3 *);
SQLITE_EXPERIMENTAL int sqlite3_preupdate_depth(sqlite3 *);
SQLITE_EXPERIMENTAL int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
/*
** CAPI3REF: Low-level system error code
**
** ^Attempt to return the underlying operating system error code or error
** number that caused the most reason I/O error or failure to open a file.
** number that caused the most recent I/O error or failure to open a file.
** The return value is OS-dependent. For example, on unix systems, after
** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be
** called to get back the underlying "errno" that caused the problem, such
+40 -18
View File
@@ -181,21 +181,6 @@
# define SQLITE_PTR_TO_INT(X) ((int)(X))
#endif
/*
** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
** something between S (inclusive) and E (exclusive).
**
** In other words, S is a buffer and E is a pointer to the first byte after
** the end of buffer S. This macro returns true if P points to something
** contained within the buffer S.
*/
#if defined(HAVE_STDINT_H)
# define SQLITE_WITHIN(P,S,E) \
((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E))
#else
# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E))
#endif
/*
** A macro to hint to the compiler that a function should not be
** inlined.
@@ -583,8 +568,12 @@
/*
** Macros to compute minimum and maximum of two numbers.
*/
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MAX(A,B) ((A)>(B)?(A):(B))
#ifndef MIN
# define MIN(A,B) ((A)<(B)?(A):(B))
#endif
#ifndef MAX
# define MAX(A,B) ((A)>(B)?(A):(B))
#endif
/*
** Swap two objects of type TYPE.
@@ -713,6 +702,27 @@ typedef INT16_TYPE LogEst;
# endif
#endif
/* The uptr type is an unsigned integer large enough to hold a pointer
*/
#if defined(HAVE_STDINT_H)
typedef uintptr_t uptr;
#elif SQLITE_PTRSIZE==4
typedef u32 uptr;
#else
typedef u64 uptr;
#endif
/*
** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
** something between S (inclusive) and E (exclusive).
**
** In other words, S is a buffer and E is a pointer to the first byte after
** the end of buffer S. This macro returns true if P points to something
** contained within the buffer S.
*/
#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))
/*
** Macros to determine whether the machine is big or little endian,
** and whether or not that determination is run-time or compile-time.
@@ -978,6 +988,7 @@ typedef struct LookasideSlot LookasideSlot;
typedef struct Module Module;
typedef struct NameContext NameContext;
typedef struct Parse Parse;
typedef struct PreUpdate PreUpdate;
typedef struct PrintfArguments PrintfArguments;
typedef struct RowSet RowSet;
typedef struct Savepoint Savepoint;
@@ -1262,6 +1273,13 @@ struct sqlite3 {
void (*xRollbackCallback)(void*); /* Invoked at every commit. */
void *pUpdateArg;
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
void *pPreUpdateArg; /* First argument to xPreUpdateCallback */
void (*xPreUpdateCallback)( /* Registered using sqlite3_preupdate_hook() */
void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64
);
PreUpdate *pPreUpdate; /* Context for active pre-update callback */
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifndef SQLITE_OMIT_WAL
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
void *pWalArg;
@@ -1594,6 +1612,7 @@ struct Column {
*/
#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */
#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */
/*
** A "Collating Sequence" is defined by an instance of the following
@@ -2916,6 +2935,9 @@ struct AuthContext {
#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
#define OPFLAG_ISNOOP 0x40 /* OP_Delete does pre-update-hook only */
#endif
#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
@@ -3297,7 +3319,7 @@ int sqlite3IsIdChar(u8);
*/
int sqlite3StrICmp(const char*,const char*);
int sqlite3Strlen30(const char*);
const char *sqlite3StrNext(const char*);
char *sqlite3ColumnType(Column*,char*);
#define sqlite3StrNICmp sqlite3_strnicmp
int sqlite3MallocInit(void);
+2 -2
View File
@@ -101,8 +101,8 @@
** The suggested maximum number of in-memory pages to use for
** the main database table and for temporary tables.
**
** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size
** is 2000*1024 bytes.
** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,
** which means the cache size is limited to 2048000 bytes of memory.
** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
*/
+192 -40
View File
@@ -140,6 +140,7 @@ struct SqliteDb {
char *zNull; /* Text to substitute for an SQL NULL value */
SqlFunc *pFunc; /* List of SQL functions */
Tcl_Obj *pUpdateHook; /* Update hook script (if any) */
Tcl_Obj *pPreUpdateHook; /* Pre-update hook script (if any) */
Tcl_Obj *pRollbackHook; /* Rollback hook script (if any) */
Tcl_Obj *pWalHook; /* WAL hook script (if any) */
Tcl_Obj *pUnlockNotify; /* Unlock notify script (if any) */
@@ -519,6 +520,9 @@ static void DbDeleteCmd(void *db){
if( pDb->pUpdateHook ){
Tcl_DecrRefCount(pDb->pUpdateHook);
}
if( pDb->pPreUpdateHook ){
Tcl_DecrRefCount(pDb->pPreUpdateHook);
}
if( pDb->pRollbackHook ){
Tcl_DecrRefCount(pDb->pRollbackHook);
}
@@ -686,6 +690,42 @@ static void DbUnlockNotify(void **apArg, int nArg){
}
#endif
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** Pre-update hook callback.
*/
static void DbPreUpdateHandler(
void *p,
sqlite3 *db,
int op,
const char *zDb,
const char *zTbl,
sqlite_int64 iKey1,
sqlite_int64 iKey2
){
SqliteDb *pDb = (SqliteDb *)p;
Tcl_Obj *pCmd;
static const char *azStr[] = {"DELETE", "INSERT", "UPDATE"};
assert( (SQLITE_DELETE-1)/9 == 0 );
assert( (SQLITE_INSERT-1)/9 == 1 );
assert( (SQLITE_UPDATE-1)/9 == 2 );
assert( pDb->pPreUpdateHook );
assert( db==pDb->db );
assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );
pCmd = Tcl_DuplicateObj(pDb->pPreUpdateHook);
Tcl_IncrRefCount(pCmd);
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(azStr[(op-1)/9], -1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zDb, -1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zTbl, -1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewWideIntObj(iKey1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewWideIntObj(iKey2));
Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);
Tcl_DecrRefCount(pCmd);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
static void DbUpdateHandler(
void *p,
int op,
@@ -695,14 +735,18 @@ static void DbUpdateHandler(
){
SqliteDb *pDb = (SqliteDb *)p;
Tcl_Obj *pCmd;
static const char *azStr[] = {"DELETE", "INSERT", "UPDATE"};
assert( (SQLITE_DELETE-1)/9 == 0 );
assert( (SQLITE_INSERT-1)/9 == 1 );
assert( (SQLITE_UPDATE-1)/9 == 2 );
assert( pDb->pUpdateHook );
assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );
pCmd = Tcl_DuplicateObj(pDb->pUpdateHook);
Tcl_IncrRefCount(pCmd);
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(
( (op==SQLITE_INSERT)?"INSERT":(op==SQLITE_UPDATE)?"UPDATE":"DELETE"), -1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(azStr[(op-1)/9], -1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zDb, -1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zTbl, -1));
Tcl_ListObjAppendElement(0, pCmd, Tcl_NewWideIntObj(rowid));
@@ -1614,6 +1658,46 @@ static int DbEvalNextCmd(
return rc;
}
/*
** This function is used by the implementations of the following database
** handle sub-commands:
**
** $db update_hook ?SCRIPT?
** $db wal_hook ?SCRIPT?
** $db commit_hook ?SCRIPT?
** $db preupdate hook ?SCRIPT?
*/
static void DbHookCmd(
Tcl_Interp *interp, /* Tcl interpreter */
SqliteDb *pDb, /* Database handle */
Tcl_Obj *pArg, /* SCRIPT argument (or NULL) */
Tcl_Obj **ppHook /* Pointer to member of SqliteDb */
){
sqlite3 *db = pDb->db;
if( *ppHook ){
Tcl_SetObjResult(interp, *ppHook);
if( pArg ){
Tcl_DecrRefCount(*ppHook);
*ppHook = 0;
}
}
if( pArg ){
assert( !(*ppHook) );
if( Tcl_GetCharLength(pArg)>0 ){
*ppHook = pArg;
Tcl_IncrRefCount(*ppHook);
}
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
sqlite3_preupdate_hook(db, (pDb->pPreUpdateHook?DbPreUpdateHandler:0), pDb);
#endif
sqlite3_update_hook(db, (pDb->pUpdateHook?DbUpdateHandler:0), pDb);
sqlite3_rollback_hook(db, (pDb->pRollbackHook?DbRollbackHandler:0), pDb);
sqlite3_wal_hook(db, (pDb->pWalHook?DbWalHandler:0), pDb);
}
/*
** The "sqlite" command below creates a new Tcl command for each
** connection it opens to an SQLite database. This routine is invoked
@@ -1639,11 +1723,12 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
"errorcode", "eval", "exists",
"function", "incrblob", "interrupt",
"last_insert_rowid", "nullvalue", "onecolumn",
"profile", "progress", "rekey",
"restore", "rollback_hook", "status",
"timeout", "total_changes", "trace",
"transaction", "unlock_notify", "update_hook",
"version", "wal_hook", 0
"preupdate", "profile", "progress",
"rekey", "restore", "rollback_hook",
"status", "timeout", "total_changes",
"trace", "transaction", "unlock_notify",
"update_hook", "version", "wal_hook",
0
};
enum DB_enum {
DB_AUTHORIZER, DB_BACKUP, DB_BUSY,
@@ -1653,11 +1738,11 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
DB_ERRORCODE, DB_EVAL, DB_EXISTS,
DB_FUNCTION, DB_INCRBLOB, DB_INTERRUPT,
DB_LAST_INSERT_ROWID, DB_NULLVALUE, DB_ONECOLUMN,
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_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,
};
/* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */
@@ -2855,6 +2940,90 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
break;
}
/*
** $db preupdate_hook count
** $db preupdate_hook hook ?SCRIPT?
** $db preupdate_hook new INDEX
** $db preupdate_hook old INDEX
*/
case DB_PREUPDATE: {
#ifndef SQLITE_ENABLE_PREUPDATE_HOOK
Tcl_AppendResult(interp, "preupdate_hook was omitted at compile-time");
rc = TCL_ERROR;
#else
static const char *azSub[] = {"count", "depth", "hook", "new", "old", 0};
enum DbPreupdateSubCmd {
PRE_COUNT, PRE_DEPTH, PRE_HOOK, PRE_NEW, PRE_OLD
};
int iSub;
if( objc<3 ){
Tcl_WrongNumArgs(interp, 2, objv, "SUB-COMMAND ?ARGS?");
}
if( Tcl_GetIndexFromObj(interp, objv[2], azSub, "sub-command", 0, &iSub) ){
return TCL_ERROR;
}
switch( (enum DbPreupdateSubCmd)iSub ){
case PRE_COUNT: {
int nCol = sqlite3_preupdate_count(pDb->db);
Tcl_SetObjResult(interp, Tcl_NewIntObj(nCol));
break;
}
case PRE_HOOK: {
if( objc>4 ){
Tcl_WrongNumArgs(interp, 2, objv, "hook ?SCRIPT?");
return TCL_ERROR;
}
DbHookCmd(interp, pDb, (objc==4 ? objv[3] : 0), &pDb->pPreUpdateHook);
break;
}
case PRE_DEPTH: {
Tcl_Obj *pRet;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 3, objv, "");
return TCL_ERROR;
}
pRet = Tcl_NewIntObj(sqlite3_preupdate_depth(pDb->db));
Tcl_SetObjResult(interp, pRet);
break;
}
case PRE_NEW:
case PRE_OLD: {
int iIdx;
sqlite3_value *pValue;
if( objc!=4 ){
Tcl_WrongNumArgs(interp, 3, objv, "INDEX");
return TCL_ERROR;
}
if( Tcl_GetIntFromObj(interp, objv[3], &iIdx) ){
return TCL_ERROR;
}
if( iSub==PRE_OLD ){
rc = sqlite3_preupdate_old(pDb->db, iIdx, &pValue);
}else{
assert( iSub==PRE_NEW );
rc = sqlite3_preupdate_new(pDb->db, iIdx, &pValue);
}
if( rc==SQLITE_OK ){
Tcl_Obj *pObj;
pObj = Tcl_NewStringObj((char*)sqlite3_value_text(pValue), -1);
Tcl_SetObjResult(interp, pObj);
}else{
Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), 0);
return TCL_ERROR;
}
}
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
break;
}
/*
** $db wal_hook ?script?
** $db update_hook ?script?
@@ -2863,42 +3032,19 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
case DB_WAL_HOOK:
case DB_UPDATE_HOOK:
case DB_ROLLBACK_HOOK: {
/* set ppHook to point at pUpdateHook or pRollbackHook, depending on
** whether [$db update_hook] or [$db rollback_hook] was invoked.
*/
Tcl_Obj **ppHook;
if( choice==DB_UPDATE_HOOK ){
ppHook = &pDb->pUpdateHook;
}else if( choice==DB_WAL_HOOK ){
ppHook = &pDb->pWalHook;
}else{
ppHook = &pDb->pRollbackHook;
}
if( objc!=2 && objc!=3 ){
if( choice==DB_WAL_HOOK ) ppHook = &pDb->pWalHook;
if( choice==DB_UPDATE_HOOK ) ppHook = &pDb->pUpdateHook;
if( choice==DB_ROLLBACK_HOOK ) ppHook = &pDb->pRollbackHook;
if( objc>3 ){
Tcl_WrongNumArgs(interp, 2, objv, "?SCRIPT?");
return TCL_ERROR;
}
if( *ppHook ){
Tcl_SetObjResult(interp, *ppHook);
if( objc==3 ){
Tcl_DecrRefCount(*ppHook);
*ppHook = 0;
}
}
if( objc==3 ){
assert( !(*ppHook) );
if( Tcl_GetCharLength(objv[2])>0 ){
*ppHook = objv[2];
Tcl_IncrRefCount(*ppHook);
}
}
sqlite3_update_hook(pDb->db, (pDb->pUpdateHook?DbUpdateHandler:0), pDb);
sqlite3_rollback_hook(pDb->db,(pDb->pRollbackHook?DbRollbackHandler:0),pDb);
sqlite3_wal_hook(pDb->db,(pDb->pWalHook?DbWalHandler:0),pDb);
DbHookCmd(interp, pDb, (objc==3 ? objv[2] : 0), ppHook);
break;
}
@@ -3772,6 +3918,9 @@ static void init_all(Tcl_Interp *interp){
extern int Sqlitemultiplex_Init(Tcl_Interp*);
extern int SqliteSuperlock_Init(Tcl_Interp*);
extern int SqlitetestSyscall_Init(Tcl_Interp*);
#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
extern int TestSession_Init(Tcl_Interp*);
#endif
extern int Fts5tcl_Init(Tcl_Interp *);
extern int SqliteRbu_Init(Tcl_Interp*);
extern int Sqlitetesttcl_Init(Tcl_Interp*);
@@ -3817,6 +3966,9 @@ static void init_all(Tcl_Interp *interp){
Sqlitemultiplex_Init(interp);
SqliteSuperlock_Init(interp);
SqlitetestSyscall_Init(interp);
#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
TestSession_Init(interp);
#endif
Fts5tcl_Init(interp);
SqliteRbu_Init(interp);
Sqlitetesttcl_Init(interp);
+12
View File
@@ -156,6 +156,12 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options", "mem5", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
Tcl_SetVar2(interp, "sqlite_options", "preupdate", "1", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "preupdate", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_SNAPSHOT
Tcl_SetVar2(interp, "sqlite_options", "snapshot", "1", TCL_GLOBAL_ONLY);
#else
@@ -534,6 +540,12 @@ Tcl_SetVar2(interp, "sqlite_options", "mergesort", "1", TCL_GLOBAL_ONLY);
Tcl_SetVar2(interp, "sqlite_options", "schema_version", "1", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_SESSION
Tcl_SetVar2(interp, "sqlite_options", "session", "1", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "session", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_STAT4
Tcl_SetVar2(interp, "sqlite_options", "stat4", "1", TCL_GLOBAL_ONLY);
#else
+5 -1
View File
@@ -717,7 +717,11 @@ static int multiplexCurrentTime(sqlite3_vfs *a, double *b){
return gMultiplex.pOrigVfs->xCurrentTime(gMultiplex.pOrigVfs, b);
}
static int multiplexGetLastError(sqlite3_vfs *a, int b, char *c){
return gMultiplex.pOrigVfs->xGetLastError(gMultiplex.pOrigVfs, b, c);
if( gMultiplex.pOrigVfs->xGetLastError ){
return gMultiplex.pOrigVfs->xGetLastError(gMultiplex.pOrigVfs, b, c);
}else{
return 0;
}
}
static int multiplexCurrentTimeInt64(sqlite3_vfs *a, sqlite3_int64 *b){
return gMultiplex.pOrigVfs->xCurrentTimeInt64(gMultiplex.pOrigVfs, b);
+21 -2
View File
@@ -590,11 +590,30 @@ void sqlite3Update(
VdbeCoverageNeverTaken(v);
}
sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);
/* If changing the record number, delete the old record. */
/* If changing the rowid value, or if there are foreign key constraints
** to process, delete the old record. Otherwise, add a noop OP_Delete
** to invoke the pre-update hook.
**
** That (regNew==regnewRowid+1) is true is also important for the
** pre-update hook. If the caller invokes preupdate_new(), the returned
** value is copied from memory cell (regNewRowid+1+iCol), where iCol
** is the column index supplied by the user.
*/
assert( regNew==regNewRowid+1 );
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
sqlite3VdbeAddOp3(v, OP_Delete, iDataCur,
OPFLAG_ISUPDATE | ((hasFK || chngKey || pPk!=0) ? 0 : OPFLAG_ISNOOP),
regNewRowid
);
if( !pParse->nested ){
sqlite3VdbeChangeP4(v, -1, (char*)pTab, P4_TABLE);
}
#else
if( hasFK || chngKey || pPk!=0 ){
sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);
}
#endif
if( bReplace || chngKey ){
sqlite3VdbeJumpHere(v, addr1);
}
+8 -4
View File
@@ -110,11 +110,15 @@ int sqlite3Strlen30(const char *z){
}
/*
** The string z[] is followed immediately by another string. Return
** a poiner to that other string.
** Return the declared type of a column. Or return zDflt if the column
** has no declared type.
**
** The column type is an extra string stored after the zero-terminator on
** the column name if and only if the COLFLAG_HASTYPE flag is set.
*/
const char *sqlite3StrNext(const char *z){
return z + strlen(z) + 1;
char *sqlite3ColumnType(Column *pCol, char *zDflt){
if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt;
return pCol->zName + strlen(pCol->zName) + 1;
}
/*
+104 -35
View File
@@ -86,6 +86,16 @@ static void updateMaxBlobsize(Mem *p){
}
#endif
/*
** This macro evaluates to true if either the update hook or the preupdate
** hook are enabled for database connect DB.
*/
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
# define HAS_UPDATE_HOOK(DB) ((DB)->xPreUpdateCallback||(DB)->xUpdateCallback)
#else
# define HAS_UPDATE_HOOK(DB) ((DB)->xUpdateCallback)
#endif
/*
** The next global variable is incremented each time the OP_Found opcode
** is executed. This is used to test whether or not the foreign key
@@ -2524,7 +2534,6 @@ case OP_Column: {
}while( i<=p2 && zHdr<zEndHdr );
pC->nHdrParsed = i;
pC->iHdrOffset = (u32)(zHdr - zData);
if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
/* The record is corrupt if any of the following are true:
** (1) the bytes of the header extend past the declared header size
@@ -2534,9 +2543,12 @@ case OP_Column: {
if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset64!=pC->payloadSize))
|| (offset64 > pC->payloadSize)
){
if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
rc = SQLITE_CORRUPT_BKPT;
goto abort_due_to_error;
}
if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
}else{
t = 0;
}
@@ -2889,7 +2901,7 @@ case OP_Savepoint: {
}else{
db->nSavepoint++;
}
/* Link the new savepoint into the database handle's list. */
pNew->pNext = db->pSavepoint;
db->pSavepoint = pNew;
@@ -4246,9 +4258,9 @@ case OP_NewRowid: { /* out2 */
** is part of an INSERT operation. The difference is only important to
** the update hook.
**
** Parameter P4 may point to a string containing the table-name, or
** may be NULL. If it is not NULL, then the update-hook
** (sqlite3.xUpdateCallback) is invoked following a successful insert.
** Parameter P4 may point to a Table structure, or may be NULL. If it is
** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked
** following a successful insert.
**
** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically
** allocated, then ownership of P2 is transferred to the pseudo-cursor
@@ -4274,9 +4286,10 @@ case OP_InsertInt: {
int nZero; /* Number of zero-bytes to append */
int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */
const char *zDb; /* database name - used by the update hook */
const char *zTbl; /* Table name - used by the opdate hook */
Table *pTab; /* Table structure - used by update and pre-update hooks */
int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */
op = 0;
pData = &aMem[pOp->p2];
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
assert( memIsValid(pData) );
@@ -4285,6 +4298,7 @@ case OP_InsertInt: {
assert( pC->eCurType==CURTYPE_BTREE );
assert( pC->uc.pCursor!=0 );
assert( pC->isTable );
assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC );
REGISTER_TRACE(pOp->p2, pData);
if( pOp->opcode==OP_Insert ){
@@ -4298,6 +4312,28 @@ case OP_InsertInt: {
iKey = pOp->p3;
}
if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
assert( pC->isTable );
assert( pC->iDb>=0 );
zDb = db->aDb[pC->iDb].zName;
pTab = pOp->p4.pTab;
assert( HasRowid(pTab) );
op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);
}else{
pTab = 0; /* Not needed. Silence a comiler warning. */
zDb = 0; /* Not needed. Silence a compiler warning. */
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/* Invoke the pre-update hook, if any */
if( db->xPreUpdateCallback
&& pOp->p4type==P4_TABLE
&& !(pOp->p5 & OPFLAG_ISUPDATE)
){
sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2);
}
#endif
if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey;
if( pData->flags & MEM_Null ){
@@ -4321,18 +4357,13 @@ case OP_InsertInt: {
/* Invoke the update-hook if required. */
if( rc ) goto abort_due_to_error;
if( db->xUpdateCallback && pOp->p4.z ){
zDb = db->aDb[pC->iDb].zName;
zTbl = pOp->p4.z;
op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);
assert( pC->isTable );
db->xUpdateCallback(db->pUpdateArg, op, zDb, zTbl, iKey);
assert( pC->iDb>=0 );
if( db->xUpdateCallback && op ){
db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey);
}
break;
}
/* Opcode: Delete P1 P2 * P4 P5
/* Opcode: Delete P1 P2 P3 P4 P5
**
** Delete the record at which the P1 cursor is currently pointing.
**
@@ -4356,15 +4387,24 @@ case OP_InsertInt: {
** P1 must not be pseudo-table. It has to be a real table with
** multiple rows.
**
** If P4 is not NULL, then it is the name of the table that P1 is
** pointing to. The update hook will be invoked, if it exists.
** If P4 is not NULL then the P1 cursor must have been positioned
** using OP_NotFound prior to invoking this opcode.
** If P4 is not NULL then it points to a Table struture. In this case either
** the update or pre-update hook, or both, may be invoked. The P1 cursor must
** have been positioned using OP_NotFound prior to invoking this opcode in
** this case. Specifically, if one is configured, the pre-update hook is
** invoked if P4 is not NULL. The update-hook is invoked if one is configured,
** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2.
**
** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address
** of the memory cell that contains the value that the rowid of the row will
** be set to by the update.
*/
case OP_Delete: {
VdbeCursor *pC;
u8 hasUpdateCallback;
const char *zDb;
Table *pTab;
int opflags;
opflags = pOp->p2;
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
assert( pC!=0 );
@@ -4372,22 +4412,48 @@ case OP_Delete: {
assert( pC->uc.pCursor!=0 );
assert( pC->deferredMoveto==0 );
hasUpdateCallback = db->xUpdateCallback && pOp->p4.z && pC->isTable;
if( pOp->p5 && hasUpdateCallback ){
sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget);
}
#ifdef SQLITE_DEBUG
/* The seek operation that positioned the cursor prior to OP_Delete will
** have also set the pC->movetoTarget field to the rowid of the row that
** is being deleted */
if( pOp->p4.z && pC->isTable && pOp->p5==0 ){
if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
/* If p5 is zero, the seek operation that positioned the cursor prior to
** OP_Delete will have also set the pC->movetoTarget field to the rowid of
** the row that is being deleted */
i64 iKey = 0;
sqlite3BtreeKeySize(pC->uc.pCursor, &iKey);
assert( pC->movetoTarget==iKey );
assert( pC->movetoTarget==iKey );
}
#endif
/* If the update-hook or pre-update-hook will be invoked, set zDb to
** the name of the db to pass as to it. Also set local pTab to a copy
** of p4.pTab. Finally, if p5 is true, indicating that this cursor was
** last moved with OP_Next or OP_Prev, not Seek or NotFound, set
** VdbeCursor.movetoTarget to the current rowid. */
if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
assert( pC->iDb>=0 );
assert( pOp->p4.pTab!=0 );
zDb = db->aDb[pC->iDb].zName;
pTab = pOp->p4.pTab;
if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget);
}
}else{
zDb = 0; /* Not needed. Silence a compiler warning. */
pTab = 0; /* Not needed. Silence a compiler warning. */
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/* Invoke the pre-update-hook if required. */
if( db->xPreUpdateCallback && pOp->p4.pTab && HasRowid(pTab) ){
assert( !(opflags & OPFLAG_ISUPDATE) || (aMem[pOp->p3].flags & MEM_Int) );
sqlite3VdbePreUpdateHook(p, pC,
(opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE,
zDb, pTab, pC->movetoTarget,
pOp->p3
);
}
if( opflags & OPFLAG_ISNOOP ) break;
#endif
/* Only flags that can be set are SAVEPOISTION and AUXDELETE */
assert( (pOp->p5 & ~(OPFLAG_SAVEPOSITION|OPFLAG_AUXDELETE))==0 );
assert( OPFLAG_SAVEPOSITION==BTREE_SAVEPOSITION );
@@ -4409,15 +4475,18 @@ case OP_Delete: {
rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);
pC->cacheStatus = CACHE_STALE;
if( rc ) goto abort_due_to_error;
/* Invoke the update-hook if required. */
if( rc ) goto abort_due_to_error;
if( hasUpdateCallback ){
db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE,
db->aDb[pC->iDb].zName, pOp->p4.z, pC->movetoTarget);
assert( pC->iDb>=0 );
if( opflags & OPFLAG_NCHANGE ){
p->nChange++;
if( db->xUpdateCallback && HasRowid(pTab) ){
db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,
pC->movetoTarget);
assert( pC->iDb>=0 );
}
}
if( pOp->p2 & OPFLAG_NCHANGE ) p->nChange++;
break;
}
/* Opcode: ResetCount * * * * *
+3 -1
View File
@@ -60,6 +60,7 @@ struct VdbeOp {
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
int *ai; /* Used when p4type is P4_INTARRAY */
SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
Table *pTab; /* Used when p4type is P4_TABLE */
#ifdef SQLITE_ENABLE_CURSOR_HINTS
Expr *pExpr; /* Used when p4type is P4_EXPR */
#endif
@@ -124,7 +125,8 @@ typedef struct VdbeOpList VdbeOpList;
#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
#define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */
#define P4_ADVANCE (-19) /* P4 is a pointer to BtreeNext() or BtreePrev() */
#define P4_FUNCCTX (-20) /* P4 is a pointer to an sqlite3_context object */
#define P4_TABLE (-20) /* P4 is a pointer to a Table structure */
#define P4_FUNCCTX (-21) /* P4 is a pointer to an sqlite3_context object */
/* Error message codes for OP_Halt */
#define P5_ConstraintNotNull 1
+22
View File
@@ -428,6 +428,25 @@ struct Vdbe {
#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */
#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */
/*
** Structure used to store the context required by the
** sqlite3_preupdate_*() API functions.
*/
struct PreUpdate {
Vdbe *v;
VdbeCursor *pCsr; /* Cursor to read old values from */
int op; /* One of SQLITE_INSERT, UPDATE, DELETE */
u8 *aRecord; /* old.* database record */
KeyInfo keyinfo;
UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
int iNewReg; /* Register for new.* values */
i64 iKey1; /* First key value passed to hook */
i64 iKey2; /* Second key value passed to hook */
int iPKey; /* If not negative index of IPK column */
Mem *aNew; /* Array of new.* values */
};
/*
** Function prototypes
*/
@@ -487,6 +506,9 @@ int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
int sqlite3VdbeCloseStatement(Vdbe *, int);
void sqlite3VdbeFrameDelete(VdbeFrame*);
int sqlite3VdbeFrameRestore(VdbeFrame *);
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
void sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int);
#endif
int sqlite3VdbeTransferError(Vdbe *p);
int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
+181
View File
@@ -1604,6 +1604,187 @@ int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
return (int)v;
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** Allocate and populate an UnpackedRecord structure based on the serialized
** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
** if successful, or a NULL pointer if an OOM error is encountered.
*/
static UnpackedRecord *vdbeUnpackRecord(
KeyInfo *pKeyInfo,
int nKey,
const void *pKey
){
char *dummy; /* Dummy argument for AllocUnpackedRecord() */
UnpackedRecord *pRet; /* Return value */
pRet = sqlite3VdbeAllocUnpackedRecord(pKeyInfo, 0, 0, &dummy);
if( pRet ){
memset(pRet->aMem, 0, sizeof(Mem)*(pKeyInfo->nField+1));
sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, pRet);
}
return pRet;
}
/*
** This function is called from within a pre-update callback to retrieve
** a field of the row currently being updated or deleted.
*/
int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
PreUpdate *p = db->pPreUpdate;
int rc = SQLITE_OK;
/* Test that this call is being made from within an SQLITE_DELETE or
** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */
if( !p || p->op==SQLITE_INSERT ){
rc = SQLITE_MISUSE_BKPT;
goto preupdate_old_out;
}
if( iIdx>=p->pCsr->nField || iIdx<0 ){
rc = SQLITE_RANGE;
goto preupdate_old_out;
}
/* If the old.* record has not yet been loaded into memory, do so now. */
if( p->pUnpacked==0 ){
u32 nRec;
u8 *aRec;
rc = sqlite3BtreeDataSize(p->pCsr->uc.pCursor, &nRec);
if( rc!=SQLITE_OK ) goto preupdate_old_out;
aRec = sqlite3DbMallocRaw(db, nRec);
if( !aRec ) goto preupdate_old_out;
rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec);
if( rc==SQLITE_OK ){
p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
if( !p->pUnpacked ) rc = SQLITE_NOMEM;
}
if( rc!=SQLITE_OK ){
sqlite3DbFree(db, aRec);
goto preupdate_old_out;
}
p->aRecord = aRec;
}
if( iIdx>=p->pUnpacked->nField ){
*ppValue = (sqlite3_value *)columnNullValue();
}else{
*ppValue = &p->pUnpacked->aMem[iIdx];
if( iIdx==p->iPKey ){
sqlite3VdbeMemSetInt64(*ppValue, p->iKey1);
}
}
preupdate_old_out:
sqlite3Error(db, rc);
return sqlite3ApiExit(db, rc);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** This function is called from within a pre-update callback to retrieve
** the number of columns in the row being updated, deleted or inserted.
*/
int sqlite3_preupdate_count(sqlite3 *db){
PreUpdate *p = db->pPreUpdate;
return (p ? p->keyinfo.nField : 0);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** This function is designed to be called from within a pre-update callback
** only. It returns zero if the change that caused the callback was made
** immediately by a user SQL statement. Or, if the change was made by a
** trigger program, it returns the number of trigger programs currently
** on the stack (1 for a top-level trigger, 2 for a trigger fired by a
** top-level trigger etc.).
**
** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL
** or SET DEFAULT action is considered a trigger.
*/
int sqlite3_preupdate_depth(sqlite3 *db){
PreUpdate *p = db->pPreUpdate;
return (p ? p->v->nFrame : 0);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** This function is called from within a pre-update callback to retrieve
** a field of the row currently being updated or inserted.
*/
int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
PreUpdate *p = db->pPreUpdate;
int rc = SQLITE_OK;
Mem *pMem;
if( !p || p->op==SQLITE_DELETE ){
rc = SQLITE_MISUSE_BKPT;
goto preupdate_new_out;
}
if( iIdx>=p->pCsr->nField || iIdx<0 ){
rc = SQLITE_RANGE;
goto preupdate_new_out;
}
if( p->op==SQLITE_INSERT ){
/* For an INSERT, memory cell p->iNewReg contains the serialized record
** that is being inserted. Deserialize it. */
UnpackedRecord *pUnpack = p->pNewUnpacked;
if( !pUnpack ){
Mem *pData = &p->v->aMem[p->iNewReg];
rc = sqlite3VdbeMemExpandBlob(pData);
if( rc!=SQLITE_OK ) goto preupdate_new_out;
pUnpack = vdbeUnpackRecord(&p->keyinfo, pData->n, pData->z);
if( !pUnpack ){
rc = SQLITE_NOMEM;
goto preupdate_new_out;
}
p->pNewUnpacked = pUnpack;
}
if( iIdx>=pUnpack->nField ){
pMem = (sqlite3_value *)columnNullValue();
}else{
pMem = &pUnpack->aMem[iIdx];
if( iIdx==p->iPKey ){
sqlite3VdbeMemSetInt64(pMem, p->iKey2);
}
}
}else{
/* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required
** value. Make a copy of the cell contents and return a pointer to it.
** It is not safe to return a pointer to the memory cell itself as the
** caller may modify the value text encoding.
*/
assert( p->op==SQLITE_UPDATE );
if( !p->aNew ){
p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem) * p->pCsr->nField);
if( !p->aNew ){
rc = SQLITE_NOMEM;
goto preupdate_new_out;
}
}
assert( iIdx>=0 && iIdx<p->pCsr->nField );
pMem = &p->aNew[iIdx];
if( pMem->flags==0 ){
if( iIdx==p->iPKey ){
sqlite3VdbeMemSetInt64(pMem, p->iKey2);
}else{
rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
if( rc!=SQLITE_OK ) goto preupdate_new_out;
}
}
}
*ppValue = pMem;
preupdate_new_out:
sqlite3Error(db, rc);
return sqlite3ApiExit(db, rc);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
/*
** Return status data for a single loop within query pStmt.
+90
View File
@@ -78,6 +78,7 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt){
void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
Vdbe tmp, *pTmp;
char *zTmp;
assert( pA->db==pB->db );
tmp = *pA;
*pA = *pB;
*pB = tmp;
@@ -1317,6 +1318,10 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
zTemp[0] = 0;
break;
}
case P4_TABLE: {
sqlite3XPrintf(&x, "%s", pOp->p4.pTab->zName);
break;
}
default: {
zP4 = pOp->p4.z;
if( zP4==0 ){
@@ -3507,6 +3512,7 @@ void sqlite3VdbeRecordUnpack(
pMem->db = pKeyInfo->db;
/* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
pMem->szMalloc = 0;
pMem->z = 0;
d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
pMem++;
if( (++u)>=p->nField ) break;
@@ -4486,3 +4492,87 @@ void sqlite3VtabImportErrmsg(Vdbe *p, sqlite3_vtab *pVtab){
}
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** If the second argument is not NULL, release any allocations associated
** with the memory cells in the p->aMem[] array. Also free the UnpackedRecord
** structure itself, using sqlite3DbFree().
**
** This function is used to free UnpackedRecord structures allocated by
** the vdbeUnpackRecord() function found in vdbeapi.c.
*/
static void vdbeFreeUnpacked(sqlite3 *db, UnpackedRecord *p){
if( p ){
int i;
for(i=0; i<p->nField; i++){
Mem *pMem = &p->aMem[i];
if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);
}
sqlite3DbFree(db, p);
}
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call,
** then cursor passed as the second argument should point to the row about
** to be update or deleted. If the application calls sqlite3_preupdate_old(),
** the required value will be read from the row the cursor points to.
*/
void sqlite3VdbePreUpdateHook(
Vdbe *v, /* Vdbe pre-update hook is invoked by */
VdbeCursor *pCsr, /* Cursor to grab old.* values from */
int op, /* SQLITE_INSERT, UPDATE or DELETE */
const char *zDb, /* Database name */
Table *pTab, /* Modified table */
i64 iKey1, /* Initial key value */
int iReg /* Register for new.* record */
){
sqlite3 *db = v->db;
i64 iKey2;
PreUpdate preupdate;
const char *zTbl = pTab->zName;
static const u8 fakeSortOrder = 0;
assert( db->pPreUpdate==0 );
memset(&preupdate, 0, sizeof(PreUpdate));
if( op==SQLITE_UPDATE ){
iKey2 = v->aMem[iReg].u.i;
}else{
iKey2 = iKey1;
}
assert( pCsr->nField==pTab->nCol
|| (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1)
);
preupdate.v = v;
preupdate.pCsr = pCsr;
preupdate.op = op;
preupdate.iNewReg = iReg;
preupdate.keyinfo.db = db;
preupdate.keyinfo.enc = ENC(db);
preupdate.keyinfo.nField = pTab->nCol;
preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;
preupdate.iKey1 = iKey1;
preupdate.iKey2 = iKey2;
preupdate.iPKey = pTab->iPKey;
db->pPreUpdate = &preupdate;
db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);
db->pPreUpdate = 0;
sqlite3DbFree(db, preupdate.aRecord);
vdbeFreeUnpacked(db, preupdate.pUnpacked);
vdbeFreeUnpacked(db, preupdate.pNewUnpacked);
if( preupdate.aNew ){
int i;
for(i=0; i<pCsr->nField; i++){
sqlite3VdbeMemRelease(&preupdate.aNew[i]);
}
sqlite3DbFree(db, preupdate.aNew);
}
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
+28
View File
@@ -30,6 +30,8 @@ struct Incrblob {
BtCursor *pCsr; /* Cursor pointing at blob row */
sqlite3_stmt *pStmt; /* Statement holding cursor open */
sqlite3 *db; /* The associated database */
char *zDb; /* Database name */
Table *pTab; /* Table object */
};
@@ -173,6 +175,8 @@ int sqlite3_blob_open(
sqlite3BtreeLeaveAll(db);
goto blob_open_out;
}
pBlob->pTab = pTab;
pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zName;
/* Now search pTab for the exact column. */
for(iCol=0; iCol<pTab->nCol; iCol++) {
@@ -394,6 +398,30 @@ static int blobReadWrite(
*/
assert( db == v->db );
sqlite3BtreeEnterCursor(p->pCsr);
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
if( xCall==sqlite3BtreePutData && db->xPreUpdateCallback ){
/* If a pre-update hook is registered and this is a write cursor,
** invoke it here.
**
** TODO: The preupdate-hook is passed SQLITE_DELETE, even though this
** operation should really be an SQLITE_UPDATE. This is probably
** incorrect, but is convenient because at this point the new.* values
** are not easily obtainable. And for the sessions module, an
** SQLITE_UPDATE where the PK columns do not change is handled in the
** same way as an SQLITE_DELETE (the SQLITE_DELETE code is actually
** slightly more efficient). Since you cannot write to a PK column
** using the incremental-blob API, this works. For the sessions module
** anyhow.
*/
sqlite3_int64 iKey;
sqlite3BtreeKeySize(p->pCsr, &iKey);
sqlite3VdbePreUpdateHook(
v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
);
}
#endif
rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);
sqlite3BtreeLeaveCursor(p->pCsr);
if( rc==SQLITE_ABORT ){
-4
View File
@@ -802,10 +802,6 @@ void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
int rc = SQLITE_OK;
/* The pFrom==0 case in the following assert() is when an sqlite3_value
** from sqlite3_value_dup() is used as the argument
** to sqlite3_result_value(). */
assert( pTo->db==pFrom->db || pFrom->db==0 );
assert( (pFrom->flags & MEM_RowSet)==0 );
if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
memcpy(pTo, pFrom, MEMCELLSIZE);
+7 -13
View File
@@ -564,22 +564,16 @@ static int vtabCallConstructor(
pTab->pVTable = pVTable;
for(iCol=0; iCol<pTab->nCol; iCol++){
char *zType = (char*)sqlite3StrNext(pTab->aCol[iCol].zName);
char *zType = sqlite3ColumnType(&pTab->aCol[iCol], "");
int nType;
int i = 0;
if( !zType[0] ){
pTab->tabFlags |= oooHidden;
continue;
}
nType = sqlite3Strlen30(zType);
if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){
for(i=0; i<nType; i++){
if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
&& (zType[i+7]=='\0' || zType[i+7]==' ')
){
i++;
break;
}
for(i=0; i<nType; i++){
if( 0==sqlite3StrNICmp("hidden", &zType[i], 6)
&& (i==0 || zType[i-1]==' ')
&& (zType[i+6]=='\0' || zType[i+6]==' ')
){
break;
}
}
if( i<nType ){
+12 -2
View File
@@ -2201,8 +2201,6 @@ static int whereLoopAddBtreeIndex(
assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
if( pNew->wsFlags & WHERE_BTM_LIMIT ){
opMask = WO_LT|WO_LE;
}else if( /*pProbe->tnum<=0 ||*/ (pSrc->fg.jointype & JT_LEFT)!=0 ){
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE;
}else{
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
}
@@ -2240,6 +2238,18 @@ static int whereLoopAddBtreeIndex(
** to mix with a lower range bound from some other source */
if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
/* Do not allow IS constraints from the WHERE clause to be used by the
** right table of a LEFT JOIN. Only constraints in the ON clause are
** allowed */
if( (pSrc->fg.jointype & JT_LEFT)!=0
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
&& (eOp & (WO_IS|WO_ISNULL))!=0
){
testcase( eOp & WO_IS );
testcase( eOp & WO_ISNULL );
continue;
}
pNew->wsFlags = saved_wsFlags;
pNew->u.btree.nEq = saved_nEq;
pNew->nLTerm = saved_nLTerm;
+1 -1
View File
@@ -929,7 +929,7 @@ do_test capi3-11.10 {
do_test capi3-11.11 {
sqlite3_step $STMT
} {SQLITE_DONE}
ifcapable api_armor {
ifcapable !autoreset {
do_test capi3-11.12armor {
sqlite3_step $STMT
sqlite3_step $STMT
+1 -1
View File
@@ -868,7 +868,7 @@ do_test capi3c-11.10 {
do_test capi3c-11.11 {
sqlite3_step $STMT
} {SQLITE_DONE}
ifcapable api_armor {
ifcapable !autoreset {
do_test capi3c-11.12armor {
sqlite3_step $STMT
sqlite3_step $STMT
+1 -1
View File
@@ -1,4 +1,4 @@
# 2013-07-11
# 2012 December 17
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
+1 -1
View File
@@ -189,7 +189,7 @@ static int progressHandler(void *pVdbeLimitFlag){
** Reallocate memory. Show and error and quit if unable.
*/
static void *safe_realloc(void *pOld, int szNew){
void *pNew = realloc(pOld, szNew);
void *pNew = realloc(pOld, szNew<=0 ? 1 : szNew);
if( pNew==0 ) fatalError("unable to realloc for %d bytes", szNew);
return pNew;
}
+410
View File
@@ -21,6 +21,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix hook
do_test hook-1.2 {
db commit_hook
@@ -438,4 +439,413 @@ do_test hook-6.2 {
} {COMMIT ROLLBACK}
unset ::hooks
#----------------------------------------------------------------------------
# The following tests - hook-7.* - test the pre-update hook.
#
ifcapable !preupdate {
finish_test
return
}
#
# 7.1.1 - INSERT statement.
# 7.1.2 - INSERT INTO ... SELECT statement.
# 7.1.3 - REPLACE INTO ... (rowid conflict)
# 7.1.4 - REPLACE INTO ... (other index conflicts)
# 7.1.5 - REPLACE INTO ... (both rowid and other index conflicts)
#
# 7.2.1 - DELETE statement.
# 7.2.2 - DELETE statement that uses the truncate optimization.
#
# 7.3.1 - UPDATE statement.
# 7.3.2 - UPDATE statement that modifies the rowid.
# 7.3.3 - UPDATE OR REPLACE ... (rowid conflict).
# 7.3.4 - UPDATE OR REPLACE ... (other index conflicts)
# 7.3.4 - UPDATE OR REPLACE ... (both rowid and other index conflicts)
#
# 7.4.1 - Test that the pre-update-hook is invoked only once if a row being
# deleted is removed by a BEFORE trigger.
#
# 7.4.2 - Test that the pre-update-hook is invoked if a BEFORE trigger
# removes a row being updated. In this case the update hook should
# be invoked with SQLITE_INSERT as the opcode when inserting the
# new version of the row.
#
# TODO: Short records (those created before a column is added to a table
# using ALTER TABLE)
#
proc do_preupdate_test {tn sql x} {
set X [list]
foreach elem $x {lappend X $elem}
uplevel do_test $tn [list "
set ::preupdate \[list\]
execsql { $sql }
set ::preupdate
"] [list $X]
}
proc preupdate_hook {args} {
set type [lindex $args 0]
eval lappend ::preupdate $args
if {$type != "INSERT"} {
for {set i 0} {$i < [db preupdate count]} {incr i} {
lappend ::preupdate [db preupdate old $i]
}
}
if {$type != "DELETE"} {
for {set i 0} {$i < [db preupdate count]} {incr i} {
set rc [catch { db preupdate new $i } v]
lappend ::preupdate $v
}
}
}
db close
forcedelete test.db
sqlite3 db test.db
db preupdate hook preupdate_hook
# Set up a schema to use for tests 7.1.* to 7.3.*.
do_execsql_test 7.0 {
CREATE TABLE t1(a, b);
CREATE TABLE t2(x, y);
CREATE TABLE t3(i, j, UNIQUE(i));
INSERT INTO t2 VALUES('a', 'b');
INSERT INTO t2 VALUES('c', 'd');
INSERT INTO t3 VALUES(4, 16);
INSERT INTO t3 VALUES(5, 25);
INSERT INTO t3 VALUES(6, 36);
}
do_preupdate_test 7.1.1 {
INSERT INTO t1 VALUES('x', 'y')
} {INSERT main t1 1 1 x y}
# 7.1.2.1 does not use the xfer optimization. 7.1.2.2 does.
do_preupdate_test 7.1.2.1 {
INSERT INTO t1 SELECT y, x FROM t2;
} {INSERT main t1 2 2 b a INSERT main t1 3 3 d c}
do_preupdate_test 7.1.2.2 {
INSERT INTO t1 SELECT * FROM t2;
} {INSERT main t1 4 4 a b INSERT main t1 5 5 c d}
do_preupdate_test 7.1.3 {
REPLACE INTO t1(rowid, a, b) VALUES(1, 1, 1);
} {
DELETE main t1 1 1 x y
INSERT main t1 1 1 1 1
}
do_preupdate_test 7.1.4 {
REPLACE INTO t3 VALUES(4, NULL);
} {
DELETE main t3 1 1 4 16
INSERT main t3 4 4 4 {}
}
do_preupdate_test 7.1.5 {
REPLACE INTO t3(rowid, i, j) VALUES(2, 6, NULL);
} {
DELETE main t3 2 2 5 25
DELETE main t3 3 3 6 36
INSERT main t3 2 2 6 {}
}
do_execsql_test 7.2.0 { SELECT rowid FROM t1 } {1 2 3 4 5}
do_preupdate_test 7.2.1 {
DELETE FROM t1 WHERE rowid = 3
} {
DELETE main t1 3 3 d c
}
do_preupdate_test 7.2.2 {
DELETE FROM t1
} {
DELETE main t1 1 1 1 1
DELETE main t1 2 2 b a
DELETE main t1 4 4 a b
DELETE main t1 5 5 c d
}
do_execsql_test 7.3.0 {
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
INSERT INTO t2 VALUES('a', 'b');
INSERT INTO t2 VALUES('c', 'd');
INSERT INTO t3 VALUES(4, 16);
INSERT INTO t3 VALUES(5, 25);
INSERT INTO t3 VALUES(6, 36);
}
do_preupdate_test 7.3.1 {
UPDATE t2 SET y = y||y;
} {
UPDATE main t2 1 1 a b a bb
UPDATE main t2 2 2 c d c dd
}
do_preupdate_test 7.3.2 {
UPDATE t2 SET rowid = rowid-1;
} {
UPDATE main t2 1 0 a bb a bb
UPDATE main t2 2 1 c dd c dd
}
do_preupdate_test 7.3.3 {
UPDATE OR REPLACE t2 SET rowid = 1 WHERE x = 'a'
} {
DELETE main t2 1 1 c dd
UPDATE main t2 0 1 a bb a bb
}
do_preupdate_test 7.3.4.1 {
UPDATE OR REPLACE t3 SET i = 5 WHERE i = 6
} {
DELETE main t3 2 2 5 25
UPDATE main t3 3 3 6 36 5 36
}
do_execsql_test 7.3.4.2 {
INSERT INTO t3 VALUES(10, 100);
SELECT rowid, * FROM t3;
} {1 4 16 3 5 36 4 10 100}
do_preupdate_test 7.3.5 {
UPDATE OR REPLACE t3 SET rowid = 1, i = 5 WHERE j = 100;
} {
DELETE main t3 1 1 4 16
DELETE main t3 3 3 5 36
UPDATE main t3 4 1 10 100 5 100
}
do_execsql_test 7.4.1.0 {
CREATE TABLE t4(a, b);
INSERT INTO t4 VALUES('a', 1);
INSERT INTO t4 VALUES('b', 2);
INSERT INTO t4 VALUES('c', 3);
CREATE TRIGGER t4t BEFORE DELETE ON t4 BEGIN
DELETE FROM t4 WHERE b = 1;
END;
}
do_preupdate_test 7.4.1.1 {
DELETE FROM t4 WHERE b = 3
} {
DELETE main t4 1 1 a 1
DELETE main t4 3 3 c 3
}
do_execsql_test 7.4.1.2 {
INSERT INTO t4(rowid, a, b) VALUES(1, 'a', 1);
INSERT INTO t4(rowid, a, b) VALUES(3, 'c', 3);
}
do_preupdate_test 7.4.1.3 {
DELETE FROM t4 WHERE b = 1
} {
DELETE main t4 1 1 a 1
}
do_execsql_test 7.4.2.0 {
CREATE TABLE t5(a, b);
INSERT INTO t5 VALUES('a', 1);
INSERT INTO t5 VALUES('b', 2);
INSERT INTO t5 VALUES('c', 3);
CREATE TRIGGER t5t BEFORE UPDATE ON t5 BEGIN
DELETE FROM t5 WHERE b = 1;
END;
}
do_preupdate_test 7.4.2.1 {
UPDATE t5 SET b = 4 WHERE a = 'c'
} {
DELETE main t5 1 1 a 1
UPDATE main t5 3 3 c 3 c 4
}
do_execsql_test 7.4.2.2 {
INSERT INTO t5(rowid, a, b) VALUES(1, 'a', 1);
}
do_preupdate_test 7.4.2.3 {
UPDATE t5 SET b = 5 WHERE a = 'a'
} {
DELETE main t5 1 1 a 1
}
do_execsql_test 7.5.1.0 {
CREATE TABLE t7(a, b);
INSERT INTO t7 VALUES('one', 'two');
INSERT INTO t7 VALUES('three', 'four');
ALTER TABLE t7 ADD COLUMN c DEFAULT NULL;
}
do_preupdate_test 7.5.1.1 {
DELETE FROM t7 WHERE a = 'one'
} {
DELETE main t7 1 1 one two {}
}
do_preupdate_test 7.5.1.2 {
UPDATE t7 SET b = 'five'
} {
UPDATE main t7 2 2 three four {} three five {}
}
do_execsql_test 7.5.2.0 {
CREATE TABLE t8(a, b);
INSERT INTO t8 VALUES('one', 'two');
INSERT INTO t8 VALUES('three', 'four');
ALTER TABLE t8 ADD COLUMN c DEFAULT 'xxx';
}
ifcapable !session {
# At time of writing, these two are broken. They demonstrate that the
# sqlite3_preupdate_old() method does not handle the case where ALTER TABLE
# has been used to add a column with a default value other than NULL.
#
do_preupdate_test 7.5.2.1 {
DELETE FROM t8 WHERE a = 'one'
} {
DELETE main t8 1 1 one two xxx
}
do_preupdate_test 7.5.2.2 {
UPDATE t8 SET b = 'five'
} {
UPDATE main t8 2 2 three four xxx three five xxx
}
}
# This block of tests verifies that IPK values are correctly reported
# by the sqlite3_preupdate_old() and sqlite3_preupdate_new() functions.
#
do_execsql_test 7.6.1 { CREATE TABLE t9(a, b INTEGER PRIMARY KEY, c) }
do_preupdate_test 7.6.2 {
INSERT INTO t9 VALUES(1, 2, 3);
UPDATE t9 SET b = b+1, c = c+1;
DELETE FROM t9 WHERE a = 1;
} {
INSERT main t9 2 2 1 2 3
UPDATE main t9 2 3 1 2 3 1 3 4
DELETE main t9 3 3 1 3 4
}
#--------------------------------------------------------------------------
# Test that the sqlite3_preupdate_depth() API seems to work.
#
proc preupdate_hook {args} {
set type [lindex $args 0]
eval lappend ::preupdate $args
eval lappend ::preupdate [db preupdate depth]
if {$type != "INSERT"} {
for {set i 0} {$i < [db preupdate count]} {incr i} {
lappend ::preupdate [db preupdate old $i]
}
}
if {$type != "DELETE"} {
for {set i 0} {$i < [db preupdate count]} {incr i} {
set rc [catch { db preupdate new $i } v]
lappend ::preupdate $v
}
}
}
db close
forcedelete test.db
sqlite3 db test.db
db preupdate hook preupdate_hook
do_execsql_test 7.6.1 {
CREATE TABLE t1(x PRIMARY KEY);
CREATE TABLE t2(x PRIMARY KEY);
CREATE TABLE t3(x PRIMARY KEY);
CREATE TABLE t4(x PRIMARY KEY);
CREATE TRIGGER a AFTER INSERT ON t1 BEGIN INSERT INTO t2 VALUES(new.x); END;
CREATE TRIGGER b AFTER INSERT ON t2 BEGIN INSERT INTO t3 VALUES(new.x); END;
CREATE TRIGGER c AFTER INSERT ON t3 BEGIN INSERT INTO t4 VALUES(new.x); END;
CREATE TRIGGER d AFTER UPDATE ON t1 BEGIN UPDATE t2 SET x = new.x; END;
CREATE TRIGGER e AFTER UPDATE ON t2 BEGIN UPDATE t3 SET x = new.x; END;
CREATE TRIGGER f AFTER UPDATE ON t3 BEGIN UPDATE t4 SET x = new.x; END;
CREATE TRIGGER g AFTER DELETE ON t1 BEGIN DELETE FROM t2 WHERE 1; END;
CREATE TRIGGER h AFTER DELETE ON t2 BEGIN DELETE FROM t3 WHERE 1; END;
CREATE TRIGGER i AFTER DELETE ON t3 BEGIN DELETE FROM t4 WHERE 1; END;
}
do_preupdate_test 7.6.2 {
INSERT INTO t1 VALUES('xyz');
} {
INSERT main t1 1 1 0 xyz
INSERT main t2 1 1 1 xyz
INSERT main t3 1 1 2 xyz
INSERT main t4 1 1 3 xyz
}
do_preupdate_test 7.6.3 {
UPDATE t1 SET x = 'abc';
} {
UPDATE main t1 1 1 0 xyz abc
UPDATE main t2 1 1 1 xyz abc
UPDATE main t3 1 1 2 xyz abc
UPDATE main t4 1 1 3 xyz abc
}
do_preupdate_test 7.6.4 {
DELETE FROM t1 WHERE 1;
} {
DELETE main t1 1 1 0 abc
DELETE main t2 1 1 1 abc
DELETE main t3 1 1 2 abc
DELETE main t4 1 1 3 abc
}
do_execsql_test 7.6.5 {
DROP TRIGGER a; DROP TRIGGER b; DROP TRIGGER c;
DROP TRIGGER d; DROP TRIGGER e; DROP TRIGGER f;
DROP TRIGGER g; DROP TRIGGER h; DROP TRIGGER i;
CREATE TRIGGER a BEFORE INSERT ON t1 BEGIN INSERT INTO t2 VALUES(new.x); END;
CREATE TRIGGER b BEFORE INSERT ON t2 BEGIN INSERT INTO t3 VALUES(new.x); END;
CREATE TRIGGER c BEFORE INSERT ON t3 BEGIN INSERT INTO t4 VALUES(new.x); END;
CREATE TRIGGER d BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET x = new.x; END;
CREATE TRIGGER e BEFORE UPDATE ON t2 BEGIN UPDATE t3 SET x = new.x; END;
CREATE TRIGGER f BEFORE UPDATE ON t3 BEGIN UPDATE t4 SET x = new.x; END;
CREATE TRIGGER g BEFORE DELETE ON t1 BEGIN DELETE FROM t2 WHERE 1; END;
CREATE TRIGGER h BEFORE DELETE ON t2 BEGIN DELETE FROM t3 WHERE 1; END;
CREATE TRIGGER i BEFORE DELETE ON t3 BEGIN DELETE FROM t4 WHERE 1; END;
}
do_preupdate_test 7.6.6 {
INSERT INTO t1 VALUES('xyz');
} {
INSERT main t4 1 1 3 xyz
INSERT main t3 1 1 2 xyz
INSERT main t2 1 1 1 xyz
INSERT main t1 1 1 0 xyz
}
do_preupdate_test 7.6.3 {
UPDATE t1 SET x = 'abc';
} {
UPDATE main t4 1 1 3 xyz abc
UPDATE main t3 1 1 2 xyz abc
UPDATE main t2 1 1 1 xyz abc
UPDATE main t1 1 1 0 xyz abc
}
do_preupdate_test 7.6.4 {
DELETE FROM t1 WHERE 1;
} {
DELETE main t4 1 1 3 abc
DELETE main t3 1 1 2 abc
DELETE main t2 1 1 1 abc
DELETE main t1 1 1 0 abc
}
finish_test
+1 -1
View File
@@ -257,7 +257,7 @@ do_test memsubsys1-7.4 {
} 0
do_test memsubsys1-7.5 {
set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
expr {$maxreq<4100 + 4200*[nonzero_reserved_bytes]}
expr {$maxreq<(4100 + 8200*[nonzero_reserved_bytes])}
} 1
do_test memsubsys1-7.6 {
set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+32 -29
View File
@@ -183,35 +183,38 @@ db2 close
db close
tvfs delete
# 2016-03-11: Make sure all works when transitioning to WAL mode under nolock.
#
do_test nolock-4.1 {
forcedelete test.db
sqlite3 db file:test.db?nolock=1 -uri 1
db eval {
PRAGMA journal_mode=WAL;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('youngling');
SELECT * FROM t1;
}
} {delete youngling}
db close
do_test nolock-4.2 {
forcedelete test.db
sqlite3 db test.db
db eval {
PRAGMA journal_mode=WAL;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('catbird');
SELECT * FROM t1;
}
} {wal catbird}
do_test nolock-4.3 {
if {[permutation]!="inmemory_journal"} {
# 2016-03-11: Make sure all works when transitioning to WAL mode
# under nolock.
#
do_test nolock-4.1 {
forcedelete test.db
sqlite3 db file:test.db?nolock=1 -uri 1
db eval {
PRAGMA journal_mode=WAL;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('youngling');
SELECT * FROM t1;
}
} {delete youngling}
db close
sqlite3 db file:test.db?nolock=1 -uri 1
set rc [catch {db eval {SELECT * FROM t1}} msg]
lappend rc $msg
} {1 {unable to open database file}}
do_test nolock-4.2 {
forcedelete test.db
sqlite3 db test.db
db eval {
PRAGMA journal_mode=WAL;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('catbird');
SELECT * FROM t1;
}
} {wal catbird}
do_test nolock-4.3 {
db close
sqlite3 db file:test.db?nolock=1 -uri 1
set rc [catch {db eval {SELECT * FROM t1}} msg]
lappend rc $msg
} {1 {unable to open database file}}
}
finish_test
+24
View File
@@ -92,6 +92,9 @@ foreach f [glob -nocomplain \
] {
lappend alltests $f
}
foreach f [glob -nocomplain $testdir/../ext/session/*.test] {
lappend alltests $f
}
if {$::tcl_platform(platform)!="unix"} {
set alltests [test_set $alltests -exclude crash.test crash2.test]
@@ -100,6 +103,7 @@ set alltests [test_set $alltests -exclude {
all.test async.test quick.test veryquick.test
memleak.test permutations.test soak.test fts3.test
mallocAll.test rtree.test full.test extraquick.test
session.test
}]
set allquicktests [test_set $alltests -exclude {
@@ -975,6 +979,26 @@ test_suite "rtree" -description {
All R-tree related tests. Provides coverage of source file rtree.c.
} -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
test_suite "session" -description {
All session module related tests.
} -files [glob -nocomplain $::testdir/../ext/session/*.test]
test_suite "session_eec" -description {
All session module related tests with sqlite3_extended_result_codes() set.
} -files [
glob -nocomplain $::testdir/../ext/session/*.test
] -dbconfig {
sqlite3_extended_result_codes $::dbhandle 1
}
test_suite "session_strm" -description {
All session module related tests using the streaming APIs.
} -files [
glob -nocomplain $::testdir/../ext/session/*.test
] -dbconfig {
set ::sqlite3session_streams 1
}
test_suite "rbu" -description {
RBU tests.
} -files [
+22
View File
@@ -0,0 +1,22 @@
# 2008 June 23
#
# 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 runs all rtree related tests.
#
set testdir [file dirname $argv0]
source $testdir/permutations.test
ifcapable session {
# First run tests with sqlite3_extended_error_codes() set, then
# again with it clear.
run_test_suite session_eec
run_test_suite session
run_test_suite session_strm
}
finish_test
+54 -17
View File
@@ -45,7 +45,7 @@ do_test shell1-1.1.1b {
} {1 1}
# error on extra options
do_test shell1-1.1.2 {
catchcmd "test.db \"select 3\" \"select 4\"" ""
catchcmd "test.db \"select+3\" \"select+4\"" ""
} {0 {3
4}}
# error on extra options
@@ -76,20 +76,20 @@ do_test shell1-1.3.3 {
# -echo print commands before execution
do_test shell1-1.4.1 {
catchcmd "-echo test.db" ""
catchcmd "-echo test.db" ""
} {0 {}}
# -[no]header turn headers on or off
do_test shell1-1.5.1 {
catchcmd "-header test.db" ""
catchcmd "-header test.db" ""
} {0 {}}
do_test shell1-1.5.2 {
catchcmd "-noheader test.db" ""
catchcmd "-noheader test.db" ""
} {0 {}}
# -bail stop after hitting an error
do_test shell1-1.6.1 {
catchcmd "-bail test.db" ""
catchcmd "-bail test.db" ""
} {0 {}}
# -interactive force interactive I/O
@@ -103,40 +103,40 @@ do_test shell1-1.7.1 {
# -batch force batch I/O
do_test shell1-1.8.1 {
catchcmd "-batch test.db" ""
catchcmd "-batch test.db" ""
} {0 {}}
# -column set output mode to 'column'
do_test shell1-1.9.1 {
catchcmd "-column test.db" ""
catchcmd "-column test.db" ""
} {0 {}}
# -csv set output mode to 'csv'
do_test shell1-1.10.1 {
catchcmd "-csv test.db" ""
catchcmd "-csv test.db" ""
} {0 {}}
# -html set output mode to HTML
do_test shell1-1.11.1 {
catchcmd "-html test.db" ""
catchcmd "-html test.db" ""
} {0 {}}
# -line set output mode to 'line'
do_test shell1-1.12.1 {
catchcmd "-line test.db" ""
catchcmd "-line test.db" ""
} {0 {}}
# -list set output mode to 'list'
do_test shell1-1.13.1 {
catchcmd "-list test.db" ""
catchcmd "-list test.db" ""
} {0 {}}
# -separator 'x' set output field separator (|)
do_test shell1-1.14.1 {
catchcmd "-separator 'x' test.db" ""
catchcmd "-separator 'x' test.db" ""
} {0 {}}
do_test shell1-1.14.2 {
catchcmd "-separator x test.db" ""
catchcmd "-separator x test.db" ""
} {0 {}}
do_test shell1-1.14.3 {
set res [catchcmd "-separator" ""]
@@ -147,7 +147,7 @@ do_test shell1-1.14.3 {
# -stats print memory stats before each finalize
do_test shell1-1.14b.1 {
catchcmd "-stats test.db" ""
catchcmd "-stats test.db" ""
} {0 {}}
# -nullvalue 'text' set text string for NULL values
@@ -175,7 +175,7 @@ do_test shell1-1.16.1 {
# check first token handling
do_test shell1-2.1.1 {
catchcmd "test.db" ".foo"
catchcmd "test.db" ".foo"
} {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}}
do_test shell1-2.1.2 {
catchcmd "test.db" ".\"foo OFF\""
@@ -276,11 +276,11 @@ do_test shell1-3.2.4 {
# .databases List names and files of attached databases
do_test shell1-3.3.1 {
catchcmd "-csv test.db" ".databases"
} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/"
} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
do_test shell1-3.3.2 {
# extra arguments ignored
catchcmd "test.db" ".databases BAD"
} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/"
} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
# .dump ?TABLE? ... Dump the database in an SQL text format
# If TABLE specified, only dump tables matching
@@ -910,4 +910,41 @@ do_test shell1-5.0 {
}
} {}
# The string used here is the word "test" in Chinese.
# In UTF-8, it is encoded as: \xE6\xB5\x8B\xE8\xAF\x95
set test \u6D4B\u8BD5
do_test shell1-6.0 {
set fileName $test; append fileName .db
catch {forcedelete $fileName}
set x [catchcmdex $fileName "CREATE TABLE t1(x);\n.schema\n"]
set code [lindex $x 0]
set res [string trim [lindex $x 1]]
if {$code ne "0"} {
error "failed with error: $res"
}
if {$res ne "CREATE TABLE t1(x);"} {
error "failed with mismatch: $res"
}
if {![file exists $fileName]} {
error "file \"$fileName\" (Unicode) does not exist"
}
forcedelete $fileName
} {}
do_test shell1-6.1 {
catch {forcedelete test3.db}
set x [catchcmdex test3.db \
"CREATE TABLE [encoding convertto utf-8 $test](x);\n.schema\n"]
set code [lindex $x 0]
set res [string trim [lindex $x 1]]
if {$code ne "0"} {
error "failed with error: $res"
}
if {$res ne "CREATE TABLE ${test}(x);"} {
error "failed with mismatch: $res"
}
forcedelete test3.db
} {}
finish_test
+1 -1
View File
@@ -43,7 +43,7 @@ do_test shell2-1.1.1 {
# Shell silently ignores extra parameters.
# Ticket [f5cb008a65].
do_test shell2-1.2.1 {
set rc [catch { eval exec $CLI \":memory:\" \"select 3\" \"select 4\" } msg]
set rc [catch { eval exec $CLI \":memory:\" \"select+3\" \"select+4\" } msg]
list $rc $msg
} {0 {3
4}}
+12
View File
@@ -26,6 +26,18 @@ db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
# There are inconsistencies in command-line argument quoting on Windows.
# In particular, individual applications are responsible for command-line
# parsing in Windows, not the shell. Depending on whether the sqlite3.exe
# program is compiled with MinGW or MSVC, the command-line parsing is
# different. This causes problems for the tests below. To avoid
# issues, these tests are disabled for windows.
#
if {$::tcl_platform(platform)=="windows"} {
finish_test
return
}
#----------------------------------------------------------------------------
# shell3-1.*: Basic tests for running SQL statments from command line.
#
+9
View File
@@ -17,6 +17,15 @@ source $testdir/tester.tcl
ifcapable !snapshot {finish_test; return}
set testprefix snapshot
# This test does not work with the inmemory_journal permutation. The reason
# is that each connection opened as part of this permutation executes
# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
# and there are one or more existing connections.
if {[permutation]=="inmemory_journal"} {
finish_test
return
}
#-------------------------------------------------------------------------
# Check some error conditions in snapshot_get(). It is an error if:
#
+1 -1
View File
@@ -146,7 +146,7 @@ do_faultsim_test 3.0 -prep {
error $msg
}
} -test {
faultsim_test_result {0 {}} {1 SQLITE_IOERR} \
faultsim_test_result {0 {}} {1 SQLITE_IOERR} {1 SQLITE_NOMEM} \
{1 SQLITE_IOERR_NOMEM} {1 SQLITE_IOERR_READ}
if {$testrc==0} {
set res [db eval {
+2 -1
View File
@@ -1236,7 +1236,8 @@ int main(int argc, char **argv){
int rc; /* API return code */
/* Display the version of SQLite being tested */
printf("Speedtest1 for SQLite %s %.50s\n", sqlite3_libversion(), sqlite3_sourceid());
printf("-- Speedtest1 for SQLite %s %.50s\n",
sqlite3_libversion(), sqlite3_sourceid());
/* Process command-line arguments */
g.zWR = "";
+1 -1
View File
@@ -34,7 +34,7 @@ do_test tcl-1.1 {
do_test tcl-1.2 {
set v [catch {db bogus} msg]
lappend v $msg
} {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, transaction, unlock_notify, update_hook, version, or wal_hook}}
} {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, transaction, unlock_notify, update_hook, version, or wal_hook}}
do_test tcl-1.2.1 {
set v [catch {db cache bogus} msg]
lappend v $msg
+6
View File
@@ -881,6 +881,12 @@ proc fix_testname {varname} {
}
}
proc normalize_list {L} {
set L2 [list]
foreach l $L {lappend L2 $l}
set L2
}
proc do_execsql_test {testname sql {result {}}} {
fix_testname testname
uplevel do_test [list $testname] [list "execsql {$sql}"] [list [list {*}$result]]
+5 -1
View File
@@ -111,6 +111,8 @@ foreach hdr {
pcache.h
pragma.h
rtree.h
sqlite3session.h
sqlite3ext.h
sqlite3.h
sqlite3ext.h
sqlite3rbu.h
@@ -126,6 +128,7 @@ foreach hdr {
set available_hdr($hdr) 1
}
set available_hdr(sqliteInt.h) 0
set available_hdr(sqlite3session.h) 0
# These headers should be copied into the amalgamation without modifying any
# of their function declarations or definitions.
@@ -220,7 +223,7 @@ proc copy_file {filename} {
regsub {^SQLITE_API } $line {} line
# Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
# so that linkage can be modified at compile-time.
if {[regexp {^sqlite3(_|rbu_)} $funcname]} {
if {[regexp {^sqlite3[a-z]*_} $funcname]} {
set line SQLITE_API
append line " " [string trim $rettype]
if {[string index $rettype end] ne "*"} {
@@ -378,6 +381,7 @@ foreach file {
fts3_icu.c
sqlite3rbu.c
dbstat.c
sqlite3session.c
json1.c
fts5.c
} {
+7
View File
@@ -71,6 +71,7 @@ fconfigure stdout -translation lf
set filelist [subst {
$TOP/src/sqlite.h.in
$TOP/ext/rtree/sqlite3rtree.h
$TOP/ext/session/sqlite3session.h
$TOP/ext/fts5/fts5.h
}]
@@ -91,6 +92,9 @@ set cdecllist {
#
foreach file $filelist {
set in [open $file]
if {![regexp {sqlite\.h\.in} $file]} {
puts "/******** Begin file [file tail $file] *********/"
}
while {![eof $in]} {
set line [gets $in]
@@ -124,4 +128,7 @@ foreach file $filelist {
puts $line
}
close $in
if {![regexp {sqlite\.h\.in} $file]} {
puts "/******** End of [file tail $file] *********/"
}
}
+29 -7
View File
@@ -12,7 +12,7 @@
#
# summary-$BASE.txt # Copy of standard output
# cout-$BASE.txt # cachegrind output
# explain-$BASE.txt # EXPLAIN listings
# explain-$BASE.txt # EXPLAIN listings (only with --explain)
#
if test "$1" = ""
then
@@ -21,9 +21,10 @@ then
fi
NAME=$1
shift
CC_OPTS="-DSQLITE_ENABLE_RTREE"
SPEEDTEST_OPTS="--shrink-memory --reprepare"
CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5"
SPEEDTEST_OPTS="--shrink-memory --reprepare --heap 10000000 64"
SIZE=5
doExplain=0
while test "$1" != ""; do
case $1 in
--reprepare)
@@ -35,12 +36,29 @@ while test "$1" != ""; do
--utf16be)
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
;;
--stats)
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
;;
--without-rowid)
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
;;
--nomemstat)
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
;;
--wal)
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal"
;;
--size)
shift; SIZE=$1
;;
--explain)
doExplain=1
;;
--heap)
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5"
shift;
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64"
;;
*)
CC_OPTS="$CC_OPTS $1"
;;
@@ -54,9 +72,11 @@ echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt
rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o
gcc -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
size sqlite3.o | tee -a summary-$NAME.txt
gcc -g -Os -Wall -I. $CC_OPTS \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
if test $doExplain -eq 1; then
gcc -g -Os -Wall -I. $CC_OPTS \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
fi
SRC=./speedtest1.c
gcc -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
ls -l speedtest1 | tee -a summary-$NAME.txt
@@ -65,4 +85,6 @@ valgrind --tool=cachegrind ./speedtest1 speedtest1.db \
size sqlite3.o | tee -a summary-$NAME.txt
wc sqlite3.c
cg_anno.tcl cachegrind.out.* >cout-$NAME.txt
./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt
if test $doExplain -eq 1; then
./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt
fi
+1 -1
View File
@@ -10,7 +10,7 @@ gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \
-DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \
-DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \
-DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \
-DSQLITE_ENABLE_ICU \
-DSQLITE_ENABLE_ICU -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_SESSION \
sqlite3.c
nm sqlite3.o | grep ' [TD] ' | sort -k 3