Compare commits

..

15 Commits

Author SHA1 Message Date
dan e8814cc83c Fix problems in the previous commit.
FossilOrigin-Name: 74ad80eb745c708bdbbbf24cbbbf50971e84182f
2017-01-21 16:21:24 +00:00
dan 0fbee29700 Add extra (somewhat inefficient) trace callbacks for triggers if SQLITE_TRACE_TRIGGER is defined.
FossilOrigin-Name: ffda1d1e1c858abd02f0c07b906cfac5ad075498
2017-01-21 15:58:42 +00:00
drh 184d902db1 In the kvtest.c test utility, reuse the buffer into which blobs are read,
rather than reallocating it for each row.  This is a closer match to how
other test programs work, and thus provides a better comparison.

FossilOrigin-Name: 0d1ad13a296b22d6fe36879b56f99bd6af1acd3a
2017-01-21 15:55:41 +00:00
drh 36cae856ee Remove an unnecessary sqlite3_bind_int64() call from sqlite3_blob_open().
Also other minor refactoring of the sqlite3_blob implementation.

FossilOrigin-Name: 9d197a532349f4b1caf66bbed70ca46df86cb86f
2017-01-21 14:11:28 +00:00
drh cd64553015 Minor performance optimization and size reduction to the accessPayload()
routine in btree.c.

FossilOrigin-Name: 264e5c10d7144910b3223b64546567fa20e4bc65
2017-01-20 20:43:14 +00:00
dan dfd0de82f1 Fix a typo in the help message for kvtest.
FossilOrigin-Name: 8971d98f25a4f5fb060db8ed6a4b06f083122a50
2017-01-20 16:47:34 +00:00
dan befcd8ad84 Add option "--stats" to test program kvtest. Specifying --stats causes kvtest
to output information similar to the shell tool option of the same name.

FossilOrigin-Name: 90291327fc127671d9847a4a2ce1ed47a408cfc6
2017-01-20 16:46:20 +00:00
drh 508286701a Get the "--testset rtree" option working on speedtest1. Add the --rtree,
--lookaside, and --clang options to the speed-check.sh script.

FossilOrigin-Name: 87b640c8d07a76b2bc7e896e01965cc09e06f77b
2017-01-20 16:09:12 +00:00
drh 4df65fc20f Minor performance optimizations to sqlite3_blob_open() and
sqlite3_blob_reopen().

FossilOrigin-Name: 52a61967d920047ea0b4409b79793e05c0128964
2017-01-20 00:40:26 +00:00
drh 8674e49214 If compiled with SQLITE_INLINE_MEMCPY, all memcpy() calls are replaced with
in-line code.  With that change, cachegrind shows which memcpy() calls
are taking the most time.  This is a performance-measurement hack only and
is not for production use.

