Compare commits

...

88 Commits

Author SHA1 Message Date
dan 8343a6bf5e Cherrypick commit [1d5e744cc6] from the trunk in order to avoid leaving a file-ddescriptor open in test scripts capi3.test and capi3c.test.
FossilOrigin-Name: 86b8481be7e76cccc92d14ce762d21bfb69504af
2012-04-03 19:43:07 +00:00
adam 4678255c4e bad assert
FossilOrigin-Name: 0c0150f2a349460d685e63be1a747d2bfbe5c8c4
2012-04-02 23:42:48 +00:00
adam 0cb33b650c Merge in latest changes, autologging options, read only file system wal support, test config conditionalization, WAL frame write prebuffering
FossilOrigin-Name: d51c086e5c006821e2ab932f229649a729d914b2
2012-04-02 23:35:45 +00:00
drh 9817307d2f Merge all the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 18ec60cacd37a70d598ac1af5e50faffa73bb134
2012-03-31 02:46:20 +00:00
dan 296c8cad4d Merge latest trunk changes into apple-osx branch.
FossilOrigin-Name: f999197b75465a1f71ac1dab8f22ba2167fc0c67
2012-03-19 16:21:28 +00:00
drh 40d50d1b0f Pull in all the latest trunk changes.
FossilOrigin-Name: 504bf4908618f4dc8c9d67380934016b311ca6d0
2012-03-05 16:39:56 +00:00
drh 2f1e7b8a74 Pull the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: e248598649dd69ed4b4d3da80566d2a7a36a349a
2012-02-10 18:18:00 +00:00
drh e0ba85df8b Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 2cc414cd144cd84aad6420058c6e674c2920ba72
2012-01-14 14:13:31 +00:00
drh 39ab1aef89 Pull all the latest trunk changes over into the apple-osx branch.
FossilOrigin-Name: 8a048423f0e409d2332558cb5148e5a1d251ae30
2012-01-03 21:54:09 +00:00
drh 90defefb85 Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 59e0d4f3d9af81d0c920812a6583228faa300cd6
2011-12-08 21:08:53 +00:00
drh 48249a7397 Fix a problem with sqlite3_backup_step() that resulted from a faulty merge.
FossilOrigin-Name: dacdec78d010922b6357f5319108289d087b6028
2011-10-31 19:59:09 +00:00
drh ffa0ae9924 Fix the os_unix.c source file so that it will build as part of an
amalgamation on non-apple platforms.

FossilOrigin-Name: b2f7639c8faf962239d41bb3a151448fad84e84c
2011-10-31 19:34:47 +00:00
drh 495cd6b419 Pull the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 4fa9ee794713e7a2298f53d9b517c90745b3408b
2011-10-31 14:42:31 +00:00
drh 7d59b89dc9 Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: be62ef058bcee55b31127ee779f7ecbf762986f8
2011-10-21 17:18:20 +00:00
drh aa09d0503d Simplify the readonly_shm implementation so that it conforms to the
implementation on trunk.  Update the test cases to agree with the new
behavior.

FossilOrigin-Name: 9efb74cefb2b7444112e16f3da48d5645746fdfa
2011-10-11 18:38:13 +00:00
drh 3a0022dad4 Fix a locking error introduced when porting the new Apple locking code.
FossilOrigin-Name: cce1f521362a87cc46fc5bfba68b7c188e2ea34f
2011-10-11 15:03:45 +00:00
drh 0d92f761ed Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 7e2c4898224f9fabf724a6d4e1ac597845a66f73
2011-10-11 14:19:38 +00:00
drh cc40f4ceb1 Forward port the Apple-specific changes from [db5b7b778c] in the
apple-osx-377 branch.  Fix this up so that it will compile and run on Linux.

FossilOrigin-Name: 6cb43f6c6e9d8054e00acab378b8af0d82d3084c
2011-10-10 23:53:48 +00:00
adam aec336af26 Merging in cherry picked diffs for persist wal, alloc padding, wal-safe vacuum and sqlite3_file_control based lockstate checking
FossilOrigin-Name: db5b7b778c09c57501cb8266895a0ea4f2de7649
2011-10-10 22:11:44 +00:00
drh d74c576ee6 Cherrypick the sqlite_data_count() changes from [d4f95b3b6e] and
[9913996e7b] into the apple-osx branch for version 3.7.7.

FossilOrigin-Name: aef7945c423a8338374572eeda9444866c64569b
2011-10-10 18:59:05 +00:00
drh 65f0fd40d6 Merge in all trunk changes through the 3.7.8 release.
FossilOrigin-Name: ade72b1874c7672ae8d62b9ebac8e4d63fee80cc
2011-09-19 20:32:36 +00:00
drh f9ae91deed Remove a couple of comments that were causing problems for the
amalgamation generator script.

FossilOrigin-Name: ffed86bf969b98d196ac50bb5e5faddecab4fc59
2011-09-17 18:56:19 +00:00
drh 8062d660f1 Merge the latest trunk fixes into the apple-osx branch.
FossilOrigin-Name: 070bf203bb7cd59d69c10b29d7d9374e0361a47a
2011-09-16 19:36:42 +00:00
drh b19e7036cd Merge in the latest changes from trunk.
FossilOrigin-Name: 2456b4d0d2522dd2541146031347bc5e51f2036f
2011-09-14 19:05:55 +00:00
drh 253df3a264 Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 55af80035f0432bbd4c4b3f4dbc9def13c5356b3
2011-08-26 19:18:50 +00:00
dan 343811ce13 Merge latest trunk changes into the apple-osx branch.
FossilOrigin-Name: c5f7977b899e93bf90bd44572db78c744ea81c14
2011-08-23 18:06:04 +00:00
drh 1b1b8325e1 Merge all the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 77376b332b4460208f837f7bdf6df8c90d5071d5
2011-08-02 18:25:20 +00:00
adam 027200ec51 Changes to make pragma synchronous sticky when SQLITE_DEFAULT_WAL_SAFETYLEVEL is used
FossilOrigin-Name: c6158b254fabd02a3d58b1a047a3c5fa979b41a8
2011-06-25 21:43:15 +00:00
dan d819aea05f Fix test cases so that they work with SQLITE_DEFAULT_WAL_SAFETYLEVEL defined.
FossilOrigin-Name: 8f8b373eed7052e6e93c1805fc1effcf1db09366
2011-06-25 16:35:41 +00:00
drh e96ab66f34 Fix the build.
FossilOrigin-Name: 97729542d53a407de1bdfeb5fa6d80bbdb4813b6
2011-06-24 21:47:39 +00:00
adam 2e4491d4b1 Merging local changes to apple-osx
FossilOrigin-Name: 34f0efa2b12e8eb09331768b1524a076baeb34ea
2011-06-24 20:47:06 +00:00
drh 1b2327c509 Pull the last-minute fixes for 3.7.7 into the apple-osx branch.
FossilOrigin-Name: 2d4458af59c697ad453996815d14442230654670
2011-06-23 17:42:45 +00:00
drh 66f6ad7b94 Pull the latest changes from trunk into the apple-osx branch.
FossilOrigin-Name: b5acda0445db39d58229d65a361d539db30f3833
2011-06-23 02:30:36 +00:00
dan b5f87f4394 Update apple-osx branch with the latest trunk changes.
FossilOrigin-Name: fb7ad09dec805ccb709b138509d6e1eb77323c2f
2011-06-22 11:24:55 +00:00
drh fbea85d6cd Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 76005fdca05d86f91e424698d86942264419c616
2011-06-21 01:30:53 +00:00
drh b09945e64c Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 4c69e827f4d65e597e125e0d6691b0c8fb5588d7
2011-06-20 11:57:58 +00:00
drh c3835e0208 Merge the latest trunk changes, including the read-only shared memory
enhancement, into the apple-osx branch.

FossilOrigin-Name: ce5f95dee6989f17a6a7af89699a02f8c5c6f787
2011-06-02 13:07:43 +00:00
drh d736884f3d Pull all the latest trunk changes, and especially the fix for WAL cache
spills causing transactions to disappear, into the apple-osx branch.

FossilOrigin-Name: 8d1a6bb002a7817fa7df932f7cab7220c1d62c0e
2011-05-19 01:51:25 +00:00
drh 283f9e7ee6 Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: f9b149e53815235aaf92f722e37c4819503d72b3
2011-05-05 15:52:46 +00:00
drh fa64665a49 Update the apple-osx branch to version 3.7.6.1.
FossilOrigin-Name: 289194d68e891e4977407d07e452e48844777a36
2011-04-13 15:42:26 +00:00
drh e127a2ea9f Pull all the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: 4eaef4ad4cfda519f18922a249904d16489ee606
2011-04-09 18:13:35 +00:00
drh 5be1b1f262 Merge the latest trunk changes into the apple-osx branch.
FossilOrigin-Name: c77a767cbd22354d9f6d5cef0d81ea721be593c7
2011-04-05 22:10:50 +00:00
drh 25d2380356 Pull the latest changes from trunk (and hence from schema-parse-refactor)
into the apple-osx branch.

FossilOrigin-Name: 8e885ddea0fc5d4c4256025c127e5d41d63c47a5
2011-04-05 13:38:12 +00:00
drh 69d67f5412 Merge in the latest changes from trunk.
FossilOrigin-Name: 6d78a25ddce75f63581be60c34dbc75f34c243df
2011-04-04 13:11:07 +00:00
drh 6f7fe3ef3e This is a version of the SQLite 3.7.5 release with Apple's changes for MacOS.
FossilOrigin-Name: 55d2e55b7b0f7851a565e3a982f772afdf8d7a12
2011-02-10 01:49:18 +00:00
drh e3a4e11bcc Pull in all the changes from trunk up through the version 3.7.5
release candidate 1.

FossilOrigin-Name: 09d6c91dcff0699daec02de0cfd1cdc4e61b4f6b
2011-01-27 18:48:02 +00:00
drh 67d225da53 Merge in all changes to the trunk through version 3.7.4rc3.
FossilOrigin-Name: d2ccf7fc0673e875ff7b84cd37b89c65df4bec7f
2010-12-07 15:49:03 +00:00
drh 5a5ced7da9 Merge all the latest changes from the trunk into the apple-osx branch.
FossilOrigin-Name: c8bc057c7def6bbbebd89ee52b582bad75fb0509
2010-11-19 23:50:48 +00:00
adam 985be1bce6 Integrated proxy locking file support for WAL journal mode and double free fix
FossilOrigin-Name: fd4d38fa66de85676189ff4922fb1bf5f8cac9c4
2010-11-09 00:43:59 +00:00
adam 99f24349ea fixed memory leak in proxy lock file error handling
FossilOrigin-Name: e01c5f3eda7fe6e6afe9c3894384f09b58173da1
2010-09-10 23:16:16 +00:00
adam 890b69fb83 replaced relative lock proxy paths with absolute
FossilOrigin-Name: 782c33512ab2b677b0734c591fcecddc5a655203
2010-09-10 20:19:06 +00:00
adam f5d6f1e0c5 replaced relative lock proxy paths with absolute
FossilOrigin-Name: 6a88cd46aeef3c50c91d5aadc61dd0b0982f8a4f
2010-09-10 00:59:28 +00:00
drh 5ec0cfe070 Make sure SQLite is running with MEMSTATUS enabled at the beginning of every
test script.

FossilOrigin-Name: b6e9a4d8f7d8b683b4098270e0be149df1ef295f
2010-09-10 00:18:12 +00:00
drh 3b3b1a538d Make sure MEMSTATUS is enabled at the beginning of the memsubsys2.test
script.

FossilOrigin-Name: cf23a354975f581c2cf2299e2b2a4e00819830ad
2010-09-09 23:40:42 +00:00
drh b0fa210aa3 The merge for check-in [415c448dc4] did not do exactly write, resulting in
a subtle bug in the SQLITE_FCNTL_SIZE_HINT logic.  This check-in is the
fix.

FossilOrigin-Name: badaaa18fd4a4402add6ae1b3ecadbb79f91fe37
2010-09-09 23:31:36 +00:00
drh 801829c812 Merge in the R-tree fix from the trunk.
FossilOrigin-Name: 02ee0bd5a305e3a6cd76f2e304f8a7effacd8433
2010-08-24 01:51:07 +00:00
drh 9b3c15e860 Merge changes through release 3.7.2 into the apple-osx branch.
FossilOrigin-Name: 415c448dc45a297bd1b0bbce25c4572eeab286f0
2010-08-24 01:08:11 +00:00
drh 61d3bfb78b Merge the 3.7.1 pre-release snapshot changes as of [2010-08-18]
into the apple-osx branch.

FossilOrigin-Name: 866e9286ae4226b2bec40ef18c672a41768abf1f
2010-08-18 00:24:09 +00:00
adam 45d55a254b Updating apple-osx with minor source fixes, database truncate and replace private calls and a bunch of conditionalization for tests running in different environments
FossilOrigin-Name: 5e2ee7db0f7a2a042b182336438107e2248d7b88
2010-08-18 00:09:47 +00:00
drh 51e5db70b6 Merge in all changes up to the 3.7.0.1 release.
FossilOrigin-Name: f88c6367d2f96cc93846ba38e6b963a1a3936e8d
2010-08-07 11:46:07 +00:00
drh f219bba933 Backport fix [a6bb2108bfb56] for a typo in the OS/2 interface.
FossilOrigin-Name: 042a1abb030a0711386add7eb6e10832cc8b0f57
2010-08-04 12:31:10 +00:00
drh a0166e1873 Update the version number to 3.7.0.1.
FossilOrigin-Name: 5074b85967df8f55739ba790924347c764288a88
2010-08-04 12:19:24 +00:00
drh aff0449d8f Backport fix [267492d3a7eff7b] for the performance regression caused by
automatic indexing and reported by ticket [8011086c85c6c4040].

