mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Merge all recent trunk enhancements into the sessions branch.
FossilOrigin-Name: 1d1c57c3566d86cd44f146688b620131b3b57e52
This commit is contained in:
16
Makefile.in
16
Makefile.in
@ -549,11 +549,19 @@ mptester$(EXE): sqlite3.c $(TOP)/mptest/mptest.c
|
||||
$(LTLINK) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.c \
|
||||
$(TLIBS) -rpath "$(libdir)"
|
||||
|
||||
MPTEST1=./mptester$(EXE) mptest.db $(TOP)/mptest/crash01.test --repeat 20
|
||||
MPTEST2=./mptester$(EXE) mptest.db $(TOP)/mptest/multiwrite01.test --repeat 20
|
||||
mptest: mptester$(EXE)
|
||||
rm -f mptest1.db
|
||||
./mptester$(EXE) mptest1.db $(TOP)/mptest/crash01.test
|
||||
rm -f mptest2.db
|
||||
./mptester$(EXE) mptest2.db $(TOP)/mptest/multiwrite01.test
|
||||
rm -f mptest.db
|
||||
$(MPTEST1) --journalmode DELETE
|
||||
$(MPTEST2) --journalmode WAL
|
||||
$(MPTEST1) --journalmode WAL
|
||||
$(MPTEST2) --journalmode PERSIST
|
||||
$(MPTEST1) --journalmode PERSIST
|
||||
$(MPTEST2) --journalmode TRUNCATE
|
||||
$(MPTEST1) --journalmode TRUNCATE
|
||||
$(MPTEST2) --journalmode DELETE
|
||||
|
||||
|
||||
# This target creates a directory named "tsrc" and fills it with
|
||||
# copies of all of the C source code and header files needed to
|
||||
|
65
manifest
65
manifest
@ -1,7 +1,7 @@
|
||||
C Merge\srecent\strunk\senhancements\sinto\sthe\ssessions\sbranch.
|
||||
D 2015-03-09T13:07:45.320
|
||||
C Merge\sall\srecent\strunk\senhancements\sinto\sthe\ssessions\sbranch.
|
||||
D 2015-03-17T18:54:10.608
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 5c5f6000dd1e4d8d8a402e4e749499720318fbd9
|
||||
F Makefile.in 1bf4de5d0809e0ed046d6f2671ea46d1d6c69608
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
F Makefile.msc 0de5ab64775feb698a51950874e56cf15fb8f67f
|
||||
F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858
|
||||
@ -175,15 +175,15 @@ F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5
|
||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||
F mptest/crash01.test cce8e306d8596d5a2e497e27112dae1f6e5e3538
|
||||
F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421
|
||||
F mptest/crash02.subtest f4ef05adcd15d60e5d2bd654204f2c008b519df8
|
||||
F mptest/mptest.c 24c5f72415df2eab7088ef8c9f99f163aed590c8
|
||||
F mptest/multiwrite01.test 499ad0310da8dff8e8f98d2e272fc2a8aa741b2e
|
||||
F mptest/mptest.c 0c0c82c1d9aea0b1a60ef9456a04c35ab1106622
|
||||
F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d
|
||||
F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
|
||||
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
||||
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||
F src/alter.c ba266a779bc7ce10e52e59e7d3dc79fa342e8fdb
|
||||
F src/alter.c d23d6b6991f66b383934f137fd4384d93fb98c81
|
||||
F src/analyze.c 91540f835163d5369ccbae78e2e6c74d0dd53c1d
|
||||
F src/attach.c 880f9b8641a829c563e52dd13c452ce457ae4dd8
|
||||
F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
|
||||
@ -202,7 +202,7 @@ F src/delete.c 5075d88557eb4e2a7fdb2b61a96142830d8589b8
|
||||
F src/expr.c 3ef111b88ae2941b84b6b6ea4be8d501ba1af0cb
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c e0444b61bed271a76840cbe6182df93a9baa3f12
|
||||
F src/func.c 44512c557d6d4a40e51f3980c5854ae3e92862d6
|
||||
F src/func.c 1414c24c873c48796ad45942257a179a423ba42f
|
||||
F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e
|
||||
F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
|
||||
F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
|
||||
@ -231,7 +231,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8
|
||||
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
|
||||
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
||||
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
||||
F src/os_unix.c 49d06acee4053920e4a6429844f440b5f975cea4
|
||||
F src/os_unix.c cc903ecc6ebda90ef703d043ddaa7f33de0cab0f
|
||||
F src/os_win.c 8223e7db5b7c4a81d8b161098ac3959400434cdb
|
||||
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
||||
F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c
|
||||
@ -249,14 +249,14 @@ F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b
|
||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
||||
F src/select.c 94e016b6733b1d39a2f4c8d431155b4c2897d907
|
||||
F src/shell.c b90258c9083d94f51434ab57ab12336550a1483f
|
||||
F src/sqlite.h.in b0e4bb95b2728d7663a9d8f64ba3d3865ac646e1
|
||||
F src/sqlite.h.in dff62c6db32b6b627184edae85878d66b184bd62
|
||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
||||
F src/sqliteInt.h 9c62b8dff75ed3a8fc3bb5883a91e66ece8666da
|
||||
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
|
||||
F src/status.c 81712116e826b0089bb221b018929536b2b5406f
|
||||
F src/table.c e7a09215315a978057fb42c640f890160dbcc45e
|
||||
F src/tclsqlite.c 82984e46304db7fdf4163180b106b5bdf81b5d0e
|
||||
F src/tclsqlite.c 7ed2644b48685cba250eb71c7c298fedab6e221a
|
||||
F src/test1.c 90fbedce75330d48d99eadb7d5f4223e86969585
|
||||
F src/test2.c 577961fe48961b2f2e5c8b56ee50c3f459d3359d
|
||||
F src/test3.c 64d2afdd68feac1bb5e2ffb8226c8c639f798622
|
||||
@ -275,7 +275,7 @@ F src/test_config.c 5140cf3a0b766d177dfb9f8f2a3b00224ec3f5c8
|
||||
F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852
|
||||
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
|
||||
F src/test_fs.c ced436e3d4b8e4681328409b8081051ce614e28f
|
||||
F src/test_func.c 14e543ae4d905ee31dc322b2f8d31bfac1769d45
|
||||
F src/test_func.c f1ac201465472e76a73e2f3695c3553c63e7322a
|
||||
F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd
|
||||
F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32
|
||||
F src/test_intarray.c 6c610a21ab8edde85a3a2c7f2b069244ecf4d834
|
||||
@ -283,7 +283,7 @@ F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202
|
||||
F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa
|
||||
F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4
|
||||
F src/test_malloc.c b9495384e74923aefde8311de974bf9b0f5ba570
|
||||
F src/test_multiplex.c 61edf02530f7511a0529352cd8139ead3af4c401
|
||||
F src/test_multiplex.c 97813565daa7ee480abcc5dd1e9984ed1f71eb8c
|
||||
F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3
|
||||
F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f
|
||||
F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25
|
||||
@ -300,7 +300,7 @@ F src/test_superlock.c 06797157176eb7085027d9dd278c0d7a105e3ec9
|
||||
F src/test_syscall.c 2e21ca7f7dc54a028f1967b63f1e76155c356f9b
|
||||
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
|
||||
F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9
|
||||
F src/test_vfs.c 5a14c63da9579ba148138c1fb233100f2eb58ebb
|
||||
F src/test_vfs.c b7e6831e6fcf04c5090accff30640ec5c9630739
|
||||
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
|
||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481
|
||||
@ -310,21 +310,21 @@ F src/update.c d207deb7a031f698104bee879de0632b611e72dd
|
||||
F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
|
||||
F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e
|
||||
F src/vacuum.c 9460b9de7b2d4e34b0d374894aa6c8a0632be8ec
|
||||
F src/vdbe.c e70e58bfce88e0075c1b17a2f37c57389b7bc0ba
|
||||
F src/vdbe.c 20dc93eae5fe11a33a7edf6d863c634e4e2eb15e
|
||||
F src/vdbe.h b434bb75fbec973d18d49225a59833ae39ee2afc
|
||||
F src/vdbeInt.h 50fc184e25bfe1b39b8e508082cd3f0cd8a29b3d
|
||||
F src/vdbeapi.c be4717b0a037fd834d195ef152682513533cddb5
|
||||
F src/vdbeaux.c fbc0e6dfcf472e76001f7684b3b534710a645138
|
||||
F src/vdbeapi.c d95f2bb43d01a91d93231cde181811b38182202e
|
||||
F src/vdbeaux.c bf85a5975ade7da58fb31473a713c2f63ac86697
|
||||
F src/vdbeblob.c ab33f9b57cfce7dddb23853090186da614be4846
|
||||
F src/vdbemem.c 96e41193b4affd9ebc0eea2fa628879dac88c744
|
||||
F src/vdbemem.c 149e585645c3f3ef063f2b7251646388cfe3d47d
|
||||
F src/vdbesort.c 6d64c5448b64851b99931ede980addc3af70d5e2
|
||||
F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
|
||||
F src/vtab.c 699f2b8d509cfe379c33dde33827875d5b030e01
|
||||
F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb
|
||||
F src/wal.c 39303f2c9db02a4e422cd8eb2c8760420c6a51fe
|
||||
F src/wal.c 878c8e1a51cb2ec45c395d26b7d5cd9e1a098e4a
|
||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||
F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
|
||||
F src/where.c eb141b075776e9864d38f279333e2472a8653202
|
||||
F src/where.c 42ce3fd5ec9fe050f623be358cfddee01c1f6286
|
||||
F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
@ -344,12 +344,13 @@ F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4
|
||||
F test/analyze6.test f1c552ce39cca4ec922a7e4e0e5d0203d6b3281f
|
||||
F test/analyze7.test bb1409afc9e8629e414387ef048b8e0e3e0bdc4f
|
||||
F test/analyze8.test c05a461d0a6b05991106467d0c47480f2e709c82
|
||||
F test/analyze9.test 72795c8113604b5dcd47a1498a61d6d7fb5d041a
|
||||
F test/analyze9.test 3dd9e203fad353ec8027b18a6d9a92af59f4e727
|
||||
F test/analyzeA.test 3335697f6700c7052295cfd0067fc5b2aacddf9a
|
||||
F test/analyzeB.test 8bf35ee0a548aea831bf56762cb8e7fdb1db083d
|
||||
F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93
|
||||
F test/analyzeD.test 08f9d0bee4e118a66fff3a32d02dbe0ee0a2b594
|
||||
F test/analyzeE.test 8684e8ac5722fb97c251887ad97e5d496a98af1d
|
||||
F test/analyzeF.test 7ccd7a04f7d3061bde1a8a4dacc4792edccf6bf2
|
||||
F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b
|
||||
F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b
|
||||
F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7
|
||||
@ -459,6 +460,7 @@ F test/crash5.test 05dd3aa9dbb751a22d5cdaf22a9c49b6667aa219
|
||||
F test/crash6.test 4c56f1e40d0291e1110790a99807aa875b1647ba
|
||||
F test/crash7.test 1a194c4900a255258cf94b7fcbfd29536db572df
|
||||
F test/crash8.test 61442a9964ab6b124fc5254e4258b45747842e6f
|
||||
F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d
|
||||
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
|
||||
F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8
|
||||
F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c
|
||||
@ -609,7 +611,7 @@ F test/fts3matchinfo.test 58544fa4d254000fa4e7f494b0a832f7ba61d45e
|
||||
F test/fts3near.test 7e3354d46f155a822b59c0e957fd2a70c1d7e905
|
||||
F test/fts3prefix.test b36d4f00b128a51e7b386cc013a874246d9d7dc1
|
||||
F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce
|
||||
F test/fts3query.test d81ffb0ab1d4e1a2a330b8eb1e160b60603f4745
|
||||
F test/fts3query.test c838b18f2b859e15fd31c64be3d79ef1556803ca
|
||||
F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0
|
||||
F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e
|
||||
F test/fts3snippet.test 03c2f3be7d3b7c8bb105ed237f204833392bd57f
|
||||
@ -656,11 +658,12 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
|
||||
F test/in4.test d2b38cba404bc4320f4fe1b595b3d163f212c068
|
||||
F test/in5.test 1de657472fa9ac2924be25c2c959ac5ca1aae554
|
||||
F test/incrblob.test e81846d214f3637622620fbde7cd526781cfe328
|
||||
F test/incrblob2.test 0d8821730a84f90af78a9dd547fe7a2480a06240
|
||||
F test/incrblob2.test a5ce5ed1d0b01e2ed347245a21170372528af0a5
|
||||
F test/incrblob3.test d8d036fde015d4a159cd3cbae9d29003b37227a4
|
||||
F test/incrblob4.test f26502a5697893e5acea268c910f16478c2f0fab
|
||||
F test/incrblob_err.test af1f12ba60d220c9752073ff2bda2ad59e88960d
|
||||
F test/incrblobfault.test 280474078f6da9e732cd2a215d3d854969014b6e
|
||||
F test/incrcorrupt.test 9786cba68c5832f01887fde1c06b43c3904d86f6
|
||||
F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32
|
||||
F test/incrvacuum2.test 676c41428765d58f1da7dbe659ef27726d3d30ac
|
||||
F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a
|
||||
@ -719,14 +722,14 @@ F test/lock4.test e175ae13865bc87680607563bafba21f31a26f12
|
||||
F test/lock5.test c6c5e0ebcb21c61a572870cc86c0cb9f14cede38
|
||||
F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5
|
||||
F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431
|
||||
F test/lock_common.tcl 0c270b121d40959fa2f3add382200c27045b3d95
|
||||
F test/lock_common.tcl 7ffb45accf6ee91c736df9bafe0806a44358f035
|
||||
F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2
|
||||
F test/main.test 16131264ea0c2b93b95201f0c92958e85f2ba11a
|
||||
F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
|
||||
F test/malloc.test 96939d2d1a6f39667bbebe5bc27c6525f2ab614e
|
||||
F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a
|
||||
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
|
||||
F test/malloc5.test fafce0aa9157060445cd1a56ad50fc79d82f28c3
|
||||
F test/malloc5.test 79182b8bffd6d62f77b1a5a8ba8e6bf0e5053b8e
|
||||
F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151
|
||||
F test/malloc7.test 7c68a32942858bc715284856c5507446bba88c3a
|
||||
F test/malloc8.test 9b7a3f8cb9cf0b12fff566e80a980b1767bd961d
|
||||
@ -742,7 +745,7 @@ F test/mallocG.test 0ff91b65c50bdaba680fb75d87fe4ad35bb7934f
|
||||
F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb
|
||||
F test/mallocI.test a88c2b9627c8506bf4703d8397420043a786cdb6
|
||||
F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e
|
||||
F test/mallocK.test 223cc80c870c80d4a9c2014e94133efdf0123f82
|
||||
F test/mallocK.test da01dcdd316767b8356741f8d33a23a06a23def5
|
||||
F test/mallocL.test 252ddc7eb4fbf75364eab17b938816085ff1fc17
|
||||
F test/malloc_common.tcl 3663f9001ce3e29bbaa9677ffe15cd468e3ec7e3
|
||||
F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e
|
||||
@ -924,7 +927,7 @@ F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6
|
||||
F test/table.test 06271d61eb13871490d38168433c1ef3dd82bb2a
|
||||
F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
|
||||
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
|
||||
F test/tclsqlite.test a7308276aad2e6c0bfb5b0414424dd0d9cc0cad7
|
||||
F test/tclsqlite.test 7179b4e0bf236ddf0bfa6bfaefa76fbe0a23c28a
|
||||
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
|
||||
F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
|
||||
F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1
|
||||
@ -1157,6 +1160,7 @@ F test/wal9.test 378e76a9ad09cd9bee06c172ad3547b0129a6750
|
||||
F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe
|
||||
F test/walbak.test b9f68e39646375c2b877be906babcc15d38b4877
|
||||
F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434
|
||||
F test/walblock.test f1290524714232c109fb0b14db28f14d81c3ddd0
|
||||
F test/walcksum.test 9afeb96240296c08c72fc524d199c912cfe34daa
|
||||
F test/walcrash.test 451d79e528add5c42764cea74aa2750754171b25
|
||||
F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36
|
||||
@ -1190,6 +1194,7 @@ F test/whereG.test 69f5ec4b15760a8c860f80e2d55525669390aab3
|
||||
F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2
|
||||
F test/whereI.test 1d89199697919d4930be05a71e7fe620f114e622
|
||||
F test/whereJ.test 55a3221706a7ab706293f17cc8f96da563bf0767
|
||||
F test/whereK.test f8e3cf26a8513ecc7f514f54df9f0572c046c42b
|
||||
F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
|
||||
F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c
|
||||
F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c
|
||||
@ -1259,7 +1264,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 131a2d3116436ca6304777c9c5d46b7c4051d949 984c3fd5261619fb542a5a95dab37707b5d79dbf
|
||||
R cb093bb12447629434661af3de009e52
|
||||
P 68c8937e83b770d5ec6b1855c1bde81057c11b5f 7214dab7443d35c105904dd69635c1f8b45b2fc8
|
||||
R 2d91509a074fbfae08a7fbe6a418b4b7
|
||||
U drh
|
||||
Z afb94d5a3aa820ac14e063085ce8c969
|
||||
Z 602e4d87f819b64c7ba9f529ae0477ce
|
||||
|
@ -1 +1 @@
|
||||
68c8937e83b770d5ec6b1855c1bde81057c11b5f
|
||||
1d1c57c3566d86cd44f146688b620131b3b57e52
|
@ -32,6 +32,7 @@
|
||||
--end
|
||||
--wait 1
|
||||
--task 2
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t2 SELECT a, b FROM t1;
|
||||
UPDATE t1 SET b='x'||a||'y';
|
||||
@ -46,6 +47,7 @@
|
||||
--match 29 28 27 26 25
|
||||
--end
|
||||
--task 3
|
||||
DROP TABLE IF EXISTS t3;
|
||||
CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t3 SELECT a, b FROM t1;
|
||||
UPDATE t1 SET b='x'||a||'y';
|
||||
@ -60,6 +62,7 @@
|
||||
--match 29 28 27 26 25
|
||||
--end
|
||||
--task 4
|
||||
DROP TABLE IF EXISTS t4;
|
||||
CREATE TABLE t4(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t4 SELECT a, b FROM t1;
|
||||
UPDATE t1 SET b='x'||a||'y';
|
||||
@ -74,6 +77,7 @@
|
||||
--match 29 28 27 26 25
|
||||
--end
|
||||
--task 5
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t5 SELECT a, b FROM t1;
|
||||
UPDATE t1 SET b='x'||a||'y';
|
||||
|
@ -1262,6 +1262,9 @@ int main(int argc, char **argv){
|
||||
int taskId;
|
||||
const char *zTrace;
|
||||
const char *zCOption;
|
||||
const char *zJMode;
|
||||
const char *zNRep;
|
||||
int nRep = 1, iRep;
|
||||
|
||||
g.argv0 = argv[0];
|
||||
g.iTrace = 1;
|
||||
@ -1277,6 +1280,10 @@ int main(int argc, char **argv){
|
||||
}
|
||||
n = argc-2;
|
||||
sqlite3_snprintf(sizeof(g.zName), g.zName, "%05d.mptest", GETPID());
|
||||
zJMode = findOption(argv+2, &n, "journalmode", 1);
|
||||
zNRep = findOption(argv+2, &n, "repeat", 1);
|
||||
if( zNRep ) nRep = atoi(zNRep);
|
||||
if( nRep<1 ) nRep = 1;
|
||||
g.zVfs = findOption(argv+2, &n, "vfs", 1);
|
||||
zClient = findOption(argv+2, &n, "client", 1);
|
||||
g.zErrLog = findOption(argv+2, &n, "errlog", 1);
|
||||
@ -1348,7 +1355,11 @@ int main(int argc, char **argv){
|
||||
fatalError("missing script filename");
|
||||
}
|
||||
if( n>1 ) unrecognizedArguments(argv[0], n, argv+2);
|
||||
if( zJMode ) runSql("PRAGMA journal_mode=%Q;", zJMode);
|
||||
runSql(
|
||||
"DROP TABLE IF EXISTS task;\n"
|
||||
"DROP TABLE IF EXISTS counters;\n"
|
||||
"DROP TABLE IF EXISTS client;\n"
|
||||
"CREATE TABLE task(\n"
|
||||
" id INTEGER PRIMARY KEY,\n"
|
||||
" name TEXT,\n"
|
||||
@ -1364,10 +1375,12 @@ int main(int argc, char **argv){
|
||||
"CREATE TABLE client(id INTEGER PRIMARY KEY, wantHalt);\n"
|
||||
);
|
||||
zScript = readFile(argv[2]);
|
||||
if( g.iTrace ) logMessage("begin script [%s]\n", argv[2]);
|
||||
runScript(0, 0, zScript, argv[2]);
|
||||
for(iRep=1; iRep<=nRep; iRep++){
|
||||
if( g.iTrace ) logMessage("begin script [%s] cycle %d\n", argv[2], iRep);
|
||||
runScript(0, 0, zScript, argv[2]);
|
||||
if( g.iTrace ) logMessage("end script [%s] cycle %d\n", argv[2], iRep);
|
||||
}
|
||||
sqlite3_free(zScript);
|
||||
if( g.iTrace ) logMessage("end script [%s]\n", argv[2]);
|
||||
waitForClient(0, 2000, "during shutdown...\n");
|
||||
trySql("UPDATE client SET wantHalt=1");
|
||||
sqlite3_sleep(10);
|
||||
@ -1391,7 +1404,7 @@ int main(int argc, char **argv){
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
}
|
||||
sqlite3_close(g.db);
|
||||
sqlite3_close(g.db);
|
||||
maybeClose(g.pLog);
|
||||
maybeClose(g.pErrLog);
|
||||
if( iClient==0 ){
|
||||
|
@ -361,6 +361,8 @@ PRAGMA integrity_check(10);
|
||||
WHERE t4.b GLOB 'x4?y' AND t3.b=('x'||(t4.a+5)||'y')
|
||||
ORDER BY t3.a LIMIT 7
|
||||
--match 45 46 47 48 49 50 51
|
||||
PRAGMA integrity_check;
|
||||
--match ok
|
||||
--end
|
||||
--task 5
|
||||
SELECT t1.a FROM t1, t2
|
||||
@ -371,6 +373,8 @@ PRAGMA integrity_check(10);
|
||||
WHERE t4.b GLOB 'x4?y' AND t3.b=('x'||(t4.a+5)||'y')
|
||||
ORDER BY t3.a LIMIT 7
|
||||
--match 45 46 47 48 49 50 51
|
||||
PRAGMA integrity_check;
|
||||
--match ok
|
||||
--end
|
||||
--task 3
|
||||
SELECT t1.a FROM t1, t2
|
||||
@ -381,6 +385,8 @@ PRAGMA integrity_check(10);
|
||||
WHERE t4.b GLOB 'x4?y' AND t3.b=('x'||(t4.a+5)||'y')
|
||||
ORDER BY t3.a LIMIT 7
|
||||
--match 45 46 47 48 49 50 51
|
||||
PRAGMA integrity_check;
|
||||
--match ok
|
||||
--end
|
||||
--task 2
|
||||
SELECT t1.a FROM t1, t2
|
||||
@ -391,6 +397,8 @@ PRAGMA integrity_check(10);
|
||||
WHERE t4.b GLOB 'x4?y' AND t3.b=('x'||(t4.a+5)||'y')
|
||||
ORDER BY t3.a LIMIT 7
|
||||
--match 45 46 47 48 49 50 51
|
||||
PRAGMA integrity_check;
|
||||
--match ok
|
||||
--end
|
||||
--task 4
|
||||
SELECT t1.a FROM t1, t2
|
||||
@ -401,5 +409,7 @@ PRAGMA integrity_check(10);
|
||||
WHERE t4.b GLOB 'x4?y' AND t3.b=('x'||(t4.a+5)||'y')
|
||||
ORDER BY t3.a LIMIT 7
|
||||
--match 45 46 47 48 49 50 51
|
||||
PRAGMA integrity_check;
|
||||
--match ok
|
||||
--end
|
||||
--wait all
|
||||
|
@ -690,7 +690,10 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||
*/
|
||||
if( pDflt ){
|
||||
sqlite3_value *pVal = 0;
|
||||
if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){
|
||||
int rc;
|
||||
rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal);
|
||||
assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
|
||||
if( rc!=SQLITE_OK ){
|
||||
db->mallocFailed = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,9 @@
|
||||
** Return the collating function associated with a function.
|
||||
*/
|
||||
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
|
||||
VdbeOp *pOp = &context->pVdbe->aOp[context->iOp-1];
|
||||
VdbeOp *pOp;
|
||||
assert( context->pVdbe!=0 );
|
||||
pOp = &context->pVdbe->aOp[context->iOp-1];
|
||||
assert( pOp->opcode==OP_CollSeq );
|
||||
assert( pOp->p4type==P4_COLLSEQ );
|
||||
return pOp->p4.pColl;
|
||||
|
@ -248,6 +248,7 @@ static pid_t randomnessPid = 0;
|
||||
#define UNIXFILE_URI 0x40 /* Filename might have query parameters */
|
||||
#define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
|
||||
#define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings issued */
|
||||
#define UNIXFILE_BLOCK 0x0200 /* Next SHM lock might block */
|
||||
|
||||
/*
|
||||
** Include code that is common to all os_*.c files
|
||||
@ -4090,15 +4091,17 @@ struct unixShm {
|
||||
** otherwise.
|
||||
*/
|
||||
static int unixShmSystemLock(
|
||||
unixShmNode *pShmNode, /* Apply locks to this open shared-memory segment */
|
||||
unixFile *pFile, /* Open connection to the WAL file */
|
||||
int lockType, /* F_UNLCK, F_RDLCK, or F_WRLCK */
|
||||
int ofst, /* First byte of the locking range */
|
||||
int n /* Number of bytes to lock */
|
||||
){
|
||||
struct flock f; /* The posix advisory locking structure */
|
||||
int rc = SQLITE_OK; /* Result code form fcntl() */
|
||||
unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */
|
||||
struct flock f; /* The posix advisory locking structure */
|
||||
int rc = SQLITE_OK; /* Result code form fcntl() */
|
||||
|
||||
/* Access to the unixShmNode object is serialized by the caller */
|
||||
pShmNode = pFile->pInode->pShmNode;
|
||||
assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
|
||||
|
||||
/* Shared locks never span more than one byte */
|
||||
@ -4108,6 +4111,7 @@ static int unixShmSystemLock(
|
||||
assert( n>=1 && n<SQLITE_SHM_NLOCK );
|
||||
|
||||
if( pShmNode->h>=0 ){
|
||||
int lkType;
|
||||
/* Initialize the locking parameters */
|
||||
memset(&f, 0, sizeof(f));
|
||||
f.l_type = lockType;
|
||||
@ -4115,8 +4119,10 @@ static int unixShmSystemLock(
|
||||
f.l_start = ofst;
|
||||
f.l_len = n;
|
||||
|
||||
rc = osFcntl(pShmNode->h, F_SETLK, &f);
|
||||
lkType = (pFile->ctrlFlags & UNIXFILE_BLOCK)!=0 ? F_SETLKW : F_SETLK;
|
||||
rc = osFcntl(pShmNode->h, lkType, &f);
|
||||
rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
|
||||
pFile->ctrlFlags &= ~UNIXFILE_BLOCK;
|
||||
}
|
||||
|
||||
/* Update the global lock state and do debug tracing */
|
||||
@ -4326,13 +4332,13 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
|
||||
** If not, truncate the file to zero length.
|
||||
*/
|
||||
rc = SQLITE_OK;
|
||||
if( unixShmSystemLock(pShmNode, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
|
||||
if( unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
|
||||
if( robust_ftruncate(pShmNode->h, 0) ){
|
||||
rc = unixLogError(SQLITE_IOERR_SHMOPEN, "ftruncate", zShmFilename);
|
||||
}
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = unixShmSystemLock(pShmNode, F_RDLCK, UNIX_SHM_DMS, 1);
|
||||
rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);
|
||||
}
|
||||
if( rc ) goto shm_open_err;
|
||||
}
|
||||
@ -4564,7 +4570,7 @@ static int unixShmLock(
|
||||
|
||||
/* Unlock the system-level locks */
|
||||
if( (mask & allMask)==0 ){
|
||||
rc = unixShmSystemLock(pShmNode, F_UNLCK, ofst+UNIX_SHM_BASE, n);
|
||||
rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);
|
||||
}else{
|
||||
rc = SQLITE_OK;
|
||||
}
|
||||
@ -4592,7 +4598,7 @@ static int unixShmLock(
|
||||
/* Get shared locks at the system level, if necessary */
|
||||
if( rc==SQLITE_OK ){
|
||||
if( (allShared & mask)==0 ){
|
||||
rc = unixShmSystemLock(pShmNode, F_RDLCK, ofst+UNIX_SHM_BASE, n);
|
||||
rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);
|
||||
}else{
|
||||
rc = SQLITE_OK;
|
||||
}
|
||||
@ -4617,7 +4623,7 @@ static int unixShmLock(
|
||||
** also mark the local connection as being locked.
|
||||
*/
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n);
|
||||
rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);
|
||||
if( rc==SQLITE_OK ){
|
||||
assert( (p->sharedMask & mask)==0 );
|
||||
p->exclMask |= mask;
|
||||
@ -7222,6 +7228,10 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
|
||||
*/
|
||||
static int proxyFileControl(sqlite3_file *id, int op, void *pArg){
|
||||
switch( op ){
|
||||
case SQLITE_FCNTL_WAL_BLOCK: {
|
||||
id->ctrlFlags |= UNIXFILE_BLOCK;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
case SQLITE_FCNTL_GET_LOCKPROXYFILE: {
|
||||
unixFile *pFile = (unixFile*)id;
|
||||
if( pFile->pMethod == &proxyIoMethods ){
|
||||
|
@ -945,6 +945,13 @@ struct sqlite3_io_methods {
|
||||
** pointed to by the pArg argument. This capability is used during testing
|
||||
** and only needs to be supported when SQLITE_TEST is defined.
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
|
||||
** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
|
||||
** be advantageous to block on the next WAL lock if the lock is not immediately
|
||||
** available. The WAL subsystem issues this signal during rare
|
||||
** circumstances in order to fix a problem with priority inversion.
|
||||
** Applications should <em>not</em> use this file-control.
|
||||
**
|
||||
** </ul>
|
||||
*/
|
||||
#define SQLITE_FCNTL_LOCKSTATE 1
|
||||
@ -969,6 +976,7 @@ struct sqlite3_io_methods {
|
||||
#define SQLITE_FCNTL_SYNC 21
|
||||
#define SQLITE_FCNTL_COMMIT_PHASETWO 22
|
||||
#define SQLITE_FCNTL_WIN32_SET_HANDLE 23
|
||||
#define SQLITE_FCNTL_WAL_BLOCK 24
|
||||
|
||||
/* deprecated names */
|
||||
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
|
||||
|
@ -2405,34 +2405,49 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
||||
}
|
||||
|
||||
/*
|
||||
** $db function NAME [-argcount N] SCRIPT
|
||||
** $db function NAME [-argcount N] [-deterministic] SCRIPT
|
||||
**
|
||||
** Create a new SQL function called NAME. Whenever that function is
|
||||
** called, invoke SCRIPT to evaluate the function.
|
||||
*/
|
||||
case DB_FUNCTION: {
|
||||
int flags = SQLITE_UTF8;
|
||||
SqlFunc *pFunc;
|
||||
Tcl_Obj *pScript;
|
||||
char *zName;
|
||||
int nArg = -1;
|
||||
if( objc==6 ){
|
||||
const char *z = Tcl_GetString(objv[3]);
|
||||
int i;
|
||||
if( objc<4 ){
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "NAME ?SWITCHES? SCRIPT");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
for(i=3; i<(objc-1); i++){
|
||||
const char *z = Tcl_GetString(objv[i]);
|
||||
int n = strlen30(z);
|
||||
if( n>2 && strncmp(z, "-argcount",n)==0 ){
|
||||
if( Tcl_GetIntFromObj(interp, objv[4], &nArg) ) return TCL_ERROR;
|
||||
if( i==(objc-2) ){
|
||||
Tcl_AppendResult(interp, "option requires an argument: ", z, 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetIntFromObj(interp, objv[i+1], &nArg) ) return TCL_ERROR;
|
||||
if( nArg<0 ){
|
||||
Tcl_AppendResult(interp, "number of arguments must be non-negative",
|
||||
(char*)0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
i++;
|
||||
}else
|
||||
if( n>2 && strncmp(z, "-deterministic",n)==0 ){
|
||||
flags |= SQLITE_DETERMINISTIC;
|
||||
}else{
|
||||
Tcl_AppendResult(interp, "bad option \"", z,
|
||||
"\": must be -argcount or -deterministic", 0
|
||||
);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
pScript = objv[5];
|
||||
}else if( objc!=4 ){
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "NAME [-argcount N] SCRIPT");
|
||||
return TCL_ERROR;
|
||||
}else{
|
||||
pScript = objv[3];
|
||||
}
|
||||
|
||||
pScript = objv[objc-1];
|
||||
zName = Tcl_GetStringFromObj(objv[2], 0);
|
||||
pFunc = findSqlFunc(pDb, zName);
|
||||
if( pFunc==0 ) return TCL_ERROR;
|
||||
@ -2442,7 +2457,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
||||
pFunc->pScript = pScript;
|
||||
Tcl_IncrRefCount(pScript);
|
||||
pFunc->useEvalObjv = safeToUseEvalObjv(interp, pScript);
|
||||
rc = sqlite3_create_function(pDb->db, zName, nArg, SQLITE_UTF8,
|
||||
rc = sqlite3_create_function(pDb->db, zName, nArg, flags,
|
||||
pFunc, tclSqlFunc, 0, 0);
|
||||
if( rc!=SQLITE_OK ){
|
||||
rc = TCL_ERROR;
|
||||
|
@ -600,12 +600,26 @@ static void test_decode(
|
||||
Tcl_DecrRefCount(pRet);
|
||||
}
|
||||
|
||||
/*
|
||||
** The implementation of scalar SQL function "test_zeroblob()". This is
|
||||
** similar to the built-in zeroblob() function, except that it does not
|
||||
** check that the integer parameter is within range before passing it
|
||||
** to sqlite3_result_zeroblob().
|
||||
*/
|
||||
static void test_zeroblob(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
int nZero = sqlite3_value_int(argv[0]);
|
||||
sqlite3_result_zeroblob(context, nZero);
|
||||
}
|
||||
|
||||
static int registerTestFunctions(sqlite3 *db){
|
||||
static const struct {
|
||||
char *zName;
|
||||
signed char nArg;
|
||||
unsigned char eTextRep; /* 1: UTF-16. 0: UTF-8 */
|
||||
unsigned int eTextRep; /* 1: UTF-16. 0: UTF-8 */
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
|
||||
} aFuncs[] = {
|
||||
{ "randstr", 2, SQLITE_UTF8, randStr },
|
||||
@ -626,6 +640,7 @@ static int registerTestFunctions(sqlite3 *db){
|
||||
{ "real2hex", 1, SQLITE_UTF8, real2hex},
|
||||
{ "test_decode", 1, SQLITE_UTF8, test_decode},
|
||||
{ "test_extract", 2, SQLITE_UTF8, test_extract},
|
||||
{ "test_zeroblob", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, test_zeroblob},
|
||||
};
|
||||
int i;
|
||||
|
||||
|
@ -573,6 +573,9 @@ static int multiplexOpen(
|
||||
rc = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
|
||||
if( rc==SQLITE_OK && zName ){
|
||||
int bExists;
|
||||
if( flags & SQLITE_OPEN_MASTER_JOURNAL ){
|
||||
pGroup->bEnabled = 0;
|
||||
}else
|
||||
if( sz==0 ){
|
||||
if( flags & SQLITE_OPEN_MAIN_JOURNAL ){
|
||||
/* If opening a main journal file and the first chunk is zero
|
||||
|
@ -967,16 +967,15 @@ static void tvfsShmBarrier(sqlite3_file *pFile){
|
||||
TestvfsFd *pFd = tvfsGetFd(pFile);
|
||||
Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);
|
||||
|
||||
if( p->pScript && p->mask&TESTVFS_SHMBARRIER_MASK ){
|
||||
const char *z = pFd->pShm ? pFd->pShm->zFile : "";
|
||||
tvfsExecTcl(p, "xShmBarrier", Tcl_NewStringObj(z, -1), pFd->pShmId, 0, 0);
|
||||
}
|
||||
|
||||
if( p->isFullshm ){
|
||||
sqlite3OsShmBarrier(pFd->pReal);
|
||||
return;
|
||||
}
|
||||
|
||||
if( p->pScript && p->mask&TESTVFS_SHMBARRIER_MASK ){
|
||||
tvfsExecTcl(p, "xShmBarrier",
|
||||
Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0, 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static int tvfsShmUnmap(
|
||||
@ -1532,7 +1531,7 @@ static int testvfs_cmd(
|
||||
return TCL_OK;
|
||||
|
||||
bad_args:
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "VFSNAME ?-noshm BOOL? ?-default BOOL? ?-mxpathname INT? ?-szosfile INT? ?-iversion INT?");
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "VFSNAME ?-noshm BOOL? ?-fullshm BOOL? ?-default BOOL? ?-mxpathname INT? ?-szosfile INT? ?-iversion INT?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1527,7 +1527,7 @@ arithmetic_result_is_null:
|
||||
**
|
||||
** The interface used by the implementation of the aforementioned functions
|
||||
** to retrieve the collation sequence set by this opcode is not available
|
||||
** publicly, only to user functions defined in func.c.
|
||||
** publicly. Only built-in functions have access to this feature.
|
||||
*/
|
||||
case OP_CollSeq: {
|
||||
assert( pOp->p4type==P4_COLLSEQ );
|
||||
|
@ -370,7 +370,7 @@ void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
|
||||
pCtx->isError = errCode;
|
||||
pCtx->fErrorOrAux = 1;
|
||||
#ifdef SQLITE_DEBUG
|
||||
pCtx->pVdbe->rcApp = errCode;
|
||||
if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
|
||||
#endif
|
||||
if( pCtx->pOut->flags & MEM_Null ){
|
||||
sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1,
|
||||
@ -633,16 +633,26 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the current time for a statement
|
||||
** Return the current time for a statement. If the current time
|
||||
** is requested more than once within the same run of a single prepared
|
||||
** statement, the exact same time is returned for each invocation regardless
|
||||
** of the amount of time that elapses between invocations. In other words,
|
||||
** the time returned is always the time of the first call.
|
||||
*/
|
||||
sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
|
||||
Vdbe *v = p->pVdbe;
|
||||
int rc;
|
||||
if( v->iCurrentTime==0 ){
|
||||
rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, &v->iCurrentTime);
|
||||
if( rc ) v->iCurrentTime = 0;
|
||||
#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
|
||||
assert( p->pVdbe!=0 );
|
||||
#else
|
||||
sqlite3_int64 iTime = 0;
|
||||
sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
|
||||
#endif
|
||||
if( *piTime==0 ){
|
||||
rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
|
||||
if( rc ) *piTime = 0;
|
||||
}
|
||||
return v->iCurrentTime;
|
||||
return *piTime;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -712,6 +722,11 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
|
||||
AuxData *pAuxData;
|
||||
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
#if SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
if( pCtx->pVdbe==0 ) return 0;
|
||||
#else
|
||||
assert( pCtx->pVdbe!=0 );
|
||||
#endif
|
||||
for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
|
||||
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
|
||||
}
|
||||
@ -735,6 +750,11 @@ void sqlite3_set_auxdata(
|
||||
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
if( iArg<0 ) goto failed;
|
||||
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
if( pVdbe==0 ) goto failed;
|
||||
#else
|
||||
assert( pVdbe!=0 );
|
||||
#endif
|
||||
|
||||
for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
|
||||
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
|
||||
|
@ -2144,7 +2144,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
** doing this the directory is synced again before any individual
|
||||
** transaction files are deleted.
|
||||
*/
|
||||
rc = sqlite3OsDelete(pVfs, zMaster, 1);
|
||||
rc = sqlite3OsDelete(pVfs, zMaster, needSync);
|
||||
sqlite3DbFree(db, zMaster);
|
||||
zMaster = 0;
|
||||
if( rc ){
|
||||
|
121
src/vdbemem.c
121
src/vdbemem.c
@ -1089,7 +1089,7 @@ struct ValueNewStat4Ctx {
|
||||
** Otherwise, if the second argument is non-zero, then this function is
|
||||
** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not
|
||||
** already been allocated, allocate the UnpackedRecord structure that
|
||||
** that function will return to its caller here. Then return a pointer
|
||||
** that function will return to its caller here. Then return a pointer to
|
||||
** an sqlite3_value within the UnpackedRecord.a[] array.
|
||||
*/
|
||||
static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
|
||||
@ -1133,6 +1133,113 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
|
||||
return sqlite3ValueNew(db);
|
||||
}
|
||||
|
||||
/*
|
||||
** The expression object indicated by the second argument is guaranteed
|
||||
** to be a scalar SQL function. If
|
||||
**
|
||||
** * all function arguments are SQL literals,
|
||||
** * the SQLITE_FUNC_CONSTANT function flag is set, and
|
||||
** * the SQLITE_FUNC_NEEDCOLL function flag is not set,
|
||||
**
|
||||
** then this routine attempts to invoke the SQL function. Assuming no
|
||||
** error occurs, output parameter (*ppVal) is set to point to a value
|
||||
** object containing the result before returning SQLITE_OK.
|
||||
**
|
||||
** Affinity aff is applied to the result of the function before returning.
|
||||
** If the result is a text value, the sqlite3_value object uses encoding
|
||||
** enc.
|
||||
**
|
||||
** If the conditions above are not met, this function returns SQLITE_OK
|
||||
** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to
|
||||
** NULL and an SQLite error code returned.
|
||||
*/
|
||||
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
static int valueFromFunction(
|
||||
sqlite3 *db, /* The database connection */
|
||||
Expr *p, /* The expression to evaluate */
|
||||
u8 enc, /* Encoding to use */
|
||||
u8 aff, /* Affinity to use */
|
||||
sqlite3_value **ppVal, /* Write the new value here */
|
||||
struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */
|
||||
){
|
||||
sqlite3_context ctx; /* Context object for function invocation */
|
||||
sqlite3_value **apVal = 0; /* Function arguments */
|
||||
int nVal = 0; /* Size of apVal[] array */
|
||||
FuncDef *pFunc = 0; /* Function definition */
|
||||
sqlite3_value *pVal = 0; /* New value */
|
||||
int rc = SQLITE_OK; /* Return code */
|
||||
int nName; /* Size of function name in bytes */
|
||||
ExprList *pList = 0; /* Function arguments */
|
||||
int i; /* Iterator variable */
|
||||
|
||||
assert( pCtx!=0 );
|
||||
assert( (p->flags & EP_TokenOnly)==0 );
|
||||
pList = p->x.pList;
|
||||
if( pList ) nVal = pList->nExpr;
|
||||
nName = sqlite3Strlen30(p->u.zToken);
|
||||
pFunc = sqlite3FindFunction(db, p->u.zToken, nName, nVal, enc, 0);
|
||||
assert( pFunc );
|
||||
if( (pFunc->funcFlags & SQLITE_FUNC_CONSTANT)==0
|
||||
|| (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
|
||||
){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
if( pList ){
|
||||
apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal);
|
||||
if( apVal==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
goto value_from_function_out;
|
||||
}
|
||||
for(i=0; i<nVal; i++){
|
||||
rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
|
||||
if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;
|
||||
}
|
||||
}
|
||||
|
||||
pVal = valueNew(db, pCtx);
|
||||
if( pVal==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
goto value_from_function_out;
|
||||
}
|
||||
|
||||
assert( pCtx->pParse->rc==SQLITE_OK );
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.pOut = pVal;
|
||||
ctx.pFunc = pFunc;
|
||||
pFunc->xFunc(&ctx, nVal, apVal);
|
||||
if( ctx.isError ){
|
||||
rc = ctx.isError;
|
||||
sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
|
||||
}else{
|
||||
sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
|
||||
assert( rc==SQLITE_OK );
|
||||
rc = sqlite3VdbeChangeEncoding(pVal, enc);
|
||||
if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
|
||||
rc = SQLITE_TOOBIG;
|
||||
pCtx->pParse->nErr++;
|
||||
}
|
||||
}
|
||||
pCtx->pParse->rc = rc;
|
||||
|
||||
value_from_function_out:
|
||||
if( rc!=SQLITE_OK ){
|
||||
pVal = 0;
|
||||
}
|
||||
if( apVal ){
|
||||
for(i=0; i<nVal; i++){
|
||||
sqlite3ValueFree(apVal[i]);
|
||||
}
|
||||
sqlite3DbFree(db, apVal);
|
||||
}
|
||||
|
||||
*ppVal = pVal;
|
||||
return rc;
|
||||
}
|
||||
#else
|
||||
# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK
|
||||
#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
|
||||
|
||||
/*
|
||||
** Extract a value from the supplied expression in the manner described
|
||||
** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
|
||||
@ -1165,6 +1272,12 @@ static int valueFromExpr(
|
||||
while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft;
|
||||
if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
|
||||
|
||||
/* Compressed expressions only appear when parsing the DEFAULT clause
|
||||
** on a table column definition, and hence only when pCtx==0. This
|
||||
** check ensures that an EP_TokenOnly expression is never passed down
|
||||
** into valueFromFunction(). */
|
||||
assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );
|
||||
|
||||
if( op==TK_CAST ){
|
||||
u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
|
||||
rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
|
||||
@ -1241,6 +1354,12 @@ static int valueFromExpr(
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
else if( op==TK_FUNCTION && pCtx!=0 ){
|
||||
rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
|
||||
}
|
||||
#endif
|
||||
|
||||
*ppVal = pVal;
|
||||
return rc;
|
||||
|
||||
|
17
src/wal.c
17
src/wal.c
@ -788,9 +788,10 @@ static void walUnlockShared(Wal *pWal, int lockIdx){
|
||||
SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);
|
||||
WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx)));
|
||||
}
|
||||
static int walLockExclusive(Wal *pWal, int lockIdx, int n){
|
||||
static int walLockExclusive(Wal *pWal, int lockIdx, int n, int fBlock){
|
||||
int rc;
|
||||
if( pWal->exclusiveMode ) return SQLITE_OK;
|
||||
if( fBlock ) sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_WAL_BLOCK, 0);
|
||||
rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
|
||||
SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);
|
||||
WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal,
|
||||
@ -1076,7 +1077,7 @@ static int walIndexRecover(Wal *pWal){
|
||||
assert( pWal->writeLock );
|
||||
iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;
|
||||
nLock = SQLITE_SHM_NLOCK - iLock;
|
||||
rc = walLockExclusive(pWal, iLock, nLock);
|
||||
rc = walLockExclusive(pWal, iLock, nLock, 0);
|
||||
if( rc ){
|
||||
return rc;
|
||||
}
|
||||
@ -1610,7 +1611,7 @@ static int walBusyLock(
|
||||
){
|
||||
int rc;
|
||||
do {
|
||||
rc = walLockExclusive(pWal, lockIdx, n);
|
||||
rc = walLockExclusive(pWal, lockIdx, n, 0);
|
||||
}while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );
|
||||
return rc;
|
||||
}
|
||||
@ -2043,7 +2044,7 @@ static int walIndexReadHdr(Wal *pWal, int *pChanged){
|
||||
walUnlockShared(pWal, WAL_WRITE_LOCK);
|
||||
rc = SQLITE_READONLY_RECOVERY;
|
||||
}
|
||||
}else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){
|
||||
}else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 1)) ){
|
||||
pWal->writeLock = 1;
|
||||
if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
|
||||
badHdr = walIndexTryHdr(pWal, pChanged);
|
||||
@ -2249,7 +2250,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
|
||||
&& (mxReadMark<pWal->hdr.mxFrame || mxI==0)
|
||||
){
|
||||
for(i=1; i<WAL_NREADER; i++){
|
||||
rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
|
||||
rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame;
|
||||
mxI = i;
|
||||
@ -2505,7 +2506,7 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal){
|
||||
/* Only one writer allowed at a time. Get the write lock. Return
|
||||
** SQLITE_BUSY if unable.
|
||||
*/
|
||||
rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
|
||||
rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 0);
|
||||
if( rc ){
|
||||
return rc;
|
||||
}
|
||||
@ -2650,7 +2651,7 @@ static int walRestartLog(Wal *pWal){
|
||||
if( pInfo->nBackfill>0 ){
|
||||
u32 salt1;
|
||||
sqlite3_randomness(4, &salt1);
|
||||
rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
|
||||
rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
/* If all readers are using WAL_READ_LOCK(0) (in other words if no
|
||||
** readers are currently using the WAL), then the transactions
|
||||
@ -2975,7 +2976,7 @@ int sqlite3WalCheckpoint(
|
||||
|
||||
/* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
|
||||
** "checkpoint" lock on the database file. */
|
||||
rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
|
||||
rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1, 0);
|
||||
if( rc ){
|
||||
/* EVIDENCE-OF: R-10421-19736 If any other process is running a
|
||||
** checkpoint operation at the same time, the lock cannot be obtained and
|
||||
|
282
src/where.c
282
src/where.c
@ -770,6 +770,79 @@ static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){
|
||||
pWC->a[iParent].nChild++;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the N-th AND-connected subterm of pTerm. Or if pTerm is not
|
||||
** a conjunction, then return just pTerm when N==0. If N is exceeds
|
||||
** the number of available subterms, return NULL.
|
||||
*/
|
||||
static WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){
|
||||
if( pTerm->eOperator!=WO_AND ){
|
||||
return N==0 ? pTerm : 0;
|
||||
}
|
||||
if( N<pTerm->u.pAndInfo->wc.nTerm ){
|
||||
return &pTerm->u.pAndInfo->wc.a[N];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Subterms pOne and pTwo are contained within WHERE clause pWC. The
|
||||
** two subterms are in disjunction - they are OR-ed together.
|
||||
**
|
||||
** If these two terms are both of the form: "A op B" with the same
|
||||
** A and B values but different operators and if the operators are
|
||||
** compatible (if one is = and the other is <, for example) then
|
||||
** add a new virtual AND term to pWC that is the combination of the
|
||||
** two.
|
||||
**
|
||||
** Some examples:
|
||||
**
|
||||
** x<y OR x=y --> x<=y
|
||||
** x=y OR x=y --> x=y
|
||||
** x<=y OR x<y --> x<=y
|
||||
**
|
||||
** The following is NOT generated:
|
||||
**
|
||||
** x<y OR x>y --> x!=y
|
||||
*/
|
||||
static void whereCombineDisjuncts(
|
||||
SrcList *pSrc, /* the FROM clause */
|
||||
WhereClause *pWC, /* The complete WHERE clause */
|
||||
WhereTerm *pOne, /* First disjunct */
|
||||
WhereTerm *pTwo /* Second disjunct */
|
||||
){
|
||||
u16 eOp = pOne->eOperator | pTwo->eOperator;
|
||||
sqlite3 *db; /* Database connection (for malloc) */
|
||||
Expr *pNew; /* New virtual expression */
|
||||
int op; /* Operator for the combined expression */
|
||||
int idxNew; /* Index in pWC of the next virtual term */
|
||||
|
||||
if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
|
||||
if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
|
||||
if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
|
||||
&& (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
|
||||
assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
|
||||
assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
|
||||
if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
|
||||
if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
|
||||
/* If we reach this point, it means the two subterms can be combined */
|
||||
if( (eOp & (eOp-1))!=0 ){
|
||||
if( eOp & (WO_LT|WO_LE) ){
|
||||
eOp = WO_LE;
|
||||
}else{
|
||||
assert( eOp & (WO_GT|WO_GE) );
|
||||
eOp = WO_GE;
|
||||
}
|
||||
}
|
||||
db = pWC->pWInfo->pParse->db;
|
||||
pNew = sqlite3ExprDup(db, pOne->pExpr, 0);
|
||||
if( pNew==0 ) return;
|
||||
for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }
|
||||
pNew->op = op;
|
||||
idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
|
||||
exprAnalyze(pSrc, pWC, idxNew);
|
||||
}
|
||||
|
||||
#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)
|
||||
/*
|
||||
** Analyze a term that consists of two or more OR-connected
|
||||
@ -794,6 +867,7 @@ static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){
|
||||
** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)
|
||||
** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')
|
||||
** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)
|
||||
** (F) x>A OR (x=A AND y>=B)
|
||||
**
|
||||
** CASE 1:
|
||||
**
|
||||
@ -810,6 +884,16 @@ static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){
|
||||
**
|
||||
** CASE 2:
|
||||
**
|
||||
** If there are exactly two disjuncts one side has x>A and the other side
|
||||
** has x=A (for the same x and A) then add a new virtual conjunct term to the
|
||||
** WHERE clause of the form "x>=A". Example:
|
||||
**
|
||||
** x>A OR (x=A AND y>B) adds: x>=A
|
||||
**
|
||||
** The added conjunct can sometimes be helpful in query planning.
|
||||
**
|
||||
** CASE 3:
|
||||
**
|
||||
** If all subterms are indexable by a single table T, then set
|
||||
**
|
||||
** WhereTerm.eOperator = WO_OR
|
||||
@ -936,12 +1020,26 @@ static void exprAnalyzeOrTerm(
|
||||
}
|
||||
|
||||
/*
|
||||
** Record the set of tables that satisfy case 2. The set might be
|
||||
** Record the set of tables that satisfy case 3. The set might be
|
||||
** empty.
|
||||
*/
|
||||
pOrInfo->indexable = indexable;
|
||||
pTerm->eOperator = indexable==0 ? 0 : WO_OR;
|
||||
|
||||
/* For a two-way OR, attempt to implementation case 2.
|
||||
*/
|
||||
if( indexable && pOrWc->nTerm==2 ){
|
||||
int iOne = 0;
|
||||
WhereTerm *pOne;
|
||||
while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){
|
||||
int iTwo = 0;
|
||||
WhereTerm *pTwo;
|
||||
while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){
|
||||
whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** chngToIN holds a set of tables that *might* satisfy case 1. But
|
||||
** we have to do some additional checking to see if case 1 really
|
||||
@ -1071,7 +1169,7 @@ static void exprAnalyzeOrTerm(
|
||||
}else{
|
||||
sqlite3ExprListDelete(db, pList);
|
||||
}
|
||||
pTerm->eOperator = WO_NOOP; /* case 1 trumps case 2 */
|
||||
pTerm->eOperator = WO_NOOP; /* case 1 trumps case 3 */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1931,11 +2029,14 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
|
||||
** Estimate the location of a particular key among all keys in an
|
||||
** index. Store the results in aStat as follows:
|
||||
**
|
||||
** aStat[0] Est. number of rows less than pVal
|
||||
** aStat[1] Est. number of rows equal to pVal
|
||||
** aStat[0] Est. number of rows less than pRec
|
||||
** aStat[1] Est. number of rows equal to pRec
|
||||
**
|
||||
** Return the index of the sample that is the smallest sample that
|
||||
** is greater than or equal to pRec.
|
||||
** is greater than or equal to pRec. Note that this index is not an index
|
||||
** into the aSample[] array - it is an index into a virtual set of samples
|
||||
** based on the contents of aSample[] and the number of fields in record
|
||||
** pRec.
|
||||
*/
|
||||
static int whereKeyStats(
|
||||
Parse *pParse, /* Database connection */
|
||||
@ -1946,67 +2047,158 @@ static int whereKeyStats(
|
||||
){
|
||||
IndexSample *aSample = pIdx->aSample;
|
||||
int iCol; /* Index of required stats in anEq[] etc. */
|
||||
int i; /* Index of first sample >= pRec */
|
||||
int iSample; /* Smallest sample larger than or equal to pRec */
|
||||
int iMin = 0; /* Smallest sample not yet tested */
|
||||
int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
|
||||
int iTest; /* Next sample to test */
|
||||
int res; /* Result of comparison operation */
|
||||
int nField; /* Number of fields in pRec */
|
||||
tRowcnt iLower = 0; /* anLt[] + anEq[] of largest sample pRec is > */
|
||||
|
||||
#ifndef SQLITE_DEBUG
|
||||
UNUSED_PARAMETER( pParse );
|
||||
#endif
|
||||
assert( pRec!=0 );
|
||||
iCol = pRec->nField - 1;
|
||||
assert( pIdx->nSample>0 );
|
||||
assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
|
||||
assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );
|
||||
|
||||
/* Do a binary search to find the first sample greater than or equal
|
||||
** to pRec. If pRec contains a single field, the set of samples to search
|
||||
** is simply the aSample[] array. If the samples in aSample[] contain more
|
||||
** than one fields, all fields following the first are ignored.
|
||||
**
|
||||
** If pRec contains N fields, where N is more than one, then as well as the
|
||||
** samples in aSample[] (truncated to N fields), the search also has to
|
||||
** consider prefixes of those samples. For example, if the set of samples
|
||||
** in aSample is:
|
||||
**
|
||||
** aSample[0] = (a, 5)
|
||||
** aSample[1] = (a, 10)
|
||||
** aSample[2] = (b, 5)
|
||||
** aSample[3] = (c, 100)
|
||||
** aSample[4] = (c, 105)
|
||||
**
|
||||
** Then the search space should ideally be the samples above and the
|
||||
** unique prefixes [a], [b] and [c]. But since that is hard to organize,
|
||||
** the code actually searches this set:
|
||||
**
|
||||
** 0: (a)
|
||||
** 1: (a, 5)
|
||||
** 2: (a, 10)
|
||||
** 3: (a, 10)
|
||||
** 4: (b)
|
||||
** 5: (b, 5)
|
||||
** 6: (c)
|
||||
** 7: (c, 100)
|
||||
** 8: (c, 105)
|
||||
** 9: (c, 105)
|
||||
**
|
||||
** For each sample in the aSample[] array, N samples are present in the
|
||||
** effective sample array. In the above, samples 0 and 1 are based on
|
||||
** sample aSample[0]. Samples 2 and 3 on aSample[1] etc.
|
||||
**
|
||||
** Often, sample i of each block of N effective samples has (i+1) fields.
|
||||
** Except, each sample may be extended to ensure that it is greater than or
|
||||
** equal to the previous sample in the array. For example, in the above,
|
||||
** sample 2 is the first sample of a block of N samples, so at first it
|
||||
** appears that it should be 1 field in size. However, that would make it
|
||||
** smaller than sample 1, so the binary search would not work. As a result,
|
||||
** it is extended to two fields. The duplicates that this creates do not
|
||||
** cause any problems.
|
||||
*/
|
||||
nField = pRec->nField;
|
||||
iCol = 0;
|
||||
iSample = pIdx->nSample * nField;
|
||||
do{
|
||||
iTest = (iMin+i)/2;
|
||||
res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec);
|
||||
if( res<0 ){
|
||||
iMin = iTest+1;
|
||||
int iSamp; /* Index in aSample[] of test sample */
|
||||
int n; /* Number of fields in test sample */
|
||||
|
||||
iTest = (iMin+iSample)/2;
|
||||
iSamp = iTest / nField;
|
||||
if( iSamp>0 ){
|
||||
/* The proposed effective sample is a prefix of sample aSample[iSamp].
|
||||
** Specifically, the shortest prefix of at least (1 + iTest%nField)
|
||||
** fields that is greater than the previous effective sample. */
|
||||
for(n=(iTest % nField) + 1; n<nField; n++){
|
||||
if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break;
|
||||
}
|
||||
}else{
|
||||
i = iTest;
|
||||
n = iTest + 1;
|
||||
}
|
||||
}while( res && iMin<i );
|
||||
|
||||
pRec->nField = n;
|
||||
res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec);
|
||||
if( res<0 ){
|
||||
iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1];
|
||||
iMin = iTest+1;
|
||||
}else if( res==0 && n<nField ){
|
||||
iLower = aSample[iSamp].anLt[n-1];
|
||||
iMin = iTest+1;
|
||||
res = -1;
|
||||
}else{
|
||||
iSample = iTest;
|
||||
iCol = n-1;
|
||||
}
|
||||
}while( res && iMin<iSample );
|
||||
i = iSample / nField;
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
/* The following assert statements check that the binary search code
|
||||
** above found the right answer. This block serves no purpose other
|
||||
** than to invoke the asserts. */
|
||||
if( res==0 ){
|
||||
/* If (res==0) is true, then sample $i must be equal to pRec */
|
||||
assert( i<pIdx->nSample );
|
||||
assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
|
||||
|| pParse->db->mallocFailed );
|
||||
}else{
|
||||
/* Otherwise, pRec must be smaller than sample $i and larger than
|
||||
** sample ($i-1). */
|
||||
assert( i==pIdx->nSample
|
||||
|| sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
|
||||
|| pParse->db->mallocFailed );
|
||||
assert( i==0
|
||||
|| sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
|
||||
|| pParse->db->mallocFailed );
|
||||
if( pParse->db->mallocFailed==0 ){
|
||||
if( res==0 ){
|
||||
/* If (res==0) is true, then pRec must be equal to sample i. */
|
||||
assert( i<pIdx->nSample );
|
||||
assert( iCol==nField-1 );
|
||||
pRec->nField = nField;
|
||||
assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
|
||||
|| pParse->db->mallocFailed
|
||||
);
|
||||
}else{
|
||||
/* Unless i==pIdx->nSample, indicating that pRec is larger than
|
||||
** all samples in the aSample[] array, pRec must be smaller than the
|
||||
** (iCol+1) field prefix of sample i. */
|
||||
assert( i<=pIdx->nSample && i>=0 );
|
||||
pRec->nField = iCol+1;
|
||||
assert( i==pIdx->nSample
|
||||
|| sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
|
||||
|| pParse->db->mallocFailed );
|
||||
|
||||
/* if i==0 and iCol==0, then record pRec is smaller than all samples
|
||||
** in the aSample[] array. Otherwise, if (iCol>0) then pRec must
|
||||
** be greater than or equal to the (iCol) field prefix of sample i.
|
||||
** If (i>0), then pRec must also be greater than sample (i-1). */
|
||||
if( iCol>0 ){
|
||||
pRec->nField = iCol;
|
||||
assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0
|
||||
|| pParse->db->mallocFailed );
|
||||
}
|
||||
if( i>0 ){
|
||||
pRec->nField = nField;
|
||||
assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
|
||||
|| pParse->db->mallocFailed );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ifdef SQLITE_DEBUG */
|
||||
|
||||
/* At this point, aSample[i] is the first sample that is greater than
|
||||
** or equal to pVal. Or if i==pIdx->nSample, then all samples are less
|
||||
** than pVal. If aSample[i]==pVal, then res==0.
|
||||
*/
|
||||
if( res==0 ){
|
||||
/* Record pRec is equal to sample i */
|
||||
assert( iCol==nField-1 );
|
||||
aStat[0] = aSample[i].anLt[iCol];
|
||||
aStat[1] = aSample[i].anEq[iCol];
|
||||
}else{
|
||||
tRowcnt iLower, iUpper, iGap;
|
||||
if( i==0 ){
|
||||
iLower = 0;
|
||||
iUpper = aSample[0].anLt[iCol];
|
||||
/* At this point, the (iCol+1) field prefix of aSample[i] is the first
|
||||
** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec
|
||||
** is larger than all samples in the array. */
|
||||
tRowcnt iUpper, iGap;
|
||||
if( i>=pIdx->nSample ){
|
||||
iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
|
||||
}else{
|
||||
i64 nRow0 = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
|
||||
iUpper = i>=pIdx->nSample ? nRow0 : aSample[i].anLt[iCol];
|
||||
iLower = aSample[i-1].anEq[iCol] + aSample[i-1].anLt[iCol];
|
||||
iUpper = aSample[i].anLt[iCol];
|
||||
}
|
||||
aStat[1] = pIdx->aAvgEq[iCol];
|
||||
|
||||
if( iLower>=iUpper ){
|
||||
iGap = 0;
|
||||
}else{
|
||||
@ -2018,7 +2210,11 @@ static int whereKeyStats(
|
||||
iGap = iGap/3;
|
||||
}
|
||||
aStat[0] = iLower + iGap;
|
||||
aStat[1] = pIdx->aAvgEq[iCol];
|
||||
}
|
||||
|
||||
/* Restore the pRec->nField value before returning. */
|
||||
pRec->nField = nField;
|
||||
return i;
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
|
||||
@ -5805,10 +6001,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
|
||||
/* Seed the search with a single WherePath containing zero WhereLoops.
|
||||
**
|
||||
** TUNING: Do not let the number of iterations go above 25. If the cost
|
||||
** of computing an automatic index is not paid back within the first 25
|
||||
** TUNING: Do not let the number of iterations go above 28. If the cost
|
||||
** of computing an automatic index is not paid back within the first 28
|
||||
** rows, then do not use the automatic index. */
|
||||
aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) );
|
||||
aFrom[0].nRow = MIN(pParse->nQueryLoop, 48); assert( 48==sqlite3LogEst(28) );
|
||||
nFrom = 1;
|
||||
assert( aFrom[0].isOrdered==0 );
|
||||
if( nOrderBy ){
|
||||
|
@ -1134,4 +1134,116 @@ ifcapable stat4&&cte {
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Check that a problem in they way stat4 data is used has been
|
||||
# resolved (see below).
|
||||
#
|
||||
reset_db
|
||||
do_test 26.1.1 {
|
||||
db transaction {
|
||||
execsql {
|
||||
CREATE TABLE t1(x, y, z);
|
||||
CREATE INDEX t1xy ON t1(x, y);
|
||||
CREATE INDEX t1z ON t1(z);
|
||||
}
|
||||
for {set i 0} {$i < 10000} {incr i} {
|
||||
execsql { INSERT INTO t1(x, y) VALUES($i, $i) }
|
||||
}
|
||||
for {set i 0} {$i < 10} {incr i} {
|
||||
execsql {
|
||||
WITH cnt(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM cnt WHERE x<100)
|
||||
INSERT INTO t1(x, y) SELECT 10000+$i, x FROM cnt;
|
||||
INSERT INTO t1(x, y) SELECT 10000+$i, 100;
|
||||
}
|
||||
}
|
||||
execsql {
|
||||
UPDATE t1 SET z = rowid / 20;
|
||||
ANALYZE;
|
||||
}
|
||||
}
|
||||
} {}
|
||||
|
||||
do_execsql_test 26.1.2 {
|
||||
SELECT count(*) FROM t1 WHERE x = 10000 AND y < 50;
|
||||
} {49}
|
||||
do_execsql_test 26.1.3 {
|
||||
SELECT count(*) FROM t1 WHERE z = 444;
|
||||
} {20}
|
||||
|
||||
# The analyzer knows that any (z=?) expression matches 20 rows. So it
|
||||
# will use index "t1z" if the estimate of hits for (x=10000 AND y<50)
|
||||
# is greater than 20 rows.
|
||||
#
|
||||
# And it should be. The analyzer has a stat4 sample as follows:
|
||||
#
|
||||
# sample=(x=10000, y=100) nLt=(10000 10099)
|
||||
#
|
||||
# There should be no other samples that start with (x=10000). So it knows
|
||||
# that (x=10000 AND y<50) must match somewhere between 0 and 99 rows, but
|
||||
# know more than that. Guessing less than 20 is therefore unreasonable.
|
||||
#
|
||||
# At one point though, due to a problem in whereKeyStats(), the planner was
|
||||
# estimating that (x=10000 AND y<50) would match only 2 rows.
|
||||
#
|
||||
do_eqp_test 26.1.4 {
|
||||
SELECT * FROM t1 WHERE x = 10000 AND y < 50 AND z = 444;
|
||||
} {
|
||||
0 0 0 {SEARCH TABLE t1 USING INDEX t1z (z=?)}
|
||||
}
|
||||
|
||||
|
||||
# This test - 26.2.* - tests that another manifestation of the same problem
|
||||
# is no longer present in the library. Assuming:
|
||||
#
|
||||
# CREATE INDEX t1xy ON t1(x, y)
|
||||
#
|
||||
# and that have samples for index t1xy as follows:
|
||||
#
|
||||
#
|
||||
# sample=('A', 70) nEq=(100, 2) nLt=(900, 970)
|
||||
# sample=('B', 70) nEq=(100, 2) nLt=(1000, 1070)
|
||||
#
|
||||
# the planner should estimate that (x = 'B' AND y > 25) matches 76 rows
|
||||
# (70 * 2/3 + 30). Before, due to the problem, the planner was estimating
|
||||
# that this matched 100 rows.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 26.2.1 {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(x, y, z);
|
||||
CREATE INDEX i1 ON t1(x, y);
|
||||
CREATE INDEX i2 ON t1(z);
|
||||
|
||||
WITH
|
||||
cnt(y) AS (SELECT 0 UNION ALL SELECT y+1 FROM cnt WHERE y<99),
|
||||
letters(x) AS (
|
||||
SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'
|
||||
)
|
||||
INSERT INTO t1(x, y) SELECT x, y FROM letters, cnt;
|
||||
|
||||
WITH
|
||||
letters(x) AS (
|
||||
SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'
|
||||
)
|
||||
INSERT INTO t1(x, y) SELECT x, 70 FROM letters;
|
||||
|
||||
WITH
|
||||
cnt(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM cnt WHERE i<9999)
|
||||
INSERT INTO t1(x, y) SELECT i, i FROM cnt;
|
||||
|
||||
UPDATE t1 SET z = (rowid / 95);
|
||||
ANALYZE;
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
do_eqp_test 26.2.2 {
|
||||
SELECT * FROM t1 WHERE x='B' AND y>25 AND z=?;
|
||||
} {
|
||||
0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x=? AND y>?)}
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
|
||||
|
127
test/analyzeF.test
Normal file
127
test/analyzeF.test
Normal file
@ -0,0 +1,127 @@
|
||||
# 2015-03-12
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
# Test that deterministic scalar functions passed constant arguments
|
||||
# are used with stat4 data.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set ::testprefix analyzeF
|
||||
|
||||
ifcapable {!stat4} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
proc isqrt {i} { expr { int(sqrt($i)) } }
|
||||
db func isqrt isqrt
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(x INTEGER, y INTEGER);
|
||||
WITH data(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM data
|
||||
)
|
||||
INSERT INTO t1 SELECT isqrt(i), isqrt(i) FROM data LIMIT 400;
|
||||
CREATE INDEX t1x ON t1(x);
|
||||
CREATE INDEX t1y ON t1(y);
|
||||
ANALYZE;
|
||||
}
|
||||
|
||||
proc str {a} { return $a }
|
||||
db func str str
|
||||
|
||||
# Note: tests 7 to 12 might be unstable - as they assume SQLite will
|
||||
# prefer the expression to the right of the AND clause. Which of
|
||||
# course could change.
|
||||
#
|
||||
# Note 2: tests 9 and 10 depend on the tcl interface creating functions
|
||||
# without the SQLITE_DETERMINISTIC flag set.
|
||||
#
|
||||
foreach {tn where idx} {
|
||||
1 "x = 4 AND y = 19" {t1x (x=?)}
|
||||
2 "x = 19 AND y = 4" {t1y (y=?)}
|
||||
3 "x = '4' AND y = '19'" {t1x (x=?)}
|
||||
4 "x = '19' AND y = '4'" {t1y (y=?)}
|
||||
5 "x = substr('5195', 2, 2) AND y = substr('145', 2, 1)" {t1y (y=?)}
|
||||
6 "x = substr('145', 2, 1) AND y = substr('5195', 2, 2)" {t1x (x=?)}
|
||||
|
||||
7 "x = substr('5195', 2, 2+0) AND y = substr('145', 2, 1+0)" {t1y (y=?)}
|
||||
8 "x = substr('145', 2, 1+0) AND y = substr('5195', 2, 2+0)" {t1y (y=?)}
|
||||
|
||||
9 "x = str('19') AND y = str('4')" {t1y (y=?)}
|
||||
10 "x = str('4') AND y = str('19')" {t1y (y=?)}
|
||||
|
||||
11 "x = nullif('19', 0) AND y = nullif('4', 0)" {t1y (y=?)}
|
||||
12 "x = nullif('4', 0) AND y = nullif('19', 0)" {t1y (y=?)}
|
||||
} {
|
||||
set res "0 0 0 {SEARCH TABLE t1 USING INDEX $idx}"
|
||||
do_eqp_test 1.$tn "SELECT * FROM t1 WHERE $where" $res
|
||||
}
|
||||
|
||||
# Test that functions that do not exist - "func()" - do not cause an error.
|
||||
#
|
||||
do_catchsql_test 2.1 {
|
||||
SELECT * FROM t1 WHERE x = substr('145', 2, 1) AND y = func(1, 2, 3)
|
||||
} {1 {no such function: func}}
|
||||
do_catchsql_test 2.2 {
|
||||
UPDATE t1 SET y=y+1 WHERE x = substr('145', 2, 1) AND y = func(1, 2, 3)
|
||||
} {1 {no such function: func}}
|
||||
|
||||
|
||||
# Check that functions that accept zero arguments do not cause problems.
|
||||
#
|
||||
proc ret {x} { return $x }
|
||||
|
||||
db func det4 -deterministic [list ret 4]
|
||||
db func nondet4 [list ret 4]
|
||||
db func det19 -deterministic [list ret 19]
|
||||
db func nondet19 [list ret 19]
|
||||
|
||||
foreach {tn where idx} {
|
||||
1 "x = det4() AND y = det19()" {t1x (x=?)}
|
||||
2 "x = det19() AND y = det4()" {t1y (y=?)}
|
||||
|
||||
3 "x = nondet4() AND y = nondet19()" {t1y (y=?)}
|
||||
4 "x = nondet19() AND y = nondet4()" {t1y (y=?)}
|
||||
} {
|
||||
set res "0 0 0 {SEARCH TABLE t1 USING INDEX $idx}"
|
||||
do_eqp_test 3.$tn "SELECT * FROM t1 WHERE $where" $res
|
||||
}
|
||||
|
||||
|
||||
execsql { DELETE FROM t1 }
|
||||
|
||||
proc throw_error {err} { error $err }
|
||||
db func error -deterministic throw_error
|
||||
do_catchsql_test 4.1 {
|
||||
SELECT * FROM t1 WHERE x = error('error one') AND y = 4;
|
||||
} {1 {error one}}
|
||||
|
||||
do_catchsql_test 4.2 {
|
||||
SELECT * FROM t1 WHERE x = zeroblob(2000000000) AND y = 4;
|
||||
} {1 {string or blob too big}}
|
||||
|
||||
sqlite3_limit db SQLITE_LIMIT_LENGTH 1000000
|
||||
proc dstr {} { return [string repeat x 1100000] }
|
||||
db func dstr -deterministic dstr
|
||||
do_catchsql_test 4.3 {
|
||||
SELECT * FROM t1 WHERE x = dstr() AND y = 11;
|
||||
} {1 {string or blob too big}}
|
||||
|
||||
do_catchsql_test 4.4 {
|
||||
SELECT * FROM t1 WHERE x = test_zeroblob(1100000) AND y = 4;
|
||||
} {1 {string or blob too big}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
|
80
test/crashM.test
Normal file
80
test/crashM.test
Normal file
@ -0,0 +1,80 @@
|
||||
# 2015 Mar 13
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Crash tests for the multiplex module with 8.3 filenames enabled.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix crashM
|
||||
|
||||
ifcapable !crashtest||!8_3_names {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db close
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_uri 1
|
||||
|
||||
foreach f [glob -nocomplain test1.* test2.*] { forcedelete $f }
|
||||
sqlite3_multiplex_initialize "" 1
|
||||
sqlite3 db file:test1.db?8_3_names=1
|
||||
sqlite3_multiplex_control db main chunk_size [expr 64*1024]
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
ATTACH 'file:test2.db?8_3_names=1' AS aux;
|
||||
|
||||
CREATE TABLE t1(x, y);
|
||||
CREATE INDEX t1x ON t1(x);
|
||||
CREATE INDEX t1y ON t1(y);
|
||||
|
||||
CREATE TABLE aux.t2(x, y);
|
||||
CREATE INDEX aux.t2x ON t2(x);
|
||||
CREATE INDEX aux.t2y ON t2(y);
|
||||
|
||||
WITH s(a) AS (
|
||||
SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000
|
||||
)
|
||||
INSERT INTO t1 SELECT a, randomblob(500) FROM s;
|
||||
|
||||
WITH s(a) AS (
|
||||
SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000
|
||||
)
|
||||
INSERT INTO t2 SELECT a, randomblob(500) FROM s;
|
||||
} {}
|
||||
|
||||
for {set i 0} {$i < 20} {incr i} {
|
||||
do_test 2.$i.1 {
|
||||
crashsql -delay 1 -file test1.db -opendb {
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_uri 1
|
||||
sqlite3_multiplex_initialize crash 1
|
||||
sqlite3 db file:test1.db?8_3_names=1
|
||||
sqlite3_multiplex_control db main chunk_size [expr 64*1024]
|
||||
} {
|
||||
ATTACH 'file:test2.db?8_3_names=1' AS aux;
|
||||
BEGIN;
|
||||
UPDATE t1 SET y = randomblob(500) WHERE (x%10)==0;
|
||||
UPDATE t2 SET y = randomblob(500) WHERE (x%10)==0;
|
||||
COMMIT;
|
||||
}
|
||||
} {1 {child process exited abnormally}}
|
||||
|
||||
do_execsql_test 2.$i.2 {
|
||||
PRAGMA main.integrity_check;
|
||||
PRAGMA aux.integrity_check;
|
||||
} {ok ok}
|
||||
}
|
||||
|
||||
catch { db close }
|
||||
sqlite3_multiplex_shutdown
|
||||
finish_test
|
@ -252,15 +252,21 @@ foreach {tn iFirst iLast} [subst {
|
||||
do_execsql_test 7.2.$tn.1.[llength $res] {
|
||||
SELECT rowid FROM ft4 WHERE rowid BETWEEN $iFirst AND $iLast
|
||||
} $res
|
||||
set res [db eval {
|
||||
SELECT rowid FROM t4 WHERE rowid BETWEEN $iFirst AND $iLast
|
||||
ORDER BY +rowid DESC
|
||||
} ]
|
||||
do_execsql_test 7.2.$tn.2.[llength $res] {
|
||||
SELECT rowid FROM ft4 WHERE rowid BETWEEN $iFirst AND $iLast
|
||||
ORDER BY rowid DESC
|
||||
} [lsort -decr -integer $res]
|
||||
} $res
|
||||
}
|
||||
|
||||
foreach ii [db eval {SELECT rowid FROM t4}] {
|
||||
set res1 [db eval {SELECT rowid FROM t4 WHERE rowid > $ii}]
|
||||
set res2 [db eval {SELECT rowid FROM t4 WHERE rowid < $ii}]
|
||||
set res1s [db eval {SELECT rowid FROM t4 WHERE rowid > $ii ORDER BY +rowid DESC}]
|
||||
set res2s [db eval {SELECT rowid FROM t4 WHERE rowid < $ii ORDER BY +rowid DESC}]
|
||||
|
||||
do_execsql_test 7.3.$ii.1 {
|
||||
SELECT rowid FROM ft4 WHERE rowid > $ii
|
||||
@ -272,13 +278,11 @@ foreach ii [db eval {SELECT rowid FROM t4}] {
|
||||
|
||||
do_execsql_test 7.3.$ii.3 {
|
||||
SELECT rowid FROM ft4 WHERE rowid > $ii ORDER BY rowid DESC
|
||||
} [lsort -integer -decr $res1]
|
||||
} $res1s
|
||||
|
||||
do_execsql_test 7.3.$ii.4 {
|
||||
SELECT rowid FROM ft4 WHERE rowid < $ii ORDER BY rowid DESC
|
||||
} [lsort -integer -decr $res2]
|
||||
} $res2s
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
|
@ -324,11 +324,21 @@ do_test incrblob2-6.2 {
|
||||
sqlite3_blob_read $rdHandle 0 2
|
||||
} {AB}
|
||||
|
||||
do_test incrblob2-6.2b {
|
||||
if {$::tcl_platform(pointerSize)>=8} {
|
||||
do_test incrblob2-6.2b {
|
||||
set rc [catch {
|
||||
# Prior to 2015-02-07, the following caused a segfault due to
|
||||
# integer overflow.
|
||||
sqlite3_blob_read $rdHandle 2147483647 2147483647
|
||||
} errmsg]
|
||||
lappend rc $errmsg
|
||||
} {1 SQLITE_ERROR}
|
||||
}
|
||||
do_test incrblob2-6.2c {
|
||||
set rc [catch {
|
||||
# Prior to 2015-02-07, the following caused a segfault due to
|
||||
# integer overflow.
|
||||
sqlite3_blob_read $rdHandle 2147483647 2147483647
|
||||
sqlite3_blob_read $rdHandle 2147483647 100
|
||||
} errmsg]
|
||||
lappend rc $errmsg
|
||||
} {1 SQLITE_ERROR}
|
||||
|
127
test/incrcorrupt.test
Normal file
127
test/incrcorrupt.test
Normal file
@ -0,0 +1,127 @@
|
||||
# 2001 October 12
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
# Test that "PRAGMA incremental_vacuum" detects and reports database
|
||||
# corruption properly. And that "PRAGMA auto_vacuum = INCREMENTAL"
|
||||
# does as well.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix incrcorrupt
|
||||
|
||||
# If this build of the library does not support auto-vacuum, omit this
|
||||
# whole file.
|
||||
ifcapable {!autovacuum} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA auto_vacuum = 2;
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
|
||||
WITH data(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM data
|
||||
)
|
||||
INSERT INTO t1 SELECT i, randomblob(600) FROM data LIMIT 20;
|
||||
PRAGMA page_count;
|
||||
} {24}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
PRAGMA incremental_vacuum;
|
||||
} {}
|
||||
|
||||
do_test 1.2 {
|
||||
db_save
|
||||
hexio_write test.db 36 00000019
|
||||
catchsql { PRAGMA incremental_vacuum; }
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
do_test 1.3 {
|
||||
set stmt [sqlite3_prepare_v2 db "PRAGMA incremental_vacuum" -1 dummy]
|
||||
sqlite3_step $stmt
|
||||
} {SQLITE_CORRUPT}
|
||||
do_test 1.4 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 1.5 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
do_test 1.6 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
|
||||
do_test 1.7 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 1.8 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
|
||||
do_test 1.9 {
|
||||
set stmt [sqlite3_prepare_v2 db "PRAGMA incremental_vacuum" -1 dummy]
|
||||
sqlite3_step $stmt
|
||||
} {SQLITE_CORRUPT}
|
||||
do_test 1.10 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 1.11 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
|
||||
do_test 1.12 {
|
||||
set stmt2 [sqlite3_prepare_v2 db "SELECT 1" -1 dummy]
|
||||
sqlite3_finalize $stmt2
|
||||
} {SQLITE_OK}
|
||||
do_test 1.13 { sqlite3_errcode db } {SQLITE_OK}
|
||||
do_test 1.14 { sqlite3_errmsg db } {not an error}
|
||||
|
||||
do_test 1.15 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
|
||||
do_test 1.16 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 1.17 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
|
||||
do_execsql_test 2.1 {
|
||||
PRAGMA auto_vacuum = 1;
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
WITH data(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM data
|
||||
)
|
||||
INSERT INTO t1 SELECT i, randomblob(600) FROM data LIMIT 20;
|
||||
PRAGMA page_count;
|
||||
} {24}
|
||||
|
||||
do_test 2.2 {
|
||||
db_save
|
||||
set fd [open test.db r+]
|
||||
chan truncate $fd [expr 22*1024]
|
||||
close $fd
|
||||
catchsql { PRAGMA incremental_vacuum; }
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
do_test 2.3 {
|
||||
set stmt [sqlite3_prepare_v2 db "PRAGMA auto_vacuum = INCREMENTAL" -1 dummy]
|
||||
sqlite3_step $stmt
|
||||
} {SQLITE_CORRUPT}
|
||||
do_test 2.4 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 2.5 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
do_test 2.6 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
|
||||
do_test 2.7 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 2.8 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
|
||||
do_test 2.9 {
|
||||
set stmt [sqlite3_prepare_v2 db "PRAGMA auto_vacuum = INCREMENTAL" -1 dummy]
|
||||
sqlite3_step $stmt
|
||||
} {SQLITE_CORRUPT}
|
||||
do_test 2.10 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 2.11 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
|
||||
do_test 2.12 {
|
||||
set stmt2 [sqlite3_prepare_v2 db "SELECT 1" -1 dummy]
|
||||
sqlite3_finalize $stmt2
|
||||
} {SQLITE_OK}
|
||||
do_test 2.13 { sqlite3_errcode db } {SQLITE_OK}
|
||||
do_test 2.14 { sqlite3_errmsg db } {not an error}
|
||||
|
||||
do_test 2.15 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
|
||||
do_test 2.16 { sqlite3_errcode db } {SQLITE_CORRUPT}
|
||||
do_test 2.17 { sqlite3_errmsg db } {database disk image is malformed}
|
||||
|
||||
finish_test
|
||||
|
@ -86,21 +86,51 @@ proc launch_testfixture {{prg ""}} {
|
||||
# Execute a command in a child testfixture process, connected by two-way
|
||||
# channel $chan. Return the result of the command, or an error message.
|
||||
#
|
||||
proc testfixture {chan cmd} {
|
||||
puts $chan $cmd
|
||||
puts $chan OVER
|
||||
set r ""
|
||||
while { 1 } {
|
||||
proc testfixture {chan cmd args} {
|
||||
|
||||
if {[llength $args] == 0} {
|
||||
fconfigure $chan -blocking 1
|
||||
puts $chan $cmd
|
||||
puts $chan OVER
|
||||
|
||||
set r ""
|
||||
while { 1 } {
|
||||
set line [gets $chan]
|
||||
if { $line == "OVER" } {
|
||||
set res [lindex $r 1]
|
||||
if { [lindex $r 0] } { error $res }
|
||||
return $res
|
||||
}
|
||||
if {[eof $chan]} {
|
||||
return "ERROR: Child process hung up"
|
||||
}
|
||||
append r $line
|
||||
}
|
||||
return $r
|
||||
} else {
|
||||
set ::tfnb($chan) ""
|
||||
fconfigure $chan -blocking 0 -buffering none
|
||||
puts $chan $cmd
|
||||
puts $chan OVER
|
||||
fileevent $chan readable [list testfixture_script_cb $chan [lindex $args 0]]
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
proc testfixture_script_cb {chan script} {
|
||||
if {[eof $chan]} {
|
||||
append ::tfnb($chan) "ERROR: Child process hung up"
|
||||
set line "OVER"
|
||||
} else {
|
||||
set line [gets $chan]
|
||||
if { $line == "OVER" } {
|
||||
set res [lindex $r 1]
|
||||
if { [lindex $r 0] } { error $res }
|
||||
return $res
|
||||
}
|
||||
if {[eof $chan]} {
|
||||
return "ERROR: Child process hung up"
|
||||
}
|
||||
append r $line
|
||||
}
|
||||
|
||||
if { $line == "OVER" } {
|
||||
uplevel #0 $script [list [lindex $::tfnb($chan) 1]]
|
||||
unset ::tfnb($chan)
|
||||
fileevent $chan readable ""
|
||||
} else {
|
||||
append ::tfnb($chan) $line
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,23 @@ do_test malloc5-1.3 {
|
||||
expr $::pgalloc > 0
|
||||
} {1}
|
||||
|
||||
# The sizes of memory allocations from system malloc() might vary,
|
||||
# depending on the memory allocator algorithms used. The following
|
||||
# routine is designed to support answers that fall within a range
|
||||
# of values while also supplying easy-to-understand "expected" values
|
||||
# when errors occur.
|
||||
#
|
||||
proc value_in_range {target x args} {
|
||||
set v [lindex $args 0]
|
||||
if {$v!=""} {
|
||||
if {$v<$target*$x} {return $v}
|
||||
if {$v>$target/$x} {return $v}
|
||||
}
|
||||
return "number between [expr {int($target*$x)}] and [expr {int($target/$x)}]"
|
||||
}
|
||||
set mrange 0.98 ;# plus or minus 2%
|
||||
|
||||
|
||||
do_test malloc5-1.4 {
|
||||
# Commit the transaction and open a new one. Read 1 page into the cache.
|
||||
# Because the page is not dirty, it is eligible for collection even
|
||||
@ -81,16 +98,16 @@ do_test malloc5-1.4 {
|
||||
BEGIN;
|
||||
SELECT * FROM abc;
|
||||
}
|
||||
sqlite3_release_memory
|
||||
} $::pgalloc
|
||||
value_in_range $::pgalloc $::mrange [sqlite3_release_memory]
|
||||
} [value_in_range $::pgalloc $::mrange]
|
||||
|
||||
do_test malloc5-1.5 {
|
||||
# Conclude the transaction opened in the previous [do_test] block. This
|
||||
# causes another page (page 1) to become eligible for recycling.
|
||||
#
|
||||
execsql { COMMIT }
|
||||
sqlite3_release_memory
|
||||
} $::pgalloc
|
||||
value_in_range $::pgalloc $::mrange [sqlite3_release_memory]
|
||||
} [value_in_range $::pgalloc $::mrange]
|
||||
|
||||
do_test malloc5-1.6 {
|
||||
# Manipulate the cache so that it contains two unused pages. One requires
|
||||
@ -101,8 +118,8 @@ do_test malloc5-1.6 {
|
||||
SELECT * FROM abc;
|
||||
CREATE TABLE def(d, e, f);
|
||||
}
|
||||
sqlite3_release_memory 500
|
||||
} $::pgalloc
|
||||
value_in_range $::pgalloc $::mrange [sqlite3_release_memory 500]
|
||||
} [value_in_range $::pgalloc $::mrange]
|
||||
|
||||
do_test malloc5-1.7 {
|
||||
# Database should not be locked this time.
|
||||
|
@ -143,6 +143,33 @@ do_faultsim_test 7.2 -faults oom* -body {
|
||||
faultsim_test_result [list 0 {}]
|
||||
}
|
||||
|
||||
reset_db
|
||||
|
||||
proc isqrt {i} { expr { int(sqrt($i)) } }
|
||||
db func isqrt isqrt
|
||||
|
||||
do_execsql_test 8.0 {
|
||||
PRAGMA encoding = 'utf-16';
|
||||
CREATE TABLE x2(x TEXT, y TEXT);
|
||||
WITH data(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM data
|
||||
)
|
||||
INSERT INTO x2 SELECT isqrt(i), isqrt(i) FROM data LIMIT 400;
|
||||
CREATE INDEX x2x ON x2(x);
|
||||
CREATE INDEX x2y ON x2(y);
|
||||
ANALYZE;
|
||||
DELETE FROM x2;
|
||||
}
|
||||
|
||||
proc str {a} { return $a }
|
||||
db func str -deterministic str
|
||||
|
||||
do_faultsim_test 8 -faults oom* -body {
|
||||
execsql { SELECT * FROM x2 WHERE x = str('19') AND y = str('4') }
|
||||
} -test {
|
||||
faultsim_test_result [list 0 {}]
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
@ -118,7 +118,7 @@ do_test tcl-1.14 {
|
||||
do_test tcl-1.15 {
|
||||
set v [catch {db function} msg]
|
||||
lappend v $msg
|
||||
} {1 {wrong # args: should be "db function NAME [-argcount N] SCRIPT"}}
|
||||
} {1 {wrong # args: should be "db function NAME ?SWITCHES? SCRIPT"}}
|
||||
do_test tcl-1.16 {
|
||||
set v [catch {db last_insert_rowid xyz} msg]
|
||||
lappend v $msg
|
||||
|
117
test/walblock.test
Normal file
117
test/walblock.test
Normal file
@ -0,0 +1,117 @@
|
||||
# 2015 Mar 17
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
|
||||
ifcapable !wal {finish_test ; return }
|
||||
if {$::tcl_platform(platform)!="unix"} { finish_test ; return }
|
||||
set testprefix walblock
|
||||
|
||||
catch { db close }
|
||||
testvfs tvfs -fullshm 1
|
||||
foreach f [glob test.db*] { forcedelete $f }
|
||||
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
do_execsql_test 1.1.0 {
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
INSERT INTO t1 VALUES(5, 6);
|
||||
PRAGMA journal_mode = wal;
|
||||
INSERT INTO t1 VALUES(7, 8);
|
||||
} {wal}
|
||||
|
||||
do_test 1.1.1 {
|
||||
lsort [glob test.db*]
|
||||
} {test.db test.db-shm test.db-wal}
|
||||
|
||||
do_test 1.1.2 {
|
||||
set C [launch_testfixture]
|
||||
testfixture $C {
|
||||
sqlite3 db test.db
|
||||
db eval { SELECT * FROM t1 }
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
|
||||
do_test 1.1.3 {
|
||||
set ::out [list]
|
||||
testfixture $C {
|
||||
db eval { SELECT * FROM t1 }
|
||||
} [list set ::out]
|
||||
set ::out
|
||||
} {}
|
||||
|
||||
do_test 1.1.4 {
|
||||
vwait ::out
|
||||
set ::out
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
|
||||
#
|
||||
# Test that if a read client cannot read the wal-index header because a
|
||||
# write client is in the middle of updating it, the reader blocks until
|
||||
# the writer finishes.
|
||||
#
|
||||
# 1. Open a write transaction using client [db] in this process.
|
||||
#
|
||||
# 2. Attempt to commit the write transaction. Intercept the xShmBarrier()
|
||||
# call made by the writer between updating the two copies of the
|
||||
# wal-index header.
|
||||
#
|
||||
# 3. Within the xShmBarrier() callback, make an asynchronous request to
|
||||
# the other process to read from the database. It should block, as it
|
||||
# cannot get read the wal-index header.
|
||||
#
|
||||
# 4. Still in xShmBarrier(), wait for 5 seconds. Check that the other
|
||||
# process has not answered the request.
|
||||
#
|
||||
# 5: Finish committing the transaction. Then wait for 0.5 seconds more.
|
||||
# Ensure that the second process has by this stage read the database
|
||||
# and that the snapshot it read included the transaction committed in
|
||||
# step (4).
|
||||
#
|
||||
do_execsql_test 1.2.1 {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(9, 10);
|
||||
} {}
|
||||
|
||||
tvfs script barrier_callback
|
||||
tvfs filter xShmBarrier
|
||||
proc barrier_callback {method args} {
|
||||
set ::out ""
|
||||
testfixture $::C { db eval { SELECT * FROM t1 } } {set ::out}
|
||||
|
||||
do_test "1.2.2.(blocking 5 seconds)" {
|
||||
set ::continue 0
|
||||
after 5000 {set ::continue 1}
|
||||
vwait ::continue
|
||||
set ::out
|
||||
} {}
|
||||
}
|
||||
|
||||
execsql COMMIT
|
||||
|
||||
do_test "1.2.3.(blocking 0.5 seconds)" {
|
||||
set ::continue 0
|
||||
after 500 {set ::continue 1}
|
||||
vwait ::continue
|
||||
set ::out
|
||||
} {1 2 3 4 5 6 7 8 9 10}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
|
||||
|
72
test/whereK.test
Normal file
72
test/whereK.test
Normal file
@ -0,0 +1,72 @@
|
||||
# 2015-03-16
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing OR expressions where terms can be
|
||||
# factored from either side of the OR and combined into a single new
|
||||
# AND term that is beneficial to the search. Examples:
|
||||
#
|
||||
# (x>A OR x=A) --> ... AND (x>=A)
|
||||
# (x>A OR (x=A AND y>=B) --> ... AND (x>=A)
|
||||
#
|
||||
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set ::testprefix whereK
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
CREATE TABLE t1(a,b,c);
|
||||
WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<99)
|
||||
INSERT INTO t1(a,b,c) SELECT x, x/10, x%10 FROM c;
|
||||
CREATE INDEX t1bc ON t1(b,c);
|
||||
SELECT a FROM t1 WHERE b>9 OR b=9 ORDER BY +a;
|
||||
} {90 91 92 93 94 95 96 97 98 99}
|
||||
do_execsql_test 1.1eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1 WHERE b>9 OR b=9 ORDER BY +a;
|
||||
} {/SEARCH TABLE t1 USING INDEX t1bc/}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
SELECT a FROM t1 WHERE b>8 OR (b=8 AND c>7) ORDER BY +a;
|
||||
} {88 89 90 91 92 93 94 95 96 97 98 99}
|
||||
do_execsql_test 1.2eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1 WHERE b>8 OR (b=8 AND c>7) ORDER BY +a;
|
||||
} {/SEARCH TABLE t1 USING INDEX t1bc/}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
SELECT a FROM t1 WHERE (b=8 AND c>7) OR b>8 ORDER BY +a;
|
||||
} {88 89 90 91 92 93 94 95 96 97 98 99}
|
||||
do_execsql_test 1.3eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1 WHERE (b=8 AND c>7) OR b>8 ORDER BY +a;
|
||||
} {/SEARCH TABLE t1 USING INDEX t1bc/}
|
||||
|
||||
do_execsql_test 1.4 {
|
||||
SELECT a FROM t1 WHERE (b=8 AND c>7) OR 8<b ORDER BY +a;
|
||||
} {88 89 90 91 92 93 94 95 96 97 98 99}
|
||||
do_execsql_test 1.4eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1 WHERE (b=8 AND c>7) OR 8<b ORDER BY +a;
|
||||
} {/SEARCH TABLE t1 USING INDEX t1bc/}
|
||||
|
||||
do_execsql_test 1.5 {
|
||||
SELECT a FROM t1 WHERE (b=8 AND c>7) OR (b>8 AND c NOT IN (4,5,6))
|
||||
ORDER BY +a;
|
||||
} {88 89 90 91 92 93 97 98 99}
|
||||
do_execsql_test 1.5eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1 WHERE (b=8 AND c>7) OR (b>8 AND c NOT IN (4,5,6))
|
||||
ORDER BY +a;
|
||||
} {/SEARCH TABLE t1 USING INDEX t1bc/}
|
||||
|
||||
finish_test
|
Reference in New Issue
Block a user