FossilOrigin-Name: 9ed38521617136223a667988aed40e25797faf84
2017-01-19 21:20:11 +00:00
mistachkin 2f31d02049 In the 'vtshim' extension, avoid accessing freed memory when handling errors from xCreate/xConnect.
FossilOrigin-Name: ffd559afd32dcdce9c733ebccdee88fda9b689cf
2017-01-19 18:20:36 +00:00
mistachkin aac853bae8 In the 'windirent' test module, use a macro for the hidden/system attribute checking.
FossilOrigin-Name: a84a08d0716656dc0b26eafb1841c48d83c67ef2
2017-01-18 22:47:42 +00:00
mistachkin d3e73d6c1c Remove superfluous option to Tcl 'lsort' in the vtabH test file.
FossilOrigin-Name: b92cc6e58ae31cbe6600a522beb5485f7add04b2
2017-01-18 22:19:01 +00:00
mistachkin 7059138a08 Make the vtabH-3.1 test more portable and robust.
FossilOrigin-Name: d3c91c1fb345fbcbfc60a897bebf771c795430c9
2017-01-18 22:16:34 +00:00
mistachkin 8a9e83583b Fix handling of initial hidden and/or system files in the opendir() implementation for Windows. No changes to non-test code.
FossilOrigin-Name: 26dd42b462dc621b8b0a2295fc91d3e61ac732b6
2017-01-18 22:16:20 +00:00
25 changed files with 355 additions and 374 deletions
+1 -5
View File
@@ -174,7 +174,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
fts3_unicode.lo fts3_unicode2.lo fts3_write.lo \
fts5.lo \
func.lo global.lo hash.lo \
icu.lo insert.lo json1.lo kvapi.o legacy.lo loadext.lo \
icu.lo insert.lo json1.lo legacy.lo loadext.lo \
main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
memjournal.lo \
mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
@@ -226,7 +226,6 @@ SRC = \
$(TOP)/src/hash.h \
$(TOP)/src/hwtime.h \
$(TOP)/src/insert.c \
$(TOP)/src/kvapi.c \
$(TOP)/src/legacy.c \
$(TOP)/src/loadext.c \
$(TOP)/src/main.c \
@@ -768,9 +767,6 @@ hash.lo: $(TOP)/src/hash.c $(HDR)
insert.lo: $(TOP)/src/insert.c $(HDR)
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/insert.c
kvapi.lo: $(TOP)/src/kvapi.c $(HDR)
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/kvapi.c
legacy.lo: $(TOP)/src/legacy.c $(HDR)
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/legacy.c
+1 -5
View File
@@ -1081,7 +1081,7 @@ LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \
fts3_tokenize_vtab.lo fts3_unicode.lo fts3_unicode2.lo fts3_write.lo \
fts5.lo \
func.lo global.lo hash.lo \
icu.lo insert.lo kvapi.lo legacy.lo loadext.lo \
icu.lo insert.lo legacy.lo loadext.lo \
main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
memjournal.lo \
mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
@@ -1146,7 +1146,6 @@ SRC00 = \
$(TOP)\src\global.c \
$(TOP)\src\hash.c \
$(TOP)\src\insert.c \
$(TOP)\src\kvapi.c \
$(TOP)\src\legacy.c \
$(TOP)\src\loadext.c \
$(TOP)\src\main.c \
@@ -1742,9 +1741,6 @@ hash.lo: $(TOP)\src\hash.c $(HDR)
insert.lo: $(TOP)\src\insert.c $(HDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\insert.c
kvapi.lo: $(TOP)\src\kvapi.c $(HDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\kvapi.c
legacy.lo: $(TOP)\src\legacy.c $(HDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\legacy.c
+2
View File
@@ -95,6 +95,7 @@ static int vtshimCreate(
if( rc ){
sqlite3_free(pNew);
*ppVtab = 0;
return rc;
}
pNew->pAux = pAux;
pNew->ppPrev = &pAux->pAllVtab;
@@ -133,6 +134,7 @@ static int vtshimConnect(
if( rc ){
sqlite3_free(pNew);
*ppVtab = 0;
return rc;
}
pNew->pAux = pAux;
pNew->ppPrev = &pAux->pAllVtab;
+2 -3
View File
@@ -62,7 +62,7 @@ LIBOBJ+= vdbe.o parse.o \
fts3_tokenize_vtab.o \
fts3_unicode.o fts3_unicode2.o \
fts3_write.o fts5.o func.o global.o hash.o \
icu.o insert.o json1.o kvapi.o legacy.o loadext.o \
icu.o insert.o json1.o legacy.o loadext.o \
main.o malloc.o mem0.o mem1.o mem2.o mem3.o mem5.o \
memjournal.o \
mutex.o mutex_noop.o mutex_unix.o mutex_w32.o \
@@ -106,7 +106,6 @@ SRC = \
$(TOP)/src/hash.h \
$(TOP)/src/hwtime.h \
$(TOP)/src/insert.c \
$(TOP)/src/kvapi.c \
$(TOP)/src/legacy.c \
$(TOP)/src/loadext.c \
$(TOP)/src/main.c \
@@ -894,7 +893,7 @@ wordcount$(EXE): $(TOP)/test/wordcount.c sqlite3.c
$(TOP)/test/wordcount.c sqlite3.c
speedtest1$(EXE): $(TOP)/test/speedtest1.c sqlite3.o
$(TCC) -I. $(OTAFLAGS) -o speedtest1$(EXE) $(TOP)/test/speedtest1.c sqlite3.o $(THREADLIB)
$(TCCX) -I. $(OTAFLAGS) -o speedtest1$(EXE) $(TOP)/test/speedtest1.c sqlite3.o $(THREADLIB)
rbu$(EXE): $(TOP)/ext/rbu/rbu.c $(TOP)/ext/rbu/sqlite3rbu.c sqlite3.o
$(TCC) -I. -o rbu$(EXE) $(TOP)/ext/rbu/rbu.c sqlite3.o \
+28 -29
View File
@@ -1,8 +1,8 @@
C Add\sa\sprototype\sof\sthe\ssqlite3_kv_reset()\sinterface.
D 2017-01-19T12:07:08.814
F Makefile.in 78688a52015911e4b841b265c5fef09fbf81e655
C Fix\sproblems\sin\sthe\sprevious\scommit.
D 2017-01-21T16:21:24.115
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 836dde6df991bd855e93db1721f9347678cb9cda
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7
F VERSION cddd8d88dc8202afa0ebc96da61fc4acbd1e96a5
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
@@ -227,7 +227,7 @@ F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
F ext/rbu/rbu.c b2c0b5e6ae1a89affc0edfc127ebfa5f637a0ce4
F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842
@@ -314,7 +314,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
F main.mk c909362c60f2cb7b0a804605e4ccb43ac4ce79e9
F main.mk 8f620f3418d7252a3f428f5aacf674b5507807a8
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@@ -333,7 +333,7 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
F src/btree.c 69966fb2c574954cd3216f09407c9a02c52d3bd7
F src/btree.c e6b8f39d7dd1ad65f1747956de36f2595172a23d
F src/btree.h e6d352808956ec163a17f832193a3e198b3fb0ac
F src/btreeInt.h 10c4b77c2fb399580babbcc7cf652ac10dba796e
F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af
@@ -353,9 +353,8 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 05e47e2de7b712a3a4148cd469e5f60873f5ef13
F src/kvapi.c 3b20d8f7d7e69f17f81e7917e0f3a5ceca559d20
F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d
F src/loadext.c a68d8d1d14cf7488bb29dc5311cb1ce9a4404258
F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0
F src/malloc.c fc1b9f445290f2145da48fc08730c26e6082b640
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
@@ -389,17 +388,17 @@ F src/pragma.h 61aa5389118594bebb28120a6720401aee34ce1a
F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a
F src/printf.c ff10a9b9902cd2afe5f655f3013c6307d969b1fd
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c bb070cf5f23611c44ab7e4788803684e385fc3fb
F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6
F src/shell.c 6095531aa900decdaa765e0f3993fba7153c92c1
F src/sqlite.h.in ff59423b65e5573b3abdf65c8a437ceaef93eb69
F src/shell.c 0344f71dc008df2433ae10175f59ad432c428810
F src/sqlite.h.in e71655293c9bde26939496f3aac9d1821d2c07a2
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
F src/sqliteInt.h ce3e07c720b0cebc8887ea86b3b128da0913c5d3
F src/sqliteInt.h 525c061ae9aafc8d4720a018d82f0936d9eee5ab
F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247
F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1
F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
F src/tclsqlite.c 418f5e5e0840425a7e5b33f3600dccd378a57549
F src/test1.c 8a98191a1da8e100f77cdb5cc716df67d405028d
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
@@ -447,8 +446,8 @@ F src/test_tclvar.c df9fe1213c2634687a9ca0b0bec0d2119d359ae3
F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858
F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
F src/test_windirent.c 600398db0198ca1c77ca183831bf456746b6f5c4
F src/test_windirent.h 7edc57e2faa727026dbd5d010dd0e2e665d5aa01
F src/test_windirent.c 17f91f5f2aa1bb7328abb49414c363b5d2a9d3ff
F src/test_windirent.h 5d67483a55442e31e1bde0f4a230e6e932ad5906
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
F src/tokenize.c 5c2f516876fc27fbd7753913f032f49eb89e83b5
@@ -458,12 +457,12 @@ F src/update.c b356b29d04c71f33c779f2cb557cf953819bdd7a
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
F src/util.c a88b0466fddf445ce752226d4698ca3faada620a
F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16
F src/vdbe.c c7add5978cb84ae3a7bcb16f8b56cb3bbdf04b7e
F src/vdbe.c 132f552033f72820c27a100861fa83254358cbcd
F src/vdbe.h b0866e4191f096f1c987a84b042c3599bdf5423b
F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e
F src/vdbeInt.h 4cad10b68ed052104a997454540ea71ceb2888e1
F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24
F src/vdbeaux.c 35c9a9908174e5a26c96d15e1f98214814a39147
F src/vdbeblob.c f4f98ea672b242f807c08c92c7faaa79e5091b65
F src/vdbeblob.c 824f360105b8cd43c2ec8c4611fd3b162a3a3eed
F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd
F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face
F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
@@ -899,7 +898,7 @@ F test/json101.test c0897616f32d95431f37fd291cb78742181980ac
F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a
F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0
F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
F test/kvtest.c 2c66ddefcd03c2caa337f6dd79e6c82368af83df
F test/kvtest.c 9e428931f0733b5ba65b6b5abd95b27320e875a3
F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302
@@ -1132,7 +1131,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef
F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
F test/speedtest1.c 4e8ea6165046f02e1cfe0f4700256e91c981ec10
F test/speedtest1.c 02fe15bb784c5276a083ffe9969cc51e0bce7644
F test/spellfix.test f9c1f431e2c096c8775fec032952320c0e4700db
F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3
F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33
@@ -1384,7 +1383,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292
F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96
F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe
F test/vtabF.test 1918844c7c902f6a16c8dacf1ec8f84886d6e78b
F test/vtabH.test 97f61b0253260831af6232163f7852e2653baed6
F test/vtabH.test a2912cd3ea3386aecc3cb74ebfdfcc4e6d4b7dd3
F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
@@ -1488,8 +1487,8 @@ F tool/mkopcodeh.tcl a01d2c1d8a6205b03fc635adf3735b4c523befd3
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
F tool/mkpragmatab.tcl ebb4bfcd2f8010e0a3934b6118db4b5f2f5edf5c
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 12c48e8b822ed989e606450b372ee215aa6750ab
F tool/mksqlite3c.tcl 062485c4c907c5fdc824b4ccdf2c405f40fdf3fe
F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb
F tool/mksqlite3c.tcl 06b2e6a0f21cc0a5d70fbbd136b3e0a96470645e
F tool/mksqlite3h.tcl c006c4e5da57c649b24b689511dcd270dd7b0249
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5
@@ -1508,7 +1507,7 @@ F tool/showstat4.c b14159aa062f661b394ba37b6b7b94bfb8012ab9
F tool/showwal.c ec79959834f7b21f1e0a2aa52bb7c056d2203977
F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
F tool/spaceanal.tcl ab7d9bf68062907282a64b3e12ccbfad47193c5a
F tool/speed-check.sh e6ca0695b047af64201ebe0ef452e423f55d78b1
F tool/speed-check.sh 65ac2f5b00771b9dcefb95bebae1aab76c537ea3
F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
@@ -1548,7 +1547,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 02d60e196fe2a07ef90a5cfad0daa46020bfd06e
R a9d74517ea3f75ec81817c95ce60d493
U drh
Z 706252d4c96233de5edfe4f55ad55c0d
P ffda1d1e1c858abd02f0c07b906cfac5ad075498
R c37bc6770e2789d7f8851d61fd232055
U dan
Z a07b3b8a92ddc391359da9de406f8455
+1 -1
View File
@@ -1 +1 @@
088c590379f844c1443b0ccdf8695f1506584451
74ad80eb745c708bdbbbf24cbbbf50971e84182f
+8 -7
View File
@@ -4523,16 +4523,14 @@ static int accessPayload(
pCur->aOverflow, nOvfl*2*sizeof(Pgno)
);
if( aNew==0 ){
rc = SQLITE_NOMEM_BKPT;
return SQLITE_NOMEM_BKPT;
}else{
pCur->nOvflAlloc = nOvfl*2;
pCur->aOverflow = aNew;
}
}
if( rc==SQLITE_OK ){
memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
pCur->curFlags |= BTCF_ValidOvfl;
}
memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
pCur->curFlags |= BTCF_ValidOvfl;
}
/* If the overflow page-list cache has been allocated and the
@@ -4547,8 +4545,8 @@ static int accessPayload(
offset = (offset%ovflSize);
}
for( ; rc==SQLITE_OK && amt>0 && nextPage; iIdx++){
assert( rc==SQLITE_OK && amt>0 );
while( nextPage ){
/* If required, populate the overflow page-list cache. */
if( (pCur->curFlags & BTCF_ValidOvfl)!=0 ){
assert( pCur->aOverflow[iIdx]==0
@@ -4637,6 +4635,9 @@ static int accessPayload(
amt -= a;
pBuf += a;
}
if( amt==0 ) break;
if( rc ) break;
iIdx++;
}
}
-129
View File
@@ -1,129 +0,0 @@
/*
** 2017-01-18
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code used to implement key/value access interface.
*/
#include "sqliteInt.h"
#ifndef SQLITE_OMIT_KEYVALUE_ACCESSOR
/*
** An sqlite3_kv object is an accessor for key/value pairs.
**
** This is an opaque object. The public interface sees pointers to this
** object, but not the internals. So the internal composition of this
** object is free to change from one release to the next without breaking
** compatibility.
*/
struct sqlite3_kv {
sqlite3 *db; /* The database holding the table to be accessed */
u32 iRoot; /* Root page of the table */
int iGen; /* Schema generation number */
int iCookie; /* Schema cookie number from the database file */
Schema *pSchema; /* Schema holding the table */
sqlite3_int64 iRowid; /* Current rowid */
};
/*
** Create a new sqlite3_kv object open on zDb.zTable and return
** a pointer to that object.
*/
int sqlite3_kv_open(
sqlite3 *db, /* The database connection */
const char *zDb, /* Schema containing zTable. NULL for "main" */
const char *zTable, /* Name of table the key/value table */
unsigned int flags, /* Must be zero. Reserved for future expansion. */
sqlite3_kv **ppKvOut /* Store the new sqlite3_kv object here */
){
sqlite3_kv *pKv;
Table *pTab;
int rc = SQLITE_ERROR;
#ifdef SQLITE_ENABLE_API_ARMOR
if( ppKvOut==0 ){
return SQLITE_MISUSE_BKPT;
}
#endif
*ppKvOut = 0;
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) || zTable==0 ){
return SQLITE_MISUSE_BKPT;
}
#endif
sqlite3_mutex_enter(db->mutex);
sqlite3BtreeEnterAll(db);
pTab = sqlite3FindTable(db, zTable, zDb);
if( pTab==0 ){
goto kv_open_done;
}
if( !((pTab->nCol==1 && pTab->iPKey<0)
|| (pTab->nCol==2 && pTab->iPKey==0))
){
/* Must be an single-column table without an INTEGER PRIMARY KEY,
** or a two-column table where the first column is the INTEGER PRIMARY KEY
*/
goto kv_open_done;
}
if( pTab->pIndex!=0 || pTab->pFKey!=0 || pTab->pCheck!=0 ){
/* Do not allow secondary indexes, foreign keys, or CHECK constraints */
goto kv_open_done;
}
if( pTab->tabFlags & (TF_Autoincrement|TF_Virtual|TF_WithoutRowid) ){
/* Must not have autoincrement. Must not be a virtual table or a
** without rowid table */
goto kv_open_done;
}
*ppKvOut = pKv = sqlite3_malloc(sizeof(*pKv));
if( pKv==0 ){
rc = SQLITE_NOMEM;
goto kv_open_done;
}
pKv->db = db;
pKv->iGen = pTab->pSchema->iGeneration;
pKv->iCookie = pTab->pSchema->schema_cookie;
pKv->pSchema = pTab->pSchema;
pKv->iRoot = pTab->tnum;
rc = SQLITE_OK;
kv_open_done:
sqlite3BtreeLeaveAll(db);
sqlite3_mutex_leave(db->mutex);
return rc;
}
/*
** Free the key/value accessor at pKv
*/
int sqlite3_kv_close(sqlite3_kv *pKv){
sqlite3_free(pKv);
return SQLITE_OK;
}
int sqlite3_kv_seek(sqlite3_kv *pKv, sqlite3_int64 rowid){
return SQLITE_MISUSE;
}
int sqlite3_kv_reset(sqlite3_kv *pKv){
return SQLITE_MISUSE;
}
int sqlite3_kv_bytes(sqlite3_kv *pKv){
return -1;
}
int sqlite3_kv_read(sqlite3_kv *pKv, void *pBuf, int amt, int offset){
return SQLITE_MISUSE;
}
int sqlite3_kv_insert(sqlite3_kv *pKv, sqlite3_int64 rid, int sz, void *pBuf){
return SQLITE_MISUSE;
}
#endif /* #ifndef SQLITE_OMIT_KEYVALU_ACCESSOR */
-1
View File
@@ -18,7 +18,6 @@
#endif
#include "sqlite3ext.h"
#include "sqliteInt.h"
#include <string.h>
#ifndef SQLITE_OMIT_LOAD_EXTENSION
/*
-2
View File
@@ -15,8 +15,6 @@
** table and column.
*/
#include "sqliteInt.h"
#include <stdlib.h>
#include <string.h>
/*
** Walk the expression tree pExpr and increase the aggregate function
+17
View File
@@ -614,6 +614,7 @@ struct ShellState {
int autoExplain; /* Automatically turn on .explain mode */
int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
int statsOn; /* True to display memory stats before each finalize */
int vmstepsOn; /* Display VM steps before each finalize */
int scanstatsOn; /* True to display scan stats before each finalize */
int countChanges; /* True to display change counts */
int backslashOn; /* Resolve C-style \x escapes in SQL input text */
@@ -1997,6 +1998,12 @@ static int shell_exec(
display_stats(db, pArg, 0);
}
if( pArg && pArg->vmstepsOn && pStmt ){
int iCur = sqlite3_stmt_status(pStmt, SQLITE_STMTSTATUS_VM_STEP, 0);
FILE *out = pArg->traceOut ? pArg->traceOut : pArg->out;
raw_printf(out, "VM steps: %d\n", iCur);
}
/* print loop-counters if required */
if( pArg && pArg->scanstatsOn ){
display_scanstats(db, pArg);
@@ -5339,6 +5346,16 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else
if( c=='v' && strncmp(azArg[0], "vmsteps", n)==0 ){
if( nArg==2 ){
p->vmstepsOn = booleanValue(azArg[1]);
}else{
raw_printf(stderr, "Usage: .vmsteps ?on|off?\n");
rc = 1;
}
}else
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){
sqlite3WhereTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff;
-112
View File
@@ -497,8 +497,6 @@ int sqlite3_exec(
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
#define SQLITE_KV_BEFORE (SQLITE_NOTFOUND | (1<<8))
#define SQLITE_KV_AFTER (SQLITE_NOTFOUND | (2<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
@@ -8450,116 +8448,6 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
*/
SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
/*
** CAPI3REF: Key/Value Access
** EXPERIMENTAL
**
** The sqlite3_kv object is used to access database tables using
** the key/value interface.
*/
typedef struct sqlite3_kv sqlite3_kv;
/*
** CAPI3REF: Open a key/value accessor object
** CONSTRUCTOR: sqlite3_kv
** EXPERIMENTAL
**
** This interface attempts create a new [sqlite3_kv] object and
** return a pointer to that object in the 5th parameter.
** SQLITE_OK is returned on success or an error code if something
** goes wrong.
*/
int sqlite3_kv_open(
sqlite3 *db,
const char *zDb,
const char *zTable,
unsigned int flags, /* Must be zero. Reserved for future expansion. */
sqlite3_kv **ppKvOut
);
/*
** CAPI3REF: Close a key/value accessor object
** DESTRUCTOR: sqlite3_kv
** EXPERIMENTAL
**
** The sqlite3_kv_close(P) interface closes a key/value accessor P.
** The argument to sqlite3_kv_close(P) may be NULL, resulting in a harmless
** no-op.
*/
int sqlite3_kv_close(sqlite3_kv*);
/*
** CAPI3REF: Reposition a key/value accessor object
** METHOD: sqlite3_kv
** EXPERIMENTAL
**
** The sqlite3_kv_seek(P,I) interface attempts to reposition
** the key/value accessor object P so that it is pointing to a table
** entry with rowid I. The sqlite3_kv_seek(P,I) interface returns
** SQLITE_OK on success or an error code if it is unable to complete
** the operation. If no record exists with rowid I, then sqlite3_kv_seek(P,I)
** attempts to position itself at another nearby record and returns
** either SQLITE_KV_BEFORE or SQLITE_KV_AFTER depending on whether the
** record the accessor is left pointing to is less than or greater than I,
** respectively. If the table is empty, sqlite3_kv_seek(P,I) returns
** SQLITE_EMPTY.
**
** A successful sqlite3_kv_seek(P,I) call leave the key/value accessor
** P holding a read transaction open on the database. Use sqlite3_kv_reset(P)
** or sqlite3_kv_close(P) to release this transaction.
*/
int sqlite3_kv_seek(sqlite3_kv*, sqlite3_int64 rowid);
/*
** CAPI3REF: Reset a key/value accessor object
** METHOD: sqlite3_kv
** EXPERIMENTAL
**
** The sqlite3_kv_reset(P) interface restores the key/value accessor P
** back to its original state, releasing any transactions held.
*/
int sqlite3_kv_reset(sqlite3_kv*);
/*
** CAPI3REF: Find the size of the value for a key/value pair
** METHOD: sqlite3_kv
** EXPERIMENTAL
**
** The sqlite3_kv_bytes(P) interface returns the size of the value
** in the key/value pair that the key/value accessor object P is currently
** pointing to. The sqlite3_kv_bytes(P) interface returns a negative
** number if the key/value accessor object P is not currently pointing
** to a valid entry in the table.
*/
int sqlite3_kv_bytes(sqlite3_kv*);
/*
** CAPI3REF: Read the value for a key/value pair
** METHOD: sqlite3_kv
** EXPERIMENTAL
**
** The sqlite3_kv_read(P,B,A,O) interface attempts to read A bytes of
** content beginning at offset O from the value that the key/value accessor P
** is currently pointing at, storing the results in buffer B.
** The caller must ensure that the buffer B is at least A bytes in length.
*/
int sqlite3_kv_read(sqlite3_kv*, void *pBuf, int amt, int offset);
/*
** CAPI3REF: Insert a new key/value pair
** METHOD: sqlite3_kv
** EXPERIMENTAL
**
** The sqlite3_kv_insert(P,I,N,B) interface inserts a key/value pair
** having key I and a value that is an N-byte BLOB pointed to by B.
** In a call to sqlite3_kv_insert(P,I,N,B), if a previous row with key I
** already exists in the table, then that previous row is replaced by
** the new row.
*/
int sqlite3_kv_insert(sqlite3_kv*, sqlite3_int64 rowid, int size, void *pBuf);
/*
** Undo the hack that converts floating point types to integer for
** builds on processors without floating point support.
+12
View File
@@ -511,6 +511,18 @@
#include <assert.h>
#include <stddef.h>
/*
** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.
** This allows better measurements of where memcpy() is used when running
** cachegrind. But this macro version of memcpy() is very slow so it
** should not be used in production. This is a performance measurement
** hack only.
*/
#ifdef SQLITE_INLINE_MEMCPY
# define memcpy(D,S,N) {char*xxd=(char*)(D);const char*xxs=(const char*)(S);\
int xxn=(N);while(xxn-->0)*(xxd++)=*(xxs++);}
#endif
/*
** If compiling for a processor that lacks floating point support,
** substitute integer for floating-point
-2
View File
@@ -17,8 +17,6 @@
** if they are not used.
*/
#include "sqliteInt.h"
#include <stdlib.h>
#include <string.h>
#ifndef SQLITE_OMIT_GET_TABLE
+15 -8
View File
@@ -63,6 +63,7 @@ LPDIR opendir(
dirname = windirent_getenv("SystemDrive");
}
memset(&data, 0, sizeof(struct _finddata_t));
_snprintf(data.name, namesize, "%s\\*", dirname);
dirp->d_handle = _findfirst(data.name, &data);
@@ -71,12 +72,18 @@ LPDIR opendir(
return NULL;
}
/* TODO: Remove this block to allow hidden and system files. */
if( data.attrib&_A_HIDDEN || data.attrib&_A_SYSTEM ){
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ){
next:
memset(&data, 0, sizeof(struct _finddata_t));
if( _findnext(dirp->d_handle, &data)==-1 ){
closedir(dirp);
return NULL;
}
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ) goto next;
}
dirp->d_first.d_attributes = data.attrib;
@@ -105,11 +112,11 @@ LPDIRENT readdir(
next:
memset(&data, 0, sizeof(struct _finddata_t));
if( _findnext(dirp->d_handle, &data)==-1 ) return NULL;
/* TODO: Remove this block to allow hidden and system files. */
if( data.attrib&_A_HIDDEN ) goto next;
if( data.attrib&_A_SYSTEM ) goto next;
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ) goto next;
dirp->d_next.d_ino++;
dirp->d_next.d_attributes = data.attrib;
@@ -146,14 +153,14 @@ INT readdir_r(
next:
memset(&data, 0, sizeof(struct _finddata_t));
if( _findnext(dirp->d_handle, &data)==-1 ){
*result = NULL;
return ENOENT;
}
/* TODO: Remove this block to allow hidden and system files. */
if( data.attrib&_A_HIDDEN ) goto next;
if( data.attrib&_A_SYSTEM ) goto next;
/* TODO: Remove this block to allow hidden and/or system files. */
if( is_filtered(data) ) goto next;
entry->d_ino = (ino_t)-1; /* not available */
entry->d_attributes = data.attrib;
+11
View File
@@ -92,6 +92,17 @@ struct DIR {
DIRENT d_next; /* DIRENT constructed based on "_findnext". */
};
/*
** Provide a macro, for use by the implementation, to determine if a
** particular directory entry should be skipped over when searching for
** the next directory entry that should be returned by the readdir() or
** readdir_r() functions.
*/
#ifndef is_filtered
# define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
#endif
/*
** Provide the function prototype for the POSIX compatiable getenv()
** function. This function is not thread-safe.
+34
View File
@@ -960,6 +960,25 @@ case OP_Halt: {
p->nFrame--;
sqlite3VdbeSetChanges(db, p->nChange);
pcx = sqlite3VdbeFrameRestore(pFrame);
#ifdef SQLITE_TRACE_TRIGGER
if( (db->mTrace & SQLITE_TRACE_STMT) && aOp[0].p4.z ){
int nTotal = nVmStep - pFrame->nVmStep;
char *zTrace;
assert( nTotal>=0 );
assert( db->xTrace );
zTrace = sqlite3_mprintf("%.*s%s completed (VM steps: total=%d self=%d)",
p->nFrame, " :",
aOp[0].p4.z, nTotal, nVmStep - pFrame->nVmStepAdj
);
if( zTrace ){
(void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, 0, zTrace);
sqlite3_free(zTrace);
}
if( p->pFrame ){
p->pFrame->nVmStepAdj += nTotal;
}
}
#endif
lastRowid = db->lastRowid;
if( pOp->p2==OE_Ignore ){
/* Instruction pcx is the OP_Program that invoked the sub-program
@@ -5854,6 +5873,10 @@ case OP_Program: { /* jump */
pFrame->nDbChange = p->db->nChange;
assert( pFrame->pAuxData==0 );
pFrame->pAuxData = p->pAuxData;
#ifdef SQLITE_TRACE_TRIGGER
pFrame->nVmStep = nVmStep;
pFrame->nVmStepAdj = nVmStep;
#endif
p->pAuxData = 0;
p->nChange = 0;
p->pFrame = pFrame;
@@ -6889,6 +6912,17 @@ case OP_Init: { /* jump */
x(db->pTraceArg, z);
sqlite3_free(z);
}else
#endif
#ifdef SQLITE_TRACE_TRIGGER
if( p->pFrame ){
zTrace = sqlite3_mprintf("%.*s%s", p->nFrame-1,
" :", zTrace
);
if( zTrace ){
(void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
sqlite3_free(zTrace);
}
}else
#endif
{
(void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
+4
View File
@@ -175,6 +175,10 @@ struct VdbeFrame {
int nChildCsr; /* Number of cursors for child frame */
int nChange; /* Statement changes (Vdbe.nChange) */
int nDbChange; /* Value of db->nChange */
#ifdef SQLITE_TRACE_TRIGGER
int nVmStep; /* Value of nVmStep at start of program */
int nVmStepAdj; /* Adjusted for nested programs */
#endif
};
#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
+27 -25
View File
@@ -23,10 +23,10 @@
*/
typedef struct Incrblob Incrblob;
struct Incrblob {
int flags; /* Copy of "flags" passed to sqlite3_blob_open() */
int nByte; /* Size of open blob, in bytes */
int iOffset; /* Byte offset of blob in cursor data */
int iCol; /* Table column this handle is open on */
u16 iCol; /* Table column this handle is open on */
u8 isPureKV; /* True if pTab is a pure key/value table */
BtCursor *pCsr; /* Cursor pointing at blob row */
sqlite3_stmt *pStmt; /* Statement holding cursor open */
sqlite3 *db; /* The associated database */
@@ -57,12 +57,17 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
char *zErr = 0; /* Error message */
Vdbe *v = (Vdbe *)p->pStmt;
/* Set the value of the SQL statements only variable to integer iRow.
** This is done directly instead of using sqlite3_bind_int64() to avoid
** triggering asserts related to mutexes.
/* Set the value of register r[1] in the SQL statement to integer iRow.
** This is done directly as a performance optimization
*/
assert( v->aVar[0].flags&MEM_Int );
v->aVar[0].u.i = iRow;
v->aMem[1].flags = MEM_Int;
v->aMem[1].u.i = iRow;
/* If the statement has been run before (and is paused at the OP_ResultRow)
** then back it up to the point where it does the OP_SeekRowid. This could
** have been down with an extra OP_Goto, but simply setting the program
** counter is faster. */
if( v->pc>3 ) v->pc = 3;
rc = sqlite3_step(p->pStmt);
if( rc==SQLITE_ROW ){
@@ -112,7 +117,7 @@ int sqlite3_blob_open(
const char *zTable, /* The table containing the blob */
const char *zColumn, /* The column containing the blob */
sqlite_int64 iRow, /* The row containing the glob */
int flags, /* True -> read/write access, false -> read-only */
int wrFlag, /* True -> read/write access, false -> read-only */
sqlite3_blob **ppBlob /* Handle for accessing the blob returned here */
){
int nAttempt = 0;
@@ -134,7 +139,7 @@ int sqlite3_blob_open(
return SQLITE_MISUSE_BKPT;
}
#endif
flags = !!flags; /* flags = (flags ? 1 : 0); */
wrFlag = !!wrFlag; /* wrFlag = (wrFlag ? 1 : 0); */
sqlite3_mutex_enter(db->mutex);
@@ -194,9 +199,8 @@ int sqlite3_blob_open(
/* If the value is being opened for writing, check that the
** column is not indexed, and that it is not part of a foreign key.
** It is against the rules to open a column to which either of these
** descriptions applies for writing. */
if( flags ){
*/
if( wrFlag ){
const char *zFault = 0;
Index *pIdx;
#ifndef SQLITE_OMIT_FOREIGN_KEY
@@ -257,18 +261,17 @@ int sqlite3_blob_open(
static const VdbeOpList openBlob[] = {
{OP_TableLock, 0, 0, 0}, /* 0: Acquire a read or write lock */
{OP_OpenRead, 0, 0, 0}, /* 1: Open a cursor */
{OP_Variable, 1, 1, 0}, /* 2: Move ?1 into reg[1] */
{OP_NotExists, 0, 7, 1}, /* 3: Seek the cursor */
{OP_Column, 0, 0, 1}, /* 4 */
{OP_ResultRow, 1, 0, 0}, /* 5 */
{OP_Goto, 0, 2, 0}, /* 6 */
{OP_Halt, 0, 0, 0}, /* 7 */
/* blobSeekToRow() will initialize r[1] to the desired rowid */
{OP_NotExists, 0, 5, 1}, /* 2: Seek the cursor to rowid=r[1] */
{OP_Column, 0, 0, 1}, /* 3 */
{OP_ResultRow, 1, 0, 0}, /* 4 */
{OP_Halt, 0, 0, 0}, /* 5 */
};
Vdbe *v = (Vdbe *)pBlob->pStmt;
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
VdbeOp *aOp;
sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, flags,
sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, wrFlag,
pTab->pSchema->schema_cookie,
pTab->pSchema->iGeneration);
sqlite3VdbeChangeP5(v, 1);
@@ -285,7 +288,7 @@ int sqlite3_blob_open(
#else
aOp[0].p1 = iDb;
aOp[0].p2 = pTab->tnum;
aOp[0].p3 = flags;
aOp[0].p3 = wrFlag;
sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT);
}
if( db->mallocFailed==0 ){
@@ -293,7 +296,7 @@ int sqlite3_blob_open(
/* Remove either the OP_OpenWrite or OpenRead. Set the P2
** parameter of the other to pTab->tnum. */
if( flags ) aOp[1].opcode = OP_OpenWrite;
if( wrFlag ) aOp[1].opcode = OP_OpenWrite;
aOp[1].p2 = pTab->tnum;
aOp[1].p3 = iDb;
@@ -306,23 +309,22 @@ int sqlite3_blob_open(
*/
aOp[1].p4type = P4_INT32;
aOp[1].p4.i = pTab->nCol+1;
aOp[4].p2 = pTab->nCol;
aOp[3].p2 = pTab->nCol;
pParse->nVar = 1;
pParse->nVar = 0;
pParse->nMem = 1;
pParse->nTab = 1;
sqlite3VdbeMakeReady(v, pParse);
}
}
pBlob->flags = flags;
pBlob->isPureKV = (pTab->nCol==2 && pTab->iPKey==0);
pBlob->iCol = iCol;
pBlob->db = db;
sqlite3BtreeLeaveAll(db);
if( db->mallocFailed ){
goto blob_open_out;
}
sqlite3_bind_int64(pBlob->pStmt, 1, iRow);
rc = blobSeekToRow(pBlob, iRow, &zErr);
} while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );
+135 -6
View File
@@ -61,20 +61,20 @@
** ./kvtest run x1 --count 10000 --max-id 1000000
*/
static const char zHelp[] =
"Usage: kvhelp COMMAND ARGS...\n"
"Usage: kvtest COMMAND ARGS...\n"
"\n"
" kvhelp init DBFILE --count N --size M --pagesize X\n"
" kvtest init DBFILE --count N --size M --pagesize X\n"
"\n"
" Generate a new test database file named DBFILE containing N\n"
" BLOBs each of size M bytes. The page size of the new database\n"
" file will be X\n"
"\n"
" kvhelp export DBFILE DIRECTORY\n"
" kvtest export DBFILE DIRECTORY\n"
"\n"
" Export all the blobs in the kv table of DBFILE into separate\n"
" files in DIRECTORY.\n"
"\n"
" kvhelp run DBFILE [options]\n"
" kvtest run DBFILE [options]\n"
"\n"
" Run a performance test. DBFILE can be either the name of a\n"
" database or a directory containing sample files. Options:\n"
@@ -87,6 +87,7 @@ static const char zHelp[] =
" --max-id N Maximum blob key to use\n"
" --random Read blobs in a random order\n"
" --start N Start reading with this blob key\n"
" --stats Output operating stats before exiting\n"
;
/* Reference resources used */
@@ -369,6 +370,122 @@ static sqlite3_int64 timeOfDay(void){
return t;
}
#ifdef __linux__
/*
** Attempt to display I/O stats on Linux using /proc/PID/io
*/
static void displayLinuxIoStats(FILE *out){
FILE *in;
char z[200];
sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
in = fopen(z, "rb");
if( in==0 ) return;
while( fgets(z, sizeof(z), in)!=0 ){
static const struct {
const char *zPattern;
const char *zDesc;
} aTrans[] = {
{ "rchar: ", "Bytes received by read():" },
{ "wchar: ", "Bytes sent to write():" },
{ "syscr: ", "Read() system calls:" },
{ "syscw: ", "Write() system calls:" },
{ "read_bytes: ", "Bytes read from storage:" },
{ "write_bytes: ", "Bytes written to storage:" },
{ "cancelled_write_bytes: ", "Cancelled write bytes:" },
};
int i;
for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){
int n = (int)strlen(aTrans[i].zPattern);
if( strncmp(aTrans[i].zPattern, z, n)==0 ){
fprintf(out, "%-36s %s", aTrans[i].zDesc, &z[n]);
break;
}
}
}
fclose(in);
}
#endif
/*
** Display memory stats.
*/
static int display_stats(
sqlite3 *db, /* Database to query */
int bReset /* True to reset SQLite stats */
){
int iCur;
int iHiwtr;
FILE *out = stdout;
fprintf(out, "\n");
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
fprintf(out,
"Memory Used: %d (max %d) bytes\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
fprintf(out, "Number of Outstanding Allocations: %d (max %d)\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
fprintf(out,
"Number of Pcache Pages Used: %d (max %d) pages\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
fprintf(out,
"Number of Pcache Overflow Bytes: %d (max %d) bytes\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
fprintf(out,
"Number of Scratch Allocations Used: %d (max %d)\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
fprintf(out,
"Number of Scratch Overflow Bytes: %d (max %d) bytes\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
fprintf(out, "Largest Allocation: %d bytes\n",
iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
fprintf(out, "Largest Pcache Allocation: %d bytes\n",
iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);
fprintf(out, "Largest Scratch Allocation: %d bytes\n",
iHiwtr);
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
fprintf(out, "Pager Heap Usage: %d bytes\n",
iCur);
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
fprintf(out, "Page cache hits: %d\n", iCur);
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
fprintf(out, "Page cache misses: %d\n", iCur);
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
fprintf(out, "Page cache writes: %d\n", iCur);
iHiwtr = iCur = -1;
#ifdef __linux__
displayLinuxIoStats(out);
#endif
/* Do not remove this machine readable comment: extra-stats-output-here */
fprintf(out, "\n");
return 0;
}
/* Blob access order */
#define ORDER_ASC 1
#define ORDER_DESC 2
@@ -389,6 +506,7 @@ static int runMain(int argc, char **argv){
int iPagesize = 0; /* Database page size */
int iCache = 1000; /* Database cache size in kibibytes */
int bBlobApi = 0; /* Use the incremental blob I/O API */
int bStats = 0; /* Print stats before exiting */
int eOrder = ORDER_ASC; /* Access order */
sqlite3 *db = 0; /* Database connection */
sqlite3_stmt *pStmt = 0; /* Prepared statement for SQL access */
@@ -398,6 +516,7 @@ static int runMain(int argc, char **argv){
int nData = 0; /* Bytes of data */
sqlite3_int64 nTotal = 0; /* Total data read */
unsigned char *pData; /* Content of the blob */
int nAlloc = 0; /* Space allocated for pData[] */
assert( strcmp(argv[1],"run")==0 );
@@ -449,6 +568,10 @@ static int runMain(int argc, char **argv){
bBlobApi = 1;
continue;
}
if( strcmp(z, "-stats")==0 ){
bStats = 1;
continue;
}
fatalError("unknown option: \"%s\"", argv[i]);
}
tmStart = timeOfDay();
@@ -499,14 +622,16 @@ static int runMain(int argc, char **argv){
}
if( rc==SQLITE_OK ){
nData = sqlite3_blob_bytes(pBlob);
pData = sqlite3_malloc( nData+1 );
if( nAlloc<nData+1 ){
nAlloc = nData+100;
pData = sqlite3_realloc(pData, nAlloc);
}
if( pData==0 ) fatalError("cannot allocate %d bytes", nData+1);
rc = sqlite3_blob_read(pBlob, pData, nData, 0);
if( rc!=SQLITE_OK ){
fatalError("could not read the blob at %d: %s", iKey,
sqlite3_errmsg(db));
}
sqlite3_free(pData);
}
}else{
/* CASE 3: Reading from database using SQL */
@@ -540,8 +665,12 @@ static int runMain(int argc, char **argv){
nTotal += nData;
if( nData==0 ){ nCount++; nExtra++; }
}
if( nAlloc ) sqlite3_free(pData);
if( pStmt ) sqlite3_finalize(pStmt);
if( pBlob ) sqlite3_blob_close(pBlob);
if( bStats ){
display_stats(db, 0);
}
if( db ) sqlite3_close(db);
tmElapsed = timeOfDay() - tmStart;
if( nExtra ){
+10 -18
View File
@@ -61,9 +61,6 @@ static const char zHelp[] =
#if SQLITE_VERSION_NUMBER<3005000
# define sqlite3_int64 sqlite_int64
#endif
#ifdef SQLITE_ENABLE_RBU
# include "sqlite3rbu.h"
#endif
/* All global state is held in this structure */
static struct Global {
@@ -1181,10 +1178,10 @@ void testset_rtree(int p1, int p2){
unsigned mxCoord;
unsigned x0, x1, y0, y1, z0, z1;
unsigned iStep;
int *aCheck = sqlite3_malloc( sizeof(int)*g.szTest*100 );
int *aCheck = sqlite3_malloc( sizeof(int)*g.szTest*500 );
mxCoord = 15000;
n = g.szTest*100;
n = g.szTest*500;
speedtest1_begin_test(100, "%d INSERTs into an r-tree", n);
speedtest1_exec("BEGIN");
speedtest1_exec("CREATE VIRTUAL TABLE rt1 USING rtree(id,x0,x1,y0,y1,z0,z1)");
@@ -1207,11 +1204,11 @@ void testset_rtree(int p1, int p2){
speedtest1_end_test();
speedtest1_begin_test(101, "Copy from rtree to a regular table");
speedtest1_exec(" TABLE t1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)");
speedtest1_exec("CREATE TABLE t1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)");
speedtest1_exec("INSERT INTO t1 SELECT * FROM rt1");
speedtest1_end_test();
n = g.szTest*20;
n = g.szTest*100;
speedtest1_begin_test(110, "%d one-dimensional intersect slice queries", n);
speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x0>=?1 AND x1<=?2");
iStep = mxCoord/n;
@@ -1224,7 +1221,7 @@ void testset_rtree(int p1, int p2){
speedtest1_end_test();
if( g.bVerify ){
n = g.szTest*20;
n = g.szTest*100;
speedtest1_begin_test(111, "Verify result from 1-D intersect slice queries");
speedtest1_prepare("SELECT count(*) FROM t1 WHERE x0>=?1 AND x1<=?2");
iStep = mxCoord/n;
@@ -1240,7 +1237,7 @@ void testset_rtree(int p1, int p2){
speedtest1_end_test();
}
n = g.szTest*20;
n = g.szTest*100;
speedtest1_begin_test(120, "%d one-dimensional overlap slice queries", n);
speedtest1_prepare("SELECT count(*) FROM rt1 WHERE y1>=?1 AND y0<=?2");
iStep = mxCoord/n;
@@ -1253,7 +1250,7 @@ void testset_rtree(int p1, int p2){
speedtest1_end_test();
if( g.bVerify ){
n = g.szTest*20;
n = g.szTest*100;
speedtest1_begin_test(121, "Verify result from 1-D overlap slice queries");
speedtest1_prepare("SELECT count(*) FROM t1 WHERE y1>=?1 AND y0<=?2");
iStep = mxCoord/n;
@@ -1270,7 +1267,7 @@ void testset_rtree(int p1, int p2){
}
n = g.szTest*20;
n = g.szTest*100;
speedtest1_begin_test(125, "%d custom geometry callback queries", n);
sqlite3_rtree_geometry_callback(g.db, "xslice", xsliceGeometryCallback, 0);
speedtest1_prepare("SELECT count(*) FROM rt1 WHERE id MATCH xslice(?1,?2)");
@@ -1286,7 +1283,7 @@ void testset_rtree(int p1, int p2){
}
speedtest1_end_test();
n = g.szTest*80;
n = g.szTest*400;
speedtest1_begin_test(130, "%d three-dimensional intersect box queries", n);
speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x1>=?1 AND x0<=?2"
" AND y1>=?1 AND y0<=?2 AND z1>=?1 AND z0<=?2");
@@ -1299,7 +1296,7 @@ void testset_rtree(int p1, int p2){
}
speedtest1_end_test();
n = g.szTest*100;
n = g.szTest*500;
speedtest1_begin_test(140, "%d rowid queries", n);
speedtest1_prepare("SELECT * FROM rt1 WHERE id=?1");
for(i=1; i<=n; i++){
@@ -1458,11 +1455,6 @@ int main(int argc, char **argv){
noSync = 1;
}else if( strcmp(z,"notnull")==0 ){
g.zNN = "NOT NULL";
#ifdef SQLITE_ENABLE_RBU
}else if( strcmp(z,"rbu")==0 ){
sqlite3ota_create_vfs("rbu", 0);
sqlite3_vfs_register(sqlite3_vfs_find("rbu"), 1);
#endif
}else if( strcmp(z,"pagesize")==0 ){
if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]);
pageSize = integerValue(argv[++i]);
+31 -16
View File
@@ -121,29 +121,43 @@ if {$tcl_platform(platform)!="windows" || \
SELECT name FROM fsdir WHERE dir = '.' AND name = '.'
} {test.db .}
proc sort_files { names {nocase false} } {
if {$nocase && $::tcl_platform(platform) eq "windows"} {
return [lsort -nocase $names]
} else {
return [lsort $names]
}
}
proc list_root_files {} {
if {$::tcl_platform(platform) eq "windows"} {
set res [list]
foreach name [glob -directory $::env(fstreeDrive)/ -- *] {
set res [list]; set dir $::env(fstreeDrive)/; set names [list]
eval lappend names [glob -nocomplain -directory $dir -- *]
foreach name $names {
if {[string index [file tail $name] 0] eq "."} continue
if {[file attributes $name -hidden]} continue
if {[file attributes $name -system]} continue
lappend res $name
}
return $res
return [sort_files $res true]
} else {
return [string map {/ {}} [glob /*]]
return [sort_files [string map {/ {}} [glob -nocomplain -- /*]]]
}
}
proc list_files { pattern } {
if {$::tcl_platform(platform) eq "windows"} {
set res [list]
foreach name [glob -nocomplain $pattern] {
set res [list]; set names [list]
eval lappend names [glob -nocomplain -- $pattern]
foreach name $names {
if {[string index [file tail $name] 0] eq "."} continue
if {[file attributes $name -hidden]} continue
if {[file attributes $name -system]} continue
lappend res $name
}
return $res
return [sort_files $res]
} else {
return [glob -nocomplain $pattern]
return [sort_files [glob -nocomplain -- $pattern]]
}
}
@@ -153,18 +167,19 @@ if {$tcl_platform(platform)!="windows" || \
#
set res [list]
set root_files [list_root_files]
set num_root_files [llength $root_files]
set lim_root_files [expr {$num_root_files > 5 ? 5 : $num_root_files}]
foreach p [lrange $root_files 0 [expr {$lim_root_files - 1}]] {
foreach p $root_files {
if {$::tcl_platform(platform) eq "windows"} {
if {[regexp {\$} $p]} {incr lim_root_files -1} else {lappend res $p}
if {![regexp {\$} $p]} {lappend res $p}
} else {
lappend res "/$p"
}
}
do_execsql_test 3.1 [subst {
SELECT path FROM fstree WHERE path NOT GLOB '*\$*' LIMIT $lim_root_files;
}] $res
set num_root_files [llength $root_files]
do_test 3.1 {
sort_files [execsql {
SELECT path FROM fstree WHERE path NOT GLOB '*\$*' LIMIT $num_root_files;
}] true
} [sort_files $res true]
# Read all entries in the current directory.
#
@@ -182,7 +197,7 @@ if {$tcl_platform(platform)!="windows" || \
set res [contents $pwd]
do_execsql_test 3.2 {
SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1
} [lsort $res]
} [sort_files $res]
# Add some sub-directories and files to the current directory.
#
-1
View File
@@ -338,7 +338,6 @@ foreach file {
func.c
fkey.c
insert.c
kvapi.c
legacy.c
loadext.c
pragma.c
-1
View File
@@ -346,7 +346,6 @@ foreach file {
func.c
fkey.c
insert.c
kvapi.c
legacy.c
loadext.c
pragma.c
+16 -3
View File
@@ -23,6 +23,7 @@ NAME=$1
shift
#CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5"
CC_OPTS="-DSQLITE_ENABLE_MEMSYS5"
CC=gcc
SPEEDTEST_OPTS="--shrink-memory --reprepare --stats --heap 10000000 64"
SIZE=5
LEAN_OPTS="-DSQLITE_THREADSAFE=0"
@@ -80,11 +81,19 @@ while test "$1" != ""; do
--lean)
CC_OPTS="$CC_OPTS $LEAN_OPTS"
;;
--clang)
CC=clang
;;
--heap)
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5"
shift;
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64"
;;
--lookaside)
shift;
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --lookaside $1 $2"
shift;
;;
--repeat)
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RCACHE"
shift;
@@ -94,6 +103,10 @@ while test "$1" != ""; do
shift;
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --mmap $1"
;;
--rtree)
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset rtree"
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RTREE"
;;
*)
CC_OPTS="$CC_OPTS $1"
;;
@@ -105,15 +118,15 @@ echo "NAME = $NAME" | tee summary-$NAME.txt
echo "SPEEDTEST_OPTS = $SPEEDTEST_OPTS" | tee -a summary-$NAME.txt
echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt
rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o
gcc -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
$CC -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
size sqlite3.o | tee -a summary-$NAME.txt
if test $doExplain -eq 1; then
gcc -g -Os -Wall -I. $CC_OPTS \
$CC -g -Os -Wall -I. $CC_OPTS \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
fi
SRC=./speedtest1.c
gcc -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
$CC -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
ls -l speedtest1 | tee -a summary-$NAME.txt
if test $doCachegrind -eq 1; then
valgrind --tool=cachegrind ./speedtest1 speedtest1.db \