FossilOrigin-Name: 3f367fe00e2adf87f3cc426466db4e3088e6f175
2010-08-04 12:13:35 +00:00
drh c55e9b815f Backport the [65b8636ac6e5] fix for ticket [51ae9cad317a1] to version 3.7.0.
FossilOrigin-Name: dec70c63d052bbe41fc4a065109d2845c67d3f15
2010-08-04 11:59:06 +00:00
drh 03ba419b3c Merge in changes up to and including the 3.6.23.1 release.
FossilOrigin-Name: 21ca87f69125a9e7124c6ddc566d17f64661b0d3
2010-06-16 19:48:56 +00:00
drh c4098a3d9f Cherry-pick the SQLITE_FCNTL_SIZE_HINT patch (check-in [2b7e3b4a30d6a7c4a8]
and bump the version number to 3.6.23.2.

FossilOrigin-Name: 776679af588625f13307369770979bccae7cf03a
2010-05-19 22:09:19 +00:00
drh 21ce77989a Disable the corruptE test which SQLITE_OVERSIZE_CELL_CHECK is enabled.
This is a cherrypick merge from check-in [1dc4f9fe9b83467ba].

FossilOrigin-Name: a40d080ca3c5f152f3296caf48f20728f61317de
2010-05-19 20:30:15 +00:00
drh 91973abb4b Include shell.c and sqlite3.def in the amalgamation ZIP archive.
Ticket [e063139eb3f8]

FossilOrigin-Name: b51fcac9fb4207810ee8d33ead47886e9c46d224
2010-03-31 11:56:47 +00:00
drh 722db051c6 Update the version number to 3.6.23.1.
FossilOrigin-Name: b078b588d617e07886ad156e9f54ade6d823568e
2010-03-26 22:28:06 +00:00
drh 87dd60cd8d Pull in other fixes from the trunk: check-ins [bea9258643],
[f186b6a619], and [bb591802ff].

FossilOrigin-Name: b1f342a6643829020beef542a0700d90822e6467
2010-03-26 21:53:11 +00:00
drh 7244fdc446 Fix to the crash8.test test script.
FossilOrigin-Name: f18a129a7aab09a1e0d34155e82bcbf7479a401d
2010-03-26 21:47:59 +00:00
drh 4f7e8fcded Enhance FTS3 to take advantage of the MAX() optimization.
Cherrypick of [b7e42ae774].

FossilOrigin-Name: 4b65b4805100852a2b6a834aa6efc0bbf25b539f
2010-03-26 17:42:57 +00:00
drh 95063a5774 Correctly handle strings with zero-length tokens in the FTS3 offsets()
function.  This is a cherrypick of [d37034f7fc].

FossilOrigin-Name: ff6ae4f0e461fb5f8d08a0092488b7cd71cffb05
2010-03-26 17:40:32 +00:00
drh ad7c2a87f5 After any rollback that modifies the database file, sync the database
before deleting the rollback journal.  This is a cherry-pick merge
of check-ins [b21b911f23] and [f2326dad4e]

FossilOrigin-Name: ca0bc2a22e893062876f67e0f53cbab44b45665d
2010-03-26 17:37:12 +00:00
adam cc3ec7cb2b fix merge error and compiler warning
FossilOrigin-Name: 5c0afe70a5ee2b378896bf30426823dc5ae4e95c
2010-02-26 22:05:01 +00:00
adam 3942b4b147 More double free paranoia
FossilOrigin-Name: 62dfb44b3b66c4acb1a7a10c44cbee1022a88883
2010-02-26 20:54:10 +00:00
drh 9aa0012a08 Merge latest changes from the trunk into the apple-osx branch.
FossilOrigin-Name: 4b72e39bd00572d9375639f4b978eff1b1d9aa20
2010-02-17 19:34:11 +00:00
adam efd8e3b33d Updated open mask to include SQLITE_OPEN_AUTOPROXY
FossilOrigin-Name: 7c3bede3f21812aa78105c6685654f12f0460eea
2010-01-26 01:14:33 +00:00
drh 0b90b2209f Align the os_unix.c source file with the version found on trunk.
FossilOrigin-Name: fa0f6c140e8ff9a5eed1d8a339fb6d55ecdca688
2010-01-20 13:20:22 +00:00
drh 9782039bde Update the Apple OS-X branch to include all of the latest changes in trunk.
FossilOrigin-Name: 96499b1dd69a0954e30e4b5b4f2272ab306afcdb
2010-01-20 01:26:07 +00:00
adam 332aa832ce robustness fixes for preventing a finalized statement from being reused
FossilOrigin-Name: a7a0c8d644873764cb799f9d6aacede4a4fb531f
2010-01-19 23:50:21 +00:00
drh bf4cad1e4c Update the OS-X branch to include all trunk changes through version 3.6.22.
FossilOrigin-Name: 541e2b488e4e40706e457c6d3b5647d53da02ce9
2010-01-06 13:12:48 +00:00
drh b0c5edcd06 Fix the main.mk makefile so that the sqlrr extension is built into the
amalgamation correctly.

FossilOrigin-Name: a3204d8a217d47e5120ab16918c1b7d4be5a021e
2009-12-23 18:06:49 +00:00
drh 2250799f0c Merge the latest changes on trunk (and especially the fix for
the (xANDy)OR(z) bug) into apple-osx.

FossilOrigin-Name: 5754a3a56144ee0e073c80651bf11cb23ee7f447
2009-12-16 23:46:11 +00:00
drh ca071dfd75 Merge all changes associated with the version 3.6.21 release into the OS-X
branch.

FossilOrigin-Name: ad08794d7239bb804eb39c00170821732b60cb65
2009-12-07 23:53:51 +00:00
adam ac0c39980a Fix for lock structure sharing with AFP-style locking
FossilOrigin-Name: 62f15c0aeaec5d778addb6edba62411c698bec0f
2009-11-09 19:30:44 +00:00
drh 04d4227255 Fix an undefined variable on non-Mac builds.
FossilOrigin-Name: 9552de8fb5ec7554c989edc138c0324c5fd0a206
2009-11-05 18:31:55 +00:00
adam e6c3c72c1b Merging in OSX customizations:
A ext/sqlrr/sqlrr.[ch]
-- add sql recording/replay support (very experimental extension -- pre alpha)

M ext/rtree/rtree.c
-- fix cast compiler warning

M src/func.c
-- substring backward compatiblity <rdar://problem/6778339> 

M src/legacy.c
-- replay recorder calls

M src/main.c
-- if SQLITE_ENABLE_AUTO_PROFILE, call sqlite3_profile when env(SQLITE_AUTO_PROFILE)   
-- replay recorder calls

M src/mem1.c
-- use custom malloc zone on single core systems

M src/os_unix.c
-- hostid via gethostuuid
-- read-only file system support for proxy locking
-- improved handling of simulated shared lock on AFP/SMB on 64 bit systems
-- disable whole-file-lock NFS file locking
-- fix for downgrading from exclusive to shared lock on NFS
-- proxy lock breaking & recreating local lock files
-- support SQLITE_OPEN_AUTOPROXY flag
-- only write 1st byte into new zero-length files if fs is DOS
-- cache fs type info in unixFile struct
-- force use of fsync() even if fdatasync() is available
-- remove flock locking style support for SMB
-- replace strcpy with strlcpy

M src/prepare.c
-- replay recorder calls

M src/sqlite.h.in
-- added SQLITE_OPEN_AUTOPROXY

M src/sqliteInt.h
-- include replay recorder header

M src/vdbeapi.c
-- checking for NULL statement for <rdar://6646331> 
-- replay recorder calls

FossilOrigin-Name: 941a01eb868815f566539e9ab21f807d9e798e40
2009-11-03 22:34:35 +00:00
91 changed files with 3511 additions and 517 deletions
+14
View File
@@ -324,6 +324,9 @@ SRC += \
SRC += \
$(TOP)/ext/rtree/rtree.h \
$(TOP)/ext/rtree/rtree.c
SRC += \
$(TOP)/ext/sqlrr/sqlrr.h \
$(TOP)/ext/sqlrr/sqlrr.c
# Generated source code files
@@ -472,6 +475,17 @@ EXTHDR += \
$(TOP)/ext/icu/sqliteicu.h
EXTHDR += \
$(TOP)/ext/rtree/sqlite3rtree.h
EXTHDR += \
$(TOP)/ext/sqlrr/sqlrr.h
# If using the amalgamation, use sqlite3.c directly to build the test
# fixture. Otherwise link against libsqlite3.la. (This distinction is
# necessary because the test fixture requires non-API symbols which are
# hidden when the library is built via the amalgamation).
#
TESTFIXTURE_SRC0 = $(TESTSRC2) libsqlite3.la
TESTFIXTURE_SRC1 = sqlite3.c
TESTFIXTURE_SRC = $(TESTSRC) $(TOP)/src/tclsqlite.c $(TESTFIXTURE_SRC$(USE_AMALGAMATION))
# This is the default Makefile target. The objects listed here
# are what get build when you type just "make" with no arguments.
+1
View File
@@ -105,6 +105,7 @@
#include <string.h>
#include <assert.h>
#include <stdint.h>
#ifndef SQLITE_AMALGAMATION
#include "sqlite3rtree.h"
+54
View File
@@ -0,0 +1,54 @@
sqlrr - 10/19/2009
SQL Replay Recording
SUMMARY
-------------------------------------------------------
This extension enables recording sqlite API calls that access the database so that they can be replayed or examined.
USAGE
------------------------------------------------------
Recording is enabled by compiling sqlite with symbolic constant SQLITE_ENABLE_SQLRR defined.
By default logs are written to /tmp/<databasename>_<pid>_<connection_number>.sqlrr, to choose another directory, set the environment variable SQLITE_REPLAY_RECORD_DIR to that path.
FILE FORMAT
-----------------------------------------------------
file: <header>[<sql-command>]*
header: <signature><format-version>
signature: SQLRR (5 bytes)
format-version: n (1 byte)
sql-command: <timestamp><type><arg-data>
timestamp: n (16 bytes)
type: n (1 byte)
open 0
close 1
exec 8
bind-text 16
bind-double 17
bind-int 18
bind-null 19
bind-value 20
bind-clear 21
prep 32
step 33
reset 34
finalize 35
open-arg-data: <connection><path><flags>
close-arg-data: <connection>
exec-arg-data: <connection><len><statement-text>
bind-text-arg-data: <statement-ref><index><len><data>
bind-double-arg-data: <statement-ref><index><data>
bind-int-arg-data: <statement-ref><index><data>
bind-null-arg-data: <statement-ref><index>
bind-value-arg-data: <statement-ref><index><len><data> ???
bind-clear-arg-data: <statement-ref>
prep-arg-data: <connection><len><statement-text>
step-arg-data: <statement-ref>
reset-arg-data: <statement-ref>
finalize-arg-data: <statement-ref>
NOTES
+581
View File
@@ -0,0 +1,581 @@
/*
* sqlrr.c
*/
#include "sqlrr.h"
#if defined(SQLITE_ENABLE_SQLRR)
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/param.h>
#include <errno.h>
#include <pthread.h>
#include <libkern/OSAtomic.h>
#include "sqliteInt.h"
#include "vdbeInt.h"
#define LOGSUFFIXLEN 48
/*
* Data types
*/
typedef struct SRRLogRef SRRLogRef;
struct SRRLogRef {
int fd;
sqlite3 *db;
const char *dbPath;
char *logPath;
int connection;
int depth;
SRRLogRef *nextRef;
};
/*
* Globals
*/
SRRLogRef *logRefHead = NULL;
int dbLogCount = 0;
static int srr_enabled = 1;
pthread_mutex_t srr_log_mutex;
static volatile int32_t srr_initialized = 0;
/*
* Log management
*/
extern void SRRecInitialize() {
int go = OSAtomicCompareAndSwap32Barrier(0, 1, &srr_initialized);
if( go ){
pthread_mutex_init(&srr_log_mutex, NULL);
}
}
static SRRLogRef *createLog(sqlite3 *db, const char *dbPath) {
SRRLogRef *ref = NULL;
char *baseDir = getenv("SQLITE_REPLAY_RECORD_DIR");
char logPath[MAXPATHLEN] = "";
char suffix[LOGSUFFIXLEN] = "";
const char *dbName = dbPath;
int len = 0;
int index = 0;
int fd = -1;
size_t out;
unsigned char version = SRR_FILE_VERSION;
SRRecInitialize();
/* construct the path for the log file
* ${SQLITE_REPLAY_DIR}/<dbname>_<pid>_<connection_number>.sqlrr
*/
if (baseDir == NULL) {
baseDir = "/tmp"; /* getenv(TMPDIR) */
}
len = strlen(baseDir);
strlcat(logPath, baseDir, MAXPATHLEN);
if ((len>0) && (baseDir[len-1] != '/')) {
strlcat(logPath, "/", MAXPATHLEN);
}
len = strlen(dbPath);
for (index = len-2; index >= 0; index --){
if (dbPath[index] == '/') {
dbName = &dbPath[index+1];
break;
}
}
strlcat(logPath, dbName, MAXPATHLEN);
int cNum = ++dbLogCount;
snprintf(suffix, sizeof(suffix), "_%d_%d_XXXX.sqlrr", getpid(), cNum);
len = strlcat(logPath, suffix, MAXPATHLEN);
/* make it unique if we have the space */
if ((len + 1) < MAXPATHLEN) {
fd = mkstemps(logPath, 6);
} else {
fprintf(stderr, "Failed to create sqlite replay log path for %s [%s]\n", dbPath, logPath);
return NULL;
}
if (fd == -1) {
fprintf(stderr, "Failed to create sqlite replay log file for %s with path %s [%s]\n", dbPath, logPath, strerror(errno));
return NULL;
}
fprintf(stdout, "Writing sqlite replay log file %s\n", logPath);
out = write(fd, SRR_FILE_SIGNATURE, SRR_FILE_SIGNATURE_LEN);
if (out!=-1) {
out = write(fd, &version, 1);
}
if (out == -1){
fprintf(stderr, "Write failure on log [%s]: %s\n", logPath, strerror(errno));
close(fd);
return NULL;
}
len = strlen(logPath) + 1;
ref = (SRRLogRef *)malloc(sizeof(SRRLogRef));
ref->db = db;
ref->dbPath = dbPath;
ref->logPath = (char *)malloc(len * sizeof(char));
strlcpy(ref->logPath, logPath, len);
ref->fd = fd;
ref->connection = cNum;
ref->depth = 0;
pthread_mutex_lock(&srr_log_mutex);
ref->nextRef = logRefHead;
logRefHead = ref;
pthread_mutex_unlock(&srr_log_mutex);
return ref;
}
static void closeLog(sqlite3 *db) {
SRRLogRef *ref = NULL;
SRRLogRef *lastRef = NULL;
pthread_mutex_lock(&srr_log_mutex);
for (ref = logRefHead; ref != NULL; ref = ref->nextRef) {
if (ref->db == db) {
if (lastRef == NULL) {
logRefHead = ref->nextRef;
} else {
lastRef->nextRef = ref->nextRef;
}
}
}
pthread_mutex_unlock(&srr_log_mutex);
if (ref != NULL) {
fprintf(stdout, "Closing sqlite replay log file %s\n", ref->logPath);
close(ref->fd);
free(ref->logPath);
free(ref);
}
}
static SRRLogRef *getLog(sqlite3 *db) {
pthread_mutex_lock(&srr_log_mutex);
SRRLogRef *ref = logRefHead;
for (ref = logRefHead; ref != NULL; ref = ref->nextRef) {
if (ref->db == db) {
pthread_mutex_unlock(&srr_log_mutex);
return ref;
}
}
pthread_mutex_unlock(&srr_log_mutex);
return NULL;
}
/*
* SQLite recording API
*/
void SQLiteReplayRecorder(int flag) {
srr_enabled = flag;
}
// open-arg-data: <connection><len><path><flags>
void _SRRecOpen(sqlite3 *db, const char *path, int flags) {
if (!srr_enabled) return;
if (db) {
SRRLogRef *ref = createLog(db, path);
if (ref) {
SRRCommand code = SRROpen;
int len = strlen(path);
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out=write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) { out=write(ref->fd, &(ref->connection), sizeof(ref->connection)); }
if (out!=-1) { out=write(ref->fd, &len, sizeof(len)); }
if (out!=-1) { out=write(ref->fd, path, len); }
if (out!=-1) { out=write(ref->fd, &flags, sizeof(flags)); }
if (out==-1) {
fprintf(stderr, "Error writing open to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(db);
}
}
}
}
//close-arg-data: <connection>
void SRRecClose(sqlite3 *db) {
if (!srr_enabled) return;
if (db) {
SRRLogRef *ref = getLog(db);
if (ref) {
SRRCommand code = SRRClose;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) { out = write(ref->fd, &(ref->connection), sizeof(ref->connection)); }
if (out==-1) {
fprintf(stderr, "Error writing close to log file [%s]: %s\n", ref->logPath, strerror(errno));
}
closeLog(db);
}
}
}
// exec-arg-data: <connection><len><statement-text>
void SRRecExec(sqlite3 *db, const char *sql) {
if (!srr_enabled) return;
if (db) {
SRRLogRef *ref = getLog(db);
if (ref) {
if (ref->depth == 0) {
SRRCommand code = SRRExec;
int len = strlen(sql);
struct timeval tv;
size_t out;
ref->depth = 1;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) { out = write(ref->fd, &(ref->connection), sizeof(ref->connection)); }
if (out!=-1) { out = write(ref->fd, &len, sizeof(len)); }
if (out!=-1) { out = write(ref->fd, sql, len); }
if (out==-1) {
fprintf(stderr, "Error writing exec to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(db);
}
} else {
ref->depth ++;
}
}
}
}
void SRRecExecEnd(sqlite3 *db) {
if (!srr_enabled) return;
if (db) {
SRRLogRef *ref = getLog(db);
if (ref) {
ref->depth --;
}
}
}
// prep-arg-data: <connection><len><statement-text><savesql><statement-ref>
void _SRRecPrepare(sqlite3 *db, const char *sql, int nBytes, int saveSql, sqlite3_stmt *pStmt) {
if (!srr_enabled) return;
if ((db!=NULL)&&(pStmt!=NULL)) {
SRRLogRef *ref = getLog(db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRPrepare;
struct timeval tv;
size_t out;
int sqlLen = nBytes;
if (sqlLen == -1) {
sqlLen = strlen(sql);
}
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) { out = write(ref->fd, &(ref->connection), sizeof(ref->connection)); }
if (out!=-1) { out = write(ref->fd, &sqlLen, sizeof(sqlLen)); }
if (out!=-1) { out = write(ref->fd, sql, sqlLen); }
if (out!=-1) { out = write(ref->fd, &saveSql, sizeof(saveSql)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out==-1) {
fprintf(stderr, "Error writing prepare to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(db);
}
}
}
}
//step-arg-data: <statement-ref>
void SRRecStep(sqlite3_stmt *pStmt) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref) {
if (ref->depth == 0) {
SRRCommand code = SRRStep;
struct timeval tv;
size_t out;
ref->depth = 1;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out==-1) {
fprintf(stderr, "Error writing step to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
} else {
ref->depth ++;
}
}
}
}
void SRRecStepEnd(sqlite3_stmt *pStmt) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref) {
ref->depth --;
}
}
}
// reset-arg-data: <statement-ref>
void SRRecReset(sqlite3_stmt *pStmt) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRReset;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out==-1) {
fprintf(stderr, "Error writing reset to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
// finalize-arg-data: <statement-ref>
void SRRecFinalize(sqlite3_stmt *pStmt) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRFinalize;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out==-1) {
fprintf(stderr, "Error writing finalize to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
// bind-text-arg-data: <statement-ref><index><len><data>
void SRRecBindText(sqlite3_stmt *pStmt, int i, const char *zData, int64_t nData) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRBindText;
struct timeval tv;
size_t out;
int64_t textLen = nData;
if (textLen == -1) {
textLen = strlen(zData);
}
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out!=-1) { out = write(ref->fd, &i, sizeof(i)); }
if (out!=-1) { out = write(ref->fd, &textLen, sizeof(textLen)); }
if (out!=-1) { out = write(ref->fd, zData, textLen); }
if (out==-1) {
fprintf(stderr, "Error writing bind text to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
// bind-blob-arg-data: <statement-ref><index><len>[<data>]
void SRRecBindBlob(sqlite3_stmt *pStmt, int i, const char *zData, int64_t nData) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRBindBlob;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out!=-1) { out = write(ref->fd, &i, sizeof(i)); }
if (zData == NULL) {
int64_t negNData = -nData;
if (out!=-1) { out = write(ref->fd, &negNData, sizeof(negNData)); }
} else {
if (out!=-1) { out = write(ref->fd, &nData, sizeof(nData)); }
if (out!=-1) { out = write(ref->fd, zData, nData); }
}
if (out==-1) {
fprintf(stderr, "Error writing bind blob to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
// bind-double-arg-data: <statement-ref><index><data>
void SRRecBindDouble(sqlite3_stmt *pStmt, int i, double value) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRBindDouble;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out!=-1) { out = write(ref->fd, &i, sizeof(i)); }
if (out!=-1) { out = write(ref->fd, &value, sizeof(value)); }
if (out==-1) {
fprintf(stderr, "Error writing bind double to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
// bind-int-arg-data: <statement-ref><index><data>
void SRRecBindInt64(sqlite3_stmt *pStmt, int i, int64_t value) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRBindInt;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out!=-1) { out = write(ref->fd, &i, sizeof(i)); }
if (out!=-1) { out = write(ref->fd, &value, sizeof(value)); }
if (out==-1) {
fprintf(stderr, "Error writing bind int to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
// bind-null-arg-data: <statement-ref><index>
void SRRecBindNull(sqlite3_stmt *pStmt, int i) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRBindNull;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out!=-1) { out = write(ref->fd, &i, sizeof(i)); }
if (out==-1) {
fprintf(stderr, "Error writing bind null to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
// bind-value-arg-data: <statement-ref><index><len><data> ???
void SRRecBindValue(sqlite3_stmt *pStmt, int i, const sqlite3_value *value) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
fprintf(stderr, "SRRecBindValue(sqlite3_bind_value) is not yet supported, closing [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
// bind-clear-arg-data: <statement-ref>
void SRRecClearBindings(sqlite3_stmt *pStmt) {
if (!srr_enabled) return;
if(pStmt!=NULL) {
Vdbe *v = (Vdbe *)pStmt;
SRRLogRef *ref = getLog(v->db);
if (ref && (ref->depth == 0)) {
SRRCommand code = SRRBindClear;
struct timeval tv;
size_t out;
gettimeofday(&tv, NULL);
out = write(ref->fd, &tv, sizeof(tv));
if (out!=-1) { out = write(ref->fd, &code, sizeof(SRRCommand)); }
if (out!=-1) {
int64_t stmtInt = (int64_t)((intptr_t)(pStmt));
out = write(ref->fd, &stmtInt, sizeof(int64_t));
}
if (out==-1) {
fprintf(stderr, "Error writing clear bindings to log file [%s]: %s\n", ref->logPath, strerror(errno));
closeLog(ref->db);
}
}
}
}
#endif /* SQLITE_ENABLE_SQLRR */
+61
View File
@@ -0,0 +1,61 @@
/*
* sqlrr.h
*/
#ifndef _SQLRR_H_
#define _SQLRR_H_
/*
** Header constants
*/
#define SRR_FILE_SIGNATURE "SQLRR"
#define SRR_FILE_SIGNATURE_LEN 5
#define SRR_FILE_VERSION 0x1
#define SRR_FILE_VERSION_LEN 1
#if defined(SQLITE_ENABLE_SQLRR)
#include "sqlite3.h"
#include <sys/types.h>
#define SRRecOpen(A,B,C) if(!rc){_SRRecOpen(A,B,C);}
#define SRRecPrepare(A,B,C,D,E) if(!rc){_SRRecPrepare(A,B,C,D,E);}
typedef enum {
SRROpen = 0,
SRRClose = 1,
SRRExec = 8,
SRRBindText = 16,
SRRBindBlob = 17,
SRRBindDouble = 18,
SRRBindInt = 19,
SRRBindNull = 20,
SRRBindValue = 21,
SRRBindClear = 22,
SRRPrepare = 32,
SRRStep = 33,
SRRReset = 34,
SRRFinalize = 35
} SRRCommand;
extern void SQLiteReplayRecorder(int flag);
extern void _SRRecOpen(sqlite3 *db, const char *path, int flags);
extern void SRRecClose(sqlite3 *db);
extern void SRRecExec(sqlite3 *db, const char *sql);
extern void SRRecExecEnd(sqlite3 *db);
extern void _SRRecPrepare(sqlite3 *db, const char *sql, int nBytes, int saveSql, sqlite3_stmt *stmt);
extern void SRRecStep(sqlite3_stmt *pStmt);
extern void SRRecStepEnd(sqlite3_stmt *pStmt);
extern void SRRecReset(sqlite3_stmt *pStmt);
extern void SRRecFinalize(sqlite3_stmt *pStmt);
extern void SRRecBindText(sqlite3_stmt *pStmt, int i, const char *zData, int64_t nData);
extern void SRRecBindBlob(sqlite3_stmt *pStmt, int i, const char *zData, int64_t nData);
extern void SRRecBindDouble(sqlite3_stmt *pStmt, int i, double value);
extern void SRRecBindInt64(sqlite3_stmt *pStmt, int i, int64_t value);
extern void SRRecBindNull(sqlite3_stmt *pStmt, int i);
extern void SRRecBindValue(sqlite3_stmt *pStmt, int i, const sqlite3_value *value);
extern void SRRecClearBindings(sqlite3_stmt *pStmt);
#endif /* defined(SQLITE_ENABLE_SQLRR) */
#endif /* _SQLRR_H_ */
+5 -18
View File
@@ -205,6 +205,8 @@ SRC += \
SRC += \
$(TOP)/ext/rtree/rtree.h \
$(TOP)/ext/rtree/rtree.c
SRC += \
$(TOP)/ext/sqlrr/sqlrr.c
# Generated source code files
@@ -331,22 +333,7 @@ HDR = \
# Header files used by extensions
#
EXTHDR += \
$(TOP)/ext/fts1/fts1.h \
$(TOP)/ext/fts1/fts1_hash.h \
$(TOP)/ext/fts1/fts1_tokenizer.h
EXTHDR += \
$(TOP)/ext/fts2/fts2.h \
$(TOP)/ext/fts2/fts2_hash.h \
$(TOP)/ext/fts2/fts2_tokenizer.h
EXTHDR += \
$(TOP)/ext/fts3/fts3.h \
$(TOP)/ext/fts3/fts3Int.h \
$(TOP)/ext/fts3/fts3_hash.h \
$(TOP)/ext/fts3/fts3_tokenizer.h
EXTHDR += \
$(TOP)/ext/rtree/rtree.h
EXTHDR += \
$(TOP)/ext/icu/sqliteicu.h
$(TOP)/ext/sqlrr/sqlrr.h
# This is the default Makefile target. The objects listed here
# are what get build when you type just "make" with no arguments.
@@ -371,10 +358,10 @@ sqlite3.o: sqlite3.c
# files are automatically generated. This target takes care of
# all that automatic generation.
#
target_source: $(SRC) $(TOP)/tool/vdbe-compress.tcl
target_source: $(SRC) $(EXTHDR) $(TOP)/tool/vdbe-compress.tcl
rm -rf tsrc
mkdir tsrc
cp -f $(SRC) tsrc
cp -f $(SRC) $(EXTHDR) tsrc
rm tsrc/sqlite.h.in tsrc/parse.y
tclsh $(TOP)/tool/vdbe-compress.tcl <tsrc/vdbe.c >vdbe.new
mv vdbe.new tsrc/vdbe.c
+95 -90
View File
@@ -1,7 +1,7 @@
C Do\smore\saggressive\soptimization\sof\sthe\sAND\soperator\swhere\sone\sside\sor\sthe\nother\sis\salways\sfalse.
D 2012-03-31T02:34:35.585
C Cherrypick\scommit\s[1d5e744cc6]\sfrom\sthe\strunk\sin\sorder\sto\savoid\sleaving\sa\sfile-ddescriptor\sopen\sin\stest\sscripts\scapi3.test\sand\scapi3c.test.
D 2012-04-03T19:43:07.319
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
F Makefile.in 7bd2fa7753fc9de38994b8d4fa7f10deb19966a5
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F Makefile.msc 7849a871b6cdb20fd51baee6bbe5965a03326be4
F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca
@@ -86,7 +86,7 @@ F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9
F ext/icu/icu.c eb9ae1d79046bd7871aa97ee6da51eb770134b5a
F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
F ext/rtree/rtree.c 4c1878818fc50efe5c2c7b8809d5cd0d88c7d396
F ext/rtree/rtree.c 4e69b25ba3ec9ce229dbbd388d5281e1486b3bef
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
F ext/rtree/rtree1.test 28e1b8da4da98093ce3210187434dd760a8d89d8
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
@@ -104,9 +104,12 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F ext/sqlrr/README.txt 4239030e73023e72a2e727808cd433577d5bf730
F ext/sqlrr/sqlrr.c 8d1e6571cd6a6beabdb5bcdfe3a0e723b914db41
F ext/sqlrr/sqlrr.h 09e4f8929ad9bc2638732c0cc0db5eef8c417824
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F main.mk a80771d44176a0c744d9d4e048497e7ed0b4040d
F main.mk 92babfc15d7838f01b4bf1cc14ea8d9c06772c2b
F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac
@@ -126,7 +129,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c 6be23a344d3301ae38e92fddb3a33b91c309fce4
F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
F src/btree.c 02aeee1f6d425e11f7b9b2d9d461ac501645ed6f
F src/btree.c 748ff64c56e6aee3d60200321e6b86c1b9a777b8
F src/btree.h 48a013f8964f12d944d90e4700df47b72dd6d923
F src/btreeInt.h 26d8ca625b141927fe6620c1d2cf58eaf494ca0c
F src/build.c 987c6933ea170e443dc6a79d52f8d2506206b12b
@@ -138,17 +141,17 @@ F src/delete.c 4c20ea4f6213b3bc1c6a510586864b679946e05e
F src/expr.c ebb0e2b21379d4ec0c5c2c7c952784cb300c8436
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5
F src/func.c c6b3c94320253a35bda43fb69cc292618e3285d6
F src/func.c 067e50003af2b3c3b2f65575837ae8ef4be676f9
F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
F src/insert.c 93eb9542ae1376d9317a7c8335d7e379f010aa76
F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/legacy.c 015826a958f690302d27e096a68d50b3657e4201
F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416
F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d
F src/main.c 91458c713e9b7f8dbc98d79e78f1150f0ca9c2a1
F src/main.c 2ba24071c42849fde838c32f1b508712c51dd758
F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1
@@ -163,34 +166,35 @@ F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f
F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc
F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33
F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c
F src/os.c 4c8c8d72a6c58ad2fde4865783e8ae26b494a85e
F src/os.h 59beba555b65a450bd1d804220532971d4299f60
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1
F src/os_win.c 5e9e933a412ab35de2a6506b3c6a8295b31b309e
F src/pager.c 85988507fa20acc60defb834722eddf4633e4aeb
F src/os_unix.c 5e6ead4f8f4236f0ed016ca4518300985daddf7e
F src/os_win.c 12e76b4aa5426022939f92e894a5c20dd40be7f4
F src/pager.c ce4fde5951bf71b4f5316ff5afd0219ff7e99b3f
F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5
F src/parse.y eb054bb40a5bf90d3422a01ed0e5df229461727a
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c
F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60
F src/pragma.c e708b3bb5704605816f617e0b1d63a5488060715
F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e
F src/pragma.c 29db41fc84bd7853d6c7ef85f9f8bd56a8be4320
F src/prepare.c 4450a714a7ebb4b0ce4159087338e1159d083885
F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c 3d3e80a98f203ac6b9329e9621e29eda85ddfd40
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c f6f141cb1ea13f1e6564d3e162700e4937baa2a1
F src/select.c 36d5ed5c4504fd37c024141ce2b699148b231a8d
F src/shell.c abf18d6ee54f2631860a98fdd7ab1327f470db67
F src/sqlite.h.in 11a883919b0baf4ffaa7550cfeef99be613ec2bf
F src/sqlite.h.in 8714ac9f594717d667fb0c1149f97332bebce8e0
F src/sqlite3_private.h 77bebe843a3eabfb7994990aab780d34d25819c7
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
F src/sqliteInt.h d701123ab4c8774ee2837cd4ade84e370d665f87
F src/sqliteInt.h efee04f7c9e000b77d89f87baf77397b4025246c
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c 086dfdd72e5892de223968a258e1ccbd9693e717
F src/test1.c 8631f728c9c3afcf79e3e22b510e451435e3d15e
F src/test1.c a23a59fb8aaa49f94fe5d214907618264f05b923
F src/test2.c 711555927f1f7e8db9aab86b512bc6934a774abe
F src/test3.c f82399ec50d9cd7378bf9d6db6c1409d5e77b042
F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7
@@ -201,9 +205,9 @@ F src/test8.c 61b41d79509a479dec1ac32b6d4209b27c4b1ba5
F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60
F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad
F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e
F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de
F src/test_backup.c 64fd6173ad99daade1227aa17c3ca0d18fa5e5fa
F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2
F src/test_config.c a036a69b550ebc477ab9ca2b37269201f888436e
F src/test_config.c 7f1aa0d93f76c2657bfa00a54e5837ab9af1a912
F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_func.c 6232d722a4ddb193035aa13a03796bf57d6c12fd
@@ -223,11 +227,11 @@ F src/test_osinst.c 7f790ac89c5a585d51b341274d9691c3391e0923
F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00
F src/test_quota.c a545115f837da4ef32f6b5578f147b44cfb13fd7
F src/test_quota.h 9ffa1d3ad6d0a6a24e8670ea64b909c717ec3358
F src/test_rtree.c 6d06306e29946dc36f528a3a2cdc3add794656f1
F src/test_rtree.c a2eebb68c0f1463918cdfbe603cb2e869c551038
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f
F src/test_stat.c d7035cfcc0ff1f93c000b621f36524318e004e11
F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
F src/test_superlock.c 12e2bc484c6c2ba837327d37f2e6a6fd9d1464f8
F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4
@@ -241,21 +245,21 @@ F src/update.c d3076782c887c10e882996550345da9c4c9f9dea
F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84
F src/util.c 4f6cfad661b2e3454b0cdd5b1b9d39a54942d0e3
F src/vacuum.c bfd53f9bd20a8fdb70b0fa8e77182b866875c0d8
F src/vdbe.c 8913926230bfc9d183fcd44e3d023c6d393b6548
F src/vdbe.c bcf472eecfe0bab9e7be7b615aa71c16cb27c6ea
F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb
F src/vdbeInt.h 6ff4180a05683566a8835d12f7ec504b22932c82
F src/vdbeapi.c 3662b6a468a2a4605a15dfab313baa6dff81ad91
F src/vdbeaux.c 79cf42b70e211a52d664fc4d585ee2da0a64deac
F src/vdbeapi.c bf1f632719ee596d43ccf6c2ed68ff8911f5b376
F src/vdbeaux.c dfaa1694e43aea6470a53e50a318fe9f54d63374
F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb
F src/vdbemem.c fb0ac964ccbcd94f595eb993c05bfd9c52468a4a
F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9
F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843
F src/vdbetrace.c 2405f68d14c49d2e0a798d71e35d62b8569bfb65
F src/vtab.c ab90fb600a3f5e4b7c48d22a4cdb2d6b23239847
F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146
F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
F src/wal.c b5ba968e7d5a17f745b78b3acde2214ec985d21e
F src/wal.h a8ade3069ab75e3c79e9ca067a5ac7e1dbaf93a6
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 2112422a404dcca5d47f6630bdf180bccd36c62b
F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823
F test/8_3_names.test 0ed0f6711fefac33829ef9f1d6ca3c56c48ef1c7
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F test/all.test 52fc8dee494092031a556911d404ca30a749a30b
@@ -276,10 +280,10 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b
F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7
F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a
F test/async5.test 0dd8701bd588bf6e70c2557a22ae3f22b2567b4c
F test/attach.test 0d112b7713611fdf0340260192749737135fda5f
F test/attach.test 63033baa59be42c811ef0d4e73ebd2d6dba4805c
F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966
F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e
F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c
F test/attach4.test faaaf33fa51f986b414520cb03cecdc7999df108
F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0
F test/auth.test 304e82f31592820d3bde26ab6b75deaa123e1a6f
F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882
@@ -301,7 +305,7 @@ F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070
F test/bigfile.test 82dfe93ee7eb9e2e05641afa2b39ffd947a92ff1
F test/bigfile2.test 852f948cb492aadab45b58f4d2f3b0832a115cb0
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bind.test 3c7b320969000c441a70952b0b15938fbb66237c
F test/bind.test 30af0fc61bc3836034215cdbdeca46113ca1b4a1
F test/bindxfer.test efecd12c580c14df5f4ad3b3e83c667744a4f7e0
F test/bitvec.test 75894a880520164d73b1305c1c3f96882615e142
F test/blob.test e7ac6c7d3a985cc4678c64f325292529a69ae252
@@ -316,9 +320,9 @@ F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b
F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0
F test/cache.test f64136b0893c293d0b910ed057b3b711249099a7
F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360
F test/capi3.test 9c8b58b6a6aeb14e69bd8c8c7721b47d640464d1
F test/capi3.test 8dedb0050610e9ff95cd9d487beb0ce5f33a31ee
F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4
F test/capi3c.test 1b5424d2ac57b7b443b5de5b9a287642c02279b6
F test/capi3c.test 01f197d73f4d4d66316483662f475cab7ab5bd60
F test/capi3d.test 17b57ca28be3e37e14c2ba8f787d292d84b724a1
F test/capi3e.test f7408dda65c92b9056199fdc180f893015f83dde
F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3
@@ -400,12 +404,12 @@ F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020
F test/eqp.test 6a389bba6ea113fd5179515001be788a38d53ec7
F test/errmsg.test 3bb606db9d040cc6854459f8f5e5a2bcd9b7fd2a
F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3
F test/exclusive.test a1b324cb21834a490cd052d409d34789cfef57cb
F test/exclusive.test bd8976a6e67daf8e9948eb1c6a27afafe79752fa
F test/exclusive2.test 372be98f6de44dd78734e364b7b626ea211761a6
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30
F test/expr.test 67c9fd6f8f829e239dc8b0f4a08a73c08b09196d
F test/fallocate.test b5d34437bd7ab01d41b1464b8117aefd4d32160e
F test/fallocate.test 1abe364ff739f494523e88ba881c5eab72df9143
F test/filectrl.test f0327bd804d9c7bd048fa7a151c5eab8e27df42b
F test/filefmt.test ffa17b5aebc3eb4b1e3be1ccb5ee906ffbd97f6e
F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da
@@ -521,12 +525,12 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
F test/in4.test 64f3cc1acde1b9161ccdd8e5bde3daefdb5b2617
F test/incrblob.test 26fde912a1e0aff158b3a84ef3b265f046aad3be
F test/incrblob2.test edc3a96e557bd61fb39acc8d2edd43371fbbaa19
F test/incrblob3.test aedbb35ea1b6450c33b98f2b6ed98e5020be8dc7
F test/incrblob3.test 086482e7937202be9f8cf327117a042d8628fe7d
F test/incrblob4.test 09be37d3dd996a31ea6993bba7837ece549414a8
F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597
F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0
F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32
F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b
F test/incrvacuum2.test a1828b6165af6c248c4eb80aeaee2bcbb45768c1
F test/incrvacuum_ioerr.test 22f208d01c528403240e05beecc41dc98ed01637
F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097
F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
@@ -557,7 +561,7 @@ F test/join5.test 86675fc2919269aa923c84dd00ee4249b97990fe
F test/join6.test cfe6503791ceb0cbb509966740286ec423cbf10b
F test/journal1.test 8b71ef1ed5798bdc0e6eb616d8694e2c2c188d4d
F test/journal2.test ae06f566c28552c313ded3fee79a6c69e6d049b1
F test/journal3.test ff8af941f9e06161d3db1b46bb9f965ff0e7f307
F test/journal3.test ef775301aa8c64c80efa859e6aa0207add921a93
F test/jrnlmode.test 9ee3a78f53d52cca737db69293d15dc41c0cbd36
F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d
F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa
@@ -573,12 +577,13 @@ F test/lock.test db74fdf5a73bad29ab3d862ea78bf1068972cc1d
F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff
F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00
F test/lock4.test e175ae13865bc87680607563bafba21f31a26f12
F test/lock5.test 5ad6a1f536036ff1be915cfdd41481aeafda3273
F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5
F test/lock5.test 71d0ba9cd23212b5ce1a433107c806203fa6d5f9
F test/lock6.test 83434ae8ca1d1c5e2eaf74d4e44aa24ab62b291c
F test/lock7.test 64006c84c1c616657e237c7ad6532b765611cf64
F test/lock_common.tcl 0c270b121d40959fa2f3add382200c27045b3d95
F test/lock_proxy.test 95be9c32d79be25cf643b4e41a0aa0e53aa21621
F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2
F test/main.test 39c4bb8a157f57298ed1659d6df89d9f35aaf2c8
F test/main.test 3991157c720c2b2b9ec27254d940f06ab81aab84
F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
F test/malloc.test bc745155ff4252d4f35ec8316625b0dfe2abc659
F test/malloc3.test de8eca0c3e748878845fdca3663ec4b642073caf
@@ -600,12 +605,12 @@ F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb
F test/mallocI.test a88c2b9627c8506bf4703d8397420043a786cdb6
F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e
F test/mallocK.test d79968641d1b70d88f6c01bdb9a7eb4a55582cc9
F test/malloc_common.tcl 2930895b0962823ec679853e67e58dd6d8198b3c
F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e
F test/malloc_common.tcl 11838863dc689f2d2b10896c8f4276771a60b42f
F test/manydb.test 3cd8e52ab3112cb8365afeedd6e8231977920577
F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f
F test/memdb.test 708a028d6d373e5b3842e4bdc8ba80998c9a4da6
F test/memdb.test 499d199e612bc229f52d1c46c6038deeef93d1f2
F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2
F test/memsubsys1.test a8f9e37567453a5d1d9d37ec102d4d88ab6be33f
F test/memsubsys1.test f431d42296dc502d4dbc19a6f89a76e46d74275f
F test/memsubsys2.test 3a1c1a9de48e5726faa85108b02459fae8cb9ee9
F test/minmax.test 722d80816f7e096bf2c04f4111f1a6c1ba65453d
F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0
@@ -619,7 +624,7 @@ F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5
F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
F test/misc7.test 4337d84e441f36cee62656f9f7ba8bc22a7ca721
F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054
F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256
F test/multiplex.test 85a4be2b23e7294d468b6e3a578ec00020723bee
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101
F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41
@@ -632,10 +637,10 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
F test/pager1.test eb6d64d2e148dc4bfc6420605bee3717e2d5f10c
F test/pager1.test 4fbf634d26661578af38db830bd3442287aed91d
F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1
F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442
F test/pagerfault.test a15ef77c8495882d7debb43794e87b6e46174c8a
F test/pagerfault2.test 1f79ea40d1133b2683a2f811b00f2399f7ec2401
F test/pagerfault3.test f16e2efcb5fc9996d1356f7cbc44c998318ae1d7
F test/pageropt.test 9191867ed19a2b3db6c42d1b36b6fbc657cd1ab0
@@ -643,7 +648,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/permutations.test dbda172249564f43ec556108a704581044c57dbd
F test/pragma.test c51c148defe32bf4a419a522f95d26838d5cf677
F test/pragma.test e284a28b6e9debfb8b55d5413b7c27996e3ae2cd
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301
@@ -687,7 +692,7 @@ F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532
F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25
F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977
F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118
F test/shared.test 34945a516532b11182c3eb26e31247eee3c9ae48
F test/shared.test 9d9b7085f877a8fd4bf3b353f53e52352edbf3f5
F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879
F test/shared3.test ebf77f023f4bdaa8f74f65822b559e86ce5c6257
F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d
@@ -710,23 +715,23 @@ F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298
F test/stat.test 08e8185b3fd5b010c90d7ad82b9dd4ea1cbf14b0
F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9
F test/stat.test 4ce96d67f6a0bc9647a042c7140cf1c56e049a69
F test/stmt.test 78a6764439cfa5abdcbf98d4d084739e81eeec4f
F test/subquery.test b524f57c9574b2c0347045b4510ef795d4686796
F test/subquery2.test edcad5c118f0531c2e21bf16a09bbb105252d4cd
F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4
F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2
F test/superlock.test 2b27b4ae7c6b9d534b0412e0d99f989aa1f3b9cf
F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85
F test/syscall.test bea9bf329bff733c791310244617c2a76974e64a
F test/sysfault.test c79441d88d23696fbec7b147dba98d42a04f523f
F test/table.test a59d985ca366e39b17b175f387f9d5db5a18d4e2
F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
F test/tclsqlite.test 1597d353308531527583481d14d9da52ea8ed0af
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
F test/tempdb.test 3263e5c3f0604e54d307481e8587327c54544d18
F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2
F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d
F test/tester.tcl 7db9e90e4a9cc57ea92118ee011634f86dc8e847
F test/tester.tcl 7925398e4f994a8296ecbe81c8f3575941928e77
F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@ -740,17 +745,17 @@ F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9
F test/threadtest3.c 0ed13e09690f6204d7455fac3b0e8ece490f6eef
F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c
F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660
F test/tkt-2d1a5c67d.test b028a811049eb472cb2d3a43fc8ce4f6894eebda
F test/tkt-2d1a5c67d.test 0e23cbbbecda6ce453ffb560fdac28489d491d36
F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28
F test/tkt-31338dca7e.test 1f714c14b6682c5db715e0bda347926a3456f7a9
F test/tkt-313723c356.test c47f8a9330523e6f35698bf4489bcb29609b53ac
F test/tkt-313723c356.test 54a1558d2719e171bd88967d66c73be4c617ec55
F test/tkt-38cb5df375.test f3cc8671f1eb604d4ae9cf886ed4366bec656678
F test/tkt-3998683a16.test 6d1d04d551ed1704eb3396ca87bb9ccc8c5c1eb7
F test/tkt-3a77c9714e.test 32bb28afa8c63fc76e972e996193139b63551ed9
F test/tkt-3fe897352e.test 10de1a67bd5c66b238a4c96abe55531b37bb4f00
F test/tkt-4a03edc4c8.test 2865e4edbc075b954daa82f8da7cc973033ec76e
F test/tkt-54844eea3f.test a12b851128f46a695e4e378cca67409b9b8f5894
F test/tkt-5d863f876e.test 884072c2de496ddbb90c387c9ebc0d4f44a91b8e
F test/tkt-5d863f876e.test b4b58f9e14ddd29f6e7577aad16b2d43b1237429
F test/tkt-5e10420e8d.test 904d1687b3c06d43e5b3555bbcf6802e7c0ffd84
F test/tkt-5ee23731f.test 9db6e1d7209dc0794948b260d6f82b2b1de83a9f
F test/tkt-752e1646fc.test ea78d88d14fe9866bdd991c634483334639e13bf
@@ -826,7 +831,7 @@ F test/tkt3357.test 77c37c6482b526fe89941ce951c22d011f5922ed
F test/tkt3419.test 1bbf36d7ea03b638c15804251287c2391f5c1f6b
F test/tkt3424.test 61f831bd2b071bd128fa5d00fbda57e656ca5812
F test/tkt3442.test 0adb70e9fe9cb750a702065a68ad647409dbc158
F test/tkt3457.test eb68bb3b19c8677cff06c639ff15d206dbf17fd6
F test/tkt3457.test 026dae357d34b416b07cf042794c0c83ea661d23
F test/tkt3461.test 228ea328a5a21e8663f80ee3d212a6ad92549a19
F test/tkt3493.test 1686cbde85f8721fc1bdc0ee72f2ef2f63139218
F test/tkt3508.test d75704db9501625c7f7deec119fcaf1696aefb7d
@@ -914,30 +919,30 @@ F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839
F test/wal.test 2fbf4bbd0cb03aff6ada8150f29808c79370d50b
F test/wal2.test 8871e7fd2c86711ff415a5817d68ea3101a15312
F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437
F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3
F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd
F test/wal8.test 5ab217d21f7e5e86af2933a4ffd0d8357cc2c0bd
F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe
F test/walbak.test b9f68e39646375c2b877be906babcc15d38b4877
F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434
F test/walcksum.test f5447800a157c9e2234fbb8e80243f0813941bde
F test/walcrash.test 4457436593be8c136f9148487c7dccd5e9013af2
F test/walcrash2.test 019d60b89d96c1937adb2b30b850ac7e86e5a142
F test/walcrash3.test 595e44c6197f0d0aa509fc135be2fd0209d11a2c
F test/walfault.test 97394d8de82a99f7abf1c12ed229640607fd0ad2
F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483
F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c
F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496
F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
F test/walro.test e6bb27762c9f22601cbb8bff6e0acfd124e74b63
F test/walshared.test 6dda2293880c300baf5d791c307f653094585761
F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a
F test/walthread.test a2ed5270eb695284d4ad27d252517bdc3317ee2a
F test/wal.test 9c29891ca329de5bba41dfa26b855ca82950e01c
F test/wal2.test ea811f7bc9abbc4282700c8969b175c31e884045
F test/wal3.test ae86a92d41d81730278fca0b71368f3e78e9c64a
F test/wal4.test 5755887f321baa4c55de0b91066fa7d0cafcac9d
F test/wal5.test 46a422956ec203bc5899dad5e70d9e655b1c91e4
F test/wal6.test c561d1e44c89f9cb458a7b03003ed4baac08ba07
F test/wal7.test 18cf68ab8010ae0a2baaa48e5b59567a9503e63e
F test/wal8.test a0b7dee73fc3d3bbf167e04533d37df379a0b7d1
F test/wal_common.tcl 15f152fd55703975878741beca6cfa4209d5b3b3
F test/walbak.test 8edea4daad739587f049633071d0f063fa808049
F test/walbig.test 3ca3d94751b80054eed5bda20a1339ae1f619483
F test/walcksum.test 6510e82303f6fffc2c55bb77a7774cd0eed21a6e
F test/walcrash.test a8fa8d8a9a50a49b7abaf8a4a7e2c7ea352c49be
F test/walcrash2.test c032d0040374ae28b41f99fc0cc290b4e2e34f17
F test/walcrash3.test 97e775404f4c76e5c46f71fbd09691c7e9c25c68
F test/walfault.test e5309befcaf4ab08151c35dba20cc5b8a5846748
F test/walhook.test 9716f865303130d7fcda61bcabb863090be9cca2
F test/walmode.test 9308ffc25555a1c4eaa44a863792240406637496
F test/walnoshm.test b1337ce99aabdf4da7a4a3f0c5ce1f05450bc3cc
F test/walpersist.test 12d1a54a5d5e06af0ec4bbd5421608a957ed8630
F test/walro.test 04d6382b2a87cfc82b87336eb8d8a8e9afd8bcf8
F test/walshared.test 04590b10c677f75318701818c50bc0dda5da64ab
F test/walslow.test 658066419a92d3bd85be71a11ce477af4ffe9153
F test/walthread.test c3aaf9ef7ad21ae79c2345425bfddb39cdac954f
F test/where.test de337a3fe0a459ec7c93db16a519657a90552330
F test/where2.test 43d4becaf5a5df854e6c21d624a1cb84c6904554
F test/where3.test 667e75642102c97a00bf9b23d3cb267db321d006
@@ -968,7 +973,7 @@ F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 105023aa86f696a74b1d6a4929d1e1c3baf9471c
F tool/mksqlite3c.tcl 9fbac513cd9d5ac95ad55630f49bb16c5347ab75
F tool/mksqlite3c.tcl 90f243ad9c76f814716452a4867a6a3befdb721a
F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8
F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091
@@ -999,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 196ca3a8b007b9f792e969893d981f6c5aa2fccc
R d4cee1bded14d0c2a35aac2c2a8ea01d
U drh
Z c8013359e2c16f7dbb75906fb62e335f
P 0c0150f2a349460d685e63be1a747d2bfbe5c8c4
R 4a632657509f5ed1cfb05420592ec8ff
U dan
Z fcb9e7416b7e86cf09e8dde2e964f1f0
+1 -1
View File
@@ -1 +1 @@
f9a7e179cbbeeab5e57bbf392bef89750215546b
86b8481be7e76cccc92d14ce762d21bfb69504af
+27
View File
@@ -68,8 +68,14 @@ static BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;
** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
*/
int sqlite3_enable_shared_cache(int enable){
#if defined(__APPLE__) && !defined(SQLITE_TEST) && !defined(TH3_COMPATIBILITY)
/* Enable global shared cache function for debugging and unit tests,
** but not for release */
return SQLITE_MISUSE;
#else
sqlite3GlobalConfig.sharedCacheEnabled = enable;
return SQLITE_OK;
#endif
}
#endif
@@ -2356,6 +2362,27 @@ static int lockBtree(BtShared *pBt){
if( rc!=SQLITE_OK ){
goto page1_init_failed;
}else if( isOpen==0 ){
#ifdef SQLITE_DEFAULT_WAL_SAFETYLEVEL
/* Default to specified safety_level for WAL mode */
if( pBt->db!=0 && pBt->db->aDb!=0 ){
int iDb;
sqlite3 *db = pBt->db;
Db *aDb = db->aDb;
u8 level = 0;
for(iDb=0; iDb<db->nDb; iDb++){
if( aDb[iDb].pBt && aDb[iDb].pBt->pBt==pBt ) break;
}
assert( iDb<db->nDb );
level = db->aDb[iDb].safety_level;
if( !SQLITE_DbSafetyLevelIsFixed(level) &&
(SQLITE_DbSafetyLevelValue(level) != SQLITE_DEFAULT_WAL_SAFETYLEVEL) ){
aDb[iDb].safety_level = SQLITE_DEFAULT_WAL_SAFETYLEVEL;
sqlite3PagerSetSafetyLevel(pBt->pPager, SQLITE_DEFAULT_WAL_SAFETYLEVEL,
(db->flags&SQLITE_FullFSync)!=0,
(db->flags&SQLITE_CkptFullFSync)!=0);
}
}
#endif
releasePage(pPage1);
return SQLITE_OK;
}
+3
View File
@@ -215,6 +215,9 @@ static void substrFunc(
}
}
}
#ifdef SQLITE_SUBSTR_COMPATIBILITY
if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */
#endif
if( argc==3 ){
p2 = sqlite3_value_int(argv[2]);
if( p2<0 ){
+9 -1
View File
@@ -16,6 +16,9 @@
*/
#include "sqliteInt.h"
#ifdef SQLITE_ENABLE_SQLRR
# include "sqlrr.h"
#endif
/*
** Execute SQL code. Return one of the SQLITE_ success/failure
@@ -43,7 +46,9 @@ int sqlite3_exec(
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
if( zSql==0 ) zSql = "";
#ifdef SQLITE_ENABLE_SQLRR
SRRecExec(db, zSql);
#endif
sqlite3_mutex_enter(db->mutex);
sqlite3Error(db, SQLITE_OK, 0);
while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0] ){
@@ -124,6 +129,9 @@ int sqlite3_exec(
exec_out:
if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
sqlite3DbFree(db, azCols);
#ifdef SQLITE_ENABLE_SQLRR
SRRecExecEnd(db);
#endif
rc = sqlite3ApiExit(db, rc);
if( rc!=SQLITE_OK && ALWAYS(rc==sqlite3_errcode(db)) && pzErrMsg ){
+149
View File
@@ -16,6 +16,9 @@
*/
#include "sqliteInt.h"
#ifdef SQLITE_ENABLE_SQLRR
# include "sqlrr.h"
#endif
#ifdef SQLITE_ENABLE_FTS3
# include "fts3.h"
#endif
@@ -844,6 +847,10 @@ int sqlite3_close(sqlite3 *db){
if( db->lookaside.bMalloced ){
sqlite3_free(db->lookaside.pStart);
}
#ifdef SQLITE_ENABLE_SQLRR
SRRecClose(db);
#endif
sqlite3_free(db);
return SQLITE_OK;
}
@@ -1842,6 +1849,44 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
}
return oldLimit; /* IMP: R-53341-35419 */
}
#if defined(SQLITE_ENABLE_AUTO_PROFILE)
/* stderr logging */
void _sqlite_auto_profile(void *aux, const char *sql, u64 ns);
void _sqlite_auto_trace(void *aux, const char *sql);
void _sqlite_auto_profile(void *aux, const char *sql, u64 ns) {
#pragma unused(aux)
fprintf(stderr, "Query: %s\n Execution Time: %llu ms\n", sql, ns / 1000000);
}
void _sqlite_auto_trace(void *aux, const char *sql) {
fprintf(stderr, "TraceSQL(%p): %s\n", aux, sql);
}
/* syslog logging */
#include <asl.h>
static aslclient autolog_client = NULL;
static void _close_asl_log() {
if( NULL!=autolog_client ){
asl_close(autolog_client);
autolog_client = NULL;
}
}
static void _open_asl_log() {
if( NULL==autolog_client ){
autolog_client = asl_open("SQLite", NULL, 0);
atexit(_close_asl_log);
}
}
void _sqlite_auto_profile_syslog(void *aux, const char *sql, u64 ns);
void _sqlite_auto_trace_syslog(void *aux, const char *sql);
void _sqlite_auto_profile_syslog(void *aux, const char *sql, u64 ns) {
#pragma unused(aux)
asl_log(autolog_client, NULL, ASL_LEVEL_NOTICE, "Query: %s\n Execution Time: %llu ms\n", sql, ns / 1000000);
}
void _sqlite_auto_trace_syslog(void *aux, const char *sql) {
asl_log(autolog_client, NULL, ASL_LEVEL_NOTICE, "TraceSQL(%p): %s\n", aux, sql);
}
#endif
/*
** This function is used to parse both URIs and non-URI filenames passed by the
@@ -2072,6 +2117,57 @@ int sqlite3ParseUri(
return rc;
}
#if defined(SQLITE_ENABLE_AUTO_PROFILE)
#define SQLITE_AUTOLOGGING_STDERR 1
#define SQLITE_AUTOLOGGING_SYSLOG 2
static void enableAutoLogging(
sqlite3 *db
){
char *envprofile = getenv("SQLITE_AUTO_PROFILE");
if( envprofile!=NULL ){
int where = 0;
if( !strncasecmp("1", envprofile, 1) ){
if( isatty(STDERR_FILENO) ){
where = SQLITE_AUTOLOGGING_STDERR;
}else{
where = SQLITE_AUTOLOGGING_SYSLOG;
}
} else if( !strncasecmp("stderr", envprofile, 6) ){
where = SQLITE_AUTOLOGGING_STDERR;
} else if( !strncasecmp("syslog", envprofile, 6) ){
where = SQLITE_AUTOLOGGING_SYSLOG;
}
if( where==SQLITE_AUTOLOGGING_STDERR ){
sqlite3_profile(db, _sqlite_auto_profile, db);
}else if( where==SQLITE_AUTOLOGGING_SYSLOG ){
_open_asl_log();
sqlite3_profile(db, _sqlite_auto_profile_syslog, db);
}
}
char *envtrace = getenv("SQLITE_AUTO_TRACE");
if( envtrace!=NULL ){
int where = 0;
if( !strncasecmp("1", envtrace, 1) ){
if( isatty(STDERR_FILENO) ){
where = SQLITE_AUTOLOGGING_STDERR;
}else{
where = SQLITE_AUTOLOGGING_SYSLOG;
}
} else if( !strncasecmp("stderr", envtrace, 6) ){
where = SQLITE_AUTOLOGGING_STDERR;
} else if( !strncasecmp("syslog", envtrace, 6) ){
where = SQLITE_AUTOLOGGING_SYSLOG;
}
if( where==SQLITE_AUTOLOGGING_STDERR ){
sqlite3_trace(db, _sqlite_auto_trace, db);
}else if( where==SQLITE_AUTOLOGGING_SYSLOG ){
_open_asl_log();
sqlite3_trace(db, _sqlite_auto_trace_syslog, db);
}
}
}
#endif
/*
** This routine does the work of opening a database on behalf of
@@ -2175,6 +2271,9 @@ static int openDatabase(
db->nextAutovac = -1;
db->nextPagesize = 0;
db->flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger
#if SQLITE_DEFAULT_CKPTFULLFSYNC
| SQLITE_CkptFullFSync
#endif
#if SQLITE_DEFAULT_FILE_FORMAT<4
| SQLITE_LegacyFileFmt
#endif
@@ -2330,7 +2429,30 @@ opendb_out:
}else if( rc!=SQLITE_OK ){
db->magic = SQLITE_MAGIC_SICK;
}
#if defined(__APPLE__) && ENABLE_FORCE_WAL
if( db && !rc ){
if ((0 == access("/var/db/enableForceWAL", R_OK))) {
#ifdef SQLITE_DEBUG
fprintf(stderr, "SQLite WAL journal_mode ENABLED by default.\n");
#endif
sqlite3_exec(db, "pragma journal_mode=wal", NULL, NULL, NULL);
#ifdef SQLITE_DEBUG
// } else {
// fprintf(stderr, "SQLite WAL journal_mode NOT ENABLED by default.\n");
#endif
}
}
#endif
#if defined(SQLITE_ENABLE_AUTO_PROFILE)
if( db && !rc ){
enableAutoLogging(db);
}
#endif
*ppDb = db;
#ifdef SQLITE_ENABLE_SQLRR
SRRecOpen(db, zFilename, flags);
#endif
return sqlite3ApiExit(0, rc);
}
@@ -3051,3 +3173,30 @@ int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
Btree *pBt = sqlite3DbNameToBtree(db, zDbName);
return pBt ? sqlite3PagerIsreadonly(sqlite3BtreePager(pBt)) : -1;
}
#if (SQLITE_ENABLE_APPLE_SPI>0) && defined(__APPLE__)
#include "sqlite3_private.h"
/*
** Testing a file path for sqlite locks held by a process ID.
** Returns SQLITE_LOCKSTATE_ON if locks are present on path
** that would prevent writing to the database.
*/
int _sqlite3_lockstate(const char *path, pid_t pid){
sqlite3 *db = NULL;
if( sqlite3_open_v2(path, &db, SQLITE_OPEN_READONLY, NULL) == SQLITE_OK ){
LockstatePID lockstate = {pid, -1};
sqlite3_file_control(db, NULL, SQLITE_FCNTL_LOCKSTATE_PID, &lockstate);
sqlite3_close(db);
int state = lockstate.state;
return state;
}
if( NULL!=db ){
sqlite3_close(db); /* need to close even if open returns an error */
}
return SQLITE_LOCKSTATE_ERROR;
}
#endif /* SQLITE_ENABLE_APPLE_SPI */
+7 -1
View File
@@ -153,12 +153,18 @@ int sqlite3OsOpen(
int *pFlagsOut
){
int rc;
int openFlags;
DO_OS_MALLOC_TEST(0);
/* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
** reaching the VFS. */
rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);
#if SQLITE_ENABLE_DATA_PROTECTION
openFlags = flags & (0x87f7f | SQLITE_OPEN_FILEPROTECTION_MASK);
#else
openFlags = flags & 0x87f7f;
#endif
rc = pVfs->xOpen(pVfs, zPath, pFile, openFlags, pFlagsOut);
assert( rc==SQLITE_OK || pFile->pMethods==0 );
return rc;
}
+1114 -58
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -2211,6 +2211,15 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
}
return SQLITE_OK;
}
case SQLITE_FCNTL_PERSIST_WAL: {
int bPersist = *(int*)pArg;
if( bPersist<0 ){
*(int*)pArg = pFile->bPersistWal;
}else{
pFile->bPersistWal = bPersist!=0;
}
return SQLITE_OK;
}
case SQLITE_FCNTL_PERSIST_WAL: {
winModeBit(pFile, WINFILE_PERSIST_WAL, (int*)pArg);
return SQLITE_OK;
+39 -9
View File
@@ -2386,7 +2386,11 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){
if( !pMaster ){
rc = SQLITE_NOMEM;
}else{
const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL);
const int flags =
#if SQLITE_ENABLE_DATA_PROTECTION
(pPager->vfsFlags&SQLITE_OPEN_FILEPROTECTION_MASK)|
#endif
(SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL);
rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0);
}
if( rc!=SQLITE_OK ) goto delmaster_out;
@@ -2422,7 +2426,11 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){
** so, return without deleting the master journal file.
*/
int c;
int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);
int flags =
#if SQLITE_ENABLE_DATA_PROTECTION
(pPager->vfsFlags&SQLITE_OPEN_FILEPROTECTION_MASK)|
#endif
(SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);
rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);
if( rc!=SQLITE_OK ){
goto delmaster_out;
@@ -3436,7 +3444,11 @@ static int pagerOpentemp(
sqlite3_opentemp_count++; /* Used for testing and analysis only */
#endif
vfsFlags |= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
vfsFlags |=
#if SQLITE_ENABLE_DATA_PROTECTION
(pPager->vfsFlags&SQLITE_OPEN_FILEPROTECTION_MASK)|
#endif
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;
rc = sqlite3OsOpen(pPager->pVfs, 0, pFile, vfsFlags, 0);
assert( rc!=SQLITE_OK || isOpen(pFile) );
@@ -4563,6 +4575,9 @@ int sqlite3PagerOpen(
pPager->readOnly = (u8)readOnly;
assert( useJournal || pPager->tempFile );
pPager->noSync = pPager->tempFile;
pPager->fullSync = pPager->noSync ?0:1;
pPager->syncFlags = pPager->noSync ? 0 : SQLITE_SYNC_NORMAL;
pPager->ckptSyncFlags = pPager->syncFlags;
if( pPager->noSync ){
assert( pPager->fullSync==0 );
assert( pPager->syncFlags==0 );
@@ -4684,7 +4699,11 @@ static int hasHotJournal(Pager *pPager, int *pExists){
** it can be ignored.
*/
if( !jrnlOpen ){
int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;
int f =
#if SQLITE_ENABLE_DATA_PROTECTION
(pPager->vfsFlags&SQLITE_OPEN_FILEPROTECTION_MASK)|
#endif
SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;
rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);
}
if( rc==SQLITE_OK ){
@@ -4819,7 +4838,11 @@ int sqlite3PagerSharedLock(Pager *pPager){
pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &bExists);
if( rc==SQLITE_OK && bExists ){
int fout = 0;
int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;
int f =
#if SQLITE_ENABLE_DATA_PROTECTION
(pPager->vfsFlags&SQLITE_OPEN_FILEPROTECTION_MASK)|
#endif
SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;
assert( !pPager->tempFile );
rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);
assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
@@ -5195,6 +5218,9 @@ static int pager_open_journal(Pager *pPager){
sqlite3MemJournalOpen(pPager->jfd);
}else{
const int flags = /* VFS flags to open journal file */
#if SQLITE_ENABLE_DATA_PROTECTION
(pPager->vfsFlags&SQLITE_OPEN_FILEPROTECTION_MASK)|
#endif
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|
(pPager->tempFile ?
(SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL):
@@ -6789,10 +6815,14 @@ static int pagerOpenWal(Pager *pPager){
** (e.g. due to malloc() failure), return an error code.
*/
if( rc==SQLITE_OK ){
rc = sqlite3WalOpen(pPager->pVfs,
pPager->fd, pPager->zWal, pPager->exclusiveMode,
pPager->journalSizeLimit, &pPager->pWal
);
#if SQLITE_ENABLE_DATA_PROTECTION
rc = sqlite3WalOpen(pPager->pVfs, pPager->fd, pPager->zWal, pPager->exclusiveMode,
pPager->journalSizeLimit, (pPager->vfsFlags & (SQLITE_OPEN_FILEPROTECTION_MASK | SQLITE_OPEN_READONLY)),
&pPager->pWal);
#else
rc = sqlite3WalOpen(pPager->pVfs, pPager->fd, pPager->zWal, pPager->exclusiveMode,
pPager->journalSizeLimit, (pPager->vfsFlags & SQLITE_OPEN_READONLY), &pPager->pWal);
#endif
}
return rc;
+43 -21
View File
@@ -145,12 +145,12 @@ static int changeTempStorage(Parse *pParse, const char *zStorageType){
/*
** Generate code to return a single integer value.
*/
static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
static void returnSingleInt(Parse *pParse, const char *zLabel, i64 *pValue){
Vdbe *v = sqlite3GetVdbe(pParse);
int mem = ++pParse->nMem;
i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));
i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(*pValue));
if( pI64 ){
memcpy(pI64, &value, sizeof(value));
memcpy(pI64, pValue, sizeof(*pValue));
}
sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64);
sqlite3VdbeSetNumCols(v, 1);
@@ -212,7 +212,8 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
assert( v!=0 ); /* Already allocated by sqlite3Pragma() */
if( ALWAYS(v) ){
if( zRight==0 ){
returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );
i64 value = ((db->flags & p->mask)!=0 ? 1 : 0);
returnSingleInt(pParse, p->zName, &value);
}else{
int mask = p->mask; /* Mask of bits to set or clear. */
if( db->autoCommit==0 ){
@@ -442,8 +443,8 @@ void sqlite3Pragma(
Btree *pBt = pDb->pBt;
assert( pBt!=0 );
if( !zRight ){
int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
returnSingleInt(pParse, "page_size", size);
i64 size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
returnSingleInt(pParse, "page_size", &size);
}else{
/* Malloc may fail when setting the page-size, as there is an internal
** buffer that the pager module resizes using sqlite3_realloc().
@@ -465,7 +466,7 @@ void sqlite3Pragma(
*/
if( sqlite3StrICmp(zLeft,"secure_delete")==0 ){
Btree *pBt = pDb->pBt;
int b = -1;
sqlite3_int64 b = -1;
assert( pBt!=0 );
if( zRight ){
b = sqlite3GetBoolean(zRight, 0);
@@ -473,11 +474,11 @@ void sqlite3Pragma(
if( pId2->n==0 && b>=0 ){
int ii;
for(ii=0; ii<db->nDb; ii++){
sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);
sqlite3BtreeSecureDelete(db->aDb[ii].pBt, (int)b);
}
}
b = sqlite3BtreeSecureDelete(pBt, b);
returnSingleInt(pParse, "secure_delete", b);
b = (int)sqlite3BtreeSecureDelete(pBt, (int)b);
returnSingleInt(pParse, "secure_delete", &b);
}else
/*
@@ -603,6 +604,20 @@ void sqlite3Pragma(
iDb = 0;
pId2->n = 1;
}
#ifdef SQLITE_DEFAULT_WAL_SAFETYLEVEL
if( ! SQLITE_DbSafetyLevelIsFixed(pDb->safety_level) ){
if( eMode == PAGER_JOURNALMODE_WAL ){
/* when entering wal mode, immediately switch the safety_level
** so that a query to pragma synchronous returns the correct value */
pDb->safety_level = SQLITE_DEFAULT_WAL_SAFETYLEVEL;
}else{
/* If the user hasn't overridden the synchronous setting, use the
** default for non-wal databases */
pDb->safety_level = 3;
}
}
#endif /* SQLITE_DEFAULT_WAL_SAFETYLEVEL */
for(ii=db->nDb-1; ii>=0; ii--){
if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
sqlite3VdbeUsesBtree(v, ii);
@@ -626,7 +641,7 @@ void sqlite3Pragma(
if( iLimit<-1 ) iLimit = -1;
}
iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
returnSingleInt(pParse, "journal_size_limit", iLimit);
returnSingleInt(pParse, "journal_size_limit", &iLimit);
}else
#endif /* SQLITE_OMIT_PAGER_PRAGMAS */
@@ -646,13 +661,13 @@ void sqlite3Pragma(
goto pragma_out;
}
if( !zRight ){
int auto_vacuum;
i64 auto_vacuum;
if( ALWAYS(pBt) ){
auto_vacuum = sqlite3BtreeGetAutoVacuum(pBt);
}else{
auto_vacuum = SQLITE_DEFAULT_AUTOVACUUM;
}
returnSingleInt(pParse, "auto_vacuum", auto_vacuum);
returnSingleInt(pParse, "auto_vacuum", &auto_vacuum);
}else{
int eAuto = getAutoVacuum(zRight);
assert( eAuto>=0 && eAuto<=2 );
@@ -732,7 +747,8 @@ void sqlite3Pragma(
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
if( !zRight ){
returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
i64 cacheSize = pDb->pSchema->cache_size;
returnSingleInt(pParse, "cache_size", &cacheSize);
}else{
int size = sqlite3Atoi(zRight);
pDb->pSchema->cache_size = size;
@@ -753,7 +769,8 @@ void sqlite3Pragma(
*/
if( sqlite3StrICmp(zLeft, "temp_store")==0 ){
if( !zRight ){
returnSingleInt(pParse, "temp_store", db->temp_store);
i64 tempStore = db->temp_store;
returnSingleInt(pParse, "temp_store", &tempStore);
}else{
changeTempStorage(pParse, zRight);
}
@@ -866,13 +883,16 @@ void sqlite3Pragma(
if( sqlite3StrICmp(zLeft,"synchronous")==0 ){
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
if( !zRight ){
returnSingleInt(pParse, "synchronous", pDb->safety_level-1);
u8 level = pDb->safety_level;
i64 safetyLevel = (i64)(SQLITE_DbSafetyLevelValue(level)-1);
returnSingleInt(pParse, "synchronous", &safetyLevel);
}else{
if( !db->autoCommit ){
sqlite3ErrorMsg(pParse,
"Safety level may not be changed inside a transaction");
}else{
pDb->safety_level = getSafetyLevel(zRight,0,1)+1;
u8 level = getSafetyLevel(zRight,0,1)+1;
pDb->safety_level = (level | SQLITE_SAFETYLEVEL_FIXED);
}
}
}else
@@ -1459,12 +1479,14 @@ void sqlite3Pragma(
** of N.
*/
if( sqlite3StrICmp(zLeft, "wal_autocheckpoint")==0 ){
i64 walArg = 0;
if( zRight ){
sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));
}
returnSingleInt(pParse, "wal_autocheckpoint",
db->xWalCallback==sqlite3WalDefaultHook ?
SQLITE_PTR_TO_INT(db->pWalArg) : 0);
if( db->xWalCallback==sqlite3WalDefaultHook ){
walArg = SQLITE_PTR_TO_INT(db->pWalArg);
}
returnSingleInt(pParse, "wal_autocheckpoint", &walArg);
}else
#endif
@@ -1559,7 +1581,7 @@ void sqlite3Pragma(
*/
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
if( db->autoCommit ){
sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,
sqlite3BtreeSetSafetyLevel(pDb->pBt, SQLITE_DbSafetyLevelValue(pDb->safety_level),
(db->flags&SQLITE_FullFSync)!=0,
(db->flags&SQLITE_CkptFullFSync)!=0);
}
+12 -1
View File
@@ -14,6 +14,9 @@
** from disk.
*/
#include "sqliteInt.h"
#ifdef SQLITE_ENABLE_SQLRR
# include "sqlrr.h"
#endif
/*
** Fill the InitData structure with an error message that indicates
@@ -763,6 +766,9 @@ int sqlite3_prepare(
){
int rc;
rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
#ifdef SQLITE_ENABLE_SQLRR
SRRecPrepare(db, zSql, nBytes, 0, *ppStmt);
#endif
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
@@ -775,6 +781,9 @@ int sqlite3_prepare_v2(
){
int rc;
rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail);
#ifdef SQLITE_ENABLE_SQLRR
SRRecPrepare(db, zSql, nBytes, 1, *ppStmt);
#endif
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
@@ -810,7 +819,9 @@ static int sqlite3Prepare16(
if( zSql8 ){
rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
}
#ifdef SQLITE_ENABLE_SQLRR
SRRecPrepare(db, zSql8, -1, 1, *ppStmt);
#endif
if( zTail8 && pzTail ){
/* If sqlite3_prepare returns a tail pointer, we calculate the
** equivalent pointer into the UTF-16 string by counting the unicode
+3
View File
@@ -4516,6 +4516,9 @@ select_end:
}
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
void sqlite3PrintExpr(Expr *p);
void sqlite3PrintExprList(ExprList *pList);
void sqlite3PrintSelect(Select *p, int indent);
/*
** Generate a human-readable description of a the Select object.
*/
+13 -3
View File
@@ -484,6 +484,7 @@ int sqlite3_exec(
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
#define SQLITE_OPEN_FILEPROTECTION_MASK 0x00700000
/* Reserved: 0x00F00000 */
@@ -832,9 +833,9 @@ struct sqlite3_io_methods {
** </ul>
*/
#define SQLITE_FCNTL_LOCKSTATE 1
#define SQLITE_GET_LOCKPROXYFILE 2
#define SQLITE_SET_LOCKPROXYFILE 3
#define SQLITE_LAST_ERRNO 4
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
#define SQLITE_FCNTL_LAST_ERRNO 4
#define SQLITE_FCNTL_SIZE_HINT 5
#define SQLITE_FCNTL_CHUNK_SIZE 6
#define SQLITE_FCNTL_FILE_POINTER 7
@@ -845,6 +846,10 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_VFSNAME 12
#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
#define SQLITE_FCNTL_PRAGMA 14
/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
/*
** CAPI3REF: Mutex Handle
@@ -4644,6 +4649,11 @@ void *sqlite3_update_hook(
** future releases of SQLite. Applications that care about shared
** cache setting should set it explicitly.
**
** ^Note: This method is deprecated on MacOS X 10.7 and iOS version 5.0
** and will always return SQLITE_MISUSE, instead of calling this function
** shared cache mode should be enabled per-database connection via
** sqlite3_open_v2 with SQLITE_OPEN_SHAREDCACHE instead.
**
** See Also: [SQLite Shared-Cache Mode]
*/
int sqlite3_enable_shared_cache(int);
+71
View File
@@ -0,0 +1,71 @@
/*
* sqlite3_private.h
*/
#ifndef _SQLITE3_PRIVATE_H
#define _SQLITE3_PRIVATE_H
#define SQLITE_LOCKSTATE_OFF 0
#define SQLITE_LOCKSTATE_ON 1
#define SQLITE_LOCKSTATE_NOTADB 2
#define SQLITE_LOCKSTATE_ERROR -1
#define SQLITE_LOCKSTATE_ANYPID -1
/*
** Test a file path for sqlite locks held by a process ID (-1 = any PID).
** Returns one of the following integer codes:
**
** SQLITE_LOCKSTATE_OFF no active sqlite file locks match the specified pid
** SQLITE_LOCKSTATE_ON active sqlite file locks match the specified pid
** SQLITE_LOCKSTATE_NOTADB path points to a file that is not an sqlite db file
** SQLITE_LOCKSTATE_ERROR path was not vaild or was unreadable
**
** There is no support for identifying db files encrypted via SEE encryption
** currently. Zero byte files are tested for sqlite locks, but if no sqlite
** locks are present then SQLITE_LOCKSTATE_NOTADB is returned.
*/
extern int _sqlite3_lockstate(const char *path, pid_t pid);
/*
** Test an open database connection for sqlite locks held by a process ID,
** if a process has an open database connection this will avoid trashing file
** locks by re-using open file descriptors for the database file and support
** files (-shm)
*/
#define SQLITE_FCNTL_LOCKSTATE_PID 103
/*
** Pass the SQLITE_TRUNCATE_DATABASE operation code to sqlite3_file_control()
** to truncate a database and its associated journal file to zero length. The
** SQLITE_TRUNCATE_* flags represent optional flags to safely initialize an
** empty database in the place of the truncated database, the flags are passed
** into sqlite3_file_control via the fourth argument using a pointer to an integer
** configured with the ORed flags. If the fourth argument is NULL, the default
** behavior is applied and the database file is truncated to zero bytes, a rollback
** journal (if present) is unlinked, a WAL journal (if present) is truncated to zero
** bytes and the first few bytes of the -shm file is scrambled to trigger existing
** connections to rebuild the index from the database file contents.
*/
#define SQLITE_FCNTL_TRUNCATE_DATABASE 101
#define SQLITE_TRUNCATE_DATABASE SQLITE_FCNTL_TRUNCATE_DATABASE
#define SQLITE_TRUNCATE_JOURNALMODE_WAL (0x1<<0)
#define SQLITE_TRUNCATE_AUTOVACUUM_MASK (0x3<<2)
#define SQLITE_TRUNCATE_AUTOVACUUM_OFF (0x1<<2)
#define SQLITE_TRUNCATE_AUTOVACUUM_FULL (0x2<<2)
#define SQLITE_TRUNCATE_AUTOVACUUM_INCREMENTAL (0x3<<2)
#define SQLITE_TRUNCATE_PAGESIZE_MASK (0x7<<4)
#define SQLITE_TRUNCATE_PAGESIZE_1024 (0x1<<4)
#define SQLITE_TRUNCATE_PAGESIZE_2048 (0x2<<4)
#define SQLITE_TRUNCATE_PAGESIZE_4096 (0x3<<4)
#define SQLITE_TRUNCATE_PAGESIZE_8192 (0x4<<4)
/*
** Pass the SQLITE_REPLACE_DATABASE operation code to sqlite3_file_control()
** and a sqlite3 pointer to another open database file to safely copy the
** contents of that database file into the receiving database.
*/
#define SQLITE_FCNTL_REPLACE_DATABASE 102
#define SQLITE_REPLACE_DATABASE SQLITE_FCNTL_REPLACE_DATABASE
#endif
+35
View File
@@ -674,6 +674,16 @@ typedef struct WhereLevel WhereLevel;
#include "os.h"
#include "mutex.h"
/* When using a default wal safety level, the safety level should only
** change with the journal mode if the user hasn't manually specified
** pragma synchronous, if they have the defaults shouldn't be applied.
** The SQLITE_SAFETYLEVEL_FIXED value is ORed into the Db->safety_level
** field when the user has specified a synchronous setting via pragma.
*/
#define SQLITE_SAFETYLEVEL_FIXED 0x10
#define SQLITE_SAFETYLEVEL_VALUE_MASK 0x03
#define SQLITE_DbSafetyLevelValue(level) (level&SQLITE_SAFETYLEVEL_VALUE_MASK)
#define SQLITE_DbSafetyLevelIsFixed(level) (level&SQLITE_SAFETYLEVEL_FIXED)
/*
** Each database file to be accessed by the system is an instance
@@ -3280,4 +3290,29 @@ SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...);
#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */
#define MEMTYPE_DB 0x10 /* Uses sqlite3DbMalloc, not sqlite_malloc */
#if (SQLITE_ENABLE_APPLE_SPI>0) && defined(__APPLE__)
/*
** An instance of the following structure is used to hold the process ID
** and return-by-reference lockstate value. The SQLITE_FCNTL_LOCKSTATE_PID
** requires the 4th argument to sqlite3_file_control to be a pointer to an
** instance of LockstatePID initialized with a LockstatePID.pid value equal
** to a process ID to be tested, or the special value SQLITE_LOCKSTATE_ANYPID
** The Lockstate.state value is always set to one of the following values
** when sqlite3_file_control returns:
**
** SQLITE_LOCKSTATE_OFF no active sqlite file locks match the specified pid
** SQLITE_LOCKSTATE_ON active sqlite file locks match the specified pid
** SQLITE_LOCKSTATE_NOTADB path points to a file that is not an sqlite db file
** SQLITE_LOCKSTATE_ERROR path was not vaild or was unreadable
*/
typedef struct LockstatePID LockstatePID;
struct LockstatePID {
pid_t pid; /* Process ID to test */
int state; /* The state of the lock (return value) */
};
#endif
#endif /* _SQLITEINT_H_ */
+206 -1
View File
@@ -3434,6 +3434,24 @@ static int test_clear_bindings(
return TCL_OK;
}
/*
** Usage: sqlite3_clear_bindings STMT
**
*/
static int test_clear_bindings_null(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
if( objc!=1 ){
return TCL_ERROR;
}
/* test for handling NULL <rdar://problem/6646331> */
Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_clear_bindings(0)));
return TCL_OK;
}
/*
** Usage: sqlite3_sleep MILLISECONDS
*/
@@ -5046,6 +5064,97 @@ static int file_control_lasterrno_test(
return TCL_OK;
}
#ifdef __APPLE__
/* From sqlite3_priavet.h */
# ifndef SQLITE_TRUNCATE_DATABASE
# define SQLITE_TRUNCATE_DATABASE 101
# define SQLITE_TRUNCATE_JOURNALMODE_WAL (0x1<<0)
# define SQLITE_TRUNCATE_AUTOVACUUM_MASK (0x3<<2)
# define SQLITE_TRUNCATE_AUTOVACUUM_OFF (0x1<<2)
# define SQLITE_TRUNCATE_AUTOVACUUM_FULL (0x2<<2)
# define SQLITE_TRUNCATE_AUTOVACUUM_INCREMENTAL (0x3<<2)
# define SQLITE_TRUNCATE_PAGESIZE_MASK (0x7<<4)
# define SQLITE_TRUNCATE_PAGESIZE_1024 (0x1<<4)
# define SQLITE_TRUNCATE_PAGESIZE_2048 (0x2<<4)
# define SQLITE_TRUNCATE_PAGESIZE_4096 (0x3<<4)
# define SQLITE_TRUNCATE_PAGESIZE_8192 (0x4<<4)
# endif
# ifndef SQLITE_REPLACE_DATABASE
# define SQLITE_REPLACE_DATABASE 102
# endif
/*
** tclcmd: file_control_truncate_test DB
**
** This TCL command runs the sqlite3_file_control interface and
** verifies correct operation of the SQLITE_TRUNCATE_DATABASE verb.
*/
static int file_control_truncate_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
sqlite3 *db;
int flags;
int rc;
if( objc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"",
Tcl_GetStringFromObj(objv[0], 0), " DB FLAGS", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){
return TCL_ERROR;
}
if( Tcl_GetIntFromObj(interp, objv[2], &flags) ){
return TCL_ERROR;
}
rc = sqlite3_file_control(db, NULL, SQLITE_TRUNCATE_DATABASE, &flags);
if( rc ){
Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
return TCL_ERROR;
}
return TCL_OK;
}
/*
** tclcmd: file_control_replace_test DB
**
** This TCL command runs the sqlite3_file_control interface and
** verifies correct operation of the SQLITE_REPLACE_DATABASE verb.
*/
static int file_control_replace_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
int iArg = 0;
sqlite3 *src_db;
sqlite3 *dst_db;
int rc;
if( objc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"",
Tcl_GetStringFromObj(objv[0], 0), " DST_DB SRC_DB", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &dst_db) ){
return TCL_ERROR;
}
if( getDbPointer(interp, Tcl_GetString(objv[2]), &src_db) ){
return TCL_ERROR;
}
rc = sqlite3_file_control(dst_db, NULL, SQLITE_REPLACE_DATABASE, src_db);
if( rc ){
Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
return TCL_ERROR;
}
return TCL_OK;
}
#endif /* __APPLE__ */
/*
** tclcmd: file_control_chunksize_test DB DBNAME SIZE
**
@@ -5191,6 +5300,96 @@ static int file_control_lockproxy_test(
return TCL_OK;
}
#ifdef __APPLE__
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/errno.h>
#endif
/*
** tclcmd: path_is_local PWD
*/
static int path_is_local(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
const char *zPath;
int nPath;
if( objc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"",
Tcl_GetStringFromObj(objv[0], 0), " PATH", 0);
return TCL_ERROR;
}
zPath = Tcl_GetStringFromObj(objv[1], &nPath);
#ifdef __APPLE__
{
struct statfs fsInfo;
if( statfs(zPath, &fsInfo) == -1 ){
int err = errno;
Tcl_AppendResult(interp, "Error calling statfs on path",
Tcl_NewIntObj(err), 0);
return TCL_ERROR;
}
if( fsInfo.f_flags&MNT_LOCAL ){
Tcl_SetObjResult(interp, Tcl_NewIntObj(1));
} else {
Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
}
}
#else
Tcl_SetObjResult(interp, Tcl_NewIntObj(1));
#endif
return TCL_OK;
}
/*
** tclcmd: path_is_dos PWD
*/
static int path_is_dos(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
const char *zPath;
int nPath;
if( objc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"",
Tcl_GetStringFromObj(objv[0], 0), " PATH", 0);
return TCL_ERROR;
}
zPath = Tcl_GetStringFromObj(objv[1], &nPath);
#ifdef __APPLE__
{
struct statfs fsInfo;
if( statfs(zPath, &fsInfo) == -1 ){
int err = errno;
Tcl_AppendResult(interp, "Error calling statfs on path",
Tcl_NewIntObj(err), 0);
return TCL_ERROR;
}
if (0 == strncmp("msdos", fsInfo.f_fstypename, 5)) {
Tcl_SetObjResult(interp, Tcl_NewIntObj(1));
} else if (0 == strncmp("exfat", fsInfo.f_fstypename, 5)) {
Tcl_SetObjResult(interp, Tcl_NewIntObj(1));
} else {
Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
}
}
#else
Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
#endif
return TCL_OK;
}
/*
** tclcmd: file_control_win32_av_retry DB NRETRY DELAY
**
@@ -5255,7 +5454,6 @@ static int file_control_persist_wal(
Tcl_AppendResult(interp, z, (char*)0);
return TCL_OK;
}
/*
** tclcmd: file_control_powersafe_overwrite DB PSOW-FLAG
**
@@ -6049,6 +6247,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_bind_parameter_name", test_bind_parameter_name, 0},
{ "sqlite3_bind_parameter_index", test_bind_parameter_index, 0},
{ "sqlite3_clear_bindings", test_clear_bindings, 0},
{ "sqlite3_clear_bindings_null", test_clear_bindings_null, 0},
{ "sqlite3_sleep", test_sleep, 0},
{ "sqlite3_errcode", test_errcode ,0 },
{ "sqlite3_extended_errcode", test_ex_errcode ,0 },
@@ -6144,6 +6343,10 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "file_control_test", file_control_test, 0 },
{ "file_control_lasterrno_test", file_control_lasterrno_test, 0 },
{ "file_control_lockproxy_test", file_control_lockproxy_test, 0 },
#ifdef __APPLE__
{ "file_control_truncate_test", file_control_truncate_test, 0 },
{ "file_control_replace_test", file_control_replace_test, 0 },
#endif
{ "file_control_chunksize_test", file_control_chunksize_test, 0 },
{ "file_control_sizehint_test", file_control_sizehint_test, 0 },
{ "file_control_win32_av_retry", file_control_win32_av_retry, 0 },
@@ -6152,6 +6355,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "file_control_vfsname", file_control_vfsname, 0 },
{ "sqlite3_vfs_list", vfs_list, 0 },
{ "sqlite3_create_function_v2", test_create_function_v2, 0 },
{ "path_is_local", path_is_local, 0 },
{ "path_is_dos", path_is_dos, 0 },
/* Functions from os.h */
#ifndef SQLITE_OMIT_UTF16
+1 -1
View File
@@ -14,7 +14,7 @@
*/
#include "tcl.h"
#include <sqlite3.h>
#include "sqlite3.h"
#include <assert.h>
/* These functions are implemented in test1.c. */
+27 -1
View File
@@ -455,7 +455,17 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double",
#else
Tcl_SetVar2(interp,"sqlite_options","prefer_proxy_locking","0",TCL_GLOBAL_ONLY);
#endif
#if SQLITE_DEFAULT_CKPTFULLFSYNC
Tcl_SetVar2(interp,"sqlite_options","default_ckptfullfsync","1",TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp,"sqlite_options","default_ckptfullfsync","0",TCL_GLOBAL_ONLY);
#endif
#if SQLITE_DEFAULT_WAL_SAFETYLEVEL
Tcl_SetVar2(interp,"sqlite_options","default_wal_safetylevel",
STRINGVALUE(SQLITE_DEFAULT_WAL_SAFETYLEVEL),TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp,"sqlite_options","default_wal_safetylevel","0",TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_OMIT_SHARED_CACHE
Tcl_SetVar2(interp, "sqlite_options", "shared_cache", "0", TCL_GLOBAL_ONLY);
@@ -568,6 +578,22 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double",
#else
Tcl_SetVar2(interp, "sqlite_options", "yytrackmaxstackdepth", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef __APPLE__
# if defined(__ppc__)
Tcl_SetVar2(interp, "os_options", "arch", "ppc", TCL_GLOBAL_ONLY);
# elif defined(__i386__)
Tcl_SetVar2(interp, "os_options", "arch", "i386", TCL_GLOBAL_ONLY);
# elif defined(__x86_64__)
Tcl_SetVar2(interp, "os_options", "arch", "x86_64", TCL_GLOBAL_ONLY);
# elif defined(__arm__)
Tcl_SetVar2(interp, "os_options", "arch", "arm", TCL_GLOBAL_ONLY);
# else
# error Unrecognized architecture for exec_options
# endif
#else
Tcl_SetVar2(interp, "os_options", "arch", "unknown", TCL_GLOBAL_ONLY);
#endif
#define LINKVAR(x) { \
static const int cv_ ## x = SQLITE_ ## x; \
+1 -1
View File
@@ -13,7 +13,7 @@
** is not included in the SQLite library.
*/
#include <sqlite3.h>
#include "sqlite3.h"
/* Solely for the UNUSED_PARAMETER() macro. */
#include "sqliteInt.h"
+6 -5
View File
@@ -18,7 +18,7 @@
** sqlite3demo_superunlock()
*/
#include <sqlite3.h>
#include "sqlite3.h"
#include <string.h> /* memset(), strlen() */
#include <assert.h> /* assert() */
@@ -148,7 +148,7 @@ static int superlockWalLock(
** this function must have been obtained from a successful call to
** sqlite3demo_superlock().
*/
void sqlite3demo_superunlock(void *pLock){
static void sqlite3demo_superunlock(void *pLock){
Superlock *p = (Superlock *)pLock;
if( p->bWal ){
int rc; /* Return code */
@@ -179,9 +179,10 @@ void sqlite3demo_superunlock(void *pLock){
** until either the lock can be obtained or the busy-handler function returns
** 0 (indicating "give up").
*/
int sqlite3demo_superlock(
static int sqlite3demo_superlock(
const char *zPath, /* Path to database file to lock */
const char *zVfs, /* VFS to use to access database file */
int flags, /* Additional flags to pass to sqlite3_open_v2 */
int (*xBusy)(void*,int), /* Busy handler callback */
void *pBusyArg, /* Context arg for busy handler */
void **ppLock /* OUT: Context to pass to superunlock() */
@@ -196,7 +197,7 @@ int sqlite3demo_superlock(
/* Open a database handle on the file to superlock. */
rc = sqlite3_open_v2(
zPath, &pLock->db, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs
zPath, &pLock->db, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|flags, zVfs
);
/* Install a busy-handler and execute a BEGIN EXCLUSIVE. If this is not
@@ -331,7 +332,7 @@ static int superlock_cmd(
xBusy = superlock_busy;
}
rc = sqlite3demo_superlock(zPath, zVfs, xBusy, &busy, &pLock);
rc = sqlite3demo_superlock(zPath, zVfs, 0, xBusy, &busy, &pLock);
assert( rc==SQLITE_OK || pLock==0 );
assert( rc!=SQLITE_OK || pLock!=0 );
+1 -1
View File
@@ -579,7 +579,7 @@ int sqlite3VdbeExec(
** sqlite3_column_text16() failed. */
goto no_mem;
}
assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY );
assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || ((p->rc&0xFF) == SQLITE_LOCKED));
p->rc = SQLITE_OK;
assert( p->explain==0 );
p->pResultSet = 0;
+46 -2
View File
@@ -15,6 +15,9 @@
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
#ifdef SQLITE_ENABLE_SQLRR
# include "sqlrr.h"
#endif
#ifndef SQLITE_OMIT_DEPRECATED
/*
@@ -37,7 +40,8 @@ int sqlite3_expired(sqlite3_stmt *pStmt){
** invalid). Return false if it is ok.
*/
static int vdbeSafety(Vdbe *p){
if( p->db==0 ){
sqlite3* db = p->db;
if((db==0) || (db->magic != SQLITE_MAGIC_OPEN) || ((p->magic != VDBE_MAGIC_RUN) && (p->magic != VDBE_MAGIC_HALT))){
sqlite3_log(SQLITE_MISUSE, "API called with finalized prepared statement");
return 1;
}else{
@@ -70,6 +74,9 @@ int sqlite3_finalize(sqlite3_stmt *pStmt){
rc = SQLITE_OK;
}else{
Vdbe *v = (Vdbe*)pStmt;
#ifdef SQLITE_ENABLE_SQLRR
SRRecFinalize(pStmt);
#endif
sqlite3 *db = v->db;
#if SQLITE_THREADSAFE
sqlite3_mutex *mutex;
@@ -100,6 +107,9 @@ int sqlite3_reset(sqlite3_stmt *pStmt){
rc = SQLITE_OK;
}else{
Vdbe *v = (Vdbe*)pStmt;
#ifdef SQLITE_ENABLE_SQLRR
SRRecReset(pStmt);
#endif
sqlite3_mutex_enter(v->db->mutex);
rc = sqlite3VdbeReset(v);
sqlite3VdbeRewind(v);
@@ -118,7 +128,14 @@ int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
int rc = SQLITE_OK;
Vdbe *p = (Vdbe*)pStmt;
#if SQLITE_THREADSAFE
sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
sqlite3_mutex *mutex=NULL;
#endif
if( NULL==pStmt ){ return SQLITE_OK; } /* <rdar://problem/6646331> */
#ifdef SQLITE_ENABLE_SQLRR
SRRecClearBindings(pStmt);
#endif
#if SQLITE_THREADSAFE
mutex = ((Vdbe*)pStmt)->db->mutex;
#endif
sqlite3_mutex_enter(mutex);
for(i=0; i<p->nVar; i++){
@@ -1070,11 +1087,17 @@ int sqlite3_bind_blob(
int nData,
void (*xDel)(void*)
){
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindBlob(pStmt, i, zData, nData);
#endif
return bindText(pStmt, i, zData, nData, xDel, 0);
}
int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
int rc;
Vdbe *p = (Vdbe *)pStmt;
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindDouble(pStmt, i, rValue);
#endif
rc = vdbeUnbind(p, i);
if( rc==SQLITE_OK ){
sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
@@ -1083,11 +1106,17 @@ int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
return rc;
}
int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindInt64(p, i, (i64)iValue);
#endif
return sqlite3_bind_int64(p, i, (i64)iValue);
}
int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
int rc;
Vdbe *p = (Vdbe *)pStmt;
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindInt64(pStmt, i, iValue);
#endif
rc = vdbeUnbind(p, i);
if( rc==SQLITE_OK ){
sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
@@ -1098,6 +1127,9 @@ int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
int rc;
Vdbe *p = (Vdbe*)pStmt;
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindNull(pStmt, i);
#endif
rc = vdbeUnbind(p, i);
if( rc==SQLITE_OK ){
sqlite3_mutex_leave(p->db->mutex);
@@ -1111,6 +1143,9 @@ int sqlite3_bind_text(
int nData,
void (*xDel)(void*)
){
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindText(pStmt, i, zData, nData);
#endif
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
}
#ifndef SQLITE_OMIT_UTF16
@@ -1121,6 +1156,9 @@ int sqlite3_bind_text16(
int nData,
void (*xDel)(void*)
){
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindText(pStmt, i, zData, nData);
#endif
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
}
#endif /* SQLITE_OMIT_UTF16 */
@@ -1144,6 +1182,9 @@ int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
break;
}
case SQLITE_TEXT: {
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindText(pStmt, i, pValue->z, pValue->n);
#endif
rc = bindText(pStmt,i, pValue->z, pValue->n, SQLITE_TRANSIENT,
pValue->enc);
break;
@@ -1158,6 +1199,9 @@ int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
int rc;
Vdbe *p = (Vdbe *)pStmt;
#ifdef SQLITE_ENABLE_SQLRR
SRRecBindBlob(pStmt, i, NULL, n);
#endif
rc = vdbeUnbind(p, i);
if( rc==SQLITE_OK ){
sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);
+2
View File
@@ -1515,6 +1515,8 @@ void sqlite3VdbeMakeReady(
assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
p->expired = 0;
p->expired = 0;
/* Memory for registers, parameters, cursor, etc, is allocated in two
** passes. On the first pass, we try to reuse unused space at the
** end of the opcode array. If we are unable to satisfy all memory
+4 -1
View File
@@ -85,9 +85,12 @@ char *sqlite3VdbeExpandSql(
if( db->vdbeExecCnt>1 ){
while( *zRawSql ){
const char *zStart = zRawSql;
sqlite_int64 iStart = SQLITE_PTR_TO_INT(zRawSql);
sqlite_int64 iCurrent;
while( *(zRawSql++)!='\n' && *zRawSql );
sqlite3StrAccumAppend(&out, "-- ", 3);
sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
iCurrent = SQLITE_PTR_TO_INT(zRawSql);
sqlite3StrAccumAppend(&out, zStart, (int)(iCurrent-iStart));
}
}else{
while( zRawSql[0] ){
+41 -5
View File
@@ -1253,11 +1253,12 @@ int sqlite3WalOpen(
const char *zWalName, /* Name of the WAL file */
int bNoShm, /* True to run in heap-memory mode */
i64 mxWalSize, /* Truncate WAL to this size on reset */
int flags, /* VFS file protection flags */
Wal **ppWal /* OUT: Allocated Wal handle */
){
int rc; /* Return Code */
Wal *pRet; /* Object to allocate and return */
int flags; /* Flags passed to OsOpen() */
int vfsFlags; /* Flags passed to OsOpen() */
assert( zWalName && zWalName[0] );
assert( pDbFd );
@@ -1292,9 +1293,13 @@ int sqlite3WalOpen(
pRet->exclusiveMode = (bNoShm ? WAL_HEAPMEMORY_MODE: WAL_NORMAL_MODE);
/* Open file handle on the write-ahead log file. */
flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);
rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);
if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){
if( flags&SQLITE_OPEN_READONLY ){
vfsFlags = flags | SQLITE_OPEN_WAL;
} else {
vfsFlags = flags | (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);
}
rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, vfsFlags, &vfsFlags);
if( rc==SQLITE_OK && vfsFlags&SQLITE_OPEN_READONLY ){
pRet->readOnly = WAL_RDONLY;
}
@@ -1913,6 +1918,9 @@ static int walIndexTryHdr(Wal *pWal, int *pChanged){
** reordering the reads and writes.
*/
aHdr = walIndexHdr(pWal);
if( aHdr==NULL ){
return 1; /* Shouldn't be getting NULL from walIndexHdr, but we are */
}
memcpy(&h1, (void *)&aHdr[0], sizeof(h1));
walShmBarrier(pWal);
memcpy(&h2, (void *)&aHdr[1], sizeof(h2));
@@ -2097,7 +2105,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
*/
if( cnt>5 ){
int nDelay = 1; /* Pause time in microseconds */
if( cnt>100 ){
if( cnt>500 ){
VVA_ONLY( pWal->lockError = 1; )
return SQLITE_PROTOCOL;
}
@@ -2644,6 +2652,10 @@ typedef struct WalWriter {
sqlite3_int64 iSyncPoint; /* Fsync at this offset */
int syncFlags; /* Flags for the fsync */
int szPage; /* Size of one page */
#if defined(SQLITE_WRITE_WALFRAME_PREBUFFERED)
void *aFrameBuf; /* Frame buffer */
size_t szFrameBuf; /* Size of frame buffer */
#endif
} WalWriter;
/*
@@ -2687,17 +2699,31 @@ static int walWriteOneFrame(
){
int rc; /* Result code from subfunctions */
void *pData; /* Data actually written */
#if defined(SQLITE_WRITE_WALFRAME_PREBUFFERED)
void *aFrame;
aFrame = p->aFrameBuf;
#else
u8 aFrame[WAL_FRAME_HDRSIZE]; /* Buffer to assemble frame-header in */
#endif
#if defined(SQLITE_HAS_CODEC)
if( (pData = sqlite3PagerCodec(pPage))==0 ) return SQLITE_NOMEM;
#else
pData = pPage->pData;
#endif
walEncodeFrame(p->pWal, pPage->pgno, nTruncate, pData, aFrame);
#if defined(SQLITE_WRITE_WALFRAME_PREBUFFERED)
memcpy(&aFrame[WAL_FRAME_HDRSIZE], pData, p->szPage);
rc = walWriteToLog(p, aFrame, (p->szPage + WAL_FRAME_HDRSIZE), iOffset);
#else
rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);
if( rc ) return rc;
/* Write the page data */
rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));
#endif
return rc;
}
@@ -2796,6 +2822,13 @@ int sqlite3WalFrames(
w.szPage = szPage;
iOffset = walFrameOffset(iFrame+1, szPage);
szFrame = szPage + WAL_FRAME_HDRSIZE;
#if defined(SQLITE_WRITE_WALFRAME_PREBUFFERED)
w.aFrameBuf = (void *)malloc(szFrame);
if( NULL==w.aFrameBuf ){
return SQLITE_NOMEM;
}
#endif
/* Write all frames into the log file exactly once */
for(p=pList; p; p=p->pDirty){
@@ -2838,6 +2871,9 @@ int sqlite3WalFrames(
}
}
#if defined(SQLITE_WRITE_WALFRAME_PREBUFFERED)
free(w.aFrameBuf);
#endif
/* If this frame set completes the first transaction in the WAL and
** if PRAGMA journal_size_limit is set, then truncate the WAL to the
** journal size limit, if possible.
+1 -1
View File
@@ -54,7 +54,7 @@
typedef struct Wal Wal;
/* Open and close a connection to a write-ahead log. */
int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);
int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, int, Wal**);
int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *);
/* Set the limiting size of a WAL file. */
+2
View File
@@ -146,6 +146,8 @@ ifcapable !wal {
finish_test
return
}
if ![wal_is_ok] { finish_test; return }
db close
forcedelete test.db
do_test 8_3_names-5.0 {
+18 -17
View File
@@ -737,23 +737,24 @@ do_test attach-6.1 {
}
} {0 {}}
if {$tcl_platform(platform)=="unix"} {
do_test attach-6.2 {
sqlite3 dbx cannot-read
dbx eval {CREATE TABLE t1(a,b,c)}
dbx close
file attributes cannot-read -permission 0000
if {[file writable cannot-read]} {
puts "\n**** Tests do not work when run as root ****"
forcedelete cannot-read
exit 1
}
catchsql {
ATTACH DATABASE 'cannot-read' AS noread;
}
} {1 {unable to open database: cannot-read}}
do_test attach-6.2.2 {
db errorcode
} {14}
sqlite3 dbx cannot-read
dbx eval {CREATE TABLE t1(a,b,c)}
dbx close
file attributes cannot-read -permission 0000
if {[file writable cannot-read]} {
#puts "\n**** Tests do not work when run as root ****"
forcedelete cannot-read
#exit 1
} else {
do_test attach-6.2 {
catchsql {
ATTACH DATABASE 'cannot-read' AS noread;
}
} {1 {unable to open database: cannot-read}}
do_test attach-6.2.2 {
db errorcode
} {14}
}
forcedelete cannot-read
}
+1
View File
@@ -80,6 +80,7 @@ foreach {name f} $files {
set mode wal
}
ifcapable !wal { set mode delete }
if ![wal_is_ok] { set mode delete }
lappend L $mode
append S "
PRAGMA $name.journal_mode = WAL;
+3
View File
@@ -656,6 +656,9 @@ do_test bind-13.4 {
[sqlite3_column_type $VM 2]
} {NULL NULL NULL}
sqlite3_finalize $VM
do_test bind-13.5 {
sqlite3_clear_bindings_null
} {0}
#--------------------------------------------------------------------
# These tests attempt to reproduce bug #3463.
+6
View File
@@ -901,6 +901,12 @@ do_test capi3-11.9.3 {
do_test capi3-11.10 {
sqlite3_step $STMT
} {SQLITE_ERROR}
ifcapable !autoreset {
# If SQLITE_OMIT_AUTORESET is defined, then the statement must be
# reset() before it can be passed to step() again.
do_test capi3-11.11a { sqlite3_step $STMT } {SQLITE_MISUSE}
do_test capi3-11.11b { sqlite3_reset $STMT } {SQLITE_ABORT}
}
do_test capi3-11.11 {
sqlite3_step $STMT
} {SQLITE_ROW}
+6
View File
@@ -856,6 +856,12 @@ do_test capi3c-11.9.3 {
do_test capi3c-11.10 {
sqlite3_step $STMT
} {SQLITE_ABORT}
ifcapable !autoreset {
# If SQLITE_OMIT_AUTORESET is defined, then the statement must be
# reset() before it can be passed to step() again.
do_test capi3-11.11a { sqlite3_step $STMT } {SQLITE_MISUSE}
do_test capi3-11.11b { sqlite3_reset $STMT } {SQLITE_ABORT}
}
do_test capi3c-11.11 {
sqlite3_step $STMT
} {SQLITE_ROW}
+1 -5
View File
@@ -401,12 +401,8 @@ sqlite3 db test.db
# if we're using proxy locks, we use 3 filedescriptors for a db
# that is open but NOT writing changes, normally
# sqlite uses 1 (proxy locking adds the conch and the local lock)
set using_proxy 0
foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
set using_proxy $value
}
set extrafds 0
if {$using_proxy!=0} {
if {[forced_proxy_locking]} {
set extrafds 2
}
+2
View File
@@ -76,10 +76,12 @@ set skipwaltests [expr {
[permutation]=="journaltest" || [permutation]=="inmemory_journal"
}]
ifcapable !wal { set skipwaltests 1 }
if {![wal_is_ok]} { set skipwaltests 1 }
if {!$skipwaltests} {
db close
forcedelete test.db
if {[forced_proxy_locking]} { file delete -force .test.db-conch }
sqlite3 db test.db
file_control_chunksize_test db main [expr 32*1024]
+11 -6
View File
@@ -260,12 +260,17 @@ proc access_method {args} {
return ""
}
do_test incrblob3-7.2 {
sqlite3 db test.db
sqlite3_db_config_lookaside db 0 0 0
list [catch {db incrblob blobs v 1} msg] $msg
} {1 {database schema has changed}}
db close
#set sqlite_os_trace 1
# AFP asserts because the "db incrblob blobs v 1" clears the file locks and the unlock fails (HFS doesn't care about a failed unlock)
if {[path_is_local "."]} {
do_test incrblob3-7.2 {
sqlite3 db test.db
sqlite3_db_config_lookaside db 0 0 0
list [catch {db incrblob blobs v 1} msg] $msg
} {1 {database schema has changed}}
db close
}
tvfs delete
finish_test
+6 -1
View File
@@ -15,6 +15,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/wal_common.tcl
# If this build of the library does not support auto-vacuum, omit this
# whole file.
@@ -134,6 +135,8 @@ do_test incrvacuum2-3.2 {
integrity_check incrvacuum2-3.3
if ![wal_is_ok] { finish_test; return }
ifcapable wal {
# At one point, when a specific page was being extracted from the b-tree
# free-list (e.g. during an incremental-vacuum), all trunk pages that
@@ -188,8 +191,10 @@ ifcapable wal {
execsql {
PRAGMA journal_mode = WAL;
PRAGMA incremental_vacuum(1);
PRAGMA wal_checkpoint;
}
} {wal}
do_test 4.2.1 {
execsql { PRAGMA wal_checkpoint }
file size test.db-wal
} [expr {32+2*(512+24)}]
+1 -1
View File
@@ -20,7 +20,7 @@ source $testdir/malloc_common.tcl
# If a connection is required to create a journal file, it creates it with
# the same file-system permissions as the database file itself. Test this.
#
if {$::tcl_platform(platform) == "unix"} {
if {$::tcl_platform(platform) == "unix" && ![path_is_dos "."]} {
# Changed on 2012-02-13: umask is deliberately ignored for -wal, -journal,
# and -shm files.
+73 -69
View File
@@ -106,87 +106,91 @@ if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} {
return
}
do_test lock5-flock.1 {
sqlite3 db test.db -vfs unix-flock
execsql {
CREATE TABLE t1(a, b);
BEGIN;
INSERT INTO t1 VALUES(1, 2);
}
} {}
# Only run the flock tests on a local file system
if { [path_is_local "."] } {
# Make sure we are not accidentally using the dotfile locking scheme.
do_test lock5-flock.2 {
file exists test.db.lock
} {0}
do_test lock5-flock.1 {
sqlite3 db test.db -vfs unix-flock
execsql {
CREATE TABLE t1(a, b);
BEGIN;
INSERT INTO t1 VALUES(1, 2);
}
} {}
do_test lock5-flock.3 {
catch { sqlite3 db2 test.db -vfs unix-flock }
catchsql { SELECT * FROM t1 } db2
} {1 {database is locked}}
# Make sure we are not accidentally using the dotfile locking scheme.
do_test lock5-flock.2 {
file exists test.db.lock
} {0}
do_test lock5-flock.4 {
execsql COMMIT
catchsql { SELECT * FROM t1 } db2
} {0 {1 2}}
do_test lock5-flock.3 {
catch { sqlite3 db2 test.db -vfs unix-flock }
catchsql { SELECT * FROM t1 } db2
} {1 {database is locked}}
do_test lock5-flock.5 {
execsql BEGIN
catchsql { SELECT * FROM t1 } db2
} {0 {1 2}}
do_test lock5-flock.4 {
execsql COMMIT
catchsql { SELECT * FROM t1 } db2
} {0 {1 2}}
do_test lock5-flock.6 {
execsql {SELECT * FROM t1}
catchsql { SELECT * FROM t1 } db2
} {1 {database is locked}}
do_test lock5-flock.5 {
execsql BEGIN
catchsql { SELECT * FROM t1 } db2
} {0 {1 2}}
do_test lock5-flock.7 {
db close
catchsql { SELECT * FROM t1 } db2
} {0 {1 2}}
do_test lock5-flock.6 {
execsql {SELECT * FROM t1}
catchsql { SELECT * FROM t1 } db2
} {1 {database is locked}}
do_test lock5-flock.8 {
db2 close
} {}
do_test lock5-flock.7 {
db close
catchsql { SELECT * FROM t1 } db2
} {0 {1 2}}
#####################################################################
do_test lock5-flock.8 {
db2 close
} {}
do_test lock5-none.1 {
sqlite3 db test.db -vfs unix-none
sqlite3 db2 test.db -vfs unix-none
execsql {
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
} {}
do_test lock5-none.2 {
execsql { SELECT * FROM t1 }
} {1 2 3 4}
do_test lock5-flock.3 {
execsql { SELECT * FROM t1 } db2
} {1 2}
do_test lock5-none.4 {
execsql {
BEGIN;
SELECT * FROM t1;
} db2
} {1 2}
do_test lock5-none.5 {
execsql COMMIT
execsql {SELECT * FROM t1} db2
} {1 2}
#####################################################################
ifcapable memorymanage {
do_test lock5-none.6 {
sqlite3_release_memory 1000000
execsql {SELECT * FROM t1} db2
do_test lock5-none.1 {
sqlite3 db test.db -vfs unix-none
sqlite3 db2 test.db -vfs unix-none
execsql {
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
} {}
do_test lock5-none.2 {
execsql { SELECT * FROM t1 }
} {1 2 3 4}
}
do_test lock5-flock.3 {
execsql { SELECT * FROM t1 } db2
} {1 2}
do_test lock5-none.4 {
execsql {
BEGIN;
SELECT * FROM t1;
} db2
} {1 2}
do_test lock5-none.5 {
execsql COMMIT
execsql {SELECT * FROM t1} db2
} {1 2}
do_test lock5-flock.X {
db close
db2 close
} {}
ifcapable memorymanage {
do_test lock5-none.6 {
sqlite3_release_memory 1000000
execsql {SELECT * FROM t1} db2
} {1 2 3 4}
}
do_test lock5-flock.X {
db close
db2 close
} {}
}
ifcapable lock_proxy_pragmas {
set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy
+5 -3
View File
@@ -126,9 +126,10 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
set lockpath
} {{:auto: (not held)}}
set lpp [exec mktemp -t fail]
do_test lock6-1.4.1 {
execsql "PRAGMA lock_proxy_file='$lpp'"
catchsql {
PRAGMA lock_proxy_file="notmine";
select * from sqlite_master;
} db
} {1 {database is locked}}
@@ -137,7 +138,7 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
execsql {
PRAGMA lock_proxy_file;
} db
} {notmine}
} $lpp
do_test lock6-1.5 {
testfixture $::tf1 {
@@ -150,9 +151,10 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
catch {testfixture $::tf1 {db close}}
set lpp [exec mktemp -t ok]
do_test lock6-1.6 {
execsql "PRAGMA lock_proxy_file='$lpp'"
execsql {
PRAGMA lock_proxy_file="mine";
select * from sqlite_master;
} db
} {}
+142
View File
@@ -0,0 +1,142 @@
# 2008 June 28
#
# 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 database proxy locks.
#
# $Id$
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# This file is only run if using the unix backend compiled with the
# SQLITE_ENABLE_LOCKING_STYLE macro.
db close
if {[catch {sqlite3 db test.db -vfs unix-none} msg]} {
finish_test
return
}
db close
file delete -force test.db.lock
#####################################################################
ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
set ::using_proxy 0
foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
set ::using_proxy $value
}
# enable the proxy locking for these tests
set env(SQLITE_FORCE_PROXY_LOCKING) "1"
# test conch file creation
#
catch { file delete lock_proxy_test.db }
catch { file delete .lock_proxy_test.db-conch }
# test that proxy locking mode creates conch files
do_test lock_proxy1.0 {
sqlite3 db2 lock_proxy_test.db
catchsql {
create table x(y);
} db2
file exists .lock_proxy_test.db-conch
} {1}
catch { db2 close }
# test proxy locking readonly file system handling
#
if {[file exists /usr/bin/hdiutil]} {
puts "Creating readonly file system for proxy locking tests..."
if {[file exists /Volumes/readonly]} {
exec hdiutil detach /Volumes/readonly
}
if {[file exists readonly.dmg]} {
file delete readonly.dmg
}
exec hdiutil create -megabytes 1 -fs HFS+ readonly.dmg -volname readonly
exec hdiutil attach readonly.dmg
# create test1.db and a .test1.db-conch for host4
set sqlite_hostid_num 4
sqlite3 db2 /Volumes/readonly/test1.db
execsql {
create table x(y);
} db2
db2 close
# create test2.db and a .test2.db-conch for host5
set sqlite_hostid_num 5
sqlite3 db2 /Volumes/readonly/test2.db
execsql {
create table x(y);
} db2
db2 close
# create test3.db without a conch file
set env(SQLITE_FORCE_PROXY_LOCKING) "0"
sqlite3 db2 /Volumes/readonly/test3.db
execsql {
create table x(y);
} db2
db2 close
exec hdiutil detach /Volumes/readonly
exec hdiutil attach -readonly readonly.dmg
# test that an unwritable, host-mismatched conch file prevents
# read only proxy-locking mode database access
set env(SQLITE_FORCE_PROXY_LOCKING) "1"
do_test lock_proxy2.0 {
sqlite3 db2 /Volumes/readonly/test1.db
catchsql {
select * from sqlite_master;
} db2
} {1 {database is locked}}
catch { db2 close }
# test that an unwritable, host-matching conch file allows
# read only proxy-locking mode database access
do_test lock_proxy2.1 {
sqlite3 db2 /Volumes/readonly/test2.db
catchsql {
select * from sqlite_master;
} db2
} {0 {table x x 2 {CREATE TABLE x(y)}}}
catch { db2 close }
# test that an unwritable, nonexistant conch file allows
# read only proxy-locking mode database access
do_test lock_proxy2.2 {
sqlite3 db2 /Volumes/readonly/test3.db
catchsql {
select * from sqlite_master;
} db2
} {0 {table x x 2 {CREATE TABLE x(y)}}}
catch { db2 close }
exec hdiutil detach /Volumes/readonly
file delete readonly.dmg
}
set env(SQLITE_FORCE_PROXY_LOCKING) "0"
set sqlite_hostid_num 0
}
#####################################################################
file delete -force test.db
ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy
}
finish_test
+3 -3
View File
@@ -314,7 +314,7 @@ if {[permutation] == ""} {
#
do_test main-3.1 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {forcedelete $f}
catch {foreach f [glob -nocomplain testdb/*] {forcedelete $f}}
forcedelete testdb
sqlite3 db testdb
set v [catch {execsql {SELECT * from T1 where x!!5}} msg]
@@ -322,7 +322,7 @@ do_test main-3.1 {
} {1 {unrecognized token: "!!"}}
do_test main-3.2 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {forcedelete $f}
catch {foreach f [glob -nocomplain testdb/*] {forcedelete $f}}
forcedelete testdb
sqlite3 db testdb
set v [catch {execsql {SELECT * from T1 where ^x}} msg]
@@ -442,7 +442,7 @@ do_test main-3.2.30 {
do_test main-3.3 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {forcedelete $f}
catch {foreach f [glob -nocomplain testdb/*] {forcedelete $f}}
forcedelete testdb
sqlite3 db testdb
execsql {
+1 -1
View File
@@ -408,7 +408,7 @@ proc do_malloc_test {tn args} {
set zRepeat "transient"
if {$::iRepeat} {set zRepeat "persistent"}
restore_prng_state
foreach file [glob -nocomplain test.db-mj*] {forcedelete $file}
catch {foreach file [glob -nocomplain test.db-mj*] {forcedelete $file}}
do_test ${tn}.${zRepeat}.${::n} {
+1 -5
View File
@@ -22,12 +22,8 @@ set N 300
# if we're using proxy locks, we use 5 filedescriptors for a db
# that is open and in the middle of writing changes, normally
# sqlite uses 3 (proxy locking adds the conch and the local lock)
set using_proxy 0
foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
set using_proxy value
}
set num_fd_per_openwrite_db 3
if {$using_proxy>0} {
if {[forced_proxy_locking]} {
set num_fd_per_openwrite_db 5
}
+21 -19
View File
@@ -11,7 +11,6 @@
# This file implements regression tests for SQLite library. The
# focus of this script is in-memory database backend.
#
# $Id: memdb.test,v 1.19 2009/05/18 16:04:38 danielk1977 Exp $
set testdir [file dirname $argv0]
@@ -407,24 +406,27 @@ do_test memdb-8.2 {
# Test that auto-vacuum works with in-memory databases.
#
ifcapable autovacuum {
do_test memdb-9.1 {
db close
sqlite3 db test.db
db cache size 0
execsql {
PRAGMA auto_vacuum = full;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(randstr(1000,1000));
INSERT INTO t1 VALUES(randstr(1000,1000));
INSERT INTO t1 VALUES(randstr(1000,1000));
}
set memused [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
set pgovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 1]
execsql { DELETE FROM t1 }
set memused2 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
expr {($memused2 + 2048 < $memused) || $pgovfl==0}
} {1}
set msize [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0]
if {[lindex $msize 2]!=0} {
ifcapable autovacuum {
do_test memdb-9.1 {
db close
sqlite3 db test.db
db cache size 0
execsql {
PRAGMA auto_vacuum = full;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(randstr(1000,1000));
INSERT INTO t1 VALUES(randstr(1000,1000));
INSERT INTO t1 VALUES(randstr(1000,1000));
}
set memused [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
set pgovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 1]
execsql { DELETE FROM t1 }
set memused2 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
expr {($memused2 + 2048 < $memused) || $pgovfl==0}
} {1}
}
}
} ;# ifcapable memorydb
+29 -24
View File
@@ -184,17 +184,20 @@ build_test_db memsubsys1-5 {PRAGMA page_size=4096}
do_test memsubsys1-5.3 {
set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
} 24
do_test memsubsys1-5.4 {
set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
expr {$maxreq>4096}
} 1
do_test memsubsys1-5.5 {
set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
} 0
do_test memsubsys1-5.6 {
set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
expr {$s_ovfl>6000}
} 1
set msize [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0]
if {[lindex $msize 2]!=0} {
do_test memsubsys1-5.4 {
set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
expr {$maxreq>4096}
} 1
do_test memsubsys1-5.5 {
set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
} 0
do_test memsubsys1-5.6 {
set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
expr {$s_ovfl>6000}
} 1
}
# Test 6: Activate both PAGECACHE and SCRATCH with a 4k page size.
# Make it so that SCRATCH is large enough
@@ -270,19 +273,21 @@ do_test memsubsys1-8.1 {
do_test memsubsys1-8.2 {
set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
} 0
do_test memsubsys1-8.3 {
sqlite3 db :memory:
db eval {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(zeroblob(400));
INSERT INTO t1 VALUES(zeroblob(400));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
}
expr {[lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]>0}
} 1
db close
if {[lindex $msize 2]!=0} {
do_test memsubsys1-8.3 {
sqlite3 db :memory:
db eval {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(zeroblob(400));
INSERT INTO t1 VALUES(zeroblob(400));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
}
expr {[lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]>0}
} 1
db close
}
sqlite3_shutdown
sqlite3_config_memstatus 0
sqlite3_initialize
+6
View File
@@ -14,6 +14,12 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
# AFP doesn't like multiplex db tests
if { ![path_is_local "."] } {
finish_test
return
}
# The tests in this file assume that SQLite is compiled without
# ENABLE_8_3_NAMES.
#
+37 -31
View File
@@ -536,6 +536,8 @@ proc copy_on_mj_delete {method filename args} {
}
set pwd [get_pwd]
if {![forced_proxy_locking]} {
# proxy locking uses can't deal with auto proxy file paths longer than MAXPATHLEN
foreach {tn1 tcl} {
1 { set prefix "test.db" }
2 {
@@ -667,6 +669,7 @@ foreach {tn1 tcl} {
db close
tv delete
forcedelete $dirname
}
# Set up a VFS to make a copy of the file-system just before deleting a
@@ -1123,7 +1126,7 @@ do_execsql_test pager1-6.12 { PRAGMA max_page_count } {11}
# $ws: The expected size of the WAL file, in bytes, after executing
# the SQL script. Or -1 if the WAL is not expected to exist.
#
ifcapable wal {
if {$::sqlite_options(wal) && [wal_is_ok]} {
faultsim_delete_and_reopen
foreach {tn sql res js ws} [subst {
@@ -1927,7 +1930,7 @@ do_test pager1-20.2.2 {
}
} {}
ifcapable wal {
if {$::sqlite_options(wal) && [wal_is_ok]} {
do_test pager1-20.3.1 {
faultsim_delete_and_reopen
db func a_string a_string
@@ -1962,7 +1965,7 @@ ifcapable wal {
# pager1-21.1.*: The VFS has an iVersion less than 2, or
# pager1-21.2.*: The VFS does not provide xShmXXX() methods.
#
ifcapable wal {
if {$::sqlite_options(wal) && [wal_is_ok]} {
do_test pager1-21.0 {
faultsim_delete_and_reopen
execsql {
@@ -1993,33 +1996,36 @@ ifcapable wal {
# pager1-22.1.*: is a no-op on a non-WAL db, and
# pager1-22.2.*: does not cause xSync calls with a synchronous=off db.
#
ifcapable wal {
do_test pager1-22.1.1 {
faultsim_delete_and_reopen
execsql {
CREATE TABLE ko(c DEFAULT 'abc', b DEFAULT 'def');
INSERT INTO ko DEFAULT VALUES;
}
execsql { PRAGMA wal_checkpoint }
} {0 -1 -1}
do_test pager1-22.2.1 {
testvfs tv -default 1
tv filter xSync
tv script xSyncCb
proc xSyncCb {args} {incr ::synccount}
set ::synccount 0
sqlite3 db test.db
execsql {
PRAGMA synchronous = off;
PRAGMA journal_mode = WAL;
INSERT INTO ko DEFAULT VALUES;
}
execsql { PRAGMA wal_checkpoint }
set synccount
} {0}
db close
tv delete
}
do_test pager1-22.1.1 {
faultsim_delete_and_reopen
execsql {
CREATE TABLE ko(c DEFAULT 'abc', b DEFAULT 'def');
INSERT INTO ko DEFAULT VALUES;
}
execsql { PRAGMA wal_checkpoint }
} {0 -1 -1}
do_test pager1-22.2.1 {
testvfs tv -default 1
tv filter xSync
tv script xSyncCb
proc xSyncCb {args} {incr ::synccount}
sqlite3 db test.db
# Switch the db to WAL mode. And then execute a SELECT to make sure
# that the WAL file is open. Note that this may change the synchronous
# setting if DEFAULT_WAL_SAFETYLEVEL is defined.
execsql { PRAGMA journal_mode = WAL ; SELECT * FROM ko }
# Set synchronous=OFF. Insert some data and run a checkpoint. Since
# sync=off, this should not cause any calls to the xSync() method.
set ::synccount 0
execsql {
PRAGMA synchronous = off;
INSERT INTO ko DEFAULT VALUES;
PRAGMA wal_checkpoint;
}
set synccount
} {0}
#-------------------------------------------------------------------------
# Tests for changing journal mode.
@@ -2268,7 +2274,7 @@ do_test pager1.27.1 {
# the same database.
#
catch { db close }
ifcapable wal {
if {$::sqlite_options(wal) && [wal_is_ok]} {
do_multiclient_test tn {
do_test pager1-28.$tn.1 {
sql1 {
+33
View File
@@ -1060,6 +1060,39 @@ ifcapable crashtest {
}
#-------------------------------------------------------------------------
# When a 3.7.0 client opens a write-transaction on a database file that
# has been appended to or truncated by a pre-370 client, it updates
# the db-size in the file header immediately. This test case provokes
# errors during that operation.
#
do_test pagerfault-22-pre1 {
faultsim_delete_and_reopen
db func a_string a_string
execsql {
PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 0;
CREATE TABLE t1(a);
CREATE INDEX i1 ON t1(a);
INSERT INTO t1 VALUES(a_string(3000));
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
}
db close
sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
faultsim_save_and_close
} {}
do_faultsim_test pagerfault-22 -prep {
faultsim_restore_and_reopen
} -body {
execsql { INSERT INTO t2 VALUES(2) }
execsql { SELECT * FROM t2 }
} -test {
faultsim_test_result {0 {1 2}}
faultsim_integrity_check
}
#-------------------------------------------------------------------------
# When a 3.7.0 client opens a write-transaction on a database file that
# has been appended to or truncated by a pre-370 client, it updates
+137 -32
View File
@@ -1304,7 +1304,12 @@ sqlite3 dbX :memory:
dbX eval {PRAGMA temp_store_directory = ""}
dbX close
ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
set skip_lock_proxy_tests [path_is_dos "."]
ifcapable !(lock_proxy_pragmas&&prefer_proxy_locking) {
set skip_lock_proxy_tests 1
}
if !$skip_lock_proxy_tests {
set sqlite_hostid_num 1
set using_proxy 0
@@ -1318,67 +1323,67 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
set env(SQLITE_FORCE_PROXY_LOCKING) "0"
sqlite3 db test.db
# set lock proxy name and then query it via pragma interface
set lpp [exec mktemp -t "proxy1"]
do_test pragma-16.1 {
execsql {
PRAGMA lock_proxy_file="mylittleproxy";
select * from sqlite_master;
}
execsql {
PRAGMA lock_proxy_file;
}
} {mylittleproxy}
execsql "PRAGMA lock_proxy_file='$lpp'"
execsql "select * from sqlite_master"
execsql "PRAGMA lock_proxy_file"
} $lpp
# 2 database connections can share a lock proxy file
do_test pragma-16.2 {
sqlite3 db2 test.db
execsql {
PRAGMA lock_proxy_file="mylittleproxy";
} db2
execsql "PRAGMA lock_proxy_file='$lpp'" db2
} {}
db2 close
# 2nd database connection should auto-name an existing lock proxy file
do_test pragma-16.2.1 {
sqlite3 db2 test.db
execsql {
PRAGMA lock_proxy_file=":auto:";
select * from sqlite_master;
} db2
execsql {
PRAGMA lock_proxy_file;
} db2
} {mylittleproxy}
execsql "PRAGMA lock_proxy_file" db2
} $lpp
db2 close
set lpp2 [exec mktemp -t "proxy2"]
# 2nd database connection cannot override the lock proxy file
do_test pragma-16.3 {
sqlite3 db2 test.db
execsql {
PRAGMA lock_proxy_file="myotherproxy";
} db2
execsql "PRAGMA lock_proxy_file='$lpp2'" db2
catchsql {
select * from sqlite_master;
} db2
} {1 {database is locked}}
set lpp3 [exec mktemp -t "proxy3"]
# lock proxy file can be renamed if no other connections are active
do_test pragma-16.4 {
db2 close
db close
sqlite3 db2 test.db
execsql {
PRAGMA lock_proxy_file="myoriginalproxy";
PRAGMA lock_proxy_file="myotherproxy";
PRAGMA lock_proxy_file;
} db2
} {myotherproxy}
execsql "PRAGMA lock_proxy_file='$lpp3'" db2
execsql "PRAGMA lock_proxy_file='$lpp2'" db2
execsql "PRAGMA lock_proxy_file" db2
} $lpp2
db2 close
set env(SQLITE_FORCE_PROXY_LOCKING) "1"
# auto-naming should reuse the last proxy name when available
do_test pragma-16.5 {
sqlite3 db2 test.db
execsql {
PRAGMA lock_proxy_file=":auto:";
PRAGMA lock_proxy_file;
} db2
} {myotherproxy}
} $lpp2
# auto-naming a new proxy should use a predictable & unique name
do_test pragma-16.6 {
db2 close
sqlite3 db2 test2.db
@@ -1390,6 +1395,7 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
} {1}
set sqlite_hostid_num 2
# db access should be limited to one host at a time (simulate 2nd host id)
do_test pragma-16.7 {
list [catch {
sqlite3 db test2.db
@@ -1401,6 +1407,7 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
} {1 {database is locked}}
db close
# default to using proxy locking (simulate network file system detection)
do_test pragma-16.8 {
list [catch {
sqlite3 db test2.db
@@ -1409,19 +1416,25 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
} {1 {database is locked}}
db2 close
set lpp4 [exec mktemp -t "proxy4"]
# check that db is unlocked after first host connection closes
do_test pragma-16.8.1 {
execsql {
PRAGMA lock_proxy_file="yetanotherproxy";
PRAGMA lock_proxy_file;
}
} {yetanotherproxy}
execsql "PRAGMA lock_proxy_file='$lpp4'"
execsql "select * from sqlite_master"
execsql "PRAGMA lock_proxy_file"
} $lpp4
do_test pragma-16.8.2 {
execsql {
create table mine(x);
create table if not exists mine(x);
insert into mine values (1);
}
} {}
db close
file delete -force proxytest.db
file delete -force .proxytest.db-conch
do_test pragma-16.9 {
sqlite3 db proxytest.db
set lockpath2 [execsql {
@@ -1431,6 +1444,98 @@ ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
string match "*proxytest.db:auto:" $lockpath2
} {1}
# ensure creating directories for a lock proxy file works
set lpp5d [exec mktemp -d -t "proxy5"]
set lpp5 $lpp5d/sub/dir/lock
db close
do_test pragma-16.10.1 {
sqlite3 db proxytest.db
execsql "PRAGMA lock_proxy_file='$lpp5'"
set lockpath2 [execsql {
PRAGMA lock_proxy_file;
} db]
string match "*sub/dir/lock" $lockpath2
} {1}
# ensure that after deleting the path, setting ":auto:" works correctly
db close
file delete -force $lpp5d
do_test pragma-16.10.2 {
sqlite3 db proxytest.db
set lockpath3 [execsql {
PRAGMA lock_proxy_file=":auto:";
create table if not exists pt(y);
PRAGMA lock_proxy_file;
} db]
string match "*sub/dir/lock" $lockpath3
} {1}
# ensure that if the path can not be created (file instead of dir)
# setting :auto: deals with it by creating a new autonamed lock file
db close
file delete -force $lpp5d
close [open "$lpp5d" a]
do_test pragma-16.10.3 {
sqlite3 db proxytest.db
set lockpath2 [execsql {
PRAGMA lock_proxy_file=":auto:";
create table if not exists zz(y);
PRAGMA lock_proxy_file;
} db]
string match "*proxytest.db:auto:" $lockpath2
} {1}
# make sure we can deal with ugly file paths correctly
db close
file delete -force $lpp5d
set lpp6 [exec mktemp -d -t "proxy6"]/./././////./proxytest/../proxytest/sub/dir/lock
do_test pragma-16.10.4 {
sqlite3 db proxytest.db
execsql "PRAGMA lock_proxy_file='$lpp6'"
set lockpath4 [execsql {
create table if not exists aa(bb);
PRAGMA lock_proxy_file;
} db]
string match "*proxytest/sub/dir/lock" $lockpath4
} {1}
# ensure that if the path can not be created (perm), setting :auto: deals
db close
file delete -force $lpp5d
do_test pragma-16.10.5 {
sqlite3 db proxytest.db
execsql "PRAGMA lock_proxy_file='$lpp5'"
execsql {
create table if not exists bb(bb);
}
db close
file delete -force $lpp5d
file mkdir $lpp5d
file attributes $lpp5d -permission 0000
sqlite3 db proxytest.db
set lockpath5 [execsql {
PRAGMA lock_proxy_file=":auto:";
create table if not exists cc(bb);
PRAGMA lock_proxy_file;
} db]
string match "*proxytest.db:auto:" $lockpath5
} {1}
# ensure that if the path can not be created, locking fails
db close
do_test pragma-16.10.6 {
sqlite3 db proxytest.db
execsql "PRAGMA lock_proxy_file='$lpp5'"
catchsql {
create table if not exists faily(y);
PRAGMA lock_proxy_file;
} db
} {1 {database is locked}}
db close
file attributes $lpp5d -permission 0777
file delete -force $lpp5d
set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy
set sqlite_hostid_num 0
}
+1 -5
View File
@@ -45,13 +45,9 @@ ifcapable autovacuum {
# if we're using proxy locks, we use 2 filedescriptors for a db
# that is open but NOT yet locked, after a lock is taken we'll have 3,
# normally sqlite uses 1 (proxy locking adds the conch and the local lock)
set using_proxy 0
foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
set using_proxy $value
}
set extrafds_prelock 0
set extrafds_postlock 0
if {$using_proxy>0} {
if {[forced_proxy_locking]} {
set extrafds_prelock 1
set extrafds_postlock 2
}
+1 -1
View File
@@ -32,7 +32,7 @@ do_execsql_test stat-0.0 {
SELECT * FROM stat;
} {}
ifcapable wal {
if {$::sqlite_options(wal) && [wal_is_ok]} {
do_execsql_test stat-0.1 {
PRAGMA journal_mode = WAL;
PRAGMA journal_mode = delete;
+24 -7
View File
@@ -30,8 +30,19 @@ if {$::TEMP_STORE==3} {
finish_test
return
}
# if we're using proxy locks, we use 3 filedescriptors for a db
# that is open but NOT writing changes, normally
# sqlite uses 1 (proxy locking adds the conch and the local lock)
set extrafds 0
if {[forced_proxy_locking]} {
set extrafds 2
}
do_test stmt-1.2 {
set sqlite_open_file_count
expr $sqlite_open_file_count-$extrafds
} {1}
do_test stmt-1.3 {
execsql {
@@ -40,16 +51,19 @@ do_test stmt-1.3 {
INSERT INTO t1 VALUES(1, 1);
}
set sqlite_open_file_count
expr $sqlite_open_file_count-$extrafds
} {2}
do_test stmt-1.4 {
execsql {
INSERT INTO t1 SELECT a+1, b+1 FROM t1;
}
set sqlite_open_file_count
expr $sqlite_open_file_count-$extrafds
} {3}
do_test stmt-1.5 {
execsql COMMIT
set sqlite_open_file_count
expr $sqlite_open_file_count-$extrafds
} {1}
do_test stmt-1.6.1 {
execsql {
@@ -57,34 +71,37 @@ do_test stmt-1.6.1 {
INSERT INTO t1 SELECT a+2, b+2 FROM t1;
}
set sqlite_open_file_count
expr $sqlite_open_file_count-$extrafds
} {2}
do_test stmt-1.6.2 {
execsql { INSERT INTO t1 SELECT a+4, b+4 FROM t1 }
set sqlite_open_file_count
expr $sqlite_open_file_count-$extrafds
} {3}
do_test stmt-1.7 {
execsql COMMIT
set sqlite_open_file_count
expr $sqlite_open_file_count-$extrafds
} {1}
proc filecount {testname sql expected} {
proc filecount {testname sql expected extrafds} {
uplevel [list do_test $testname [subst -nocommand {
execsql BEGIN
execsql { $sql }
set ret [set sqlite_open_file_count]
execsql ROLLBACK
set ret
}] $expected]
}] [ expr $expected+$extrafds ] ]
}
filecount stmt-2.1 { INSERT INTO t1 VALUES(9, 9) } 2
filecount stmt-2.2 { REPLACE INTO t1 VALUES(9, 9) } 2
filecount stmt-2.3 { INSERT INTO t1 SELECT 9, 9 } 2
filecount stmt-2.1 { INSERT INTO t1 VALUES(9, 9) } 2 $extrafds
filecount stmt-2.2 { REPLACE INTO t1 VALUES(9, 9) } 2 $extrafds
filecount stmt-2.3 { INSERT INTO t1 SELECT 9, 9 } 2 $extrafds
filecount stmt-2.4 {
INSERT INTO t1 SELECT 9, 9;
INSERT INTO t1 SELECT 10, 10;
} 3
} 3 $extrafds
do_test stmt-2.5 {
execsql { CREATE INDEX i1 ON t1(b) }
@@ -92,6 +109,6 @@ do_test stmt-2.5 {
filecount stmt-2.6 {
REPLACE INTO t1 VALUES(5, 5);
REPLACE INTO t1 VALUES(5, 5);
} 3
} 3 $extrafds
finish_test
+12
View File
@@ -13,6 +13,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
set testprefix superlock
@@ -42,6 +43,11 @@ set testprefix superlock
#
#
if {[forced_proxy_locking]} {
finish_test
return
}
do_execsql_test 1.1 {
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 2);
@@ -57,6 +63,12 @@ do_test 1.2 { sqlite3demo_superlock unlock test.db } {unlock}
do_catchsql_test 1.3 { SELECT * FROM t1 } {1 {database is locked}}
do_test 1.4 { unlock } {}
ifcapable !wal {finish_test ; return }
if { ![wal_is_ok] } {
finish_test
return
}
do_execsql_test 2.1 {
INSERT INTO t1 VALUES(3, 4);
PRAGMA journal_mode = WAL;
+7 -2
View File
@@ -52,6 +52,11 @@ do_test tempdb-1.2 {
}
} {}
set extrafds 0
if {[forced_proxy_locking]} {
set extrafds 2
}
do_test tempdb-2.1 {
# Set $::jrnl_in_memory if the journal file is expected to be in-memory.
# Similarly, set $::subj_in_memory if the sub-journal file is expected
@@ -76,7 +81,7 @@ do_test tempdb-2.2 {
}
catchsql { INSERT INTO t1 SELECT * FROM t2 }
set sqlite_open_file_count
} [expr 1 + (0==$jrnl_in_memory) + (0==$subj_in_memory)]
} [expr 1 + $extrafds + (0==$jrnl_in_memory) + (0==$subj_in_memory)]
do_test tempdb-2.3 {
execsql {
PRAGMA temp_store = 'memory';
@@ -88,6 +93,6 @@ do_test tempdb-2.3 {
}
catchsql { INSERT INTO t1 SELECT * FROM t2 }
set sqlite_open_file_count
} [expr 1 + (0==$jrnl_in_memory)]
} [expr 1 + $extrafds + (0==$jrnl_in_memory)]
finish_test
+46 -4
View File
@@ -398,6 +398,23 @@ if {[info exists cmdlinearg]==0} {
#
sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
proc forced_proxy_locking {} {
if $::sqlite_options(lock_proxy_pragmas)&&$::sqlite_options(prefer_proxy_locking) {
set force_proxy_value 0
set force_key "SQLITE_FORCE_PROXY_LOCKING="
foreach {env_pair} [exec env] {
if { [string first $force_key $env_pair] == 0} {
set force_proxy_value [string range $env_pair [string length $force_key] end]
}
}
if { "$force_proxy_value " == "1 " } {
return 1
}
}
return 0
}
# Create a test database
#
proc reset_db {} {
@@ -405,6 +422,14 @@ proc reset_db {} {
forcedelete test.db
forcedelete test.db-journal
forcedelete test.db-wal
if {[forced_proxy_locking]} {
sqlite3 db ./test.db
set lock_proxy_path [db eval "PRAGMA lock_proxy_file;"]
catch {db close}
# puts "deleting $lock_proxy_path"
file delete -force $lock_proxy_path
file delete -force test.db
}
sqlite3 db ./test.db
set ::DB [sqlite3_connection_pointer db]
if {[info exists ::SETUP_SQL]} {
@@ -785,11 +810,15 @@ proc finalize_testing {} {
memdebug_log_sql leaks.sql
}
}
foreach f [glob -nocomplain test.db-*-journal] {
forcedelete $f
catch {
foreach f [glob -nocomplain test.db-*-journal] {
forcedelete $f
}
}
foreach f [glob -nocomplain test.db-mj*] {
forcedelete $f
catch {
foreach f [glob -nocomplain test.db-mj*] {
forcedelete $f
}
}
exit [expr {$nErr>0}]
}
@@ -1452,6 +1481,19 @@ proc presql {} {
set presql
}
proc wal_is_ok {} {
if { [forced_proxy_locking] } {
return 1
}
if { ![path_is_local "."] } {
return 0
}
if { [path_is_dos "."] } {
return 0
}
return 1
}
#-------------------------------------------------------------------------
#
proc slave_test_script {script} {
+1
View File
@@ -20,6 +20,7 @@ source $testdir/tester.tcl
set testprefix tkt-2d1a5c67d
ifcapable {!wal || !vtab} {finish_test; return}
if {![wal_is_ok]} {finish_test; return}
for {set ii 1} {$ii<=10} {incr ii} {
do_test tkt-2d1a5c67d.1.$ii {
+1
View File
@@ -19,6 +19,7 @@ source $testdir/tester.tcl
source $testdir/malloc_common.tcl
ifcapable !wal { finish_test ; return }
if ![wal_is_ok] { finish_test; return }
do_execsql_test tkt-313723c356.1 {
PRAGMA page_size = 1024;
+4
View File
@@ -18,6 +18,10 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
ifcapable !wal { finish_test; return }
if ![wal_is_ok] { finish_test; return }
do_multiclient_test tn {
do_test $tn.1 {
sql1 {
+22 -21
View File
@@ -62,26 +62,27 @@ do_test tkt3457-1.1 {
execsql COMMIT
} {}
do_test tkt3457-1.2 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions ---------
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.3 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions -w--w--w-
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.4 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions r--r--r--
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.5 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions rw-rw-rw-
catchsql { SELECT * FROM t1 }
} {0 {1 2 3 4 5 6}}
if { ![path_is_dos "."] } {
do_test tkt3457-1.2 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions ---------
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.3 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions -w--w--w-
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.4 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions r--r--r--
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.5 {
forcecopy bak.db-journal test.db-journal
file attributes test.db-journal -permissions rw-rw-rw-
catchsql { SELECT * FROM t1 }
} {0 {1 2 3 4 5 6}}
}
finish_test
+8 -1
View File
@@ -22,6 +22,10 @@ source $testdir/wal_common.tcl
set testprefix wal
ifcapable !wal {finish_test ; return }
if { ![wal_is_ok] } {
finish_test
return
}
proc reopen_db {} {
catch { db close }
@@ -1054,10 +1058,12 @@ foreach {tn ckpt_cmd ckpt_res ckpt_main ckpt_aux} {
PRAGMA aux.auto_vacuum = 0;
PRAGMA main.journal_mode = WAL;
PRAGMA aux.journal_mode = WAL;
SELECT count(*) FROM main.sqlite_master, aux.sqlite_master;
PRAGMA main.synchronous = NORMAL;
PRAGMA aux.synchronous = NORMAL;
PRAGMA aux.synchronous = FULL;
}
} {wal wal}
} {wal wal 0}
do_test wal-16.$tn.2 {
execsql {
@@ -1128,6 +1134,7 @@ foreach {tn sectorsize logsize} "
PRAGMA page_size = 512;
PRAGMA cache_size = -2000;
PRAGMA journal_mode = WAL;
SELECT * FROM sqlite_master;
PRAGMA synchronous = FULL;
}
execsql {
+47 -16
View File
@@ -22,6 +22,7 @@ source $testdir/wal_common.tcl
set testprefix wal2
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] {finish_test ; return }
set sqlite_sync_count 0
proc cond_incr_sync_count {adj} {
@@ -70,6 +71,13 @@ proc incr_tvfs_hdr {file idx incrval} {
set_tvfs_hdr $file $ints
}
set shmpath test.db-shm
if {[forced_proxy_locking]} {
sqlite3 db test.db
set shmpath [execsql { pragma lock_proxy_file }]-shm
db close
}
#-------------------------------------------------------------------------
# Test case wal2-1.*:
@@ -942,6 +950,9 @@ do_test wal2-10.1.1 {
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(3, 4);
}
if {[forced_proxy_locking]} {
forcecopy $shmpath sv_test.db-shm
}
faultsim_save_and_close
} {}
do_test wal2-10.1.2 {
@@ -1041,6 +1052,11 @@ tvfs delete
# file itself. Test this.
#
if {$::tcl_platform(platform) == "unix"} {
if {[forced_proxy_locking]} {
# faultsim_delete_and_reopen doesn't know about the shm file redirect...
forcedelete $shmpath
}
faultsim_delete_and_reopen
# Changed on 2012-02-13: umask is deliberately ignored for -wal files.
#set umask [exec /bin/sh -c umask]
@@ -1054,7 +1070,7 @@ if {$::tcl_platform(platform) == "unix"} {
PRAGMA journal_mode = WAL;
}
db close
list [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db-wal] [file exists $shmpath]
} {0 0}
foreach {tn permissions} {
@@ -1069,19 +1085,19 @@ if {$::tcl_platform(platform) == "unix"} {
file attributes test.db -permissions
} $permissions
do_test wal2-12.2.$tn.2 {
list [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db-wal] [file exists $shmpath]
} {0 0}
do_test wal2-12.2.$tn.3 {
sqlite3 db test.db
execsql { INSERT INTO tx DEFAULT VALUES }
list [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db-wal] [file exists $shmpath]
} {1 1}
do_test wal2-12.2.$tn.4 {
list [file attr test.db-wal -perm] [file attr test.db-shm -perm]
list [file attr test.db-wal -perm] [file attr $shmpath -perm]
} [list $effective $effective]
do_test wal2-12.2.$tn.5 {
db close
list [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db-wal] [file exists $shmpath]
} {0 0}
}
}
@@ -1094,7 +1110,7 @@ if {$::tcl_platform(platform) == "unix"} {
if {$::tcl_platform(platform) == "unix"} {
proc perm {} {
set L [list]
foreach f {test.db test.db-wal test.db-shm} {
foreach f {test.db test.db-wal $shmpath} {
if {[file exists $f]} {
lappend L [file attr $f -perm]
} else {
@@ -1104,6 +1120,10 @@ if {$::tcl_platform(platform) == "unix"} {
set L
}
if {[forced_proxy_locking]} {
# faultsim_delete_and_reopen doesn't know about the shm file redirect...
forcedelete $shmpath
}
faultsim_delete_and_reopen
execsql {
PRAGMA journal_mode = WAL;
@@ -1112,8 +1132,11 @@ if {$::tcl_platform(platform) == "unix"} {
INSERT INTO t1 VALUES('3.14', '2.72');
}
do_test wal2-13.1.1 {
list [file exists test.db-shm] [file exists test.db-wal]
list [file exists $shmpath] [file exists test.db-wal]
} {1 1}
if {[forced_proxy_locking]} {
forcecopy $shmpath proxysv_test.db-shm
}
faultsim_save_and_close
foreach {tn db_perm wal_perm shm_perm can_open can_read can_write} {
@@ -1127,14 +1150,17 @@ if {$::tcl_platform(platform) == "unix"} {
9 00000 00644 00644 0 0 0
} {
faultsim_restore
if {[forced_proxy_locking]} {
forcecopy proxysv_test.db-shm $shmpath
}
do_test wal2-13.$tn.1 {
file attr test.db -perm $db_perm
file attr test.db-wal -perm $wal_perm
file attr test.db-shm -perm $shm_perm
file attr $shmpath -perm $shm_perm
set L [file attr test.db -perm]
lappend L [file attr test.db-wal -perm]
lappend L [file attr test.db-shm -perm]
lappend L [file attr $shmpath -perm]
} [list $db_perm $wal_perm $shm_perm]
# If $can_open is true, then it should be possible to open a database
@@ -1180,10 +1206,10 @@ if {$::tcl_platform(platform) == "unix"} {
#-------------------------------------------------------------------------
# Test that "PRAGMA checkpoint_fullsync" appears to be working.
#
foreach {tn sql reslist} {
1 { } {10 0 4 0 6 0}
2 { PRAGMA checkpoint_fullfsync = 1 } {10 4 4 2 6 2}
3 { PRAGMA checkpoint_fullfsync = 0 } {10 0 4 0 6 0}
foreach {tn sql reslist altreslist} {
1 { } {10 0 4 0 6 0} {7 4 3 2 3 2}
2 { PRAGMA checkpoint_fullfsync = 1 } {10 4 4 2 6 2} {7 4 3 2 3 2}
3 { PRAGMA checkpoint_fullfsync = 0 } {10 0 4 0 6 0} {7 0 3 0 3 0}
} {
faultsim_delete_and_reopen
@@ -1195,6 +1221,11 @@ foreach {tn sql reslist} {
set sqlite_sync_count 0
set sqlite_fullsync_count 0
set useres $reslist
if $::sqlite_options(default_wal_safetylevel) {
set useres $altreslist
}
do_execsql_test wal2-14.$tn.2 {
PRAGMA wal_autocheckpoint = 10;
CREATE TABLE t1(a, b); -- 2 wal syncs
@@ -1210,7 +1241,7 @@ foreach {tn sql reslist} {
do_test wal2-14.$tn.3 {
cond_incr_sync_count 1
list $sqlite_sync_count $sqlite_fullsync_count
} [lrange $reslist 0 1]
} [lrange $useres 0 1]
set sqlite_sync_count 0
set sqlite_fullsync_count 0
@@ -1218,7 +1249,7 @@ foreach {tn sql reslist} {
do_test wal2-14.$tn.4 {
execsql { INSERT INTO t1 VALUES(7, zeroblob(12*4096)) }
list $sqlite_sync_count $sqlite_fullsync_count
} [lrange $reslist 2 3]
} [lrange $useres 2 3]
set sqlite_sync_count 0
set sqlite_fullsync_count 0
@@ -1230,7 +1261,7 @@ foreach {tn sql reslist} {
execsql { INSERT INTO t1 VALUES(13, 14) }
db close
list $sqlite_sync_count $sqlite_fullsync_count
} [lrange $reslist 4 5]
} [lrange $useres 4 5]
}
catch { db close }
+11 -2
View File
@@ -19,6 +19,7 @@ source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
source $testdir/malloc_common.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] {finish_test ; return }
set a_string_counter 1
proc a_string {n} {
@@ -194,19 +195,27 @@ catch {db close}
# in WAL mode the xSync method is invoked as expected for each of
# synchronous=off, synchronous=normal and synchronous=full.
#
foreach {tn syncmode synccount} {
foreach {tn syncmode synccount altsynccount} {
1 off
{}
{}
2 normal
{test.db-wal normal test.db normal}
{test.db-wal full test.db full}
3 full
{test.db-wal normal test.db-wal normal test.db-wal normal test.db normal}
{test.db-wal normal test.db-wal normal test.db-wal full test.db full}
} {
proc sync_counter {args} {
foreach {method filename id flags} $args break
lappend ::syncs [file tail $filename] $flags
}
set usecount $synccount
if $::sqlite_options(default_wal_safetylevel) {
set usecount $altsynccount
}
do_test wal3-3.$tn {
forcedelete test.db test.db-wal test.db-journal
@@ -228,7 +237,7 @@ foreach {tn syncmode synccount} {
}
T filter {}
set ::syncs
} $synccount
} $usecount
db close
T delete
+4
View File
@@ -16,6 +16,10 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
ifcapable !wal {finish_test ; return }
if { ![wal_is_ok] || [path_is_dos "."]} {
finish_test
return
}
do_test wal4-1.1 {
execsql {
+1
View File
@@ -18,6 +18,7 @@ source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
set testprefix wal5
+2
View File
@@ -20,6 +20,8 @@ source $testdir/wal_common.tcl
source $testdir/malloc_common.tcl
ifcapable !wal {finish_test ; return }
if { ![wal_is_ok] } {finish_test ; return }
#-------------------------------------------------------------------------
# Changing to WAL mode in one connection forces the change in others.
#
+1
View File
@@ -16,6 +16,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
# Case 1: No size limit. Journal can get large.
#
+2
View File
@@ -26,6 +26,8 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix wal8
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
db close
forcedelete test.db test.db-wal
+14
View File
@@ -33,6 +33,20 @@ proc wal_cksum_intlist {ckv1 ckv2 intlist} {
}
}
# If the synchronous mode for the main database of db handle $db
# is either OFF or NORMAL, return $nRight. Otherwise, if it is
# FULL, return $nWrite+$nTrans.
#
proc wal_frames {db nWrite nTrans} {
set nRet $nWrite
switch -- [$db one {PRAGMA main.synchronous}] {
0 { }
1 { }
default { incr nRet $nTrans }
}
set nRet
}
# This proc calculates checksums in the same way as those used by SQLite
# in WAL files. If the $endian argument is "big", then checksums are
+1
View File
@@ -21,6 +21,7 @@ source $testdir/malloc_common.tcl
do_not_use_codec
ifcapable !wal {finish_test ; return }
if { ![wal_is_ok] } { finish_test ; return }
# Test organization:
+5
View File
@@ -21,6 +21,7 @@ ifcapable !wal {
finish_test
return
}
if ![wal_is_ok] { finish_test; return }
# Do not use a codec for this file, as the database is manipulated using
# external methods (the [fake_big_file] and [hexio_write] commands).
@@ -32,6 +33,10 @@ ifcapable !lfs {
finish_test
return
}
if { ![wal_is_ok] } {
finish_test
return
}
set a_string_counter 1
proc a_string {n} {
+1
View File
@@ -16,6 +16,7 @@ source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
# Read and return the contents of file $filename. Treat the content as
# binary data.
+1
View File
@@ -28,6 +28,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
db close
+1
View File
@@ -16,6 +16,7 @@ source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
ifcapable !wal {finish_test ; return }
if { ![wal_is_ok] } { finish_test ; return }
#-------------------------------------------------------------------------
+2
View File
@@ -18,6 +18,8 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
set testprefix walcrash3
db close
+1
View File
@@ -19,6 +19,7 @@ source $testdir/malloc_common.tcl
source $testdir/lock_common.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
#-------------------------------------------------------------------------
# This test case, walfault-1-*, simulates faults while executing a
+1
View File
@@ -22,6 +22,7 @@ source $testdir/tester.tcl
source $testdir/wal_common.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
set ::wal_hook [list]
proc wal_hook {zDb nEntry} {
+23 -1
View File
@@ -35,6 +35,20 @@ ifcapable !wal {
finish_test
return
}
if { ![wal_is_ok] && ![path_is_dos "."]} {
do_test walmode-0.1 {
execsql { PRAGMA journal_mode = wal }
} {delete}
do_test walmode-0.2 {
execsql { PRAGMA main.journal_mode = wal }
} {delete}
do_test walmode-0.3 {
execsql { PRAGMA main.journal_mode }
} {delete}
finish_test
return
}
do_test walmode-1.1 {
set sqlite_sync_count 0
@@ -45,7 +59,15 @@ do_test walmode-1.2 {
file size test.db
} {1024}
set expected_sync_count 3
# Determine how many sync() calls to expect from the "journal_mode=WAL"
# command above. Note that if DEFAULT_WAL_SAFETYLEVEL is defined, the
# safety-level may have been modified while compiling the "journal_mode=WAL"
# statement.
switch -- [db eval {PRAGMA main.synchronous}] {
0 { set expected_sync_count 0 }
1 { set expected_sync_count 2 }
default { set expected_sync_count 3 }
}
if {$::tcl_platform(platform)!="windows"} {
ifcapable dirsync {
incr expected_sync_count
+1
View File
@@ -17,6 +17,7 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix walnoshm
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
db close
testvfs tvfsshm
+12 -6
View File
@@ -21,6 +21,12 @@ ifcapable !wal {
finish_test
return
}
if ![wal_is_ok] { finish_test; return }
set shmpath test.db-shm
if {[forced_proxy_locking]} {
set shmpath [execsql { pragma lock_proxy_file }]-shm
}
do_test walpersist-1.0 {
db eval {
@@ -31,18 +37,18 @@ do_test walpersist-1.0 {
file exists test.db-wal
} {1}
do_test walpersist-1.1 {
file exists test.db-shm
file exists $shmpath
} {1}
do_test walpersist-1.2 {
db close
list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db] [file exists test.db-wal] [file exists $shmpath]
} {1 0 0}
do_test walpersist-1.3 {
sqlite3 db test.db
db eval {SELECT length(a) FROM t1}
} {5000}
do_test walpersist-1.4 {
list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db] [file exists test.db-wal] [file exists $shmpath]
} {1 1 1}
do_test walpersist-1.5 {
file_control_persist_wal db -1
@@ -64,7 +70,7 @@ do_test walpersist-1.10 {
} {0 1}
do_test walpersist-1.11 {
db close
list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db] [file exists test.db-wal] [file exists $shmpath]
} {1 1 1}
# Make sure the journal_size_limit works to limit the size of the
@@ -72,7 +78,7 @@ do_test walpersist-1.11 {
# journal_size_limit causes the WAL file to be truncated to zero bytes
# when closing.
#
forcedelete test.db test.db-shm test.db-wal
forcedelete test.db $shmpath test.db-wal
do_test walpersist-2.1 {
sqlite3 db test.db
db eval {
@@ -97,7 +103,7 @@ do_test walpersist-2.3 {
do_test 3.1 {
catch {db close}
forcedelete test.db test.db-shm test.db-wal
forcedelete test.db $shmpath test.db-wal
sqlite3 db test.db
execsql {
PRAGMA page_size = 1024;
+21 -11
View File
@@ -30,6 +30,14 @@ ifcapable !wal {
finish_test
return
}
if ![wal_is_ok] { finish_test; return }
set shmpath test.db-shm
if {[forced_proxy_locking]} {
sqlite3 db test.db
set shmpath [execsql { pragma lock_proxy_file }]-shm
db close
}
do_multiclient_test tn {
# Do not run tests with the connections in the same process.
@@ -60,11 +68,11 @@ do_multiclient_test tn {
CREATE TABLE t1(x, y);
INSERT INTO t1 VALUES('a', 'b');
}
file exists test.db-shm
file exists $shmpath
} {1}
do_test 1.1.2 {
file attributes test.db-shm -permissions r--r--r--
file attributes $shmpath -permissions r--r--r--
code1 { sqlite3 db file:test.db?readonly_shm=1 }
} {}
@@ -97,7 +105,7 @@ do_multiclient_test tn {
do_test 1.2.1 {
code2 { db2 close }
code1 { db close }
list [file exists test.db-wal] [file exists test.db-shm]
list [file exists test.db-wal] [file exists $shmpath]
} {1 1}
do_test 1.2.2 {
code1 { sqlite3 db file:test.db?readonly_shm=1 }
@@ -106,9 +114,9 @@ do_multiclient_test tn {
do_test 1.2.3 {
code1 { db close }
file attributes test.db-shm -permissions rw-r--r--
hexio_write test.db-shm 0 01020304
file attributes test.db-shm -permissions r--r--r--
file attributes $shmpath -permissions rw-r--r--
hexio_write $shmpath 0 01020304
file attributes $shmpath -permissions r--r--r--
code1 { sqlite3 db file:test.db?readonly_shm=1 }
csql1 { SELECT * FROM t1 }
} {1 {attempt to write a readonly database}}
@@ -117,11 +125,11 @@ do_multiclient_test tn {
} {SQLITE_READONLY_RECOVERY}
do_test 1.2.5 {
file attributes test.db-shm -permissions rw-r--r--
file attributes $shmpath -permissions rw-r--r--
code2 { sqlite3 db2 test.db }
sql2 "SELECT * FROM t1"
} {a b c d e f g h i j}
file attributes test.db-shm -permissions r--r--r--
file attributes $shmpath -permissions r--r--r--
do_test 1.2.6 { sql1 "SELECT * FROM t1" } {a b c d e f g h i j}
do_test 1.2.7 {
@@ -147,7 +155,7 @@ do_multiclient_test tn {
do_test 1.3.2.1 {
code1 { db close }
code2 { db2 close }
file exists test.db-shm
file exists $shmpath
} {0}
do_test 1.3.2.2 {
code1 { sqlite3 db file:test.db?readonly_shm=1 }
@@ -155,8 +163,8 @@ do_multiclient_test tn {
} {1 {unable to open database file}}
do_test 1.3.2.3 {
code1 { db close }
close [open test.db-shm w]
file attributes test.db-shm -permissions r--r--r--
close [open $shmpath w]
file attributes $shmpath -permissions r--r--r--
code1 { sqlite3 db file:test.db?readonly_shm=1 }
csql1 { SELECT * FROM t1 }
} {1 {attempt to write a readonly database}}
@@ -165,4 +173,6 @@ do_multiclient_test tn {
} {SQLITE_READONLY_RECOVERY}
}
forcedelete $shmpath
finish_test
+1 -1
View File
@@ -17,6 +17,7 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
db close
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
@@ -60,4 +61,3 @@ do_test walshared-1.4 {
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test
+1
View File
@@ -18,6 +18,7 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !wal {finish_test ; return }
if ![wal_is_ok] { finish_test; return }
proc reopen_db {} {
catch { db close }
+1
View File
@@ -19,6 +19,7 @@ source $testdir/tester.tcl
source $testdir/lock_common.tcl
if {[run_thread_tests]==0} { finish_test ; return }
ifcapable !wal { finish_test ; return }
if ![wal_is_ok] { finish_test; return }
set sqlite_walsummary_mmap_incr 64
+2
View File
@@ -114,6 +114,7 @@ foreach hdr {
sqliteicu.h
sqliteInt.h
sqliteLimit.h
sqlrr.h
vdbe.h
vdbeInt.h
wal.h
@@ -320,6 +321,7 @@ foreach file {
rtree.c
icu.c
fts3_icu.c
sqlrr.c
} {
copy_file tsrc/$file
}